<DIV>&nbsp;</DIV>  <DIV>Hi,</DIV>  <DIV>I am sorry to bother&nbsp;you. I met this strange trouble yesterday, and I have tried lots of methods to solve it. But fail. My code likes this:</DIV>  <DIV>&nbsp;</DIV>  <DIV>static char help[] = "Solves a tridiagonal linear system with KSP.\n\n";<BR>#include "petscksp.h"<BR>#include "builderh.h"</DIV>  <DIV>#undef __FUNCT__<BR>#define __FUNCT__ "main"<BR>int main(int argc,char **args){<BR>&nbsp;&nbsp;&nbsp; PetscInitialize(&amp;argc,&amp;args,(char *)0,help);<BR>&nbsp;&nbsp;&nbsp; Mat A;<BR>&nbsp;&nbsp;&nbsp; Vec x;<BR>&nbsp;&nbsp;&nbsp; PetscInt k=3,v=1,n_x=5,s_t=4,row;<BR>&nbsp;&nbsp;&nbsp; PetscInt i[2];<BR>&nbsp;&nbsp;&nbsp; PetscReal h_x,h_t;<BR>&nbsp;&nbsp;&nbsp; PetscScalar temp;<BR>&nbsp;&nbsp;&nbsp; MainMatPar *mmp;<BR>&nbsp;&nbsp;&nbsp; PetscErrorCode ierr;<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; h_x = PETSC_PI/(PetscReal)(n_x+1);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; h_t =
 PETSC_PI*2/(PetscReal)(s_t);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s_t++;<BR>&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ierr = VecCreate(PETSC_COMM_WORLD,&amp;x);CHKERRQ(ierr);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ierr = PetscObjectSetName((PetscObject) x, "Solution");CHKERRQ(ierr);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ierr = VecSetSizes(x,PETSC_DECIDE,n_x*s_t);CHKERRQ(ierr); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ierr = VecSetFromOptions(x);CHKERRQ(ierr); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; temp = h_x;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (i[0]=0;i[0]&lt;n_x*s_t;i[0]++) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; row=i[0];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ierr = VecSetValues(x,1,&amp;row,&amp;temp,INSERT_VALUES);CHKERRQ(ierr);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; temp+=h_x;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; ierr = VecAssemblyBegin(x);CHKERRQ(ierr);<BR>&nbsp;&nbsp;&nbsp; ierr =
 VecAssemblyEnd(x);CHKERRQ(ierr);<BR>&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; ierr = VecSet(x,0);CHKERRQ(ierr);&nbsp;&nbsp;&nbsp; <BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; ierr = VecView(x,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; /**/<BR>&nbsp;&nbsp;&nbsp; ierr = CreateMainMatPar(RC_1,k,v,n_x,s_t,h_x,h_t,&amp;mmp);CHKERRQ(ierr);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ierr = BuildMainMatrix(&amp;A,mmp); CHKERRQ(ierr);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ierr = DestroyMainMatPar(mmp);CHKERRQ(ierr);<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; //ierr = MatView(A,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);<BR>&nbsp;&nbsp;&nbsp; ierr = MatDestroy(A);CHKERRQ(ierr);<BR>&nbsp;&nbsp;&nbsp; ierr = VecDestroy(x);CHKERRQ(ierr);<BR>&nbsp;&nbsp;&nbsp; ierr = PetscFinalize();CHKERRQ(ierr);<BR>&nbsp;&nbsp;&nbsp;&nbsp; return 0;<BR>}</DIV>  <DIV>When I delete the line "ierr = VecSet(x,0);CHKERRQ(ierr);" , the problem occurs. I don't know why.<BR>I attach the two files
 that were used in the above code.</DIV>  <DIV>And my run it in one process.</DIV>  <DIV>&nbsp;</DIV>  <DIV>Regards,<BR>Jiaxun<BR></DIV><p>&#32;
                <hr size=1><a href="http://cn.mail.yahoo.com/" target=blank> 
ÑÅ»¢Ãâ·ÑÓÊÏä-3.5GÈÝÁ¿£¬20M¸½¼þ</a>