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"><<a href="mailto:balay@mcs.anl.gov">balay@mcs.anl.gov</a>></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>
> On Wed, Sep 29, 2010 at 11:46, Moinier, Pierre (UK)<br>
> <<a href="mailto:Pierre.Moinier@baesystems.com">Pierre.Moinier@baesystems.com</a>> wrote:<br>
> > I have a Matrix and a Right Hand Side (RHS) in an ASCII format stored in 2<br>
> > different files. I have written the code that reads the data and solve the<br>
> > system in sequential. I would like to solve the same problem in parallel. I<br>
> > read the FAQ section that says:<br>
> ><br>
> > Never read or write in parallel an ASCII matrix file, instead for reading:<br>
> > read in sequentially then save the matrix with the binary viewer<br>
> > PetscBinaryViewerOpen() and load the matrix in parallel with MatLoad().<br>
> ><br>
> > So far, I did not manage to implement this. Could any one help me?<br>
><br>
> With your matrix assembled in serial:<br>
><br>
> ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,"A.dat",FILE_MODE_WRITE,&viewer);CHKERRQ(ierr);<br>
> ierr = MatView(A,viewer);CHKERRQ(ierr);<br>
> ierr = PetscViewerDestroy(viewer);CHKERRQ(ierr);<br>
><br>
> In parallel:<br>
><br>
> ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,"A.dat",FILE_MODE_READ,&viewer);CHKERRQ(ierr);<br>
> ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr);<br>
> ierr = MatLoad(A,viewer);CHKERRQ(ierr);<br>
> ierr = PetscViewerDestroy(viewer);CHKERRQ(ierr);<br>
> ierr = KSPSetOperators(ksp,A,A,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr);<br>
><br>
><br>
> Jed<br>
><br>
</div></div></blockquote></div><br>