<!-- BaNnErBlUrFlE-BoDy-start -->
<!-- Preheader Text : BEGIN -->
<div style="display:none !important;display:none;visibility:hidden;mso-hide:all;font-size:1px;color:#ffffff;line-height:1px;height:0px;max-height:0px;opacity:0;overflow:hidden;">
 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
</div>
<!-- Preheader Text : END -->

<!-- Email Banner : BEGIN -->
<div style="display:none !important;display:none;visibility:hidden;mso-hide:all;font-size:1px;color:#ffffff;line-height:1px;height:0px;max-height:0px;opacity:0;overflow:hidden;">ZjQcmQRYFpfptBannerStart</div>

<!--[if ((ie)|(mso))]>
  <table border="0" cellspacing="0" cellpadding="0" width="100%" style="padding: 16px 0px 16px 0px; direction: ltr" ><tr><td>
    <table border="0" cellspacing="0" cellpadding="0" style="padding: 0px 10px 5px 6px; width: 100%; border-radius:4px; border-top:4px solid #90a4ae;background-color:#D0D8DC;"><tr><td valign="top">
      <table align="left" border="0" cellspacing="0" cellpadding="0" style="padding: 4px 8px 4px 8px">
        <tr><td style="color:#000000; font-family: 'Arial', sans-serif; font-weight:bold; font-size:14px; direction: ltr">
          This Message Is From an External Sender
        </td></tr>
        <tr><td style="color:#000000; font-weight:normal; font-family: 'Arial', sans-serif; font-size:12px; direction: ltr">
          This message came from outside your organization.
        </td></tr>

      </table>

    </td></tr></table>
  </td></tr></table>
<![endif]-->

<![if !((ie)|(mso))]>
  <div dir="ltr"  id="pfptBanner3qsbpc4" style="all: revert !important; display:block !important; text-align: left !important; margin:16px 0px 16px 0px !important; padding:8px 16px 8px 16px !important; border-radius: 4px !important; min-width: 200px !important; background-color: #D0D8DC !important; background-color: #D0D8DC; border-top: 4px solid #90a4ae !important; border-top: 4px solid #90a4ae;">
    <div id="pfptBanner3qsbpc4" style="all: unset !important; float:left !important; display:block !important; margin: 0px 0px 1px 0px !important; max-width: 600px !important;">
      <div id="pfptBanner3qsbpc4" style="all: unset !important; display:block !important; visibility: visible !important; background-color: #D0D8DC !important; color:#000000 !important; color:#000000; font-family: 'Arial', sans-serif !important; font-family: 'Arial', sans-serif; font-weight:bold !important; font-weight:bold; font-size:14px !important; line-height:18px !important; line-height:18px">
        This Message Is From an External Sender
      </div>
      <div id="pfptBanner3qsbpc4" style="all: unset !important; display:block !important; visibility: visible !important; background-color: #D0D8DC !important; color:#000000 !important; color:#000000; font-weight:normal; font-family: 'Arial', sans-serif !important; font-family: 'Arial', sans-serif; font-size:12px !important; line-height:18px !important; line-height:18px; margin-top:2px !important;">
This message came from outside your organization.
      </div>

    </div>

    <div style="clear: both !important; display: block !important; visibility: hidden !important; line-height: 0 !important; font-size: 0.01px !important; height: 0px"> </div>
  </div>
<![endif]>

<div style="display:none !important;display:none;visibility:hidden;mso-hide:all;font-size:1px;color:#ffffff;line-height:1px;height:0px;max-height:0px;opacity:0;overflow:hidden;">ZjQcmQRYFpfptBannerEnd</div>
<!-- Email Banner : END -->

<!-- BaNnErBlUrFlE-BoDy-end -->
<html><head><!-- BaNnErBlUrFlE-HeAdEr-start -->
<style>
  #pfptBanner3qsbpc4 { all: revert !important; display: block !important; 
    visibility: visible !important; opacity: 1 !important; 
    background-color: #D0D8DC !important; 
    max-width: none !important; max-height: none !important }
  .pfptPrimaryButton3qsbpc4:hover, .pfptPrimaryButton3qsbpc4:focus {
    background-color: #b4c1c7 !important; }
  .pfptPrimaryButton3qsbpc4:active {
    background-color: #90a4ae !important; }
</style>

<!-- BaNnErBlUrFlE-HeAdEr-end -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><div>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?<br /><br />$ cat test_matrixImport_binary.py<br />import sys<br />import petsc4py<br />from petsc4py import PETSc<br />from mpi4py import MPI<br /><br /># mat files<br />#filename = "./a_mat_np_1.dat"  # Works<br />filename = "./a_mat_np_2.dat"   # Doesn't work<br /><br /># Initialize PETSc<br />petsc4py.init(sys.argv)<br /><br /># Create a viewer for reading the binary file<br />viewer = PETSc.Viewer().createBinary(filename, mode='r', comm=PETSc.COMM_WORLD)<br /><br /># Create a matrix and load data from the binary file<br />A = PETSc.Mat().create(comm=PETSc.COMM_WORLD)<br />A.load(viewer)<br /><br />$ python test_matrixImport_binary.py <br />Traceback (most recent call last):<br />  File "/projects/P35662.700/test_cklaij/test_matrixImport_binary.py", line 18, in <module><br />    A.load(viewer)<br />  File "petsc4py/PETSc/Mat.pyx", line 2025, in petsc4py.PETSc.Mat.load<br />petsc4py.PETSc.Error: error code 79<br />[0] MatLoad() at /home/cklaij/petsc-3.21.0/src/mat/interface/matrix.c:1344<br />[0] MatLoad_SeqAIJ() at /home/cklaij/petsc-3.21.0/src/mat/impls/aij/seq/aij.c:5091<br />[0] MatLoad_SeqAIJ_Binary() at /home/cklaij/petsc-3.21.0/src/mat/impls/aij/seq/aij.c:5142<br />[0] Unexpected data in file<br />[0] Inconsistent matrix data in file: nonzeros = 460, sum-row-lengths = 761<br /><br />$ mpirun -n 2 python test_matrixImport_binary.py <br />Traceback (most recent call last):<br />  File "/projects/P35662.700/test_cklaij/test_matrixImport_binary.py", line 18, in <module><br />Traceback (most recent call last):<br />  File "/projects/P35662.700/test_cklaij/test_matrixImport_binary.py", line 18, in <module><br />    A.load(viewer)<br />  File "petsc4py/PETSc/Mat.pyx", line 2025, in petsc4py.PETSc.Mat.load<br />    A.load(viewer)<br />  File "petsc4py/PETSc/Mat.pyx", line 2025, in petsc4py.PETSc.Mat.load<br />petsc4py.PETSc.Error: error code 79<br />[0] MatLoad() at /home/cklaij/petsc-3.21.0/src/mat/interface/matrix.c:1344<br />[0] MatLoad_MPIAIJ() at /home/cklaij/petsc-3.21.0/src/mat/impls/aij/mpi/mpiaij.c:3035<br />[0] MatLoad_MPIAIJ_Binary() at /home/cklaij/petsc-3.21.0/src/mat/impls/aij/mpi/mpiaij.c:3087<br />[0] Unexpected data in file<br />[0] Inconsistent matrix data in file: nonzeros = 460, sum-row-lengths = 761<br />petsc4py.PETSc.Error: error code 79<br />[1] MatLoad() at /home/cklaij/petsc-3.21.0/src/mat/interface/matrix.c:1344<br />[1] MatLoad_MPIAIJ() at /home/cklaij/petsc-3.21.0/src/mat/impls/aij/mpi/mpiaij.c:3035<br />[1] MatLoad_MPIAIJ_Binary() at /home/cklaij/petsc-3.21.0/src/mat/impls/aij/mpi/mpiaij.c:3087<br />[1] Unexpected data in file<br />[1] Inconsistent matrix data in file: nonzeros = 460, sum-row-lengths = 761<br /><br /><br /></div><div dir="ltr" style="mso-line-height-rule:exactly;-webkit-text-size-adjust:100%;font-size:1px;direction:ltr;"><table cellpadding="0" cellspacing="0" border="0" style="width:100%;border-collapse:collapse;font-size:1px;"><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse;font-size:0;line-height:normal;"><tr style="font-size:0;"><td align="left" style="padding:10px 0;vertical-align:top;"><img src="cid:image337700.png@6322CF75.C08964A2" width="125" height="40" border="0" alt="" style="width:125px;min-width:125px;max-width:125px;height:40px;min-height:40px;max-height:40px;font-size:0;" /></td></tr></table></td></tr><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse;font-size:0;"><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse;font-size:0;color:#000001;font-style:normal;font-weight:400;white-space:nowrap;"><tr style="font-size:14.67px;"><td align="left" style="vertical-align:top;font-family:Calibri,Arial,sans-serif;">dr. ir.<span style="font-family:remialcxesans;font-size:1px;color:#FFFFFF;line-height:1px;">​<span style="font-family:'template-A7LWMTpBEe2ifABQ8nUoZA';">​</span><span style="font-family:'zone-1';">​</span><span style="font-family:'zones-AQ';">​</span></span> </td><td align="left" style="vertical-align:top;font-family:Calibri,Arial,sans-serif;">Christiaan</td><td align="left" style="vertical-align:top;font-family:Calibri,Arial,sans-serif;"> Klaij</td></tr></table></td><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse;font-size:0;color:#000001;font-style:normal;font-weight:400;white-space:nowrap;"><tr style="font-size:14.67px;"><td align="left" style="vertical-align:top;font-family:Calibri,Arial,sans-serif;"> | </td><td align="left" style="vertical-align:top;font-family:Calibri,Arial,sans-serif;">Senior Researcher</td><td align="left" style="vertical-align:top;font-family:Calibri,Arial,sans-serif;"> | </td><td align="left" style="vertical-align:top;font-family:Calibri,Arial,sans-serif;">Research & Development</td><td align="left" style="vertical-align:top;font-size:0;"></td></tr></table></td></tr></table></td></tr><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse;font-size:0;"><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse;font-size:0;color:#000001;font-style:normal;font-weight:400;white-space:nowrap;"><tr style="font-size:14.67px;"><td align="left" style="vertical-align:top;font-family:Calibri,Arial,sans-serif;">T <a href="tel:+31%20317%2049%2033%2044" target="_blank" id="LPlnk689713" style="text-decoration:none;color:#000001;">+31 317 49 33 44</a></td><td align="left" style="vertical-align:top;font-family:Calibri,Arial,sans-serif;"> | </td><td align="left" style="vertical-align:top;font-family:Calibri,Arial,sans-serif;"> <a href="mailto:C.Klaij@marin.nl" target="_blank" id="LPlnk689713" style="text-decoration:none;color:#000001;">C.Klaij@marin.nl</a> </td><td align="left" style="vertical-align:top;font-family:Calibri,Arial,sans-serif;">| <a href="https://urldefense.us/v3/__https://www.marin.nl/__;!!G_uCfscf7eWS!YrcVeQ6V8OD3jKxSzzxpyuTgFdncWh4YcL1SgDT8NHqystMpzO1pkd17oNGni-ll5I8qH9_ueOtj3WYWBYeP9zg$" target="_blank" id="LPlnk689713" style="text-decoration:none;color:#000001;">www.marin.nl</a></td></tr></table></td></tr></table></td></tr><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse;font-size:0;"><tr style="font-size:0;"><td align="left" style="padding:5px 0 0;vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse;font-size:0;"><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse;font-size:0;line-height:normal;"><tr style="font-size:0;"><td align="left" style="padding:0 3px 3px 0;vertical-align:top;"><a href="https://urldefense.us/v3/__https://www.facebook.com/marin.wageningen__;!!G_uCfscf7eWS!YrcVeQ6V8OD3jKxSzzxpyuTgFdncWh4YcL1SgDT8NHqystMpzO1pkd17oNGni-ll5I8qH9_ueOtj3WYWzqK6wKw$" target="_blank" id="LPlnk689713" style="text-decoration:none;"><img src="cid:image563921.png@EE645B66.125587F0" width="15" height="15" border="0" title="Facebook" alt="Facebook" style="width:15px;min-width:15px;max-width:15px;height:15px;min-height:15px;max-height:15px;font-size:12px;" /></a></td></tr></table></td><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse;font-size:0;line-height:normal;"><tr style="font-size:0;"><td align="left" style="padding:0 3px 3px 0;vertical-align:top;"><a href="https://urldefense.us/v3/__https://www.linkedin.com/company/marin__;!!G_uCfscf7eWS!YrcVeQ6V8OD3jKxSzzxpyuTgFdncWh4YcL1SgDT8NHqystMpzO1pkd17oNGni-ll5I8qH9_ueOtj3WYWIUyfXbM$" target="_blank" id="LPlnk689713" style="text-decoration:none;"><img src="cid:image268336.png@5DDDE1C1.FF0A5891" width="15" height="15" border="0" title="LinkedIn" alt="LinkedIn" style="width:15px;min-width:15px;max-width:15px;height:15px;min-height:15px;max-height:15px;font-size:12px;" /></a></td></tr></table></td><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse;font-size:0;line-height:normal;"><tr style="font-size:0;"><td align="left" style="padding:0 3px 3px 0;vertical-align:top;"><a href="https://urldefense.us/v3/__https://www.youtube.com/marinmultimedia__;!!G_uCfscf7eWS!YrcVeQ6V8OD3jKxSzzxpyuTgFdncWh4YcL1SgDT8NHqystMpzO1pkd17oNGni-ll5I8qH9_ueOtj3WYWjtUkoeg$" target="_blank" id="LPlnk689713" style="text-decoration:none;"><img src="cid:image799923.png@2FC5EA4B.CFB78E87" width="15" height="15" border="0" title="YouTube" alt="YouTube" style="width:15px;min-width:15px;max-width:15px;height:15px;min-height:15px;max-height:15px;font-size:12px;" /></a></td></tr></table></td></tr></table></td></tr></table></td></tr></table></div></body></html>