[petsc-users] Creating HDF5 groups
Matthew Knepley
knepley at gmail.com
Mon Nov 28 15:39:57 CST 2011
On Mon, Nov 28, 2011 at 2:20 PM, Tim Gallagher <tim.gallagher at gatech.edu>wrote:
> 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:
>
I commented out the write into the root group in ex19 and it worked fine:
knepley:/PETSc3/petsc/petsc-dev$ ./arch-sieve-fdatatypes-debug/bin/h5dump
./ex19.h5
./arch-sieve-fdatatypes-debug/bin/h5dump ./ex19.h5
HDF5 "./ex19.h5" {
GROUP "/" {
GROUP "testBlockSize" {
DATASET "TestVec" {
DATATYPE H5T_IEEE_F64LE
DATASPACE SIMPLE { ( 3, 2 ) / ( 3, 2 ) }
DATA {
(0,0): 1, 1,
(1,0): 1, 1,
(2,0): 1, 1
}
}
}
GROUP "testTimestep" {
DATASET "TestVec" {
DATATYPE H5T_IEEE_F64LE
DATASPACE SIMPLE { ( 2, 3, 2 ) / ( H5S_UNLIMITED, 3, 2 ) }
DATA {
(0,0,0): 1, 1,
(0,1,0): 1, 1,
(0,2,0): 1, 1,
(1,0,0): 1, 1,
(1,1,0): 1, 1,
(1,2,0): 1, 1
}
}
}
}
}
Matt
> #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
>
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20111128/817c6243/attachment.htm>
More information about the petsc-users
mailing list