home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / UIFlow 1.0.1 / UIFlow Source / VSet2.0 / temp / eh.f < prev    next >
Encoding:
Text File  |  1991-12-12  |  2.7 KB  |  104 lines  |  [TEXT/????]

  1. c  ==================================================================    
  2. c    FORTRAN EXAMPLE
  3. c
  4. c    HDF VSET 2.1 
  5. c    Jason Ng NCSA MAY 1991
  6. c    
  7. c    This program creates a Vset to store an array of pressure values,
  8. c    and an array of color-triplets (red-green-blue). It demonstrate
  9. c    the use of the Vset high-level write routines.
  10.  
  11. c    The pressure data is stored in one vdata (pid), and the color-triplets 
  12. c    are stored in another vdata (cid). These ids are then stored together
  13. c    in a vgroup, thereby logically grouping them as one vset.
  14. c
  15. c    Note that pressure is a simple variable. It is stored using the
  16. c    function VHFSD. But color-triplet data is a compound variable, with
  17. c    3 components (red,green,blue). The function VHFSDM is used instead
  18. c    so that the order (the number of components, ie 3) can be specified.
  19. c    
  20. c    The HDF file that is created,"eh.hdf", can be looked at with the 
  21. c    Vset utility "vshow"
  22.  
  23. c  ==================================================================    
  24.     program SAMPLE
  25.  
  26.     real         pbuf(100)
  27.     integer     cbuf(60,3)
  28.     integer     i,j, npres, ncolor
  29.     integer f
  30.     integer  pid, cid, vgid
  31.     character*10  class
  32.     integer tagnums(10), refnums(10), ntagref
  33.  
  34. c    --- routines and functions used
  35.     external DFOPEN, DFCLOSE
  36.     integer    DFOPEN
  37.     external VHFSD, VHFSDM, VHFMKGP
  38.     integer    VHFSD, VHFSDM, VHFMKGP
  39.  
  40. c    --- The parameters below are defined constants from "vg.h"
  41. c    -- float and integer types
  42.     integer         T_INT, T_FLOAT 
  43.     parameter     (T_INT=2)
  44.     parameter     (T_FLOAT=3)
  45.  
  46. c    --- HDF tag for vgroup and vdata.
  47.     integer         VDATTAG, VGPTAG
  48.     parameter     (VGPTAG=1965)
  49.     parameter     (VDATTAG=1962)
  50.  
  51. c    --- full file access
  52.     integer FULLACC
  53.     parameter (FULLACC=7)
  54.  
  55. c    ------ generate pressure data -------------------
  56.         npres = 100
  57.         do 111 i=1,npres
  58.             pbuf(i) = 0.01 * i + 500
  59. 111    continue
  60. c    ------ generate color-triplet (rgb)  data -------
  61.         ncolor = 60
  62.         do 222 i=1,ncolor
  63.             do 225 j=1,3
  64.                 cbuf(i,j) = i + j * 100
  65. 225        continue
  66. 222    continue
  67.  
  68.     class = 'example'
  69.  
  70. c    --- open the HDF file
  71.     f = DFOPEN ('eh.hdf', FULLACC, 0)
  72.  
  73. c    --- store pressure values in a new vdata
  74.     pid = VHFSD (f, 'PRES', pbuf, npres, T_FLOAT, 
  75.     1                'pressure values', class)
  76.     print *, 'Pressure vdata id is ', pid
  77.  
  78. c    --- store color-triplet values in a new vdata
  79. c          Note the argument 3 (for order=3 for a triplet)
  80.  
  81.     cid = VHFSDM (f, 'RGB', cbuf, ncolor, T_INT,
  82.     1                'a set of rgb values', class, 3)
  83.     print *, 'Color-triplet vdata id is ', cid
  84.  
  85. c     --- create a new vgroup and then group the 2 vdatas into it
  86.  
  87.     tagnums(1) = VDATTAG
  88.     tagnums(2) = VDATTAG
  89.     refnums(1) = pid
  90.     refnums(2) = cid
  91.     ntagref    = 2
  92.  
  93.     vgid = VHFMKGP (f,tagnums ,refnums, ntagref,
  94.     1                    'vgroup with 2 vdatas', 
  95.     1                    class)
  96.     print *, 'Vgroup id is ', vgid
  97.  
  98. c    --- close the HDF file
  99.     call DFCLOSE (f)
  100.     print *,'HDF VSet file eh.hdf created'
  101.  
  102.     end
  103.  
  104.