[ HDF5 Tutorial Top ] [ Introductory Topics Top ] [ Next ] [ Prev ]

Creating a Group


What is a Group?

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:

  1. Obtain the location identifier where the group is to be created.
  2. Create the group.
  3. Close the group.
To create a group, the calling program must call H5Gcreate/h5gcreate_f. To close the group, H5Gclose/h5gclose_f must be called. For example:


  group_id = H5Gcreate (loc_id, name, size_hint);
  status = H5Gclose (group_id);
  CALL h5gcreate_f (loc_id, name, group_id, error, size_hint=size)
  CALL h5gcreate_f (loc_id, name, group_id, error)

  CALL h5gclose_f (group_id, error)

Programming Example


The following example shows how to create and close a group. It creates a file called group.h5 (groupf.h5 for FORTRAN), creates a group called MyGroup in the root group, and then closes the group and file.
NOTE: To download a tar file of the examples, including a Makefile, please go to the References page.


File Contents

The contents of group.h5 and the definition of the group are shown below. (The FORTRAN program creates the HDF5 file groupf.h5 and the resulting DDL shows groupf.h5 in the first line.)

Fig. 8.1   The Contents of group.h5.   Fig. 8.2   group.h5 in DDL
HDF5 "group.h5" {
GROUP "/" {
   GROUP "MyGroup" {

The National Center for Supercomputing Applications

University of Illinois at Urbana-Champaign


Last Modified: November 21, 2001