On Thu, Jun 6, 2024, 14:53 Klaij, Christiaan <[email protected]> wrote:
> I'm writing a matrix to file from my fortran code (that uses petsc-3. 19. > 4) with -mat_view binary. Then, I'm trying to load this mat into python > (that uses petsc-3. 21. 0). This works fine using single or multiple procs > when the marix > ZjQcmQRYFpfptBannerStart > This Message Is From an External Sender > This message came from outside your organization. > > ZjQcmQRYFpfptBannerEnd > I'm writing a matrix to file from my fortran code (that uses petsc-3.19.4) > with -mat_view binary. Then, I'm trying to load this mat into python (that > uses petsc-3.21.0). This works fine using single or multiple procs when the > marix was written using a single proc (attached file a_mat_np_1.dat). > However, when the matrix was written using mulitple procs (attached file > a_mat_n_2.dat) I get the error below. Is this supposed to work? If so, what > I'm I doing wrong? > This should work. And your script seems ok too . How did you save the matrix in parallel? I suspect that file is corrupt > > $ cat test_matrixImport_binary.py > import sys > import petsc4py > from petsc4py import PETSc > from mpi4py import MPI > > # mat files > #filename = "./a_mat_np_1.dat" # Works > filename = "./a_mat_np_2.dat" # Doesn't work > > # Initialize PETSc > petsc4py.init(sys.argv) > > # Create a viewer for reading the binary file > viewer = PETSc.Viewer().createBinary(filename, mode='r', > comm=PETSc.COMM_WORLD) > > # Create a matrix and load data from the binary file > A = PETSc.Mat().create(comm=PETSc.COMM_WORLD) > A.load(viewer) > > $ python test_matrixImport_binary.py > Traceback (most recent call last): > File "/projects/P35662.700/test_cklaij/test_matrixImport_binary.py", line > 18, in <module> > A.load(viewer) > File "petsc4py/PETSc/Mat.pyx", line 2025, in petsc4py.PETSc.Mat.load > petsc4py.PETSc.Error: error code 79 > [0] MatLoad() at /home/cklaij/petsc-3.21.0/src/mat/interface/matrix.c:1344 > [0] MatLoad_SeqAIJ() at > /home/cklaij/petsc-3.21.0/src/mat/impls/aij/seq/aij.c:5091 > [0] MatLoad_SeqAIJ_Binary() at > /home/cklaij/petsc-3.21.0/src/mat/impls/aij/seq/aij.c:5142 > [0] Unexpected data in file > [0] Inconsistent matrix data in file: nonzeros = 460, sum-row-lengths = 761 > > $ mpirun -n 2 python test_matrixImport_binary.py > Traceback (most recent call last): > File "/projects/P35662.700/test_cklaij/test_matrixImport_binary.py", line > 18, in <module> > Traceback (most recent call last): > File "/projects/P35662.700/test_cklaij/test_matrixImport_binary.py", line > 18, in <module> > A.load(viewer) > File "petsc4py/PETSc/Mat.pyx", line 2025, in petsc4py.PETSc.Mat.load > A.load(viewer) > File "petsc4py/PETSc/Mat.pyx", line 2025, in petsc4py.PETSc.Mat.load > petsc4py.PETSc.Error: error code 79 > [0] MatLoad() at /home/cklaij/petsc-3.21.0/src/mat/interface/matrix.c:1344 > [0] MatLoad_MPIAIJ() at > /home/cklaij/petsc-3.21.0/src/mat/impls/aij/mpi/mpiaij.c:3035 > [0] MatLoad_MPIAIJ_Binary() at > /home/cklaij/petsc-3.21.0/src/mat/impls/aij/mpi/mpiaij.c:3087 > [0] Unexpected data in file > [0] Inconsistent matrix data in file: nonzeros = 460, sum-row-lengths = 761 > petsc4py.PETSc.Error: error code 79 > [1] MatLoad() at /home/cklaij/petsc-3.21.0/src/mat/interface/matrix.c:1344 > [1] MatLoad_MPIAIJ() at > /home/cklaij/petsc-3.21.0/src/mat/impls/aij/mpi/mpiaij.c:3035 > [1] MatLoad_MPIAIJ_Binary() at > /home/cklaij/petsc-3.21.0/src/mat/impls/aij/mpi/mpiaij.c:3087 > [1] Unexpected data in file > [1] Inconsistent matrix data in file: nonzeros = 460, sum-row-lengths = 761 > > > dr. ir. Christiaan Klaij > | Senior Researcher | Research & Development > T +31 317 49 33 44 <+31%20317%2049%2033%2044> | [email protected] | > https://urldefense.us/v3/__http://www.marin.nl__;!!G_uCfscf7eWS!bo30rJrAzGhdWcQwu5TbarbyiLMX1JhUlqvIeOd9MkvOG0knvEGaXfbc0_OWtTDnRlaJwql3m5vwIgprE0TsH2sIh1Prvdg$ > > <https://urldefense.us/v3/__https://www.marin.nl/__;!!G_uCfscf7eWS!YrcVeQ6V8OD3jKxSzzxpyuTgFdncWh4YcL1SgDT8NHqystMpzO1pkd17oNGni-ll5I8qH9_ueOtj3WYWBYeP9zg$> > [image: Facebook] > <https://urldefense.us/v3/__https://www.facebook.com/marin.wageningen__;!!G_uCfscf7eWS!YrcVeQ6V8OD3jKxSzzxpyuTgFdncWh4YcL1SgDT8NHqystMpzO1pkd17oNGni-ll5I8qH9_ueOtj3WYWzqK6wKw$> > [image: LinkedIn] > <https://urldefense.us/v3/__https://www.linkedin.com/company/marin__;!!G_uCfscf7eWS!YrcVeQ6V8OD3jKxSzzxpyuTgFdncWh4YcL1SgDT8NHqystMpzO1pkd17oNGni-ll5I8qH9_ueOtj3WYWIUyfXbM$> > [image: YouTube] > <https://urldefense.us/v3/__https://www.youtube.com/marinmultimedia__;!!G_uCfscf7eWS!YrcVeQ6V8OD3jKxSzzxpyuTgFdncWh4YcL1SgDT8NHqystMpzO1pkd17oNGni-ll5I8qH9_ueOtj3WYWjtUkoeg$> >
