<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div>Check your petsc matrix before dumping the data by adding </div>
<div>MatView(A,PETSC_VIEWER_STDOUT_WORLD);<br>
</div>
<div>immediately after calling MatAssemblyEnd().</div>
<div>Do you see a correct parallel matrix?</div>
<div>Hong</div>
<div><br>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Fri, May 17, 2019 at 10:24 AM Emmanuel Ayala via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">Hello,</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">I am a newby with PETSc. I want to check some matrices generated in PETSc, using MatLab.</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">I created a matrix A (MATMPIAIJ), the partition is defined by PETSc and I defined the global size.</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">Then, I used the next code to save in binary format the matrix from PETSc:</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">PetscViewer    viewer;</div>
<div dir="ltr">PetscViewerBinaryOpen(PETSC_COMM_WORLD, "matrix", FILE_MODE_WRITE, &viewer);</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">After that (I think) MatView writes in the viewer:</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">MatView(A,viewer);</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">Then I laod the matrix in MatLab with PetscBinaryRead().</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">For one process everything is Ok, I can see the full pattern of the sparse matrix (spy(A)). But when I generate the matrix A with more than one process, the resultant matrix only contains the data from the process 0.</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">What is the mistake in my procedure?</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">1. I just want to export the PETSc matrix to MatLab, for any number of process.</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">Regards.</div>
<div dir="ltr">Thanks in advance, for your time.</div>
</div>
<div dir="ltr">
<div><br>
</div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</body>
</html>