Conversion matrix from Ellpack-Itpack to CSR to PETSc format

Satish Balay balay at mcs.anl.gov
Thu Aug 9 01:30:53 CDT 2007


- make sure the input to MatCreateSeqAIJWithArrays() is correct as per
the example in the manpage 

- run it in the debugger to determine the actual cause of the problem

Satish


On Thu, 9 Aug 2007, Ben Tay wrote:

> Hi,
> 
> My original matrix is stored in Ellpack-Itpack format, which is used by the
> NSPCG solver. I have problems when I insert the values of the matrix into a
> PETSc matrix. I guessed I made some mistakes but I can't find where during
> debugging. So I intent to just convert from the Ellpack-Itpack to CSR using a
> subroutine by SPARSKIT2 called ellcsr. Then I use MatCreateSeqAIJWithArrays to
> get my PETSc matrix.
> I'm programming in fortran so index starts from 1. I tried to shift the row
> and column index by -1.  The 1st step works but there's error when solving at
> the 2nd time step. The error is:
> 
> [0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably
> m
> emory 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/troub
> leshooting.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: likely location of problem given in stack below
> [0]PETSC ERROR: ---------------------  Stack Frames
> ----------------------------
> --------
> [0]PETSC ERROR: Note: The EXACT line numbers in the stack are not available,
> [0]PETSC ERROR:       INSTEAD the line number of the start of the function
> [0]PETSC ERROR:       is given.
> 
> 
> 
> 
> My subroutine is as follows:
> 
> Note that A_mat is declared as global variable.
> 
> if (time==1) then
> 
>    call
> ellcsr(total_k,big_A,int_a,total_k,9,A_spar,ja_spar,ia_spar,nzmax,ierr)   -
> convert big_A,int_A in Ellpack-Itpack format to CSR using ellcsr
> 
>    ia_spar=ia_spar-1;    ja_spar=ja_spar-1   -   shift by -1
> 
>    call
> MatCreateSeqAIJWithArrays(PETSC_COMM_SELF,Ntot,13,ia_spar,ja_spar,A_spar,A_mat_spar,ierr)
> 
>    call MatAssemblyBegin(A_mat,MAT_FINAL_ASSEMBLY,ierr)
> 
>    call MatAssemblyEnd(A_mat,MAT_FINAL_ASSEMBLY,ierr)
> 
> end if
> 
> ...
> 
> I thought I would only need to do this once since the A_mat does not change
> and it is declared globally. If I remove the "IF - END IF" and execute at
> every time step, everything will be fine. But I thought that will be very
> inefficient. So how should I solve the problem?
> 
> Thanks
> 
> 
> 




More information about the petsc-users mailing list