/* * exph5_simple * This example creates simple defined types and an enumeration type. */ #include "hdf5.h" #include "hdf5_hl.h" int main(void) { hid_t file, pop1_group, schema_group, pos_int, big_int, label_str, enumab, enumels; herr_t status; int ival; /* * Create a new HDF5 file. */ file = H5Fcreate("exph5_simple.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* * Create a data and schema group in the file and set required attributes and a decription. */ 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 simple defined types." ); /* Add examples of TYPE = */ pos_int = H5Tcopy (H5T_NATIVE_INT); status = H5Tcommit (schema_group, "positive_integer", pos_int); /* Add example of TYPE = */ label_str = H5Tcopy (H5T_C_S1); status = H5Tset_size (label_str, H5T_VARIABLE); status = H5Tcommit (schema_group, "label", label_str); /* Add example of TYPE = */ big_int = H5Tcopy (pos_int); status = H5Tcommit (schema_group, "big_positive_integer", big_int); /* Create the new enumeration datatype for the TYPE = ENUMERATION OF (...) */ enumels = H5Tenum_create(H5T_NATIVE_SHORT ); ival = 0; status = H5Tenum_insert(enumels, "ahead", &ival ); ival = 1; status = H5Tenum_insert(enumels, "exact", &ival ); ival = 2; status = H5Tenum_insert(enumels, "behind", &ival ); enumab = H5Tcopy (enumels); status = H5Tcommit (schema_group, "ahead_or_behind", enumab); H5Tclose(pos_int); H5Tclose(label_str); H5Tclose(big_int); H5Tclose(enumels); H5Tclose(enumab); H5Gclose(pop1_group); H5Gclose(schema_group); H5Fclose(file); }