-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwwm_petsc_controller.F90
104 lines (94 loc) · 3.43 KB
/
wwm_petsc_controller.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "wwm_functions.h"
!> \file wwm_petsc_controller.F90
!> Controls which PETSC Module to use
!> \author Thomas Huxhorn
!> \date 2012
#ifdef PETSC
!> controls at compile time which PETSC module will be use
Module PETSC_CONTROLLER
implicit none
#include "finclude/petscsysdef.h"
logical :: init = .false.
contains
!> calls the specific PETSC_INIT_* subroutine
subroutine PETSC_INIT
use datapool, only: AMETHOD, DBG
use petscpool, only: petscpoolInit, stageInit, stageSolve, petscErr
#ifdef MPI_PARALL_GRID
use petsc_parallel, only: PETSC_INIT_PARALLEL
use petsc_block, only: PETSC_INIT_BLOCK
#endif
use petsc_seriell, only: PETSC_INIT_SERIELL
use petscsys
implicit none
init = .true.
! petscpoolInit must be called BEFORE PETSC_INIT_*
call petscpoolInit
call PetscLogStagePush(stageInit, petscErr);CHKERRQ(petscErr)
#ifdef MPI_PARALL_GRID
if(AMETHOD == 4) then
call PETSC_INIT_PARALLEL
else if(AMETHOD == 5) then
call PETSC_INIT_BLOCK
else
write(DBG%FHNDL,*) "PETSC_INIT() you can use AMETHOD=4 "
write(DBG%FHNDL,*) "for petsc parallel or AMETHOD=5 for petsc block."
write(DBG%FHNDL,*) "Other AMETHOD numbers are for other solvers."
write(DBG%FHNDL,*) "AMETHOD =" , AMETHOD
endif
#else
call PETSC_INIT_SERIELL
#endif
call PetscLogStagePop(stageInit, petscErr);CHKERRQ(petscErr)
end subroutine
!> calls the specific EIMPS_PETSC_{PARALLEL, SERIELL} subroutine
!> \param ISS frequency. From 1 to NUMSIG
!> \param IDD direction. From 1 to NUMDIR
subroutine EIMPS_PETSC(ISS, IDD)
#ifdef MPI_PARALL_GRID
use petsc_parallel, only: EIMPS_PETSC_PARALLEL
use petsc_block, only: EIMPS_PETSC_BLOCK
#endif
use petsc_seriell, only: EIMPS_PETSC_SERIELL
implicit none
integer, intent(in) :: ISS, IDD
#ifdef MPI_PARALL_GRID
call EIMPS_PETSC_PARALLEL(ISS, IDD)
#else
call EIMPS_PETSC_SERIELL(ISS, IDD)
#endif
end subroutine
!> clean up memory and calls PetscFinalize()
subroutine PETSC_FINALIZE()
use datapool, only: AMETHOD, DBG
use petscpool, only: petscErr, petscpoolFinalize, stageFin
#ifdef MPI_PARALL_GRID
use petsc_parallel, only: PETSC_FINALIZE_PARALLEL
use petsc_block, only: PETSC_FINALIZE_BLOCK
#endif
use petsc_seriell, only: PETSC_FINALIZE_SERIELL
use petscsys
implicit none
! if petsc* was not initialized we must not finalize it
if(init.eqv..false.) return
call PetscLogStagePush(stageFin, petscErr);CHKERRQ(petscErr)
! petscpoolFinalize must be called BEFORE PETSC_FINALIZE_*
call petscpoolFinalize()
#ifdef MPI_PARALL_GRID
if(AMETHOD == 4) then
call PETSC_FINALIZE_PARALLEL
else if(AMETHOD == 5) then
call PETSC_FINALIZE_BLOCK
else
write(DBG%FHNDL,*) "PETSC_FINALIZE() you can use AMETHOD=4"
write(DBG%FHNDL,*) "for petsc parallel or AMETHOD=5 for petsc block."
write(DBG%FHNDL,*) "Other AMETHOD numbers are for other solvers."
write(DBG%FHNDL,*) "AMETHOD =" , AMETHOD
endif
# else
call PETSC_FINALIZE_SERIELL
# endif
call PetscFinalize(petscErr)
end subroutine
end Module
#endif