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
|
c
c In this example we will (1) open the "PointFile" HDF file,
c (2) attach to the three point structures, and (3) define
c the fields within each point.
c
program definelevels
integer status
integer*4 ptfid, ptid
integer*4 fieldtype(8), fieldorder(8)
character*255 fldlist
integer*4 ptopen, ptattach
integer ptdeflev, ptdeflink, ptdetach, ptclose
integer DFACC_RDWR
parameter (DFACC_RDWR=3)
integer DFNT_CHAR8, DFNT_INT16, DFNT_INT32
parameter (DFNT_CHAR8=4)
parameter (DFNT_INT16=22)
parameter (DFNT_INT32=24)
integer DFNT_FLOAT32, DFNT_FLOAT64
parameter (DFNT_FLOAT32=5)
parameter (DFNT_FLOAT64=6)
c
c We first open the HDF point file, "PointFile.hdf". Because this
c file already exist and we wish to write to it, we use the
c DFACC_RDWR access code in the open statement. The ptopen
c routine returns the point fileid, ptfid, which is used to
c identify the file in subsequent routines.
ptfid = ptopen("PointFile_created_with_hadeos_sample_file_write"//
1"r_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR)
c
c We next attach to the three point structures within the file
c using the ptattach routine, identifying each point by its
c name defined by the ptcreate routine previously.
c
if (ptfid .ne. -1) then
c
c Define "Simple" point
c
ptid = ptattach(ptfid, "Simple Point")
fldlist = "Time,Concentration,Species"
fieldtype(1) = DFNT_FLOAT64
fieldtype(2) = DFNT_FLOAT32
fieldtype(3) = DFNT_CHAR8
fieldorder(1) = 1
fieldorder(2) = 4
fieldorder(3) = 4
status = ptdeflev(ptid, "Sensor", fldlist, fieldtype,
1 fieldorder)
status = ptdetach(ptid)
goto 5000
c
c Define Fixed Buoy Point
c
ptid = ptattach(ptfid, "FixedBuoy Point")
c Define Description/Location Level
fldlist = "Label,Longitude,Latitude,DeployDate,ID"
fieldtype(1) = DFNT_CHAR8
fieldtype(2) = DFNT_FLOAT64
fieldtype(3) = DFNT_FLOAT64
fieldtype(4) = DFNT_INT32
fieldtype(5) = DFNT_CHAR8
c Note: order = 0 same as order = 1 for numeric scalars
fieldorder(1) = 8
fieldorder(2) = 0
fieldorder(3) = 0
fieldorder(4) = 0
fieldorder(5) = 1
status = ptdeflev(ptid, "Desc-Loc", fldlist, fieldtype,
1 fieldorder)
c Define Data Level
fldlist = "Time,Rainfall,Temperature,ID"
fieldtype(1) = DFNT_FLOAT64
fieldtype(2) = DFNT_FLOAT32
fieldtype(3) = DFNT_FLOAT32
fieldtype(4) = DFNT_CHAR8
fieldorder(1) = 0
fieldorder(2) = 0
fieldorder(3) = 0
fieldorder(4) = 1
status = ptdeflev(ptid, "Observations", fldlist,
1 fieldtype, fieldorder)
status = ptdeflink(ptid, "Desc-Loc", "Observations", "ID")
status = ptdetach(ptid)
c
c
c Floating Buoy Point
c
ptid = ptattach(ptfid, "FloatBuoy Point")
c Define Description Level */
fldlist = "Label,DeployDate,Weight,ID"
fieldtype(1) = DFNT_CHAR8
fieldtype(2) = DFNT_INT32
fieldtype(3) = DFNT_INT16
fieldtype(4) = DFNT_CHAR8
fieldorder(1) = 8
fieldorder(2) = 0
fieldorder(3) = 0
fieldorder(4) = 1
status = ptdeflev(ptid, "Description", fldlist,
1 fieldtype, fieldorder)
c Define Data Level
fldlist = "Time,Longitude,Latitude,Rainfall,Temperature,ID"
fieldtype(1) = DFNT_FLOAT64
fieldtype(2) = DFNT_FLOAT64
fieldtype(3) = DFNT_FLOAT64
fieldtype(4) = DFNT_FLOAT32
fieldtype(5) = DFNT_FLOAT32
fieldtype(6) = DFNT_CHAR8
fieldorder(1) = 0
fieldorder(2) = 0
fieldorder(3) = 0
fieldorder(4) = 0
fieldorder(5) = 0
fieldorder(6) = 1
status = ptdeflev(ptid, "Measurements", fldlist,
1 fieldtype, fieldorder)
status = ptdeflink(ptid, "Description", "Measurements", "ID")
status = ptdetach(ptid)
5000 continue
c
c Close HDF file
c
status = ptclose(swfid)
write(*,*) 'status close ', status
endif
stop
end
|