File: readlevels.f

package info (click to toggle)
hdf-eos4 2.20v1.00-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, trixie
  • size: 34,028 kB
  • sloc: ansic: 46,955; sh: 23,547; fortran: 15,467; csh: 1,098; makefile: 633
file content (131 lines) | stat: -rw-r--r-- 2,868 bytes parent folder | download | duplicates (2)
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
c
c  In this example we will (1) open the "PointFile" HDF file, (2) attach to
c  the points, and (3) read data from each level of the points.
c 
	program readlevels
	

	integer*4         ptfid, ptid, recs(32)
	integer*4         fldtype(32), fldorder(32)

        integer            status, i, pntr
	integer*2          wgt
	integer*4          n, date
	
	real*4             rain, temp, conc(4)
	real*8             lon, lat, time
				
	character         fldlist*256, buffer*100000, id*2
	character          spc*4, desc*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           ptrdlev
	integer           ptdetach, ptclose, ptlevinfo
	integer*4         ptopen, ptattach, ptnrecs
	
	
	integer DFACC_READ
	parameter (DFACC_READ=1)

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

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

c
c    Read Simple Point
c
	ptid = ptattach(ptfid, "Simple Point")

	status = ptlevinfo(ptid, 0, fldlist, fldtype, fldorder)
	n = ptnrecs(ptid, 0)
	write(*,*) n 

	do 5 i=1,n
	   recs(i) = i - 1
 5	continue
	   
	status = ptrdlev(ptid, 0, fldlist, n, recs, buffer)
	pntr = 1

	do 10 i=1,n
	   ctime = buffer(pntr:pntr+8)
	   pntr = pntr + 8
	   cconc = buffer(pntr:pntr+4*4)
	   pntr = pntr + 4*4
	   spc = buffer(pntr:pntr+4)
	   pntr = pntr + 4
	   write(*,*) time, conc(1), conc(2), conc(3), conc(4), spc
10	continue
    
	status = ptdetach(ptid)
    

c
c    Read Fixed Buoy Point
c
	ptid = ptattach(ptfid, "FixedBuoy Point")

c
c       Read First (0th) Level
c
	status = ptlevinfo(ptid, 0, fldlist, fldtype, fldorder)

	n = 2
	recs(1) = 0
	recs(2) = 2
    
	pntr = 1
	status = ptrdlev(ptid, 0, fldlist, n, recs, buffer)

	do 20 i=1,n
	   desc = buffer(pntr:pntr+8)
	   pntr = pntr + 8
	   clon = buffer(pntr:pntr+8)
	   pntr = pntr + 8
	   clat = buffer(pntr:pntr+8)
	   pntr = pntr + 8
	   cdate = buffer(pntr:pntr+4)
	   pntr = pntr + 4
	   id = buffer(pntr:pntr+1)
	   pntr = pntr + 1
	   write(*,*) desc, lon, lat, date, id(1:1)
 20	continue
	
c
c    Read Second (1th) Level
c
	status = ptlevinfo(ptid, 1, fldlist, fldtype, fldorder)
	n = ptnrecs(ptid, 1)


	do 30 i=1,n

	   recs(1) = i - 1
	   status = ptrdlev(ptid, 1, fldlist, 1, recs, buffer)

	   pntr = 1
	   
	   ctime = buffer(pntr:pntr+8)
	   pntr = pntr + 8
	   crain = buffer(pntr:pntr+4)
	   pntr = pntr + 4
	   ctemp = buffer(pntr:pntr+4)
	   pntr = pntr + 4
	   id = buffer(pntr:pntr+1)
	   pntr = pntr + 1
	   write(*,*) time, rain, temp, '  ', id(1:1)
 30	continue	

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

	stop
	end