I have run into this same problem some weeks ago. The idea as described by Jed is that you read in the matrix only once, sequentially, from the original file. After doing this, you can store the Mat file in Petsc binary format with MatView. Now for all subsequent runs you can use this binary file to read in the matrix in parallel, with MatLoad. Good luck,<br>
<br>Leo<br> <br><br><div class="gmail_quote">2010/9/29 Satish Balay <span dir="ltr">&lt;<a href="mailto:balay@mcs.anl.gov">balay@mcs.anl.gov</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
check mat/examples/tests/ex72.c,ex50.c for examples.<br>
<br>
Also ksp/ksp/examples/tutorials/ex10.c - for loading up this matrix<br>
and solving parallely.<br>
<font color="#888888"><br>
Satish<br>
</font><div><div></div><div class="h5"><br>
On Wed, 29 Sep 2010, Jed Brown wrote:<br>
<br>
&gt; On Wed, Sep 29, 2010 at 11:46, Moinier, Pierre (UK)<br>
&gt; &lt;<a href="mailto:Pierre.Moinier@baesystems.com">Pierre.Moinier@baesystems.com</a>&gt; wrote:<br>
&gt; &gt; I have a Matrix and a Right Hand Side (RHS) in an ASCII format stored in 2<br>
&gt; &gt; different files. I have written the code that reads the data and solve the<br>
&gt; &gt; system in sequential. I would like to solve the same problem in parallel. I<br>
&gt; &gt; read the FAQ section that says:<br>
&gt; &gt;<br>
&gt; &gt; Never read or write in parallel an ASCII matrix file, instead for reading:<br>
&gt; &gt; read in sequentially then save the matrix with the binary viewer<br>
&gt; &gt; PetscBinaryViewerOpen() and load the matrix in parallel with MatLoad().<br>
&gt; &gt;<br>
&gt; &gt; So far, I did not manage to implement this. Could any one help me?<br>
&gt;<br>
&gt; With your matrix assembled in serial:<br>
&gt;<br>
&gt;     ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,&quot;A.dat&quot;,FILE_MODE_WRITE,&amp;viewer);CHKERRQ(ierr);<br>
&gt;     ierr = MatView(A,viewer);CHKERRQ(ierr);<br>
&gt;     ierr = PetscViewerDestroy(viewer);CHKERRQ(ierr);<br>
&gt;<br>
&gt; In parallel:<br>
&gt;<br>
&gt;     ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,&quot;A.dat&quot;,FILE_MODE_READ,&amp;viewer);CHKERRQ(ierr);<br>
&gt;     ierr = MatCreate(PETSC_COMM_WORLD,&amp;A);CHKERRQ(ierr);<br>
&gt;     ierr = MatLoad(A,viewer);CHKERRQ(ierr);<br>
&gt;     ierr = PetscViewerDestroy(viewer);CHKERRQ(ierr);<br>
&gt;     ierr = KSPSetOperators(ksp,A,A,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr);<br>
&gt;<br>
&gt;<br>
&gt; Jed<br>
&gt;<br>
</div></div></blockquote></div><br>