Use -ksp_type preonly -pc_type lu.<div><br></div><div>   Matt<br><br><div class="gmail_quote">On Sat, May 26, 2012 at 8:04 AM, w_ang_temp <span dir="ltr"><<a href="mailto:w_ang_temp@163.com" target="_blank">w_ang_temp@163.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="line-height:1.7;font-size:14px;font-family:arial"><div>Besides,I test several situations.<br>When process=1(mpiexec -n 1),the results are right,compared with the true results.<br>
When process=2 or 5,both of the results are same.And from the tenth loop, it begins the strange error Ax!=b.<br>When process=3 or 4,both of the results are same.And from the first loop,it begins the error.<br>Thanks.<br><br>
</div><div><div class="h5">
<div></div>
<div></div>
<div><br></div>>At 2012-05-26 15:01:28,w_ang_temp <<a href="mailto:w_ang_temp@163.com" target="_blank">w_ang_temp@163.com</a>> wrote:<br>
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex">
<div style="line-height:1.7;font-size:14px;font-family:arial">
<div>>Hello, Matt<br>>   First,thanks for your help, and I have a new recognition of MPI. As you said(only part of a Vec is stored on each MPI process),I use >MPI_Send,MPI_Recv and MPI_Bcast to deal with it and get some right results.<br>
>   However,I have not yet fully solved this problem.The number of loops of the subroutine named PETSCSOLVE to solve Ax=b with PETSc is 20 >times.I print the results of each loop and find that the front 9 times are right. In the 10 time,there is a strange error: plug the result x into the >equation I find that Ax!=b. </div>

<div>>   The code and the A,x,b are shown below.So can you give me some hints? Thank you very much!<br>>                                                        Jim<br>>   (1)code<br>>      call MatView(A,PETSC_VIEWER_STDOUT_WORLD,ierr)<br>
>      call VecView(b,PETSC_VIEWER_STDOUT_WORLD,ierr)<br>>      call KSPSolve(ksp,b,x,ierr)<br>>      call VecView(x,PETSC_VIEWER_STDOUT_WORLD,ierr)<br>>   (2)Ax=b<br>>  A:<br>>  type: mpiaij<br>> row 0: (0, 1)  (1, 0)  (2, 0)  (3, 0)  (4, 0)  (5, 0)  (6, 0)  (7, 0)  (8, 0) <br>
> row 1: (0, 0)  (1, 1)  (2, 0)  (3, 0)  (4, 0)  (5, 0)  (6, 0)  (7, 0)  (8, 0) <br>> row 2: (0, 0)  (1, 0)  (2, -2e-06)  (3, -50)  (4, 0)  (5, 0)  (6, 0)  (7, -50)  (8, 0) <br>> row 3: (0, 0)  (1, 0)  (2, -50)  (3, 1.36265e+07)  (4, 0)  (5, 0)  (6, 0)  (7, 1.23877e+06)  (8, 0) <br>
> row 4: (0, 0)  (1, 0)  (2, 0)  (3, 0)  (4, 1)  (5, 0)  (6, 0)  (7, 0)  (8, 0) <br>> row 5: (0, 0)  (1, 0)  (2, 0)  (3, 0)  (4, 0)  (5, 1)  (6, 0)  (7, 0)  (8, 0) <br>> row 6: (0, 0)  (1, 0)  (2, 0)  (3, 0)  (4, 0)  (5, 0)  (6, 1)  (7, 0)  (8, 0) <br>
> row 7: (0, 0)  (1, 0)  (2, -50)  (3, 1.23877e+06)  (4, 0)  (5, 0)  (6, 0)  (7, 1.36265e+07)  (8, 0) <br>> row 8: (0, 0)  (1, 0)  (2, 0)  (3, 0)  (4, 0)  (5, 0)  (6, 0)  (7, 0)  (8, 1) <br>>  b:<br>>  type: mpi<br>
> Process [0]<br>> 0<br>> 0<br>> -0.75<br>> 96949.5<br>> 0<br>> Process [1]<br>> 0<br>> -0.015<br>> 96949.5<br>> -0.015<br> > x:<br>  >type: mpi<br> >Process [0]<br>> 0<br>> 0<br>
> 1167.84<br>> 0.00819383<br> >0<br> >Process [1]<br> >0<br>> -0.00824055<br>> 0.00390865<br>> -0.00824055<br><br><br></div>
<div></div>
<div></div>
<div><br></div>>在 2012-05-22 19:33:10,"Matthew Knepley" <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> 写道:<br>
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex">>On Tue, May 22, 2012 at 5:17 AM, w_ang_temp <span dir="ltr"><<a href="mailto:w_ang_temp@163.com" target="_blank">w_ang_temp@163.com</a>></span> wrote:<br>

<div class="gmail_quote">
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote">
<div style="LINE-HEIGHT:1.7;FONT-FAMILY:arial;FONT-SIZE:14px">
<div>>Hello</div>
<div> >    I am a beginner of PETSc.I find the petsc-users lists is very useful, however I do not know how to ask a question in it. So can you tell me? >And below is what I want to ask.<br> >   I am solving Ax=b with PETSc. And I only use it in a fortran subroutine to get x ,then the main function of my program use x to do other >things. The question is that: when the process is 1(mpiexec -n 1),the result of my program is ok, but when the process is more than 1 the > result is wrong.<br>
</div></div></blockquote>
<div><br></div>
<div>> "Wrong" is not an acceptable description. I suspect that you do not understand that only part of a Vec</div>
<div>> is stored on each MPI process. First, get the book Using MPI, and then read the PETSc manual</div>
<div>> section on vectors.</div>
<div><br></div>
<div>  > Thanks,</div>
<div><br></div>
<div>     > Matt</div>
<div> </div>
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote">
<div style="LINE-HEIGHT:1.7;FONT-FAMILY:arial;FONT-SIZE:14px">
<div>>     So where could be wrong? Can you give me some hints on how I can debug? Thanks.</div>
<div>>                                   Jim</div></div></blockquote></div>> -- <br>> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their > experiments lead.<br>
> -- Norbert Wiener<br></blockquote></div><br><br><span title="neteasefooter"><span></span></span></blockquote></div></div></div><br><br><span title="neteasefooter"><span></span></span></blockquote></div><br><br clear="all">
<div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener<br>
</div>