-
Notifications
You must be signed in to change notification settings - Fork 375
/
Copy pathfprototype.f
66 lines (56 loc) · 1.49 KB
/
fprototype.f
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
C Example of using GMTAPI from Fortran
C
C We will need some sort of include file to set the parameters later
program fprototype
parameter (GMTAPI_N_ARRAY_ARGS=8, GMTAPI_FLOAT=3, GMTAPI_ARRAY=3,
+ GMTAPI_FDESC=2)
parameter (NROW=4, NCOL=3, NREC=6)
integer row, col, unit6
integer error, val
real*8 array_par(12)
integer inarg(2)
integer outarg
real*4 matrix(3,4)
call GMTAPI_Create_Session (0, error)
if (error .ne. 0) then
call GMTAPI_Report_Error (error)
endif
C TEST 1: Create a 2-D array and register it with GMT
do 10 row = 1,NROW
do 20 col = 1,NCOL
matrix(row,col) = row*NCOL+col
20 continue
10 continue
array_par(1) = GMTAPI_FLOAT
array_par(2) = 2
array_par(3) = NROW
array_par(4) = NCOL
array_par(5) = 1
array_par(6) = array_par(4)
array_par(7) = 1
val = GMTAPI_ARRAY
call GMTAPI_Register_Import (val, matrix,
+ array_par, val, error)
inarg(1) = val
inarg(2) = 0
write (*,30) 'fprototype.f: Reg 2D array as ID = ', inarg(1)
30 format (a, i2)
C Register stdout as the output
unit6 = 6
val = GMTAPI_FDESC
call GMTAPI_Register_Export (val, unit6, array_par,
+ outarg, error)
write (*,30) 'fprototype.f: Registered output as ID =', outarg
C Call the GMT function
call GMT_read_all_write_all_records ('no command yet',
+ inarg, outarg, error)
if (error .ne. 0) then
call GMTAPI_Report_Error (error)
endif
C Shut down everything
call GMTAPI_Destroy_Session (error)
if (error .ne. 0) then
call GMTAPI_Report_Error (error)
endif
stop
end