      PROGRAM ATTRIB INFO

      integer*4 sd_id, sds_id, range_buffer(2)
      integer attr_index, data_type, count, status
      character attr_name *13
      character char_buffer *20
      integer sfstart, sffattr, sfgainfo, sfrattr, sfselect
      integer sfendacc, sfend

C     DFACC_RDWR is defined in hdf.h.
      integer DFACC_RDWR
      parameter (DFACC_RDWR = 3)

C     Open the file. 
      sd_id = sfstart('Example4.hdf', DFACC_RDONLY)

C     Find the file attribute named 'file_contents'. 
      attr_index = sffattr(sd_id, 'file_contents')

C     Get information about the file attribute. 
      status = sfgainfo(sd_id, attr_index, attr_name, data_type, count)

C     Read the attribute data. 
      status = sfrattr(sd_id, attr_index, char_buffer)

C     Get the identifier for the first data set. 
      sds_id = sfselect(sd_id, 0)

C     Find the data set attribute named 'valid_range'. 
      attr_index = sffattr(sds_id, 'valid_range')

C     Get information about the data set attribute. 
      status = sfgainfo(sds_id, attr_index, attr_name, data_type, count)

C     Read the attribute data. 
      status = sfrattr(sd_id, attr_index, range_buffer)

C     Terminate access to the array 
      status = sfendacc(sds_id)

C     Terminate access to the SD interface and close the file 
      status = sfend(sd_id)

      end
