program readhdfeos implicit none ! use hdf include "hdf.f90" include "dffunc.f90" ! real,dimension(37081) :: var character :: varname*100 real, allocatable :: tempfld(:) character (len=128) ::filename,swathname,fieldname,attribute1,attribute2 integer (kind=4) :: fid,swid,status,astat integer (kind=4) :: swopen,swattach,swdetach,swclose integer (kind=4) :: swfldinfo,swrdfld,swrdattr integer (kind=4) :: rank,dims(7),datatype,i,j character (len=255) :: dimlist integer (kind=4), allocatable :: start(:),stride(:) real (kind=4) :: factor,offset ! field attributes (used for scaling) ! real,allocatable :: lon ! print *,'Reading HDF file...' swathname = "2B-FLXHR" ! fieldname = "Radar_Reflectivity" ! swathname = "2B-FLXHR" fieldname = "Longitude" filename = '/bdd/CFMIP/OBS_LOCAL/CloudSat/2007001005141_03607_CS_2B-FLXHR_GRANULE_P_R04_E02.hdf' fid = swopen(trim(filename), DFACC_READ) if (fid .eq. -1) then print *,'CANNOT OPEN FILE',fid stop endif print *,fid !======= attach to the swath swid = swattach(fid,swathname) if (swid .eq. -1) then print *,'CANNOT ATTACH TO SWATH',swid stop endif !======= get field information status = swfldinfo(swid,fieldname,rank,dims,datatype,dimlist) if (status .ne. 0) then print *,'CANNOT GET FIELD INFO',status stop endif print *,'-------------------------------------------------' print *,'file: ',trim(filename) print *,'field: ',trim(fieldname) print *,'rank: ',rank print *,'dimension list: ',trim(dimlist) print *,'dimension sizes: ',dims(1:rank) ! print *,'datatype: ',gettype(datatype) !======= allocate the field to be read in allocate(tempfld(dims(1)),stat=astat) if (astat .ne. 0) then print *,'CANNOT ALLOCATE tempfld',astat stop endif allocate(start(rank),stride(rank),stat=astat) if (astat .ne. 0) then print *,'CANNOT ALLOCATE start or stride',astat stop endif start(:) = 0 stride(:) = 1 !======= read the field status =swrdfld(swid,fieldname,start,stride,dims(1:rank),tempfld) if (status .ne. 0) then print *,'CANNOT READ FIELD',status stop endif !======= detach from the swath status = swdetach(swid) if (status .ne. 0) then print *,'CANNOT DETACH FROM SWATH',status stop endif !======= close the file status = swclose(fid) if (status .ne. 0) then print *,'CANNOT CLOSE FILE',status stop endif print *, 'longitude' print *, tempfld(5000) end program