H5Dcreate2() bug?

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);

Hi Xunlei,

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.

  There are no reserved names for objects in HDF5 files. This sort of behavior typically indicates a memory overwrite somewhere in the application. I suggest running it with valgrind to see if you can locate the problem.

  Quincey

···

On Jan 10, 2010, at 4:43 PM, Xunlei Wu wrote:

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);

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org