-
Notifications
You must be signed in to change notification settings - Fork 3
/
demo1.f90
52 lines (39 loc) · 1.33 KB
/
demo1.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
! This demo program reads the C81 file sample1.C81 and writes the values read to
! an output file sampleOutput.C81. Both files are in the Samples/ directory.
! The working demo for the getTable() function, similar to dlmread() in Matlab, is also provided
program demo1
use libC81
implicit none
integer, parameter :: rows = 4
integer, parameter :: cols = 4
type(C81_class) :: C81
real, dimension(4,4) :: A
integer :: i,j
! Read airfoil data from C81 file
call C81%readfile('Samples/sample1.C81')
print*, 'Airfoil data read SUCCESSFUL'
print*
! Write airfoil data to C81 file
call C81%writefile('Samples/sampleOutput.C81')
print*, 'Airfoil data write SUCCESSFUL'
print*
! Read tabular data from csv file to Fortran array
! Works similar to dlmread() from Matlab
! Useful for creating arrays from airfoil data in CSV format
A = getTable('Samples/sample1.csv',rows,cols)
print*, 'Tabular data read SUCCESSFUL'
print*
do i=1,size(A,1)
print*,(A(i,j),j=1,size(A,2))
enddo
print*
! Find left and right indices from 1-d sorted array in which
! a queried value lies
print*, A(1,:)
print*, getInterval(A(1,:),0.15)
print*, 'Binary search SUCCESSFUL'
! Return 2-d interpolated value from 2-d array
print*
print*, C81%getCL(-14.5,0.425)
print*, '2-d interpolation SUCCESSFUL'
end program demo1