Oh, I will check up valgrind since I've not used it b4. The original converter starts from 1 so I've done a -1 offset. If I call converter, MatCreateSeqAIJWithArrays, MatAssemblyBegin,MatAssemblyEnd at every time step, it works perfectly and the answers are very close with another solver. However, if I only called it once, the error appears the moment I try to call KSPSolve.
One qn is if I declare A_mat as a global variable, once I finalise it with MatAssemblyBegin,MatAssemblyEnd, it should remain as global variable? I don't 've to do any more manipulation. I just 've to update the RHS vector and I can call KSPSolve to get the solution. Is that correct? Thanks Matthew Knepley wrote: > Memory is being garbaged somewhere. I suggest using valgrind as it says > in the error message. However, I also have a guess. Are you sure that the > AIJ arrays that you provided to the constructor are using 0-offset numbering? > I suspect that it would be 1-offset for both ia_spar and ja_spar which would > cause problems. > > Matt > > On 8/14/07, Ben Tay <zonexo at gmail.com> wrote: > >> Hi, >> >> I am currently using the following way to solve my poisson eqn >> >> in global.F (global variables) >> >> implicit none >> >> save >> >> Mat A_mat >> Vec xx,b_rhs >> KSP ksp >> PC pc >> PCType ptype >> KSPType ksptype >> >> then they are initialized >> >> call PetscInitialize(PETSC_NULL_CHARACTER,ierr) >> call >> MatCreateSeqAIJ(PETSC_COMM_SELF,size_x*size_y,size_x*size_y,13,PETSC_NULL_INTEGER,A_mat,ierr) >> call VecCreateSeq(PETSC_COMM_SELF,size_x*size_y,b_rhs,ierr) >> call VecDuplicate(b_rhs,xx,ierr) >> call KSPCreate(PETSC_COMM_SELF,ksp,ierr) >> call VecAssemblyBegin(b_rhs,ierr) >> call VecAssemblyEnd(b_rhs,ierr) >> call VecAssemblyBegin(xx,ierr) >> call VecAssemblyEnd(xx,ierr) >> >> My original matrix is stored as ITPACK format so I used ellcsr from >> SPARSKIT to convert to CSR format and use >> >> call >> ellcsr(total_k,big_A,int_a,total_k,13,A_spar,ja_spar,ia_spar,nzmax,ierr) >> ... >> call >> MatCreateSeqAIJWithArrays(PETSC_COMM_SELF,Ntot,Ntot,ia_spar,ja_spar,A_spar,A_mat,ierr) >> call MatAssemblyBegin(A_mat,MAT_FINAL_ASSEMBLY,ierr) >> call MatAssemblyEnd(A_mat,MAT_FINAL_ASSEMBLY,ierr) >> >> to read into PETSc. Then read in the RHS as well >> >> do k=1,Ntot >> II=k-1 >> call VecSetValue(b_rhs,II,q_p(k),INSERT_VALUES,ierr) >> end do >> >> Finally the matrix is solved using >> >> call KSPSolve(ksp,b_rhs,xx,ierr). >> >> This works but the A_mat matrix is not changing with time. Hence I tried >> to call the above sentences only at the 1st time step. However I got >> this error when KSPSolve is called: >> >> [0]PETSC ERROR: >> ------------------------------------------------------------------------ >> [0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, >> probably memory access out of range >> [0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger >> [0]PETSC ERROR: or see >> http://www.mcs.anl.gov/petsc/petsc-as/documentation/troubleshooting.html#Signal[0]PETSC >> ERROR: or try http://valgrind.org on linux or man libgmalloc on Apple to >> find memory corruption errors >> [0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, >> and run >> [0]PETSC ERROR: to get more information on the crash. >> [0]PETSC ERROR: --------------------- Error Message >> ------------------------------------ >> [0]PETSC ERROR: Signal received! >> [0]PETSC ERROR: >> ------------------------------------------------------------------------ >> [0]PETSC ERROR: Petsc Release Version 2.3.3, Patch 4, Tue Aug 7 >> 17:36:16 CDT 2007 HG revision: ee49636ddd90fb72d14b79fa8180225eb4257c59 >> [0]PETSC ERROR: See docs/changes/index.html for recent updates. >> [0]PETSC ERROR: See docs/faq.html for hints about trouble shooting. >> [0]PETSC ERROR: See docs/index.html for manual pages. >> [0]PETSC ERROR: >> ------------------------------------------------------------------------ >> [0]PETSC ERROR: ./a.out on a atlas3 named atlas3-c01 by g0306332 Tue Aug >> 14 18:13:09 2007 >> [0]PETSC ERROR: Libraries linked from >> /lsftmp/g0306332/petsc-2.3.3-p4/lib/atlas3 >> [0]PETSC ERROR: Configure run at Sat Aug 11 08:25:45 2007 >> [0]PETSC ERROR: Configure options --with-cc=icc --with-fc=ifort >> --with-x=0 --download-hypre=1 --download-mumps=1 --download-scalapack=1 >> --download-blacs=1 --with-debugging=0 >> --with-blas-lapack-dir=/opt/intel/cmkl/8.1.1/ --with-shared >> --with-mpi-dir=/lsftmp/g0306332/mpich2/ >> [0]PETSC ERROR: >> ------------------------------------------------------------------------ >> [0]PETSC ERROR: User provided function() line 0 in unknown directory >> unknown file >> [unset]: aborting job: >> application called MPI_Abort(MPI_COMM_WORLD, 59) - process 0 >> >> I thought I've delcared A_mat as a global variable so after filling up >> values using MatCreateSeqAIJWithArrays, MatAssemblyBegin, >> MatAssemblyEnd, I only need to update the RHS vector. It seems that I'm >> missing out something. >> >> >> > > >
