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.

Thank you very much.













Reply via email to