File: egfhi.f

package info (click to toggle)
libhdf4 4.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 29,892 kB
  • sloc: ansic: 128,688; sh: 14,969; fortran: 12,444; java: 5,864; xml: 1,305; makefile: 900; yacc: 678; pascal: 418; perl: 360; javascript: 203; lex: 163; csh: 41
file content (150 lines) | stat: -rw-r--r-- 4,628 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
C * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
C  Copyright by The HDF Group.                                               *
C  Copyright by the Board of Trustees of the University of Illinois.         *
C  All rights reserved.                                                      *
C                                                                            *
C  This file is part of HDF.  The full HDF copyright notice, including       *
C  terms governing use, modification, and redistribution, is contained in    *
C  the COPYING file, which can be found at the root of the source code       *
C  distribution tree, or in https://support.hdfgroup.org/ftp/HDF/releases/.  *
C  If you do not have access to either file, you may request a copy from     *
C  help@hdfgroup.org.                                                        *
C * * * * * * * * *  * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
C
C
C==========================================================
c
c     HDF VSET Sample Program
c
c     EGFHI.F
c     Uses High-Level routines
c     Creates a vset of 1 vgroup and 3 vdatas in the file 'egfhi.hdf'.
c
c
c     ===========================================================

      program HIGHLEVEL

      print *, 'This program tests the Fortran Vset High-level'
      print *, 'calls. It creates 3 vdatas, and then create a vgroup'
      print *, 'that will be linked to the 3 vdatas.'
      print *,' '

      call DOIT

      end



      subroutine DOIT

c     Remove this fortran directive if your compiler doesn't support it.
c     It forces an error message whenever a variable is not declared.

      IMPLICIT	NONE

      integer	idata(200)
      real	rdata(200)
      integer	conval(3,200)
      integer	tagarray(10), refarray(10)

c     --- declare the HDF and VSET routines used. This is compulsory!

      external HOPEN, HCLOSE ,VHFSD, VHFSDM, VHFMKGP, VFSTART, VFEND
      integer	HOPEN, VHFSD, VHFSDM, VHFMKGP

      integer 	f, i, j
      integer  vs1, vs2, vs3, vg

c     --- some defined constants. see "vg.h"

      integer 	LONGTYPE
      parameter 	(LONGTYPE=24)
      integer 	REALTYPE

      parameter 	(REALTYPE=5)
      integer		VDATATAG
      parameter 	(VDATATAG=1962)
      integer 	FULLACC
      parameter 	(FULLACC=7)

c     ------ generate some data -------

      do 111 i=1,200
         rdata(i) = i *1.001 + 500
         idata(i) = i
 111  continue

      do 112 i=1,100
         do 114 j=1,3
            conval(j,i) = i*j
 114     continue
 112  continue

c     ------- open hdf file ------

      f = HOPEN ('egfhi.hdf'//char(0), FULLACC, 0)
      call VFSTART (f)

c     ------- store 100 floats as one field in one vdata  ------
      vs1 = VHFSD (f, 'MP', rdata, 100, REALTYPE,
     +     'melting-points', 'test')

c     ------- store 120 integers as one field in one vdata  ------
      vs2 = VHFSD (f, 'AGE', idata, 120, LONGTYPE,
     +     'age-of-specimens', 'test')


c     ------- store 100*3 values as one field (of order 3) -----
c     ------- in one vdata  ------
      vs3 = VHFSDM (f, 'PLIST', conval, 100, LONGTYPE,
     +     'connectivity triplets','test',3)

c     --------- messages  ----------------------

      if (vs1 .eq. -1) then
         print *,'error creating melting-point vdata'
      else
         print *, 'created vdata "melting-points" with 100 elements'
      endif

      if (vs2 .eq. -1) then
         print *,'error creating  "age-of-specimens" vdata'
      else
         print *, 'created vdata "age-of-specimens" with 120 elements'
      endif
      if (vs3 .eq. -1) then
         print *,'error creating  "connectivity triplets" vdata'
      else
         print *, 'created vdata "connectivity triplets" with '
         print *, '   100 elements'
      endif

c     ------ make a vgroup that has links to all the above vdatas ----

      tagarray(1) = VDATATAG
      refarray(1) = vs1
      tagarray(2) = VDATATAG
      refarray(2) = vs2
      tagarray(3) = VDATATAG
      refarray(3) = vs3

      vg = VHFMKGP(f,tagarray,refarray,3,
     +     'vgroup with 3 vdatas (fortran)', 'test')
      if (vg .eq. -1) then
         print *,'error creating  vgroup'
      else
         print *, 'created vgroup that links all the 3 vdatas'
      endif
c     --- all done. close the file ---
      call VFEND (f)
      call HCLOSE (f)

      print *,' '
      print *, 'SUCCESS: created file egfhi.hdf'
      print *, 'Use the utility vshow to look at the results:'
      print *, '       vshow egfhi.hdf +'
      print *, 'Results should be as in the file egfhi.result'
      print *,' '

      end