Page tree

The license could not be verified: License Certificate has expired!

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To create an integer attribute in C, you must create the dataspace, create the attribute, write to it and then close it in separate steps:  

hid_t       attribute_id, dataspace_id;  /* identifiers */

...

hsize_t     dims;

...

int         attr_data[2];

...

herr_t      status;

   ...

...

/* Initialize the attribute data. */

...

attr_data[0] = 100;

...

attr_data[1] = 200;

   

/* Create the data space for the attribute. */

...

dims = 2;

...

dataspace_id = H5Screate_simple(1, &dims, NULL);

 

...


/* Create a dataset attribute. */

...

attribute_id = H5Acreate2 (dataset_id, "Units", H5T_STD_I32BE,

...

                           dataspace_id, H5P_DEFAULT, H5P_DEFAULT);

   

/* Write the attribute data. */

...

status = H5Awrite(attribute_id, H5T_NATIVE_INT, attr_data);

 

...


/* Close the attribute. */

...

status = H5Aclose(attribute_id);

 

...


/* Close the dataspace. */

...

status = H5Sclose(dataspace_id);