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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
<HTML><HEAD>
<TITLE>HDF5 Tutorial - Creating a Group
</TITLE>
</HEAD>
<body bgcolor="#ffffff">
<!-- BEGIN MAIN BODY -->
[ <A HREF="title.html"><I>HDF5 Tutorial Top</I></A> ]
<H1>
<BIG><BIG><BIG><FONT COLOR="#c101cd">Creating a Group</FONT>
</BIG></BIG></BIG></H1>
<hr noshade size=1>
<BODY>
<H2>Contents:</H2>
<UL>
<LI> <A HREF="#def">What is a Group</A>?
<LI> Programming Example
<UL>
<LI> <A HREF="#desc">Description</A>
<LI> <A HREF="#rem">Remarks</A>
<LI> <A HREF="#fc">File Contents</A>
</UL>
</UL>
<HR>
<A NAME="def">
<H2>What is a Group?</h2>
<P>
An HDF5 group is a structure containing zero or more HDF5 objects. The two
primary HDF5 objects are groups and datasets. To create a group, the calling
program must:
<OL>
<LI> Obtain the location identifier where the group is to be created.
<LI> Create the group.
<LI> Close the group.
</OL>
To create a group, the calling program must call
<code>H5Gcreate</code>/<code>h5gcreate_f</code>.
To close the group, <code>H5Gclose</code>/<code>h5gclose_f</code>
must be called. For example:
<P>
<I>C:</I>
<PRE>
group_id = H5Gcreate (loc_id, name, size_hint);
status = H5Gclose (group_id);
</PRE>
<I>FORTRAN:</I>
<PRE>
CALL h5gcreate_f (loc_id, name, group_id, error, size_hint=size)
<i>or</i>
CALL h5gcreate_f (loc_id, name, group_id, error)
CALL h5gclose_f (group_id, error)
</PRE>
<P>
<H2> Programming Example</H2>
<A NAME="desc">
<H3><U>Description</U></H3>
The following example shows how to create and close a group. It creates a file
called <code>group.h5</code> (<code>groupf.h5</code> for FORTRAN),
creates a group called <code>MyGroup</code> in the root group,
and then closes the group and file. <BR>
<UL>
[ <A HREF="examples/h5_crtgrp.c">C Example</A> ]
- <code>h5_crtgrp.c</code><BR>
[ <A HREF="examples/groupexample.f90">FORTRAN Example</A> ]
- <code>groupexample.f90</code><BR>
[ <A HREF="examples/java/CreateGroup.java">Java Example</A> ]
- <code>CreateGroup.java</code>
</UL>
<B>NOTE:</B> To download a tar file of the examples, including a Makefile,
please go to the <A HREF="references.html">References</A> page.
</PRE>
<A NAME="rem">
<H3><U>Remarks</U></H3>
<UL>
<LI><code>H5Gcreate</code>/<code>h5gcreate_f</code> creates
a new empty group, named <code>MyGroup</code> and located in the
root group, and returns a group identifier.
<P>
<I>C:</I>
<PRE>
hid_t H5Gcreate (hid_t loc_id, const char *name, size_t size_hint)
</PRE>
<I>FORTRAN:</I>
<PRE>
h5gcreate_f (loc_id, name, group_id, hdferr, size_hint)
loc_id INTEGER(HID_T)
name CHARACTER(LEN=*)
group_id INTEGER(HID_T)
hdferr INTEGER
(Possible values: 0 on success and -1 on failure)
size_hint INTEGER(SIZE_T), OPTIONAL
(Default value: OBJECT_NAMELEN_DEFAULT_F)
</PRE>
<UL>
<LI>The <I>loc_id</I> parameter specifies the location at which
to create the group.
<P>
<LI> The <I>name</I> parameter specifies the name of the group to be created.
<P>
<LI> The <I>size_hint</I> parameter specifies how much file space to
reserve to store the
names that will appear in the group. If a non-positive value is supplied,
then a default size is used. Passing a value of zero is usually adequate
since the library is able to dynamically resize the name heap.
<P>
<LI>In FORTRAN, the return value for the routine is passed in
<I>hdferr</I>: 0 if successful, -1 otherwise. The group identifier
is passed back in <I>group_id</I>. In C, the function returns a valid
group identifier if successful and a negative value otherwise.
</UL>
<P>
<LI><code>H5Gclose</code>/<code>h5gclose_f</code> closes the group.
This call is mandatory.
<P>
<I>C:</I>
<PRE>
herr_t H5Gclose (hid_t group_id)
</PRE>
<I>FORTRAN:</I>
<PRE>
h5gclose_f (group_id, hdferr)
group_id INTEGER(HID_T)
hdferr INTEGER
(Possible values: 0 on success and -1 on failure)
</PRE>
</UL>
<A NAME="fc">
<H3><U>File Contents</U></H3>
The contents of <code>group.h5</code> and the
definition of the group are shown below. (The FORTRAN program
creates the HDF5 file <code>groupf.h5</code> and the resulting DDL shows
<code>groupf.h5</code> in the first line.)
<P>
<table width="80%" border="1" bordercolor="#FFFFFF" cellpadding="6" cellspacing="6">
<tr valign=top>
<td width="43%"><b>Fig. 8.1</b> <i>The Contents of <code>group.h5</code>.</i>
</td>
<td width="10%">
</td>
<td width="47%"><b>Fig. 8.2</b> <i><code>group.h5</code> in DDL</i> </td>
</tr>
<tr bordercolor="#000000">
<!-- <td width="47%"><IMG src="grouph5.jpg" width="205" height="333"></td> -->
<td align=center><IMG src="img003.gif"></td>
<td bordercolor="#FFFFFF"> </td>
<td valign="top">
<pre>
HDF5 "group.h5" {
GROUP "/" {
GROUP "MyGroup" {
}
}
}
</pre>
</td>
</tr>
</table>
<!-- BEGIN FOOTER INFO -->
<P><hr noshade size=1>
<font face="arial,helvetica" size="-1">
<a href="http://www.ncsa.uiuc.edu/"><img border=0
src="footer-ncsalogo.gif"
width=78 height=27 alt="NCSA"><br>
The National Center for Supercomputing Applications</A><br>
<a href="http://www.uiuc.edu/">University of Illinois
at Urbana-Champaign</a><br>
<br>
<!-- <A HREF="helpdesk.mail.html"> -->
<A HREF="mailto:hdfhelp@ncsa.uiuc.edu">
hdfhelp@ncsa.uiuc.edu</A>
<br>
<BR> <H6>Last Modified: June 22, 2001</H6><BR>
<!-- modified by Barbara Jones - bljones@ncsa.uiuc.edu -->
</FONT>
<BR>
<!-- <A HREF="mailto:hdfhelp@ncsa.uiuc.edu"> -->
</BODY>
</HTML>
|