[petsc-users] HDF5 Write attribute

Marek Pecha marek.pecha at vsb.cz
Wed Jan 17 06:35:28 CST 2018


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
    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


More information about the petsc-users mailing list