home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / hdf / unix / examples.lha / examples / ann / get1anF.f < prev    next >
Encoding:
Text File  |  1991-10-08  |  2.4 KB  |  85 lines

  1. C
  2. C $Header: /pita/work/HDF/dev/RCS/test/annotations/get1anF.f,v 1.1 90/06/26 16:49:29 mfolk beta $
  3. C
  4. C $Log:    get1anF.f,v $
  5. c Revision 1.1  90/06/26  16:49:29  mfolk
  6. c Initial revision
  7. C
  8.       program get1an
  9.  
  10. C Program to test routines for finding and reading label and description
  11. C
  12. C An HDF file called 'o2' must already exist with at least two SDSs
  13. C in it and both a label and description annotation corresponding 
  14. C to the second SDS.
  15. C
  16. C Mike Folk  9/12/90
  17. C
  18. C****||************************************************************
  19.  
  20.       integer DFopen, DFclose
  21.       integer dfindnr, daglab, dagdesc, dagdlen
  22.       integer desclen, ref, ret, dfile
  23.       integer DFACC_READ, DFTAG_SDG
  24.       character*20  label, filename
  25.       character*400 desc
  26.     
  27.       parameter (DFACC_READ  =   1,
  28.      $           DFTAG_SDG   = 700 )
  29.  
  30.       print *, 'Enter HDF file name.  The HDF file should contain two'
  31.       print *, 'SDSs with a label and description for the second one.'
  32.       print *, 'File name: '
  33.       read *, filename
  34.       
  35.       dfile = DFopen(filename, DFACC_READ, -1)
  36.   
  37. C****||******** find ref of second SDS in file ****************
  38.       ref = 0
  39.       ref = dfindnr(dfile, DFTAG_SDG, ref)
  40.       ref = dfindnr(dfile, DFTAG_SDG, ref)
  41.       if (ref .lt. 0) 
  42.      *  call fatalerror('Unable to find second scientific data set.')
  43.  
  44.       ret = DFclose(dfile)
  45.   
  46. C****||******** get label, then description ****************
  47.       ret = daglab(filename, DFTAG_SDG, ref, label, 11)
  48.       if (ret .lt. 0) print *, 'No label'
  49.       if (ret .ge. 0) print *,'Label: ', label
  50.  
  51.       desclen = dagdlen(filename, DFTAG_SDG, ref)
  52.       if (desclen .gt. 400) 
  53.      $    call fatalerror('Description too long. Greater than 400.')
  54.       if (desclen .lt. 0) 
  55.      $    call fatalerror('Error reading description length.')
  56.  
  57.         ret = dagdesc(filename, DFTAG_SDG, ref, desc, desclen)
  58.       if (ret .lt. 0) 
  59.      $    call fatalerror('Error reading description.')
  60.       print *,'Description: '
  61.       print *, desc
  62.       print *
  63.       print *, "+++++++++++++++++++++++++"
  64.       print *
  65.       print *
  66.       stop
  67.       end
  68.  
  69. C************************************************************
  70. * fatalerror: subroutine to report fatal error and abort
  71. *
  72. C****||***********************************************************
  73.  
  74.       subroutine fatalerror(s)
  75.       character*(*) s
  76.  
  77.       print *, s
  78.       print *, 'DFerror:', DFerrno()
  79.       print *, 'Program aborted.'
  80.       print *, ' '
  81.       stop
  82.       end
  83.  
  84.