<HTML><HEAD>
<TITLE>HDF5 Tutorial - Creating Datasets in Groups
</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 Datasets in Groups</FONT>
</BIG></BIG></BIG></H1>

<hr noshade size=1>

<BODY>
<H2>Contents:</H2>
<UL>
    <LI> <A HREF="#ds"> Creating datasets in groups</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="ds">
<H2><U>Creating datasets in groups</U></H2>      
We have shown how to create groups, datasets, and attributes. 
In this section, we show how to create datasets in groups. 
Recall that <code>H5Dcreate</code>/<code>h5dcreate_f</code> 
creates a dataset at the location specified by a location identifier and 
a name. Similar to <code>H5Gcreate</code>/<code>h5gcreate_f</code>, 
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.


<H2> Programming Example</H2>
<A NAME="desc">
<H3><U>Description</U></H3>      
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.<BR>
<UL>
[ <A HREF="examples/h5_crtgrpd.c">C Example</A> ] -  <code>h5_crtgrpd.c</code>
<BR>
[ <A HREF="examples/grpdsetexample.f90">FORTRAN Example</A> ] 
- <code>grpdsetexample.f90</code><BR> 
[ <A HREF="examples/java/CreateGroupDataset.java">Java Example</A> ] 
- <code>CreateGroupDataset.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.


<A NAME="fc">
<H3><U>File Contents</U></H3>
<P>
<B>Fig. 10.1</B> &nbsp; <I>The Contents of <code>groups.h5</code> 
   (<code>groupsf.h5</code> for FORTRAN)</I>
<PRE>
<IMG src="img005.gif"></PRE>
<!-- <IMG src="groups2.jpg" width="324" height="433"></PRE> -->

</PRE>
 <B>Fig. 10.2a</B> &nbsp; <I><code>groups.h5</code> in DDL</I>
<PRE>

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
         }
      }
   }
}
}
</PRE>
 <B>Fig. 10.2b</B> &nbsp; <I><code>groupsf.h5</code> in DDL</I>
<PRE>

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
         }
      }
   }
}
}
</PRE>
<!-- 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>
<!-- <A HREF="helpdesk.mail.html"> -->
<BR><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>