[petsc-users] FORTRAN 90 with PETSc

Matthew Knepley knepley at gmail.com
Fri Aug 16 21:17:02 CDT 2013


On Fri, Aug 16, 2013 at 6:37 PM, Frank <fangxingjun0319 at gmail.com> wrote:

> Hi,
>
> I am using PETSc to iterate a problem, that is to say I call KSPSolve
> repeatedly.
> Firstly, I write all the PETSc components in one subroutine, including
> "MatCreate", "VecCreateMPI", etc. Everything works fine.
> Then, I want to only initialize ksp once outside the loop, and the matrix
> and rhs is changed within the loop repeatedly. Here are my problem:
>
> 1. I tried to use COMMON to transfer the following variables. I include
> "petsc.var" in the solver subroutine.  It cannot be compiled.
> "petsc.var"
> Vec         x,b
> Mat         A
> KSP         ksp
> PC          pc
> COMMON /MYPETSC/x, b, A,ksp,pc
>
> 2. I defined the following in the main program:
> PROGRAM MAIN
> #include <finclude/petscsys.h>
> #include <finclude/petscvec.h>
> #include <finclude/petscmat.h>
> #include <finclude/petscpc.h>
> #include <finclude/petscksp.h>
> Vec         x,b
> Mat         A
> KSP         ksp
> PC          pc
> ......
> CALL INIT_PETSC(ksp,pc,A,x,b)
> ......
> CALL LOOP(ksp,pc,A,x,b)
>
> END PROGRAM
> !-----------------------------**----------------------
> SUBROUTINE LOOP(ksp,pc,A,x,b)
> Vec         x,b
> Mat         A
> KSP         ksp
> PC          pc
> ......
> CALL SOLVE(ksp,pc,A,x,b)
> .......
> END SUBROUTINE
> !-----------------------------**----------------------
> SUBROUTINE SOLVE(ksp,pc,A,x,b)
> Vec         x,b
> Mat         A
> KSP         ksp
> PC          pc
>
> ......
> CALL (ksp, b,x,ierr)
> END SUBROUTINE
>
> It can be compiled, but ksp does not iterate.
>
> Could you please explain to me the reason and solution for this problem.
>

I do not understand "does not iterate". Is there an error message?

  Thanks,

     Matt


> Thank you very much.
>
>
>
>
>
>
>
>
>
>
>
>
>
>


-- 
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130816/6aaddd38/attachment.html>


More information about the petsc-users mailing list