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 H5G_CREATE.
To close the group, H5G_CLOSE must be called. The close call is mandatory.

For example:

C:
  group_id = H5Gcreate(file_id, "/MyGroup", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
  status = H5Gclose (group_id);

FORTRAN: 
  CALL h5gcreate_f (loc_id, name, group_id, error)
  CALL h5gclose_f (group_id, error)

Programming Example

Description

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.

Python

For details on compiling an HDF5 application: [ Compiling HDF5 Applications ]

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" {
   }
}
}