FORTRAN Example - gr_gi.f
PROGRAM gr_gi
implicit none
integer*4 gr_id, ri_id, ri_idx, file_id, il, ncomp
integer*4 data_type, nattrs, status, ndatasets, nfattrs
integer mgstart, mgselct, mggiinf, mgfinfo, mgn2ndx
integer mgendac, mgend, hopen, hclose
integer*4 DFACC_READ
parameter (DFACC_READ = 1)
character name(20)
integer*4 dimsizes(2)
C Open the file.
file_id = hopen('gr1.hdf', DFACC_READ, 0)
C Initiate the GR interface.
gr_id = mgstart(file_id)
C Get File Information from the File
status = mgfinfo (gr_id, ndatasets, nfattrs)
write (*,*)
write (*,*) 'Number of Datasets: ', ndatasets
write (*,*) 'Number of File Attributes: ', nfattrs
C Select the image named Image_1
ri_idx = mgn2ndx (gr_id, 'Image_1')
C Select the image in the file.
ri_id = mgselct(gr_id, ri_idx)
C Verify the characteristics of the image.
status = mggiinf(ri_id, name, ncomp, data_type, il, dimsizes,
+ nattrs)
write (*,*) 'Data Set Name: ', name
write (*,*) 'Number of Components: ', ncomp
write (*,*) 'Number Type: ', data_type
write (*,*) 'Interlace: ', il
write (*,*) 'Number of Attributes: ', nattrs
write (*,*) 'Dimension 1: ', dimsizes(1)
write (*,*) 'Dimension 2: ', dimsizes(2)
write (*,*)
C Terminate access to the array data set.
status = mgendac(ri_id)
C Terminate access to the GR interface.
status = mgend(gr_id)
C Close the file.
status = hclose(file_id)
end