Hi,
This is my first HDF5 experience, so forgive newbie errors. I've got a
simple HDF5 save facility working for .NET program which needs to export
data for import into Matlab. But I've got a strange problem. The first file
save works fine when I press the save button. But trying to save again
causes an error:
cid:image001.png@01CDFED0.A8BEED70
If I quit the program and start it again, I can once again save
successfully. It's as if the H5F.close function isn't really closing the
file. Here's some of the code:
public void SaveResultsHDF5() {
H5FileId fileId = H5F.create("tests.h5", H5F.CreateMode.ACC_TRUNC);
// Rank is the number of dimensions of the data array.
const int RANK = 2;
long[] dims = new long[RANK];
dims[0] = NRfPnts;
dims[1] = NFreqPnts;
H5DataSpaceId spaceId = H5S.create_simple(RANK, dims);
H5DataTypeId typeId = H5T.copy(H5T.H5Type.NATIVE_INT);
// Create the data set.
H5DataSetId dataSetId = H5D.create(fileId, "/data", typeId,
spaceId);
// Write the integer data to the data set.
H5D.write(dataSetId, typeId, new H5Array<int>(Results));
// Close all the open resources.
H5D.close(dataSetId);
H5T.close(typeId);
H5F.flush(fileId, H5F.Scope.GLOBAL);
H5F.close(fileId);
}
}
Look's pretty simple, right? What could be I be doing wrong?
Note also that I had to add H5F.flush to the code to get the file to flush.
Otherwise I can't import the file into Matlab until I quit the .NET program.
That seems like further evidence that H5F.close isn't really closing the
file in the way that I would expect a file close operation to do.
Any help on this would be greatly appreciated!
- Andy Voelkel