Commit a65e9586 authored by Marc Howison's avatar Marc Howison

fixed string attribute bug reported by Allen Sanderson

parent 3c6065e2
......@@ -1085,16 +1085,28 @@ _H5Part_write_attrib (
herr_t herr;
hid_t space_id;
hid_t attrib_id;
hid_t type = attrib_type;
space_id = H5Screate_simple (1, &attrib_nelem, NULL);
if ( space_id < 0 )
return HANDLE_H5S_CREATE_SIMPLE_ERR ( attrib_nelem );
if (type == H5T_STRING) {
type = H5Tcopy(H5T_C_S1);
if (attrib_type < 0) return HANDLE_H5T_STRING_ERR;
herr = H5Tset_size(type,attrib_nelem);
if (herr < 0) return HANDLE_H5T_STRING_ERR;
space_id = H5Screate (H5S_SCALAR);
if ( space_id < 0 )
return HANDLE_H5S_CREATE_SCALAR_ERR;
}
else {
space_id = H5Screate_simple (1, &attrib_nelem, NULL);
if ( space_id < 0 )
return HANDLE_H5S_CREATE_SIMPLE_ERR ( attrib_nelem );
}
#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 8
attrib_id = H5Acreate2 (
id,
attrib_name,
attrib_type,
type,
space_id,
H5P_DEFAULT,
H5P_DEFAULT );
......@@ -1102,13 +1114,13 @@ _H5Part_write_attrib (
attrib_id = H5Acreate (
id,
attrib_name,
attrib_type,
type,
space_id,
H5P_DEFAULT );
#endif
if ( attrib_id < 0 ) return HANDLE_H5A_CREATE_ERR ( attrib_name );
herr = H5Awrite ( attrib_id, attrib_type, attrib_value);
herr = H5Awrite ( attrib_id, type, attrib_value);
if ( herr < 0 ) return HANDLE_H5A_WRITE_ERR ( attrib_name );
herr = H5Aclose ( attrib_id );
......@@ -1209,7 +1221,7 @@ H5PartWriteFileAttribString (
h5part_int64_t herr = _H5Part_write_attrib (
group_id,
attrib_name,
H5T_NATIVE_CHAR,
H5T_STRING,
attrib_value,
strlen ( attrib_value ) + 1 );
if ( herr < 0 ) return herr;
......@@ -1247,7 +1259,7 @@ H5PartWriteStepAttribString (
h5part_int64_t herr = _H5Part_write_attrib (
f->timegroup,
name,
H5T_NATIVE_CHAR,
H5T_STRING,
value,
strlen ( value ) + 1 );
if ( herr < 0 ) return herr;
......
......@@ -50,6 +50,7 @@ extern "C" {
#define H5PART_FLOAT64 ((h5part_int64_t)H5T_NATIVE_DOUBLE)
#define H5PART_FLOAT32 ((h5part_int64_t)H5T_NATIVE_FLOAT)
#define H5PART_CHAR ((h5part_int64_t)H5T_NATIVE_CHAR)
#define H5PART_STRING ((h5part_int64_t)H5T_STRING)
/*========== File Opening/Closing ===============*/
H5PartFile*
......
......@@ -291,6 +291,12 @@
"Cannot get chunk dimensions." );
/* H5S: dataspace */
#define HANDLE_H5S_CREATE_SCALAR_ERR \
(*_err_handler) ( \
_H5Part_get_funcname(), \
H5PART_ERR_HDF5, \
"Cannot create scalar dataspace." );
#define HANDLE_H5S_CREATE_SIMPLE_ERR( n ) \
(*_err_handler) ( \
_H5Part_get_funcname(), \
......@@ -322,6 +328,12 @@
"Cannot set select hyperslap region or add the specified region" );
/* H5T: type */
#define HANDLE_H5T_STRING_ERR \
(*_err_handler) ( \
_H5Part_get_funcname(), \
H5PART_ERR_HDF5, \
"Cannot create string datatype." );
#define HANDLE_H5T_CLOSE_ERR \
(*_err_handler) ( \
_H5Part_get_funcname(), \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment