1 program read_gravity 2 USE CGNS 3 implicit none 4 5! author: Diane Poirier (diane@icemcfd.com) 6! last revised on May 31 2002 7 8! This example test the RotatingCoordinates_t data structure and its children 9 10#ifdef WINNT 11 include 'cgnswin_f.h' 12#endif 13 14 integer Ndim 15 parameter (Ndim = 3) 16 integer CellDim, PhysDim 17 integer(cgsize_t) size(Ndim*3) 18 integer ier, n, cg, nbases, base, type, zone, nzones 19 integer ndescriptors, idescr, nuser_data 20 integer mass, length, time, temp, deg 21 integer narrays, iarray, nndim, datatype, zonetype 22 integer(cgsize_t) dim_vals(12) 23 real*4 version, rot_rate(Ndim), rot_center(Ndim), data_single(100) 24 character*32 name, filename, basename, user_data_name, zonename 25 character*100 text 26 27! *** open file 28! write(6,*) 'Input filename' 29! read(5,600) filename 30 write(filename,'(a)')'Test_V2' 31 call cg_open_f(filename, MODE_READ, cg, ier) 32 if (ier .eq. ERROR) call cg_error_exit_f 33 write(6,600)'READING FILE ',filename 34 35! *** CGNS Library Version used for file creation: 36 call cg_version_f(cg, version, ier) 37 if (ier .eq. ERROR) call cg_error_exit_f 38 write(6,102) & 39 'Library Version used for file creation:',version 40 41! *** base 42 call cg_nbases_f(cg, nbases, ier) 43 if (ier .eq. ERROR) call cg_error_exit_f 44 write(6,200)'nbases=',nbases 45 46 base=1 47 48 call cg_base_read_f(cg, base, basename, CellDim, PhysDim, ier) 49 if (ier .eq. ERROR) call cg_error_exit_f 50 write(6,300)'BaseName = "',basename,'"', & 51 'cell_dimension=',CellDim 52 53! *** base attribute: GOTO base node 54 call cg_goto_f(cg, base, ier, 'end') 55 if (ier .eq. ERROR) call cg_error_exit_f 56 57! *** base attribute: Descriptor 58 call cg_ndescriptors_f(ndescriptors, ier) 59 if (ier .eq. ERROR) call cg_error_exit_f 60 write(6,400)'Base Descriptor_t Information:' 61 write(6,105) 'No. of descriptors=',ndescriptors 62 63 do idescr=1, ndescriptors 64 call cg_descriptor_read_f(idescr, name, text, ier) 65 if (ier .eq. ERROR) call cg_error_exit_f 66 if (ier.eq.ALL_OK) then 67 write(6,500)' DescriptorName="',name,'"', & 68 ' DescriptorText="',text,'"' 69 endif 70 enddo 71 72! *** read RotatingCoordinates_t node 73 call cg_rotating_read_f(rot_rate, rot_center, ier) 74 if (ier .eq. ERROR) call cg_error_exit_f 75 76 write(6,110)'rot_rate=',rot_rate(1), & 77 rot_rate(2), rot_rate(3) 78 write(6,110)'rot_center=',rot_center(1), & 79 rot_center(2), rot_center(3) 80 81! *** read children of RotatingCoordinates_t 82 call cg_goto_f(cg, base, ier, 'RotatingCoordinates_t', 1, 'end') 83 if (ier .eq. ERROR) call cg_error_exit_f 84 85! * Descriptor 86 call cg_ndescriptors_f(ndescriptors, ier) 87 if (ier .eq. ERROR) call cg_error_exit_f 88 write(6,400)'RotatingCoordinates Descriptor_t Information:' 89 write(6,105) 'No. of descriptors=',ndescriptors 90 91 do idescr=1, ndescriptors 92 call cg_descriptor_read_f(idescr, name, text, ier) 93 if (ier .eq. ERROR) call cg_error_exit_f 94 write(6,500) ' DescriptorName="',name,'"', & 95 ' DescriptorText="',text,'"' 96 enddo 97 98! * DataClass 99 call cg_dataclass_read_f(type,ier) 100 if (ier .eq. ERROR) call cg_error_exit_f 101 write(6,600)'DataClassName=',DataClassName(type) 102 103! * DimensionalUnits 104 call cg_units_read_f(mass, length, time, temp, deg, ier) 105 if (ier .eq. ERROR) call cg_error_exit_f 106 if (ier .eq. ALL_OK) then 107 write(6,100) & 108 'RotatingCoordinates Dimensional Units:', & 109 MassUnitsName(mass), LengthUnitsName(length), & 110 TemperatureUnitsName(temp), TimeUnitsName(time), & 111 AngleUnitsName(deg) 112 endif 113 114! * UserDefinedData 115 call cg_nuser_data_f(nuser_data, ier) 116 if (ier .eq. ERROR) call cg_error_exit_f 117 write(6,400)'RotatingCoordinates User Data Information:' 118 write(6,105) 'No. of UserData=',nuser_data 119 120 do n=1, nuser_data 121 call cg_user_data_read_f(n, user_data_name, ier) 122 if (ier .eq. ERROR) call cg_error_exit_f 123 write(6,500) ' user_data_name="',user_data_name,'"' 124 enddo 125 126! * DataArray_t 127 128 call cg_narrays_f(narrays, ier) 129 if (ier .eq. ERROR) call cg_error_exit_f 130 write(6,105) 'RotatingCoordinates contains ', & 131 narrays,' array(s)' 132 do iarray=1, narrays 133 call cg_goto_f(cg, base, ier, 'RotatingCoordinates_t', & 134 1, 'end') 135 if (ier .eq. ERROR) call cg_error_exit_f 136 call cg_array_info_f(iarray, name, datatype, & 137 nndim, dim_vals, ier) 138 if (ier .eq. ERROR) call cg_error_exit_f 139 write(6,600) ' DataArrayName="',name,'"' 140 write(6,600) ' DataType="',DataTypeName(datatype),'"' 141 write(6,200) ' DataNdim=',nndim 142 write(6,200) ' DataDim=',dim_vals(1) 143 write(6,105) ' Data:' 144 call cg_array_read_f(iarray, data_single, ier) 145 if (ier .eq. ERROR) call cg_error_exit_f 146 write(6,106) (data_single(n),n=1,dim_vals(1)) 147 148! * Descriptor for DataArray_t (RotationCenter & RotationRateVector) 149 call cg_goto_f(cg, base, ier, 'RotatingCoordinates_t', 1, & 150 'DataArray_t', iarray, 'end') 151 if (ier .eq. ERROR) call cg_error_exit_f 152 153 call cg_ndescriptors_f(ndescriptors, ier) 154 if (ier .eq. ERROR) call cg_error_exit_f 155 write(6,400)'Descriptor_t Information:' 156 write(6,105) 'No. of descriptors=',ndescriptors 157 158 do idescr=1, ndescriptors 159 call cg_descriptor_read_f(idescr, name, text, ier) 160 if (ier .eq. ERROR) call cg_error_exit_f 161 write(6,500) ' DescriptorName="',name,'"', & 162 ' DescriptorText="',text,'"' 163 enddo 164 165! * DimensionalUnits for DataArray_t (RotationCenter & RotationRateVector) 166 call cg_units_read_f(mass, length, time, temp, deg, ier) 167 if (ier .eq. ERROR) call cg_error_exit_f 168 if (ier .eq. ALL_OK) then 169 write(6,100) & 170 'DataArray_t Dimensional Units:', & 171 MassUnitsName(mass), LengthUnitsName(length), & 172 TemperatureUnitsName(temp), TimeUnitsName(time), & 173 AngleUnitsName(deg) 174 endif 175 write(6,102) ' ' 176 enddo 177 178! * Zone 179 180 call cg_nzones_f(cg, base, nzones, ier) 181 if (ier .eq. ERROR) call cg_error_exit_f 182 write(6,200)'nzones=',nzones 183 184 zone=1 185 186 call cg_zone_read_f(cg, base, zone, zonename, size, ier) 187 if (ier .eq. ERROR) call cg_error_exit_f 188 write(6,104)'Name of Zone',zone,' is "',zonename,'"' 189 190 call cg_zone_type_f(cg, base, zone, zonetype, ier) 191 if (ier .eq. ERROR) call cg_error_exit_f 192 write(6,600)' Zone type is ', ZoneTypeName(zonetype) 193 194 ! *** zone attribute: GOTO zone node 195 call cg_goto_f(cg, base, ier, 'Zone_t', zone, 'end') 196 if (ier .eq. ERROR) call cg_error_exit_f 197 198! *** zone attribute: Descriptor 199 call cg_ndescriptors_f(ndescriptors, ier) 200 if (ier .eq. ERROR) call cg_error_exit_f 201 write(6,400)'Zone Descriptor_t Information:' 202 write(6,105) 'No. of descriptors=',ndescriptors 203 204 do idescr=1, ndescriptors 205 call cg_descriptor_read_f(idescr, name, text, ier) 206 if (ier .eq. ERROR) call cg_error_exit_f 207 if (ier.eq.ALL_OK) then 208 write(6,500)' DescriptorName="',name,'"', & 209 ' DescriptorText="',text,'"' 210 endif 211 enddo 212 213! *** read RotatingCoordinates_t node 214 call cg_rotating_read_f(rot_rate, rot_center, ier) 215 if (ier .eq. ERROR) call cg_error_exit_f 216 217 write(6,110)'rot_rate=',rot_rate(1), & 218 rot_rate(2), rot_rate(3) 219 write(6,110)'rot_center=',rot_center(1), & 220 rot_center(2), rot_center(3) 221 222! *** read children of RotatingCoordinates_t 223 call cg_goto_f(cg, base, ier, 'Zone_t', zone, & 224 'RotatingCoordinates_t', 1, 'end') 225 if (ier .eq. ERROR) call cg_error_exit_f 226 227! * Descriptor 228 call cg_ndescriptors_f(ndescriptors, ier) 229 if (ier .eq. ERROR) call cg_error_exit_f 230 write(6,400)'RotatingCoordinates Descriptor_t Information:' 231 write(6,105) 'No. of descriptors=',ndescriptors 232 233 do idescr=1, ndescriptors 234 call cg_descriptor_read_f(idescr, name, text, ier) 235 if (ier .eq. ERROR) call cg_error_exit_f 236 write(6,500) ' DescriptorName="',name,'"', & 237 ' DescriptorText="',text,'"' 238 enddo 239 240! * DataClass 241 call cg_dataclass_read_f(type,ier) 242 if (ier .eq. ERROR) call cg_error_exit_f 243 write(6,600)'DataClassName=',DataClassName(type) 244 245! * DimensionalUnits 246 call cg_units_read_f(mass, length, time, temp, deg, ier) 247 if (ier .eq. ERROR) call cg_error_exit_f 248 if (ier .eq. ALL_OK) then 249 write(6,100) & 250 'RotatingCoordinates Dimensional Units:', & 251 MassUnitsName(mass), LengthUnitsName(length), & 252 TemperatureUnitsName(temp), TimeUnitsName(time), & 253 AngleUnitsName(deg) 254 endif 255 256! * UserDefinedData 257 call cg_nuser_data_f(nuser_data, ier) 258 if (ier .eq. ERROR) call cg_error_exit_f 259 write(6,400)'RotatingCoordinates User Data Information:' 260 write(6,105) 'No. of UserData=',nuser_data 261 262 do n=1, nuser_data 263 call cg_user_data_read_f(n, user_data_name, ier) 264 if (ier .eq. ERROR) call cg_error_exit_f 265 write(6,500) ' user_data_name="',user_data_name,'"' 266 enddo 267 268! * DataArray_t 269 270 call cg_narrays_f(narrays, ier) 271 if (ier .eq. ERROR) call cg_error_exit_f 272 write(6,105) 'RotatingCoordinates contains ', & 273 narrays,' array(s)' 274 do iarray=1, narrays 275 call cg_goto_f(cg, base, ier, 'Zone_t', zone, & 276 'RotatingCoordinates_t', 1, 'end') 277 if (ier .eq. ERROR) call cg_error_exit_f 278 279 call cg_array_info_f(iarray, name, datatype, & 280 nndim, dim_vals, ier) 281 if (ier .eq. ERROR) call cg_error_exit_f 282 write(6,600) ' DataArrayName="',name,'"' 283 write(6,600) ' DataType="',DataTypeName(datatype),'"' 284 write(6,200) ' DataNdim=',nndim 285 write(6,200) ' DataDim=',dim_vals(1) 286 write(6,105) ' Data:' 287 call cg_array_read_f(iarray, data_single, ier) 288 if (ier .eq. ERROR) call cg_error_exit_f 289 write(6,106) (data_single(n),n=1,dim_vals(1)) 290 291! * Descriptor for DataArray_t (RotationCenter & RotationRateVector) 292 call cg_goto_f(cg, base, ier, 'RotatingCoordinates_t', 1, & 293 'DataArray_t', iarray, 'end') 294 if (ier .eq. ERROR) call cg_error_exit_f 295 296 call cg_ndescriptors_f(ndescriptors, ier) 297 if (ier .eq. ERROR) call cg_error_exit_f 298 write(6,400)'Descriptor_t Information:' 299 write(6,105) 'No. of descriptors=',ndescriptors 300 301 do idescr=1, ndescriptors 302 call cg_descriptor_read_f(idescr, name, text, ier) 303 if (ier .eq. ERROR) call cg_error_exit_f 304 write(6,500) ' DescriptorName="',name,'"', & 305 ' DescriptorText="',text,'"' 306 enddo 307 308! * DimensionalUnits for DataArray_t (RotationCenter & RotationRateVector) 309 call cg_units_read_f(mass, length, time, temp, deg, ier) 310 if (ier .eq. ERROR) call cg_error_exit_f 311 if (ier .eq. ALL_OK) then 312 write(6,100) & 313 'DataArray_t Dimensional Units:', & 314 MassUnitsName(mass), LengthUnitsName(length), & 315 TemperatureUnitsName(temp), TimeUnitsName(time), & 316 AngleUnitsName(deg) 317 write(6,102) ' ' 318 endif 319 enddo 320 321 call cg_close_f(cg, ier) 322 if (ier .eq. ERROR) call cg_error_exit_f 323 324 100 format(a/,' Mass units: ',a/,' Length units: ',a/, & 325 ' Temperature units: ',a/,' Time units: ',a/, & 326 ' Angle units:',a) 327 102 format(a,f5.3) 328 104 format(a,i5,3a) 329 105 format(a,i2,a) 330 106 format(6f10.3) 331 110 format(a,5f5.1) 332 200 format(a,i5) 333 300 format(3a/a,i2) 334 400 format(/a/) 335 500 format(3a/3a) 336 600 format(3a) 337 338 9999 end 339