<!-- 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;">
Well, after trying a second time, the binary file is fine and loads into python without issues. No idea how the first file got corrupted. I've also tried without the PetscViewerPushFormat call, and that works equally well. Thanks for your
</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="pfptBannerid93tjd" 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="pfptBannerid93tjd" style="all: unset !important; float:left !important; display:block !important; margin: 0px 0px 1px 0px !important; max-width: 600px !important;">
<div id="pfptBannerid93tjd" 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="pfptBannerid93tjd" 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>
#pfptBannerid93tjd { all: revert !important; display: block !important;
visibility: visible !important; opacity: 1 !important;
background-color: #D0D8DC !important;
max-width: none !important; max-height: none !important }
.pfptPrimaryButtonid93tjd:hover, .pfptPrimaryButtonid93tjd:focus {
background-color: #b4c1c7 !important; }
.pfptPrimaryButtonid93tjd:active {
background-color: #90a4ae !important; }
</style>
<!-- BaNnErBlUrFlE-HeAdEr-end -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><div>Well, after trying a second time, the binary file is fine and loads into python without issues. No idea how the first file got corrupted. I've also tried without the PetscViewerPushFormat call, and that works equally well. Thanks for your help!<br /><br />Chris<br /><br />________________________________________<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:image634986.png@79BC6AFA.AFB345CB" 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!a9GfF_LhoavWZziwYJYPGdit19o_V12PJ7Va7HZ4FOqQrLcBCZOHGqnoEpTXlLRFh4MBui66Jv03qp9ZeiV5_rE$" 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!a9GfF_LhoavWZziwYJYPGdit19o_V12PJ7Va7HZ4FOqQrLcBCZOHGqnoEpTXlLRFh4MBui66Jv03qp9ZJXBs_NQ$" target="_blank" id="LPlnk689713" style="text-decoration:none;"><img src="cid:image728206.png@EB18B1E1.FA560FF3" 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!a9GfF_LhoavWZziwYJYPGdit19o_V12PJ7Va7HZ4FOqQrLcBCZOHGqnoEpTXlLRFh4MBui66Jv03qp9ZFNWWhnI$" target="_blank" id="LPlnk689713" style="text-decoration:none;"><img src="cid:image424860.png@56D6006A.F58C52C6" 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!a9GfF_LhoavWZziwYJYPGdit19o_V12PJ7Va7HZ4FOqQrLcBCZOHGqnoEpTXlLRFh4MBui66Jv03qp9ZNqZ_rNo$" target="_blank" id="LPlnk689713" style="text-decoration:none;"><img src="cid:image994549.png@149B4EA8.D8EB8DE4" 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><br />From: Barry Smith <bsmith@petsc.dev><br />Sent: Thursday, June 6, 2024 7:08 PM<br />To: Klaij, Christiaan<br />Cc: Stefano Zampini; PETSc users list<br />Subject: Re: [petsc-users] matload and petsc4py<br /><br />You don't often get email from bsmith@petsc.dev. Learn why this is important<<a href="https://urldefense.us/v3/__https://aka.ms/LearnAboutSenderIdentification*3E__;JQ!!G_uCfscf7eWS!a9GfF_LhoavWZziwYJYPGdit19o_V12PJ7Va7HZ4FOqQrLcBCZOHGqnoEpTXlLRFh4MBui66Jv03qp9ZsOyNmng$">https://aka.ms/LearnAboutSenderIdentification></a><br /><br /> Try without this line CALL PetscViewerPushFormat(viewer, PETSC_VIEWER_DEFAULT, ier)<br />it shouldn't matter but worth trying.<br /><br />On Jun 6, 2024, at 9:50 AM, Klaij, Christiaan <C.Klaij@marin.nl> wrote:<br /><br />This Message Is From an External Sender<br />This message came from outside your organization.<br /><br />The matrix was saved as with this code:<br /><br />CALL PetscViewerBinaryOpen(PETSC_COMM_WORLD, filename, FILE_MODE_WRITE, viewer, ier)<br />CALL PetscViewerPushFormat(viewer, PETSC_VIEWER_DEFAULT, ier)<br />CALL MatView(A, viewer, ier)<br />CALL PetscViewerDestroy(viewer, ier)<br /><br />I will try again to check for file corruption<br /><br />________________________________________<br />From: Stefano Zampini <stefano.zampini@gmail.com<mailto:stefano.zampini@gmail.com>><br />Sent: Thursday, June 6, 2024 3:01 PM<br />To: Klaij, Christiaan<br />Cc: PETSc users list<br />Subject: Re: [petsc-users] matload and petsc4py<br /><br />You don't often get email from stefano.zampini@gmail.com<mailto:stefano.zampini@gmail.com>. Learn why this is important<https://urldefense.us/v3/__https://aka.ms/LearnAboutSenderIdentification__;!!G_uCfscf7eWS!dhd_vSPt_mzy9yVfgQZvw3KcZQwq--Wojmk9JdzuGmnjbC_54Z7IF0WH6qosvtdRyyjv94blDuN1lAlZepr0msg$%3E<br /><br /><br />On Thu, Jun 6, 2024, 14:53 Klaij, Christiaan <C.Klaij@marin.nl<mailto:C.Klaij@marin.nl><mailto:C.Klaij@marin.nl>> wrote:<br />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<br />ZjQcmQRYFpfptBannerStart<br />This Message Is From an External Sender<br />This message came from outside your organization.<br /><br />ZjQcmQRYFpfptBannerEnd<br />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 /><br />This should work. And your script seems ok too . How did you save the matrix in parallel? I suspect that file is corrupt<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 />[cid:ii_18feda229ee74859a161]<br />dr. ir. Christiaan Klaij<br /> | Senior Researcher | Research & Development<br />T +31 317 49 33 44<tel:+31%20317%2049%2033%2044> | C.Klaij@marin.nl<mailto:C.Klaij@marin.nl><mailto:C.Klaij@marin.nl> | https://urldefense.us/v3/__http://www.marin.nl__;!!G_uCfscf7eWS!dhd_vSPt_mzy9yVfgQZvw3KcZQwq--Wojmk9JdzuGmnjbC_54Z7IF0WH6qosvtdRyyjv94blDuN1lAlZod9brMU$%3Chttps://urldefense.us/v3/__https://www.marin.nl/__;!!G_uCfscf7eWS!YrcVeQ6V8OD3jKxSzzxpyuTgFdncWh4YcL1SgDT8NHqystMpzO1pkd17oNGni-ll5I8qH9_ueOtj3WYWBYeP9zg$%3E<br />[Facebook]<https://urldefense.us/v3/__https://www.facebook.com/marin.wageningen__;!!G_uCfscf7eWS!YrcVeQ6V8OD3jKxSzzxpyuTgFdncWh4YcL1SgDT8NHqystMpzO1pkd17oNGni-ll5I8qH9_ueOtj3WYWzqK6wKw$%3E<br />[LinkedIn]<https://urldefense.us/v3/__https://www.linkedin.com/company/marin__;!!G_uCfscf7eWS!YrcVeQ6V8OD3jKxSzzxpyuTgFdncWh4YcL1SgDT8NHqystMpzO1pkd17oNGni-ll5I8qH9_ueOtj3WYWIUyfXbM$%3E<br />[YouTube]<https://urldefense.us/v3/__https://www.youtube.com/marinmultimedia__;!!G_uCfscf7eWS!YrcVeQ6V8OD3jKxSzzxpyuTgFdncWh4YcL1SgDT8NHqystMpzO1pkd17oNGni-ll5I8qH9_ueOtj3WYWjtUkoeg$%3E<br /><br /><br /><image337700.png><image563921.png><image268336.png><image799923.png><br /><br /></div></body></html>