File: writelevels.f

package info (click to toggle)
hdf-eos4 3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,960 kB
  • sloc: ansic: 43,570; sh: 11,324; fortran: 9,649; makefile: 261
file content (210 lines) | stat: -rw-r--r-- 3,957 bytes parent folder | download | duplicates (3)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
c
c  In this example we will (1) open the "PointFile" HDF file, (2) attach to
c  the points, and (3) write data to each level of the points.
c 


	program writelevels
	implicit none
	
	integer            status, i, pntr
	integer*2          wgt
	integer*4          ptfid, ptid, n, date

	real*4             rain, temp, conc(4)       
	real*8             lon, lat, time

	character          buffer*10000, id*3, desc*16, spc*8
	character          ctime*8, cconc*16, clon*8, clat*8
	character          cdate*4, crain*4, ctemp*4, cwgt*2
	equivalence        (time,ctime), (conc,cconc), (lon,clon)
	equivalence        (lat,clat), (rain,crain), (temp,ctemp)
	equivalence        (date,cdate), (wgt,cwgt)
	
	integer            ptwrlev, ptdetach, ptclose
	integer*4          ptopen, ptattach


	integer DFACC_RDWR
	parameter (DFACC_RDWR=3)

c
c     Open the HDF point file, "PointFile.hdf".
c

	ptfid = ptopen("PointFile_created_with_hadeos_sample_file_write"//
     1"r_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)


c
c    Write to Simple Point
c
	ptid = ptattach(ptfid, "Simple Point")

	open(unit=1, file='simple.txt', status='OLD')

	n = 0
	pntr = 1
	do 10 i=1,1000
	      
	   read(1, *, end=100)  time, conc(1), conc(2), conc(3), 
     1                            conc(4), spc
	   n = n + 1
	
	   buffer(pntr:pntr+8) = ctime
	   pntr = pntr + 8
	   buffer(pntr:pntr+4*4) = cconc
	   pntr = pntr + 4*4
	   buffer(pntr:pntr+4) = spc
	   pntr = pntr + 4
10	continue

100	close(unit=1)
    
	status = ptwrlev(ptid, 0, n, buffer)
	status = ptdetach(ptid)
    

c
c    Write to Fixed Buoy Point 
c

	ptid = ptattach(ptfid, "FixedBuoy Point")
c
c        Write First (0th) Level
c
	open(unit=1, file='fixedBuoy0.txt', status='OLD')

	n = 0
	pntr = 1
	do 20 i=1,1000
		      
	   read(1, *, end=200)  desc, lon, lat, date, id
	      
	   n = n + 1
	
	   buffer(pntr:pntr+8) = desc
	   pntr = pntr + 8
	   buffer(pntr:pntr+8) = clon
	   pntr = pntr + 8
	   buffer(pntr:pntr+8) = clat
	   pntr = pntr + 8
	   buffer(pntr:pntr+4) = cdate
	   pntr = pntr + 4
	   buffer(pntr:pntr+1) = id
	   pntr = pntr + 1
 20	continue

 200	close(unit=1)

    
	status = ptwrlev(ptid, 0, n, buffer)



c
c      Write Second (1th) Level */
c
	open(unit=1, file='fixedBuoy1.txt', status='OLD')

	n = 0
	pntr = 1
	do 30 i=1,1000

	   read(1, *, end=300) time, rain, temp, id
	   
	   n = n + 1
	   
	   buffer(pntr:pntr+8) = ctime
	   pntr = pntr + 8
	   buffer(pntr:pntr+4) = crain
	   pntr = pntr + 4
	   buffer(pntr:pntr+4) = ctemp
	   pntr = pntr + 4
	   buffer(pntr:pntr+1) = id
	   pntr = pntr + 1
 30	continue
	
 300	close(unit=1)
	  
	status = ptwrlev(ptid, 1, n, buffer)
	  
	status = ptdetach(ptid)
    

c
c    Write to Float Buoy Point 
c

	ptid = ptattach(ptfid, "FloatBuoy Point")

c
c        Write First (0th) Level
c
	open(unit=1, file='floatBuoy0.txt', status='OLD')

	n = 0
	pntr = 1
	do 40 i=1,1000
	      
	   read(1, *, end=400)  desc, date, wgt, id
	   write(*,*) desc,date,wgt,id
	   n = n + 1
	
	   buffer(pntr:pntr+8) = desc
	   pntr = pntr + 8
	   buffer(pntr:pntr+4) = cdate
	   pntr = pntr + 4
	   buffer(pntr:pntr+2) = cwgt
	   pntr = pntr + 2
	   buffer(pntr:pntr+1) = id
	   pntr = pntr + 1
 40	continue

 400	close(unit=1)

    
	status = ptwrlev(ptid, 0, n, buffer)


c
c      Write Second (1th) Level */
c
	open(unit=1, file='floatBuoy1.txt', status='OLD')

	n = 0
	pntr = 1
	do 50 i=1,1000

	   read(1, *, end=500) time, lon, lat, rain, temp, id
	      
	   n = n + 1
	
	   buffer(pntr:pntr+8) = ctime
	   pntr = pntr + 8
	   buffer(pntr:pntr+8) = clon
	   pntr = pntr + 8
	   buffer(pntr:pntr+8) = clat
	   pntr = pntr + 8	      
	   buffer(pntr:pntr+4) = crain
	   pntr = pntr + 4
	   buffer(pntr:pntr+4) = ctemp
	   pntr = pntr + 4
	   buffer(pntr:pntr+1) = id
	   pntr = pntr + 1
 50	continue

 500	close(unit=1)

	status = ptwrlev(ptid, 1, n, buffer)

	status = ptdetach(ptid)
	
 2000	continue
	
	status = ptclose(ptfid)

	stop
	end