[petsc-users] UNABLE to read '.mat' file with 'PetscViewerHDF5Open' (WSL-Ubuntu22.04)

maitri ksh maitri.ksh at gmail.com
Tue Jul 25 02:12:06 CDT 2023


Hi,
I am new to Petsc, here are some details of the relevant softwares I am
using:
1. petsc-3.19.3 (on wsl-ubuntu22.04 platform)
2. MATLAB-R2022a
3. hdf5-1.10.7 (checked using 'pkg-config --modversion hdf5')
4. configured using:  './configure --with-cc=gcc --with-cxx=g++
--with-fc=gfortran --download-mpich --download-fblaslapack --with-matlab
--with-matlab-dir=/usr/local/MATLAB/R2022a --download-hdf5 --with-hdf5=1'

I am trying to read a '.mat' file ('*myfile.mat*') using
'PetscViewerHDF5Open'  (the source code '*read_Matrix.c*' is attached
herewith). I could compile the source code with no error, but I am getting
an error ('*ERROR.txt*') indicating that there is an issue opening the HDF5
file. Could you please help me to resolve this issue?

Maitri
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230725/0a11ef07/attachment.html>
-------------- next part --------------
#include <petsc.h>
#include <petscviewerhdf5.h>

int main(int argc, char **argv)
{
    PetscInitialize(&argc, &argv, NULL, NULL);

    PetscViewer viewer;
    Mat A;
    MPI_Comm comm = PETSC_COMM_WORLD;

    MatCreate(comm, &A);
    PetscObjectSetName((PetscObject)A, "A");

    /* open HDF5 file for reading */
    PetscViewerHDF5Open(comm, "/home/maitri/my_executables/myfile.mat", FILE_MODE_READ, &viewer);
    PetscViewerPushFormat(viewer, PETSC_VIEWER_HDF5_MAT);

    /* view matrix */
    MatLoad(A, viewer); /* look up by name */

    /* ... use matrix A in computation ... */

    PetscViewerPopFormat(viewer);
    PetscViewerDestroy(&viewer);
    MatDestroy(&A);

    PetscFinalize();
    return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: myfile.mat
Type: application/octet-stream
Size: 386 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230725/0a11ef07/attachment.obj>
-------------- next part --------------
maitri at LAPTOP-0CP4FI1T:~/my_executables$ ./read_Matrix
HDF5-DIAG: Error detected in HDF5 (1.12.2) MPI-process 0:
  #000: H5F.c line 620 in H5Fopen(): unable to open file
    major: File accessibility
    minor: Unable to open file
  #001: H5VLcallback.c line 3501 in H5VL_file_open(): failed to iterate over available VOL connector plugins
    major: Virtual Object Layer
    minor: Iteration failed
  #002: H5PLpath.c line 578 in H5PL__path_table_iterate(): can't iterate over plugins in plugin path '(null)'
    major: Plugin for dynamically loaded library
    minor: Iteration failed
  #003: H5PLpath.c line 620 in H5PL__path_table_iterate_process_path(): can't open directory: /usr/local/hdf5/lib/plugin
    major: Plugin for dynamically loaded library
    minor: Can't open directory or file
  #004: H5VLcallback.c line 3351 in H5VL__file_open(): open failed
    major: Virtual Object Layer
    minor: Can't open object
  #005: H5VLnative_file.c line 97 in H5VL__native_file_open(): unable to open file
    major: File accessibility
    minor: Unable to open file
  #006: H5Fint.c line 1990 in H5F_open(): unable to read superblock
    major: File accessibility
    minor: Read failed
  #007: H5Fsuper.c line 405 in H5F__super_read(): file signature not found
    major: File accessibility
    minor: Not an HDF5 file
[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
[0]PETSC ERROR: Error in external library
[0]PETSC ERROR: Error in HDF5 call H5Fopen() Status -1
[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
[0]PETSC ERROR: Petsc Release Version 3.19.3, unknown
[0]PETSC ERROR: ./read_Matrix on a arch-linux-c-debug named LAPTOP-0CP4FI1T by maitri Tue Jul 25 09:35:41 2023
[0]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-mpich --download-fblaslapack --with-matlab --with-matlab-dir=/usr/local/MATLAB/R2022a --download-hdf5 --with-hdf5=1
[0]PETSC ERROR: #1 PetscViewerFileSetName_HDF5() at /home/maitri/petsc/src/sys/classes/viewer/impls/hdf5/hdf5v.c:423
[0]PETSC ERROR: #2 PetscViewerFileSetName() at /home/maitri/petsc/src/sys/classes/viewer/impls/ascii/filev.c:612
[0]PETSC ERROR: #3 PetscViewerHDF5Open() at /home/maitri/petsc/src/sys/classes/viewer/impls/hdf5/hdf5v.c:628
HDF5-DIAG: Error detected in HDF5 (1.12.2) MPI-process 0:
  #000: H5L.c line 938 in H5Lexists(): invalid location identifier
    major: Invalid arguments to routine
    minor: Inappropriate type
[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
[0]PETSC ERROR: Error in external library
[0]PETSC ERROR: Error in HDF5 call H5Lexists() Status -1
[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
[0]PETSC ERROR: Petsc Release Version 3.19.3, unknown
[0]PETSC ERROR: ./read_Matrix on a arch-linux-c-debug named LAPTOP-0CP4FI1T by maitri Tue Jul 25 09:35:41 2023
[0]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-mpich --download-fblaslapack --with-matlab --with-matlab-dir=/usr/local/MATLAB/R2022a --download-hdf5 --with-hdf5=1
[0]PETSC ERROR: #1 PetscViewerHDF5Traverse_Inner_Internal() at /home/maitri/petsc/src/sys/classes/viewer/impls/hdf5/hdf5v.c:1314
[0]PETSC ERROR: #2 PetscViewerHDF5Traverse_Internal() at /home/maitri/petsc/src/sys/classes/viewer/impls/hdf5/hdf5v.c:1367
[0]PETSC ERROR: #3 PetscViewerHDF5ReadAttribute() at /home/maitri/petsc/src/sys/classes/viewer/impls/hdf5/hdf5v.c:1236
[0]PETSC ERROR: #4 MatLoad_AIJ_HDF5() at /home/maitri/petsc/src/mat/impls/aij/seq/aijhdf5.c:63
[0]PETSC ERROR: #5 MatLoad_SeqAIJ() at /home/maitri/petsc/src/mat/impls/aij/seq/aij.c:4981
[0]PETSC ERROR: #6 MatLoad() at /home/maitri/petsc/src/mat/interface/matrix.c:1333
HDF5-DIAG: Error detected in HDF5 (1.12.2) MPI-process 0:
  #000: H5F.c line 668 in H5Fflush(): not a file or file object
    major: Invalid arguments to routine
    minor: Inappropriate type
[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
[0]PETSC ERROR: Error in external library
[0]PETSC ERROR: Error in HDF5 call H5Fflush() Status -1
[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
[0]PETSC ERROR: Petsc Release Version 3.19.3, unknown
[0]PETSC ERROR: ./read_Matrix on a arch-linux-c-debug named LAPTOP-0CP4FI1T by maitri Tue Jul 25 09:35:41 2023
[0]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-mpich --download-fblaslapack --with-matlab --with-matlab-dir=/usr/local/MATLAB/R2022a --download-hdf5 --with-hdf5=1
[0]PETSC ERROR: #1 PetscViewerFlush_HDF5() at /home/maitri/petsc/src/sys/classes/viewer/impls/hdf5/hdf5v.c:115
[0]PETSC ERROR: #2 PetscViewerFlush() at /home/maitri/petsc/src/sys/classes/viewer/interface/flush.c:22
[0]PETSC ERROR: #3 PetscViewerDestroy() at /home/maitri/petsc/src/sys/classes/viewer/interface/view.c:94
Attempting to use an MPI routine (internal_Comm_free) before initializing or after finalizing MPICH


More information about the petsc-users mailing list