[petsc-users] Creating HDF5 groups
Tim Gallagher
tim.gallagher at gatech.edu
Mon Nov 28 14:20:48 CST 2011
Hi,
I'm a little confused about why this section of code doesn't work, so hopefully somebody can help me. I'm able to run the vec/vec/examples/tutorials/ex19.c test that creates an HDF5 file, and h5dump verifies that it is making the groups and putting vectors in them. However, my code does not make the group (so it obviously doesn't put the vector in it!). The function is:
#undef __FUNCT__
#define __FUNCT__ "Body::SaveGrid"
PetscErrorCode Body::SaveGrid(const char filename[])
{
PetscViewer hdf5File;
Vec coordVec;
// Grab the coordinate vector
m_lastError = DMDAGetCoordinates(m_nodes,&coordVec);
CHKERRXX(m_lastError);
m_lastError = PetscObjectSetName((PetscObject) coordVec, "Coordinates");
CHKERRXX(m_lastError);
// Open the file
m_lastError = PetscViewerHDF5Open(m_commGroup, filename, FILE_MODE_WRITE, &hdf5File);
CHKERRXX(m_lastError);
// Set the group to dump the grid in
m_lastError = PetscViewerHDF5PushGroup(hdf5File, "/grid");
CHKERRXX(m_lastError);
// Dump the coordinates
m_lastError = VecView(coordVec, hdf5File);
CHKERRXX(m_lastError);
m_lastError = PetscViewerHDF5PopGroup(hdf5File);
CHKERRXX(m_lastError);
// Clean up
m_lastError = PetscViewerDestroy(&hdf5File);
CHKERRXX(m_lastError);
}
The only thing I can really see different about this and ex19 is that I don't first write any dataset to the root group, but that's not required to be valid HDF5. If I call PetscViewerHDF5GetGroup after the PushGroup call, it returns /grid.
Any ideas?
Thanks,
Tim
More information about the petsc-users
mailing list