[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Error when solving eqns with PETSc
1) there is not reason to call MatCreateSeqAIJ() at the beginning of
the code.
2) MatCreateSeqAIJWithArrays() does NOT copy the array values passed
in so if ia_spar,ja_spar,A_spar go out of scope the A_mat is garbage.
3) You can use VecPlaceArray() instead of the loop to set the vector
values.
Barry
On Tue, 14 Aug 2007, Ben Tay 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.
>
>