9hid_t
F5Aappend(hid_t loc_id,
const char *
name, hid_t type_id, hid_t space_id, hid_t create_plist )
14 id = H5Acreate2(loc_id,
name, type_id, space_id, create_plist, H5P_DEFAULT );
39 retval = H5Aopen_by_name(location,
".",
name, H5P_DEFAULT, H5P_DEFAULT );
54hid_t type_id = H5Tcopy(H5T_C_S1);
55hid_t space_id = H5Screate(H5S_SCALAR);
58 size_t size = strlen(buf);
59 H5Tset_size(type_id, size+1);
61 H5Tset_strpad(type_id, H5T_STR_NULLTERM);
64 attr_id = H5Acreate2(loc_id,
name, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT);
69 H5Awrite(attr_id, type_id, buf);
81hid_t type_id = H5Tcopy(H5T_C_S1);
82hsize_t Sdims = HowMany;
83hid_t space_id = H5Screate_simple(1, &Sdims, &Sdims);
88 size_t size = strlen(buf);
89 H5Tset_size(type_id, size+1);
91 H5Tset_strpad(type_id, H5T_STR_NULLTERM);
94 attr_id = H5Acreate2(loc_id,
name, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT);
98 H5Awrite(attr_id, type_id, buf);
123 attr_type_hid = H5Aget_type(attr_hid);
125 if (H5Tget_class(attr_type_hid) != H5T_STRING)
127 F5printf(1,
"F5 Error: getAttribute(string): attribute `%s' is not of type string!\n",
name);
132 space_hid = H5Aget_space(attr_hid);
133 assert( space_hid > 0);
134 N = H5Sget_simple_extent_npoints(space_hid);
136 len = H5Tget_size(attr_type_hid);
138 F5printf(100,
"F5 String Attribute `%s': %ld strings of len %ld\n",
name, (
long)N, (
long)len);
141 buf = (
char*)malloc(N*(len+1));
171 F5printf(50,
"-- F5Aget_type() hid_t attrib == NULL");
179 F5printf(50,
"-- F5Aget_type() hid_t attrib < 0");
184 hid_t type = H5Aget_type(*attrib);
186 F5printf(50,
"-- F5Aget_type hid_t type < 0");
197hid_t space_hid = H5Screate_simple(1, &Sdims, &Sdims);
200 F5printf(50,
"-- F5LAsave_dimensions(,aname=%s, rank=%d,)", aname, rank);
204 attr_hid = H5Acreate2(Field_id, aname, H5T_NATIVE_INT, space_hid, H5P_DEFAULT, H5P_DEFAULT);
210 attr_hid = H5Aopen_name(Field_id, aname);
216 for(i=0; i<rank; i++)
219 if (H5Awrite(attr_hid, H5T_NATIVE_INT, UADims )<0)
221 fprintf(stderr,
"F5LAsave_dimensions: CANNOT WRITE %s attribute\n", aname);
238 F5printf(50,
"-- F5LAget_dimensions(,aname=%s,)", aname);
246 hid_t space_id = H5Aget_space(attr_id);
247 int rank = H5Sget_simple_extent_npoints(space_id);
248 assert (space_id > 0);
250 F_H5Aread(attr_id, H5T_NATIVE_HSIZE, dims, aname );
271 space_id = H5Dget_space(Field_id);
278 rank = H5Sget_simple_extent_dims(space_id, dims, NULL);
290hid_t space_hid = H5Screate_simple(1, &Sdims, &Sdims);
293 version_info[0] = major;
294 version_info[1] = minor;
295 version_info[2] = release;
297 H5Awrite(attr_hid, H5T_NATIVE_INT, version_info);
310 if (major ) *major = 0;
311 if (minor ) *minor = 0;
312 if (release) *release = 0;
314 if (loc_id<=0)
return -1;
318 if (attr_hid<=0)
return -1;
320 space_hid = H5Aget_space(attr_hid);
328 assert( space_hid >0 );
332 if (H5Sget_simple_extent_npoints(space_hid) != 3)
334 if (major ) *major = 0;
335 if (minor ) *minor = 0;
336 if (release) *release = 0;
347 if (major ) *major = version_info[0];
348 if (minor ) *minor = version_info[1];
349 if (release) *release = version_info[2];
358 F5printf(50,
"-- F5Asave_ints(,name=%s,,n=%d)",
name, n);
361 hid_t space_hid = n==1? H5Screate(H5S_SCALAR) : H5Screate_simple(1, &n , &n);
363 attr_hid = H5Acreate2(loc_id,
name, H5T_NATIVE_INT, space_hid, H5P_DEFAULT, H5P_DEFAULT);
368 int file_data[ 128 ];
372 F5printf(30,
"F5Asave_ints(,%s,,%d) FAILED, comparison >128 unsupported.",
name, (
int)n);
380 if (file_data[i] != data[i])
383 F5printf(10,
"F5Asave_ints(,%s,,1) FAILED for storing attribute: current value %d; it already exists and has different value %d.",
384 name, (
int)data[0], (
int)file_data[0]);
386 F5printf(10,
"F5Asave_ints(,%s,,%d) FAILED, attribute already exists and has different values.",
name, (
int)n);
390 F5printf(50,
"F5Asave_ints(,%s,,%d) attribute already exists and has same values, nothing changed.",
name, (
int)n);
393 F5printf(10,
"F5Asave_ints(,%s,,%d) FAILED because attribute could not be created.",
name, (
int)n);
397 H5Awrite(attr_hid, H5T_NATIVE_INT, data);
415 space_hid = H5Aget_space(attr_hid);
417 assert( space_hid > 0);
421 elems = H5Sget_simple_extent_npoints(space_hid);
440hid_t space_id = H5Screate(H5S_SCALAR);
442 F5printf(50,
"-- F5Asave_integer(,%s,%d)\n",
name, data);
445 attr_id = H5Acreate2(loc_id,
name, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT);
453 int file_value = data;
454 status = H5Aread(attr_id, H5T_NATIVE_INT, &file_value);
462 if (file_value == data)
464 F5printf(40,
"F5Asave_integer(,%s,%d): attribute already has value %d, not overwritten!\n",
465 name, data, file_value);
470 F5printf(4,
"F5Asave_integer(,%s,%d): attribute has value %d, not overwritten!\n",
471 name, data, file_value);
475 F5printf(4,
"F5Asave_integer(,%s,%d): attribute could not be read, not changed!\n",
481 F5printf(4,
"F5Asave_integer(,%s,%d): can neither create nor open, don't know what to do.\n",
488 status = H5Awrite(attr_id, H5T_NATIVE_INT, &data);
490 status = H5Aclose(attr_id); assert(status>=0);
498hid_t space_id = H5Screate(H5S_SCALAR);
500 F5printf(50,
"-- F5Awrite_integer(,%s,%d)\n",
name, data);
503 attr_id = H5Acreate2(loc_id,
name, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT);
511 F5printf(4,
"F5Awrite_integer(,%s,%d): can neither create nor open, don't know what to do.\n",
516 status = H5Awrite(attr_id, H5T_NATIVE_INT, &data);
523 status = H5Aclose(attr_id);
529int F5Asave(hid_t loc_id,
const char*
name, hid_t file_type_id, hid_t mem_type_id,
const void*data, hsize_t n)
535 hid_t space_hid = n==1? H5Screate(H5S_SCALAR) : H5Screate_simple(1, &n , &n);
537 attr_hid = H5Acreate2(loc_id,
name, file_type_id, space_hid, H5P_DEFAULT, H5P_DEFAULT);
546 H5Awrite(attr_hid, mem_type_id, data);
long F5Aget_ints(hid_t loc_id, const char *name, int *data, hsize_t n)
char * F5Aget_string(hid_t loc_id, const char *name, char *buf, size_t buflen)
hid_t F5Atry_to_open(hid_t location, const char *name)
int F5Awrite_integer(hid_t loc_id, const char *name, int data)
int F5Asave_string(hid_t loc_id, const char *name, const char *buf)
herr_t F5Asave_version(hid_t loc_id, int major, int minor, int release)
int F5Asave(hid_t loc_id, const char *name, hid_t file_type_id, hid_t mem_type_id, const void *data, hsize_t n)
hid_t F5Aappend(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t create_plist)
herr_t F5Aget_version(hid_t loc_id, int *major, int *minor, int *release)
int F5Astore_integer(hid_t loc_id, const char *name, int data)
int F5Asave_ints(hid_t loc_id, const char *name, const int data[], hsize_t n)
int F5Asave_strings(hid_t loc_id, const char *name, const char *buf, int HowMany)
F5_API hid_t F5Aget_type(hid_t loc_id, const char *name, hid_t *attrib)
int F5Lget_dimensions(hid_t Field_id, hsize_t *dims)
#define FIBER_VERSION_ATTRIBUTE_NAME
#define FIBER_FIELD_DATASPACE_DIMENSIONS_ATTRIBUTE
herr_t F_H5Aread(hid_t attr_id, hid_t mem_type_id, void *buf, const char *name)
#define F5printf(verbosity,...)
int F5LAsave_dimensions(hid_t Field_id, const char *aname, int rank, const hsize_t *dims)
int F5LAget_dimensions(hid_t Field_id, const char *aname, hsize_t dims[FIBER_MAX_RANK])
hid_t F5Aopen_name(hid_t location, const char *name)