/*
 * exph5_tarray
 * This example creates defined types that are arrays, not including bags, sets or lists..
 */


#include "hdf5.h"
#include "hdf5_hl.h"

int
main(void)
{
    hid_t    file, pop1_group, schema_group, arrayreal, typearray, cdm_real;
    herr_t    status;
    int rank, perm;
    hsize_t    dimen[5]; 

    /*
     * Create a new HDF5 file.
     */
    file = H5Fcreate("exph5_tarray.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
    /*
     * Create a data and schema group in the file and set required attributes and a description.
     */
    pop1_group = H5Gcreate(file, "/Pop1", 0);
    schema_group = H5Gcreate(file, "/geometry_encoding1", 0);
    status =  H5LTset_attribute_string( pop1_group, "/Pop1", "iso_10303_26_data", "geometry" );
    status =  H5LTset_attribute_string( schema_group, "/geometry_encoding1", "iso_10303_26_schema", "geometry" );
    status =  H5LTset_attribute_string( schema_group, "/geometry_encoding1", "iso_10303_26_description", 
              "Contains example aggregate defined types." );

/* Add example of TYPE <name> = <simple type>  */
    cdm_real = H5Tcopy (H5T_NATIVE_DOUBLE);
    status = H5Tcommit (schema_group, "context_dependent_measure", cdm_real);

 /* Add example of TYPE <name> = <aggregate_type>  */
    rank = 1;
    dimen[0] = 3;
    arrayreal = H5Tarray_create(cdm_real, rank, dimen, &perm  );
    typearray = H5Tcopy (arrayreal);
    status = H5Tcommit (schema_group, "anisotropic_symmetric_tensor2_2d", typearray);

    H5Gclose(pop1_group);
    H5Gclose(schema_group);
    H5Fclose(file);

}

