[Hdf-forum] H5Dcreate2() bug?

Xunlei Wu xunlei at renci.org
Sun Jan 10 17:43:13 EST 2010


Hi All,

Reporting a weird behavior involving H5Dcreate2(). The only difference
between 2 below code sections is using "pos" or "position" as the second
parameter of H5Dcreate2(). I am wondering whether "position" is a
reserved word/macro in HDF5. When using "position", all the elements
written in the .h5 file become -4.3160208E8. Please help.

Best,
xunlei

//---- below code writes INVALID data ----
/*allocate space, initialization, and etc.*/
...
dim[0] = 100;
dim[1] = 3;
for(int j=0; j<dim[0]; j++){
val_f[ j] = ps[i][j].x;
val_f[ dim[0] + j] = ps[i][j].y;
val_f[2 * dim[0] + j] = ps[i][j].z;
}

space_id = H5Screate_simple(2, dim, NULL);
dataset_id = H5Dcreate(group_frame_id, "position", H5T_IEEE_F32BE,
space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/* Write data to the dataset; */
status = H5Dwrite(dataset_id, H5T_NATIVE_FLOAT, space_id, H5S_ALL,
H5P_DEFAULT, val_f);

H5Sclose(space_id);
H5Dclose(dataset_id);

//---- below code writes CORRECT data ----
/*allocate space, initialization, and etc.*/
...
dim[0] = 100;
dim[1] = 3;
for(int j=0; j<dim[0]; j++){
val_f[ j] = ps[i][j].x;
val_f[ dim[0] + j] = ps[i][j].y;
val_f[2 * dim[0] + j] = ps[i][j].z;
}

space_id = H5Screate_simple(2, dim, NULL);
dataset_id = H5Dcreate(group_frame_id, "pos", H5T_IEEE_F32BE, space_id,
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/* Write data to the dataset; */
status = H5Dwrite(dataset_id, H5T_NATIVE_FLOAT, space_id, H5S_ALL,
H5P_DEFAULT, val_f);

H5Sclose(space_id);
H5Dclose(dataset_id);




More information about the Hdf-forum mailing list