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       file_id, dataset_id, attribute_id, dataspace_id;  /* identifiers */

...

   int         attr_data[2];

   herr_t      status;

   ...

   /* Initialize the attribute data. */

   attr_data[0] = 100;

   attr_data[1] = 200;

 

   /* Open an existing file. */

   file_id = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT);

 

   /* Open an existing dataset. */

   dataset_id = H5Dopen2(file_id, "/dset", H5P_DEFAULT);

 

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

...

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

                              dataspace_id,                              H5P_DEFAULT, H5P_DEFAULT);

...

   status = H5Sclose(dataspace_id);

 

   /* Close to the dataset. */

   status = H5Dclose(dataset_id);

 

   /* Close the file. */

   status = H5Fclose(file_id);