home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / hdf / unix / hdf3_2r2 / test / egfhi.f < prev    next >
Encoding:
Text File  |  1992-10-29  |  4.9 KB  |  184 lines

  1. C***************************************************************************
  2. C
  3. C
  4. C                         NCSA HDF version 3.2r2
  5. C                            October 30, 1992
  6. C
  7. C NCSA HDF Version 3.2 source code and documentation are in the public
  8. C domain.  Specifically, we give to the public domain all rights for future
  9. C licensing of the source code, all resale rights, and all publishing rights.
  10. C
  11. C We ask, but do not require, that the following message be included in all
  12. C derived works:
  13. C
  14. C Portions developed at the National Center for Supercomputing Applications at
  15. C the University of Illinois at Urbana-Champaign, in collaboration with the
  16. C Information Technology Institute of Singapore.
  17. C
  18. C THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
  19. C SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
  20. C WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
  21. C
  22. C***************************************************************************
  23.  
  24. C
  25. C $Header: /hdf/hdf/v3.2r2/test/RCS/egfhi.f,v 1.5 1992/10/23 19:09:28 koziol beta koziol $
  26. C
  27. C $Log: egfhi.f,v $
  28. c Revision 1.5  1992/10/23  19:09:28  koziol
  29. c Updated for new Vset calls, DFvsetopen(), DFvsetclose, and changed
  30. c VFREESPACE and VGETSPACE to HDfreespace() and HDgetspace()
  31. c
  32. c Revision 1.4  1992/06/16  15:39:42  chouck
  33. c HP is really picky about things not extending into column 72
  34. c
  35. c Revision 1.3  1992/05/28  16:43:32  chouck
  36. c Fixed line continuation characters to make RS/6000 happy
  37. c
  38. c Revision 1.2  1992/05/18  22:11:07  sxu
  39. c modified constants for number types
  40. c
  41. c Revision 1.1  1992/03/01  22:29:07  dilg
  42. c Initial revision
  43. c
  44. c Revision 1.1  1992/02/29  21:24:40  likkai
  45. c Initial revision
  46. c
  47. C
  48. c    ==========================================================   
  49. c
  50. c  HDF VSET Sample Program
  51. c  Jason NG NCSA FEB-28-92
  52. c
  53. c  EGFHI.F
  54. c  Uses High-Level routines
  55. c  Creates a vset of 1 vgroup and 3 vdatas in the file 'egfhi.hdf'.
  56. c
  57. c
  58. c    ===========================================================
  59.  
  60.     program HIGHLEVEL
  61.  
  62.     print *, 'This program tests the Fortran Vset High-level'
  63.     print *, 'calls. It creates 3 vdatas, and then create a vgroup'
  64.     print *, 'that will be linked to the 3 vdatas.'
  65.     print *,' '
  66.  
  67.     call DOIT
  68.  
  69.     end
  70.  
  71.  
  72.  
  73.     subroutine DOIT
  74.  
  75. c  Remove this fortran directive if your compiler doesn't support it.
  76. c  It forces an error message whenever a variable is not decalred.
  77.  
  78.     IMPLICIT    NONE
  79.  
  80.     integer    idata(200)        
  81.     real    rdata(200)    
  82.     integer    conval(3,200)        
  83.     integer    tagarray(10), refarray(10) 
  84.  
  85. c    --- declare the HDF and VSET routines used. This is compulsory!
  86.  
  87.     external DFVOPEN, DFVCLOS ,VHFSD, VHFSDM, VHFMKGP
  88.     integer    DFVOPEN ,VHFSD, VHFSDM, VHFMKGP
  89.  
  90.     integer     f, i, j 
  91.     integer  vs1, vs2, vs3, vg
  92.  
  93. c    --- some defined constants. see "vg.h"
  94.         
  95.     integer     LONGTYPE    
  96.         parameter     (LONGTYPE=24)
  97.     integer     REALTYPE    
  98.         
  99.     parameter     (REALTYPE=5)
  100.     integer        VDATATAG
  101.     parameter     (VDATATAG=1962)
  102.     integer     FULLACC    
  103.     parameter     (FULLACC=7)
  104.  
  105. c    ------ generate some data -------
  106.  
  107.     do 111 i=1,200
  108.         rdata(i) = i *1.001 + 500
  109.         idata(i) = i
  110. 111    continue
  111.  
  112.     do 112 i=1,100
  113.         do 114 j=1,3
  114.           conval(j,i) = i*j
  115. 114    continue
  116. 112    continue
  117.  
  118. c    ------- open hdf file ------
  119.         
  120.     f = DFVOPEN ('egfhi.hdf'//char(0), FULLACC, 0)
  121.  
  122. c    ------- store 100 floats as one field in one vdata  ------
  123.     vs1 = VHFSD (f, 'MP', rdata, 100, REALTYPE,  
  124.      +                    'melting-points', 'test')
  125.  
  126. c    ------- store 120 integers as one field in one vdata  ------
  127.     vs2 = VHFSD (f, 'AGE', idata, 120, LONGTYPE,
  128.      +                'age-of-specimens', 'test')
  129.  
  130.  
  131. c    ------- store 100*3 values as one field (of order 3) -----
  132. c    ------- in one vdata  ------
  133.     vs3 = VHFSDM (f, 'PLIST', conval, 100, LONGTYPE, 
  134.      +                'connectivity triplets','test',3)
  135.  
  136. c    --------- messages  ----------------------
  137.  
  138.     if (vs1 .eq. -1) then 
  139.       print *,'error creating melting-point vdata' 
  140.     else 
  141.       print *, 'created vdata "melting-points" with 100 elements'
  142.     endif
  143.  
  144.     if (vs2 .eq. -1) then 
  145.       print *,'error creating  "age-of-specimens" vdata' 
  146.     else 
  147.       print *, 'created vdata "age-of-specimens" with 120 elements'
  148.     endif
  149.     if (vs3 .eq. -1) then 
  150.       print *,'error creating  "connectivity triplets" vdata' 
  151.     else 
  152.       print *, 'created vdata "connectivity triplets" with '
  153.           print *, '   100 elements'
  154.     endif
  155.  
  156. c ------ make a vgroup that has links to all the above vdatas ----  
  157.  
  158.     tagarray(1) = VDATATAG
  159.     refarray(1) = vs1
  160.     tagarray(2) = VDATATAG
  161.     refarray(2) = vs2
  162.     tagarray(3) = VDATATAG
  163.     refarray(3) = vs3
  164.  
  165.     vg = VHFMKGP(f,tagarray,refarray,3,
  166.      +            'vgroup with 3 vdatas (fortran)', 'test')
  167.     if (vg .eq. -1) then 
  168.         print *,'error creating  vgroup'
  169.     else 
  170.         print *, 'created vgroup that links all the 3 vdatas'
  171.     endif
  172. c    --- all done. close the file ---
  173.     call DFVCLOS (f)
  174.  
  175.     print *,' '
  176.     print *, 'SUCCESS: created file egfhi.hdf'
  177.     print *, 'Use the utility vshow to look at the results:'
  178.     print *, '       vshow egfhi.hdf +'
  179.     print *, 'Results should be as in the file egfhi.result'
  180.     print *,' '
  181.  
  182.     end
  183.  
  184.