vd_ex5f.f
PROGRAM vd_ex5f
implicit none
C Read vdata records. Unpack the records into field buffers.
character vdata_name*30, vdata_class*30, fields*60
integer*4 databuf(100)
integer*4 file_id, vdata_ref, vdata_id
integer*4 n_records, interlace, vdata_size
real itemp(10), ispeed(10)
integer*2 iheight(10)
character idents*10
integer istat, i
integer hopen, vsfgid, vsfatch, vsfinq, vsfgcls
integer vsfsfld, vsfread, vsfdtch, hclose
integer vsfnpak, vsfcpak, vfstart, vfend
integer*4 DFACC_READ, FULL_INTERLACE
integer*4 HDF_VSUNPACK, HDF_VSPACK
parameter (DFACC_READ = 1,
+ FULL_INTERLACE = 0,
+ HDF_VSPACK = 0,
+ HDF_VSUNPACK = 1)
C Open an HDF file with read-only access.
file_id = hopen('VD_Ex4f.hdf', DFACC_READ, 0)
C Initialize the Vset interface.
istat = vfstart(file_id)
C Get the reference number for the first Vdata in
C the file.
vdata_ref = -1
vdata_ref = vsfgid(file_id, vdata_ref)
C Attach to the first Vdata in read mode.
vdata_id = vsfatch(file_id, vdata_ref, 'r')
C Get the list of field names.
istat = vsfinq(vdata_id, n_records, interlace, fields,
+ vdata_size, vdata_name)
C Get the class.
istat = vsfgcls(vdata_id, vdata_class)
C Determine the fields that will be read.
istat = vsfsfld(vdata_id, 'Temp,Height,Speed,Ident')
C Print the Vdata information.
print *, 'Current Vdata name: ', vdata_name
print *, 'Current Vdata class: ', vdata_class
print *
C Read the data.
istat = vsfread(vdata_id, databuf, 10, FULL_INTERLACE)
istat = vsfnpak(vdata_id, HDF_VSUNPACK,fields, databuf, 400,
+ n_records, 'Temp', itemp)
if (istat .lt. 0) then
print *, 'vsfnpak failed in unpack Temp'
endif
istat = vsfnpak(vdata_id, HDF_VSUNPACK, fields, databuf, 400,
+ n_records, 'Height', iheight)
if (istat .lt. 0) then
print *, 'vsfnpak failed in unpack Height'
endif
istat = vsfnpak(vdata_id, HDF_VSUNPACK, fields, databuf, 400,
+ n_records, 'Speed', ispeed)
if (istat .lt. 0) then
print *, 'vsfnpak failed in unpack Speed'
endif
istat = vsfcpak(vdata_id, HDF_VSUNPACK,' ', databuf, 400,
+ n_records, 'Ident', idents)
if (istat .lt. 0) then
print *, 'vsfcpak failed in unpack Ident'
endif
C Print data
print *, ' Temp Speed '
print *
do 100 i=1, n_records
print *, itemp(i), ispeed(i)
100 continue
print *
print *, 'idents: ', idents
C Detach from the Vdata, close the Vset interface and the file.
istat = vsfdtch(vdata_id)
istat = vfend(file_id)
istat = hclose(file_id)
end