[petsc-users] HDF5 Write attribute
Matthew Knepley
knepley at gmail.com
Thu Jan 18 09:55:55 CST 2018
On Wed, Jan 17, 2018 at 7:35 AM, Marek Pecha <marek.pecha at vsb.cz> wrote:
> Hello,
>
> I create very simple program for writing scalar to HDF5 file (it is just
> test-program, because I learn how HDF5 works), see below.
>
> #include <petscviewerhdf5.h>
>
> int main(int argc, char *argv[]) {
> PetscErrorCode ierr;
> PetscScalar n = 5;
> PetscViewer viewer;
>
> PetscInitialize(&argc,&argv,(char*)0,NULL);
>
> PetscViewerHDF5Open(PETSC_COMM_WORLD, "test.hdf5", FILE_MODE_WRITE,
> &viewer);
> PetscViewerHDF5PushGroup(viewer, "/");
> ierr = PetscViewerHDF5WriteAttribute(viewer, "/", "n", PETSC_SCALAR,
> &n);
> CHKERRQ(ierr);
> PetscViewerDestroy(&viewer);
>
> PetscFinalize();
>
> return (0);
> }
>
> However, I got following error:
>
> HDF5-DIAG: Error detected in HDF5 (1.8.12) MPI-process 0:
> #000: H5D.c line 341 in H5Dopen2(): not a dataset
>
Sorry it took me so long to respond. I was on winter break.
The problem is that HDF5 attributes can only be applied to datasets. '/' is
not a dataset. For example,
if you wrote a Vec into the file, you could apply an attribute to it, like
'axial vector'.
Thanks,
Matt
> major: Dataset
> minor: Inappropriate type
> [0]PETSC ERROR: --------------------- Error Message
> --------------------------------------------------------------
> [0]PETSC ERROR: Error in external library
> [0]PETSC ERROR: Error in HDF5 call H5Dopen2() Status -1
> [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html
> for trouble shooting.
> [0]PETSC ERROR: Petsc Release Version 3.7.5, unknown
> [0]PETSC ERROR: ./aijmathdf5 on a arch-llvm-opt named sweety by dev Wed
> Jan 17 13:33:51 2018
> [0]PETSC ERROR: Configure options --download-blacs --download-boost
> --download-fblaslapack --download-metis --download-mpich --download-mumps
> --download-parmetis --download-scalapack --download-superlu
> --download-superlu_dist --download-hdf5 COPTFLAGS=-O3 CXXOPTFLAGS=-O3
> FOPTFLAGS=-O3 PETSC_ARCH=arch-llvm-opt
> [0]PETSC ERROR: #1 PetscViewerHDF5WriteAttribute() line 653 in
> /opt/petsc/petsc-maint/src/sys/classes/viewer/impls/hdf5/hdf5v.c
> [0]PETSC ERROR: #2 main() line 13 in /Users/dev/Desktop/sparse_
> hdf5/main.cpp
> [0]PETSC ERROR: No PETSc Option Table entries
> [0]PETSC ERROR: ----------------End of Error Message -------send entire
> error message to petsc-maint at mcs.anl.gov----------
> application called MPI_Abort(MPI_COMM_WORLD, 76) - process 0
> [unset]: write_line error; fd=-1 buf=:cmd=abort exitcode=76
> :
> system msg for write_line failure : Bad file descriptor
>
> I don’t know, what I am doing wrong.
>
> Thank you
> Marek
--
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
https://www.cse.buffalo.edu/~knepley/ <http://www.caam.rice.edu/~mk51/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180118/f46ea8b8/attachment.html>
More information about the petsc-users
mailing list