#include "hdf5.h" int main (void) { hid_t file, dataset, fid, str_id, attribute, stype; hsize_t dimsf[1]; herr_t ret; float time[]={0.0}; hid_t fapl_id; int i; char string[6]; fapl_id = H5Pcreate(H5P_FILE_ACCESS); /* only happens with V2 */ H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); file = H5Fcreate("out.h5", H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); dimsf[0] = 1; fid = H5Screate_simple(1, dimsf, NULL); dataset = H5Dcreate2(file, "data", H5T_NATIVE_FLOAT, fid, H5P_DEFAULT, H5P_DEFAULT,H5P_DEFAULT); ret = H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, time); /* We need at least 9 attributes to trigger the error */ for (i=0; i<9; i++) { str_id = H5Screate(H5S_SCALAR); stype = H5Tcopy(H5T_C_S1); H5Tset_size(stype, 4); H5Tset_strpad(stype,H5T_STR_NULLTERM); sprintf(string, "attr%i", i); attribute = H5Acreate2(dataset, string, stype, str_id, H5P_DEFAULT, H5P_DEFAULT); ret = H5Awrite(attribute, stype, "1234"); ret = H5Sclose(str_id); ret = H5Aclose(attribute); H5Tclose(stype); } H5Sclose(fid); H5Dclose(dataset); H5Fclose(file); return 0; }