I see from https://petsc.org/main/docs/manualpages/Mat/MatLoad/ that MatView for HDF5 binary format is not yet implemented. Any idea when this will be implemented?
F. Current HDF5 (MAT-File) limitations <https://petsc.org/main/docs/manualpages/Mat/MatLoad/#current-hdf5-mat-file-limitations> This reader currently supports only real MATSEQAIJ, MATMPIAIJ, MATSEQDENSE and MATMPIDENSE matrices. Corresponding MatView() is not yet implemented. The loaded matrix is actually a transpose of the original one in MATLAB, unless you push PETSC_VIEWER_HDF5_MAT format (see examples above). With this format, matrix is automatically transposed by PETSc, unless the matrix is marked as SPD or symmetric (see MatSetOption(), MAT_SPD, MAT_SYMMETRIC). On Tue, Oct 4, 2022 at 9:42 AM fujisan <[email protected]> wrote: > It turns out there is nothing in the hdf5 file: > > $ h5dump data/matrix3.mat.h5 > HDF5 "data/matrix3.mat.h5" { > GROUP "/" { > } > } > > > On Tue, Oct 4, 2022 at 9:19 AM fujisan <[email protected]> wrote: > >> Hi everyone, >> >> I have written a matrix in an HDF5 binary file without problem using >> PetscViewerHDF5Open function like this: >> >> ! Write >> if (ishdf5) then >> PetscCall(PetscViewerHDF5Open(PETSC_COMM_WORLD,trim(filename >> ),FILE_MODE_WRITE,view,ierr)) >> else >> PetscCall(PetscViewerBinaryOpen(PETSC_COMM_WORLD,trim(filename >> ),FILE_MODE_WRITE,view,ierr)) >> endif >> PetscCall(MatView(A,view,ierr)) >> PetscCall(PetscViewerDestroy(view,ierr)) >> >> But when I want to read that HDF5 file like this: >> >> ! Read >> if (ishdf5) then >> PetscCall(PetscViewerHDF5Open(PETSC_COMM_WORLD,trim(filename >> ),FILE_MODE_READ,view,ierr)) >> else >> PetscCall(PetscViewerBinaryOpen(PETSC_COMM_WORLD,trim(filename >> ),FILE_MODE_READ,view,ierr)) >> endif >> PetscCall(MatCreate(PETSC_COMM_WORLD,A,ierr)) >> PetscCall(MatSetType(A,MATMPIAIJ,ierr)) >> PetscCall(MatLoad(A,view,ierr)) >> PetscCall(PetscViewerDestroy(view,ierr)) >> >> I get this kind of error message below. >> I don't have any problem writing / reading using PetscViewerBinaryOpen, >> and no problem writing / reading a vector using PetscViewerHDF5Open either. >> >> What am I missing ? >> >> Fuji >> >> [0]PETSC ERROR: --------------------- Error Message >> -------------------------------------------------------------- >> [0]PETSC ERROR: Unexpected data in file >> [0]PETSC ERROR: Attribute /Mat_0xc4000016_0/MATLAB_sparse does not exist >> and default value not provided >> [0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting. >> [0]PETSC ERROR: Petsc Release Version 3.18.0, unknown >> [0]PETSC ERROR: ./bin/solve on a x86_64 named master by beauduin Tue Oct >> 4 08:55:55 2022 >> [0]PETSC ERROR: Configure options --with-petsc-arch=x86_64 >> --COPTFLAGS="-g -O3" --FOPTFLAGS="-g -O3" --CXXOPTFLAGS="-g -O3" >> --with-debugging=0 --with-cc=mpiicc --with-cxx=mpiicpc --with-fc=mpiifort >> --with-single-library=1 --with-mpiexec=mpiexec --with-precision=double >> --with-fortran-interfaces=1 --with-make=1 --with-mpi=1 >> --with-mpi-compilers=1 --download-fblaslapack=0 --download-hypre=1 >> --download-cmake=0 --with-cmake=1 --download-metis=1 --download-parmetis=1 >> --download-ptscotch=0 --download-suitesparse=1 --download-triangle=1 >> --download-superlu=1 --download-superlu_dist=1 --download-scalapack=1 >> --download-mumps=1 --download-elemental=1 --download-spai=0 >> --download-parms=1 --download-moab=1 --download-chaco=0 --download-fftw=1 >> --with-petsc4py=1 --download-mpi4py=1 --download-saws >> --download-concurrencykit=1 --download-revolve=1 --download-cams=1 >> --download-p4est=0 --with-zlib=1 --with-hdf5=1 --download-hdf5=1 >> --download-mfem=1 --download-glvis=0 --with-opengl=0 --download-libpng=1 >> --download-libjpeg=1 --download-slepc=1 --download-hpddm=1 >> --download-bamg=1 --download-mmg=0 --download-parmmg=0 --download-htool=1 >> --download-egads=0 --download-opencascade=0 PETSC_ARCH=x86_64 >> [0]PETSC ERROR: #1 PetscViewerHDF5ReadAttribute() at >> /data/softs/petsc/src/sys/classes/viewer/impls/hdf5/hdf5v.c:1245 >> [0]PETSC ERROR: #2 MatLoad_AIJ_HDF5() at >> /data/softs/petsc/src/mat/impls/aij/seq/aijhdf5.c:63 >> [0]PETSC ERROR: #3 MatLoad_MPIAIJ() at >> /data/softs/petsc/src/mat/impls/aij/mpi/mpiaij.c:3034 >> [0]PETSC ERROR: #4 MatLoad() at >> /data/softs/petsc/src/mat/interface/matrix.c:1304 >> [0]PETSC ERROR: #5 bigmat.F90:62 >> [0]PETSC ERROR: #6 MatCreateVecs() at >> /data/softs/petsc/src/mat/interface/matrix.c:9336 >> [0]PETSC ERROR: #7 solve.F90:143 >> Abort(73) on node 0 (rank 0 in comm 16): application called >> MPI_Abort(MPI_COMM_SELF, 73) - process 0 >> forrtl: severe (174): SIGSEGV, segmentation fault occurred >> Image PC Routine Line >> Source >> solve 000000000043258A Unknown Unknown >> Unknown >> libpthread-2.28.s 00007FCAF0B78C20 Unknown Unknown >> Unknown >> libmpi.so.12.0.0 00007FCAF17A09D3 Unknown Unknown >> Unknown >> .... >> >
