migrating from IMSL to petsc

Matthew Knepley knepley at gmail.com
Mon Oct 8 08:17:29 CDT 2007


On 10/7/07, Kamaraju Kusumanchi <kamaraju at bluebottle.com> 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?

  a) For vectors, the situation is very good. You can pull out the vector as an
      F90 array using VecGetArrayF90(). If you really want to manage your own
      memory, we can easily create a VecCreateWithArrayF90() for you, however
      I really suggest the first solution since it will work correctly
in parallel.

  b) For matrices, it is slightly for complicated. If you stick to your current
      strategy, you can use MatGetArrayF90(). However, this fails to generalize
      for other matrix storage formats. Thus, I generally suggest moving to the
      MatSetValues() paradigm, but the user is in charge.

> 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.

  No, but as I pointed out above. You should not have to change your code in
  order to use Mat and Vec.

    Matt

> thanks for any suggestions
> raju
>
> --
> Kamaraju S Kusumanchi
> http://www.people.cornell.edu/pages/kk288/
> http://malayamaarutham.blogspot.com/
>
> ----------------------------------------------------------------------
> Find out how you can get spam free email.
> http://www.bluebottle.com/tag/3
>
>


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which
their experiments lead.
-- Norbert Wiener




More information about the petsc-users mailing list