On Nov 4, 2008, at 6:24 AM, Zheng Li wrote:
Hi, everyone :
I compiled meep-0.20.3 with mpich in ubuntu and found the function call
void h5file::write(const char *dataname, const char *data)
in
file->write("stringtest", "Hello, world!\n"); @h5test.cpp:103
causes
file->close_id();
to fail in
delete file;

Hi Zheng, thanks for the bug report.

I believe the correct code in h5file::write(const char *dataname, const char *data) should be:

  if (IF_EXCLUSIVE(am_master(), 1)) {
    hid_t file_id = HID(get_id()), type_id, data_id, space_id;

    CHECK(file_id >= 0, "error opening HDF5 output file");

remove_data(dataname); // HDF5 gives error if we H5Dcreate existing dataset

    type_id = H5Tcopy(H5T_C_S1);;
    H5Tset_size(type_id, strlen(data) + 1);
    space_id = H5Screate(H5S_SCALAR);

data_id = H5Dcreate(file_id, dataname, type_id, space_id, H5P_DEFAULT);
    if (am_master())
      H5Dwrite(data_id, type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);

    H5Sclose(space_id);
    H5Tclose(type_id);
    H5Dclose(data_id);
  }

The first am_master() check is only for non-parallel HDF5 versions. The second am_master check is because only one process needs to write the data, even for parallel HDF5. (The dataset by default is opened in independent-access mode.)

Can you confirm that the test passes on your machine with this modification?

Steven

PS. Reading the PHDF5 documentation again, I notice that we also really should be calling H5Pset_dxpl_mpio to do collective I/O for the field datasets, for better performance. Another thing for the TODO list...
_______________________________________________
meep-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss

Reply via email to