migrating from IMSL to petsc

Barry Smith bsmith at mcs.anl.gov
Mon Oct 8 12:10:05 CDT 2007


  Use 

  Vec vb,vx
  Mat mA

  call VecCreateSeqWithArray(PETSC_COMM_SELF,n,b,vb,ierr)
  call VecCreateSeqWithArray(PETSC_COMM_SELF,n,x,vx,ierr)
  call MatCreateSeqDense(PETSC_COMM_SELF,n,n,A,mA,ierr)

  call KSPCreate(PETSC_COMM_SELF,ksp,ierr)
  call KSPSetType(ksp,KSPPREONLY,ierr)
  call KSPGetPC(ksp,pc,ierr)
  call PCSetType(pc,PCLU,ierr)
  call KSPSetOperators(ksp,mA,mA,SAME_NONZERO_PATTERN,ierr)
  call KSPSolve(ksp,vb,vx,ierr)

  call KSPDestroy(ksp,ierr)
  call MatDestroy(mA,ierr)
  call VecDestroy(vb,ierr)
  call VecDestroy(vx,ierr)


  The VecCreateSeqWithArray(), MatCreateSeqDense() also have parallel 
versions with Seq replaced with MPI.

  Barry

On Sun, 7 Oct 2007, Kamaraju Kusumanchi wrote:

> Hi all
> 
>     I have a rather large Fortran 90 code (say 10,000 lines long) which 
> extensively uses IMSL libraries for solving linear systems. Because of the 
> limited capabilities of IMSL, the cost involved in purchasing the license 
> etc., we are considering going with petsc instead. I have read the FAQs on 
> the petsc website, finished reading the user manual. I have a few questions 
> which the experts might find trivial to answer...
> 
>     Let's say I am solving Ax=B using IMSL's LU decomposition routine. In this 
> case, A would be an nxn matrix, x and B would nx1 vectors. In the fortran 90 
> code these are declared as (assuming statically allocated)
> 
> real :: A(1:n,1:n), B(1:n), x(1:n)
> 
> The IMSL routines just directly accept A, x, B as arguments. Whereas, the 
> petsc's solvers seem to require the arguments to be of type Vec, Mat etc., 
> Converting all the arrays into Vec, Mat types would involve quite a bit of 
> changes in the code, which I would like to avoid if possible. So my questions 
> are
> 
> 1) What is the best way to migrate a fortran 90 code using IMSL libraries to 
> Petsc libraries with minimal changes in the code?
> 
> 2) Is there any way to use petsc linear solvers (to solve Ax=b) without 
> dealing with new data types Vec, Mat etc., and just sticking with real 
> arrays? At this point, I am only interested in solving the system of 
> equations Ax=b and am not trying to exploit other cool features of petsc.
> 
> thanks for any suggestions
> raju
> 
> 




More information about the petsc-users mailing list