Compound datatypes must be built out of other datatypes. First, one creates an empty compound datatype and specifies its total size. Then members are added to the compound datatype in any order.
h5_compound.c
compound.f90
Compound.java
Field c : 1.0000 0.5000 0.3333 0.2500 0.2000 0.1667 0.1429 0.1250 0.1111 0.1000 Field a : 0 1 2 3 4 5 6 7 8 9 Field b : 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 36.0000 49.0000 64.0000 81.0000 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
H5Tcreate
creates a new datatype of the specified class with
the specified number of bytes.
hid_t H5Tcreate ( H5T_class_t class, size_t size )
H5T_COMPOUND
datatype class is supported with this
function.
H5Tinsert
adds a member to the compound datatype specified by
type_id.
herr_t H5Tinsert ( hid_t type_id, const char * name, off_t offset, hid_t field_id )
HOFFSET
macro to compute the offset of a member within
a struct:
HOFFSET ( s, m )This macro computes the offset of member m within a struct variable s.
H5Tclose
releases a datatype.
herr_t H5Tclose ( hid_t type_id )The type_id parameter is the identifier of the datatype to release.
HDF5 "SDScompound.h5" { GROUP "/" { DATASET "ArrayOfStructures" { DATATYPE { H5T_STD_I32BE "a_name"; H5T_IEEE_F32BE "b_name"; H5T_IEEE_F64BE "c_name"; } DATASPACE { SIMPLE ( 10 ) / ( 10 ) } DATA { { [ 0 ], [ 0 ], [ 1 ] }, { [ 1 ], [ 1 ], [ 0.5 ] }, { [ 2 ], [ 4 ], [ 0.333333 ] }, { [ 3 ], [ 9 ], [ 0.25 ] }, { [ 4 ], [ 16 ], [ 0.2 ] }, { [ 5 ], [ 25 ], [ 0.166667 ] }, { [ 6 ], [ 36 ], [ 0.142857 ] }, { [ 7 ], [ 49 ], [ 0.125 ] }, { [ 8 ], [ 64 ], [ 0.111111 ] }, { [ 9 ], [ 81 ], [ 0.1 ] } } } } }