<DIV> </DIV> <DIV>Hi,</DIV> <DIV>I am sorry to bother 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> </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> PetscInitialize(&argc,&args,(char *)0,help);<BR> Mat A;<BR> Vec x;<BR> PetscInt k=3,v=1,n_x=5,s_t=4,row;<BR> PetscInt i[2];<BR> PetscReal h_x,h_t;<BR> PetscScalar temp;<BR> MainMatPar *mmp;<BR> PetscErrorCode ierr;<BR> <BR> h_x = PETSC_PI/(PetscReal)(n_x+1);<BR> h_t =
PETSC_PI*2/(PetscReal)(s_t);<BR> s_t++;<BR> <BR> ierr = VecCreate(PETSC_COMM_WORLD,&x);CHKERRQ(ierr);<BR> ierr = PetscObjectSetName((PetscObject) x, "Solution");CHKERRQ(ierr);<BR> ierr = VecSetSizes(x,PETSC_DECIDE,n_x*s_t);CHKERRQ(ierr); <BR> ierr = VecSetFromOptions(x);CHKERRQ(ierr); <BR> temp = h_x;<BR> for (i[0]=0;i[0]<n_x*s_t;i[0]++) {<BR> row=i[0];<BR> ierr = VecSetValues(x,1,&row,&temp,INSERT_VALUES);CHKERRQ(ierr);<BR> temp+=h_x;<BR> }<BR> ierr = VecAssemblyBegin(x);CHKERRQ(ierr);<BR> ierr =
VecAssemblyEnd(x);CHKERRQ(ierr);<BR> <BR> ierr = VecSet(x,0);CHKERRQ(ierr); <BR> <BR> ierr = VecView(x,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);<BR> <BR> /**/<BR> ierr = CreateMainMatPar(RC_1,k,v,n_x,s_t,h_x,h_t,&mmp);CHKERRQ(ierr);<BR> ierr = BuildMainMatrix(&A,mmp); CHKERRQ(ierr);<BR> ierr = DestroyMainMatPar(mmp);CHKERRQ(ierr);<BR> <BR> //ierr = MatView(A,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);<BR> ierr = MatDestroy(A);CHKERRQ(ierr);<BR> ierr = VecDestroy(x);CHKERRQ(ierr);<BR> ierr = PetscFinalize();CHKERRQ(ierr);<BR> 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> </DIV> <DIV>Regards,<BR>Jiaxun<BR></DIV><p> 
                <hr size=1><a href="http://cn.mail.yahoo.com/" target=blank>
ÑÅ»¢Ãâ·ÑÓÊÏä-3.5GÈÝÁ¿£¬20M¸½¼þ</a>