[ HDF5 Tutorial Top ]

Creating Datasets in Groups


Contents:


Creating datasets in groups

We have shown how to create groups, datasets, and attributes. In this section, we show how to create datasets in groups. Recall that H5Dcreate/h5dcreate_f creates a dataset at the location specified by a location identifier and a name. Similar to H5Gcreate/h5gcreate_f, the location identifier can be a file identifier or a group identifier and the name can be relative or absolute. The location identifier and the name together determine the location where the dataset is to be created. If the location identifier and name refer to a group, then the dataset is created in that group.

Programming Example

Description

This example shows how to create a dataset in a particular group. It opens the file created in the previous example and creates two datasets.
NOTE: To download a tar file of the examples, including a Makefile, please go to the References page.

File Contents

Fig. 10.1   The Contents of groups.h5 (groupsf.h5 for FORTRAN)

Fig. 10.2a   groups.h5 in DDL

HDF5 "groups.h5" {
GROUP "/" {
   GROUP "MyGroup" {
      GROUP "Group_A" {
         DATASET "dset2" {
            DATATYPE { H5T_STD_I32BE }
            DATASPACE { SIMPLE ( 2, 10 ) / ( 2, 10 ) }
            DATA {
               1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
               1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            }
         }
      }
      GROUP "Group_B" {
      }
      DATASET "dset1" {
         DATATYPE { H5T_STD_I32BE }
         DATASPACE { SIMPLE ( 3, 3 ) / ( 3, 3 ) }
         DATA {
            1, 2, 3,
            1, 2, 3,
            1, 2, 3
         }
      }
   }
}
}
Fig. 10.2b   groupsf.h5 in DDL

HDF5 "groupsf.h5" {
GROUP "/" {
   GROUP "MyGroup" {
      GROUP "Group_A" {
         DATASET "dset2" {
            DATATYPE { H5T_STD_I32BE }
            DATASPACE { SIMPLE ( 10, 2 ) / ( 10, 2 ) }
            DATA {
               1, 1,
               2, 2,
               3, 3,
               4, 4,
               5, 5,
               6, 6,
               7, 7,
               8, 8,
               9, 9,
               10, 10
            }
         }
      }
      GROUP "Group_B" {
      }
      DATASET "dset1" {
         DATATYPE { H5T_STD_I32BE }
         DATASPACE { SIMPLE ( 3, 3 ) / ( 3, 3 ) }
         DATA {
            1, 1, 1,
            2, 2, 2,
            3, 3, 3
         }
      }
   }
}
}


NCSA
The National Center for Supercomputing Applications

University of Illinois at Urbana-Champaign

hdfhelp@ncsa.uiuc.edu

Last Modified: June 22, 2001