File: h4ex_AN_create_annotation.f

package info (click to toggle)
libhdf4 4.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: 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 (125 lines) | stat: -rw-r--r-- 3,827 bytes parent folder | download | duplicates (7)
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
      program create_annotation
      implicit none
C
C     Parameter declaration
C
      character*22 FILE_NAME
      character*9  VG_NAME
      character*19 FILE_LABEL_TXT
      character*53 FILE_DESC_TXT
      character*16 DATA_LABEL_TXT
      character*54 DATA_DESC_TXT
C
      parameter (FILE_NAME      = 'General_HDFobjects.hdf',
     +           VG_NAME        = 'AN Vgroup',
     +           FILE_LABEL_TXT = 'General HDF objects',
     +           DATA_LABEL_TXT = 'Common AN Vgroup',
     +           FILE_DESC_TXT  = 
     + 'This is an HDF file that contains general HDF objects',
     +           DATA_DESC_TXT  = 
     + 'This is a vgroup that is used to test data annotations')
      integer DFACC_CREATE
      parameter (DFACC_CREATE = 4)
      integer AN_FILE_LABEL, AN_FILE_DESC, AN_DATA_LABEL, AN_DATA_DESC
      parameter (AN_FILE_LABEL = 2,
     +           AN_FILE_DESC  = 3,
     +           AN_DATA_LABEL = 0,
     +           AN_DATA_DESC  = 1)
C
C     Function declaration
C
      integer hopen, hclose
      integer afstart, affcreate, afwriteann, afcreate,
     +        afendaccess, afend
      integer vfstart, vfatch, vfsnam, vqref, vqtag, vfdtch, vfend

C
C**** Variable declaration ******************************************* 
C
      integer status
      integer file_id, an_id
      integer file_label_id, file_desc_id
      integer data_label_id, data_desc_id
      integer vgroup_id, vgroup_tag, vgroup_ref
C
C**** End of variable declaration ************************************
C
C
C     Create the HDF file.
C
      file_id = hopen(FILE_NAME, DFACC_CREATE, 0)
C
C     Initialize the AN interface.
C
      an_id = afstart(file_id)
C
C     Create the file label.
C
      file_label_id = affcreate(an_id, AN_FILE_LABEL)
C
C     Write the annotation to the file label.
C
      status = afwriteann(file_label_id, FILE_LABEL_TXT,
     +                    len(FILE_LABEL_TXT))       
C
C     Create file description.
C
      file_desc_id = affcreate(an_id, AN_FILE_DESC)
C
C     Write the annotation to the file description.
C
      status = afwriteann(file_desc_id, FILE_DESC_TXT,
     +                    len(FILE_DESC_TXT))
C
C     Create a vgroup in the file. Note that the vgroup's ref number is
C     set to -1 for creating and the access mode is 'w' for writing.
C
      status    = vfstart(file_id)
      vgroup_id = vfatch(file_id, -1, 'w')
      status    = vfsnam(vgroup_id, VG_NAME)      
C
C     Obtain the tag and reference number of the vgroup for subsequent
C     references.
C
      vgroup_ref = vqref(vgroup_id)
      vgroup_tag = vqtag(vgroup_id)
C
C     Create the data label for the vgroup identified by its tag and ref 
C     number.
C
      data_label_id = afcreate(an_id, vgroup_tag, vgroup_ref,
     +                          AN_DATA_LABEL)
C
C     Write the annotation text to the data label.
C
      status = afwriteann(data_label_id, DATA_LABEL_TXT, 
     +                    len(DATA_LABEL_TXT))
      
C
C     Create the data description for the vgroup identified by its tag and ref.
C
      data_desc_id = afcreate(an_id, vgroup_tag, vgroup_ref, 
     +                        AN_DATA_DESC)
C
C     Write the annotation text to the data description.
C
      status = afwriteann(data_desc_id, DATA_DESC_TXT,
     +                    len(DATA_DESC_TXT))       
C      
C     Terminate access to the vgroup and to the V interface.
C
      status = vfdtch(vgroup_id)
      status = vfend(file_id)
C
C     Terminate access to each annotation explicitly.
C
      status = afendaccess(file_label_id)
      status = afendaccess(file_desc_id)
      status = afendaccess(data_label_id)
      status = afendaccess(data_desc_id)
C
C     Terminate access to the AN interface and close the HDF file.
C
      status = afend(an_id)
      status = hclose(file_id)
      end