30 integer(kind=kint),
intent(inout) :: iter, error
31 real(kind=
kreal),
intent(inout) :: resid, tset, tsol, tcomm
33 integer(kind=kint) :: n, np, ndof, nndof
34 integer(kind=kint) :: my_rank
35 integer(kind=kint) :: iterlog, timelog
36 real(kind=
kreal),
pointer :: b(:), x(:)
38 real(kind=
kreal),
dimension(:,:),
allocatable :: ww
40 integer(kind=kint),
parameter :: r = 1
41 integer(kind=kint),
parameter :: u = 2
42 integer(kind=kint),
parameter :: v = 3
43 integer(kind=kint),
parameter :: q = 4
44 integer(kind=kint),
parameter :: p = 5
45 integer(kind=kint),
parameter :: s = 6
46 integer(kind=kint),
parameter :: wk = 7
48 integer(kind=kint) :: maxit
50 real(kind=
kreal) :: tol
51 integer(kind=kint) :: i
52 real(kind=
kreal) :: s_time, s1_time, e_time, e1_time
53 real(kind=
kreal) :: start_time, end_time
54 real(kind=
kreal) :: bnrm2, dnrm2
55 real(kind=
kreal) :: alpha, alpha1, beta
56 real(kind=
kreal) :: gamma, gamma1, delta
57 real(kind=
kreal) :: cg(2)
58 real(kind=
kreal) :: t_max, t_min, t_avg, t_sd
59 integer(kind=kint) :: estcond
60 real(kind=
kreal),
allocatable :: d(:), e(:)
61 integer(kind=kint) :: n_indef_precond
63 integer(kind=kint),
parameter :: n_iter_recompute_r = 50
72 my_rank = hecmesh%my_rank
89 allocate(ww(ndof*np, 7))
99 if (estcond /= 0 .and. hecmesh%my_rank == 0)
then
100 allocate(d(maxit), e(maxit-1))
107 if (bnrm2.eq.0.0d0)
then
113 call hecmw_matvec(hecmesh, hecmat, ww(:,p), ww(:,s), tcomm)
120 tcomm = tcomm + end_time-start_time
123 resid = dsqrt(dnrm2/bnrm2)
124 if (resid.le.tol) maxit = 0
128 if (timelog.eq.2)
then
130 if (hecmesh%my_rank.eq.0)
then
131 write(*,*)
'Time solver setup'
132 write(*,*)
' Max :', t_max
133 write(*,*)
' Min :', t_min
134 write(*,*)
' Avg :', t_avg
135 write(*,*)
' Std Dev :', t_sd
147 if (gamma.eq.0.0d0)
then
151 elseif (gamma.ne.gamma)
then
158 if (delta.le.0.0d0)
then
162 elseif (delta.ne.delta)
then
172 if (estcond /= 0 .and. hecmesh%my_rank == 0)
then
176 d(i) = 1.0d0/alpha+beta/alpha1
177 e(i-1) = dsqrt(beta)/alpha1
184 if (mod(i,n_iter_recompute_r).eq.0)
then
197 tcomm = tcomm + end_time-start_time
200 resid = dsqrt(dnrm2/bnrm2)
203 if (resid.le.tol)
then
204 if (mod(i,n_iter_recompute_r).ne.0)
then
207 resid = dsqrt(dnrm2/bnrm2)
209 if (my_rank.eq.0 .and. iterlog.eq.1)
write(*,
'(i7, 1pe16.6)') iter, resid
210 if (resid.le.tol)
exit
215 if (my_rank.eq.0 .and. iterlog.eq.1)
write(*,
'(i7, 1pe16.6)') iter, resid
219 if (mod(i,n_iter_recompute_r).ne.0)
then
222 resid = dsqrt(dnrm2/bnrm2)
228 if (gamma1.eq.0.0d0)
then
231 elseif (gamma1.ne.gamma1)
then
234 elseif (gamma1*gamma.le.0.0d0)
then
235 n_indef_precond = n_indef_precond + 1
236 if (n_indef_precond.ge.3)
then
242 call hecmw_matvec(hecmesh, hecmat, ww(:,u), ww(:,v), tcomm)
257 tcomm = tcomm + end_time-start_time
265 if (estcond /= 0 .and. hecmesh%my_rank == 0)
then
271 if (timelog.eq.2)
then
273 if (hecmesh%my_rank.eq.0)
then
274 write(*,*)
'Time solver iterations'
275 write(*,*)
' Max :', t_max
276 write(*,*)
' Min :', t_min
277 write(*,*)
' Avg :', t_avg
278 write(*,*)
' Std Dev :', t_sd
282 tsol = e1_time-s1_time
287 end module hecmw_solver_GroppCG
subroutine, public hecmw_estimate_condition_cg(ITER, D, E)
Jagged Diagonal Matrix storage for vector processors. Original code was provided by JAMSTEC.
subroutine, public hecmw_jad_init(hecMAT)
subroutine, public hecmw_jad_finalize(hecMAT)
subroutine, public hecmw_mat_integrate(hecMAT)
Integrate matrix components into a single array for efficient access.
real(kind=kreal) function, public hecmw_mat_get_resid(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_iterlog(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_timelog(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_estcond(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_usejad(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_iter(hecMAT)
subroutine, public hecmw_precond_setup(hecMAT, hecMESH, sym)
subroutine, public hecmw_precond_apply(hecMESH, hecMAT, R, Z, ZP, COMMtime)
subroutine, public hecmw_solve_groppcg(hecMESH, hecMAT, ITER, RESID, error, Tset, Tsol, Tcomm)
subroutine, public hecmw_matresid(hecMESH, hecMAT, X, B, R, COMMtime)
subroutine, public hecmw_matvec(hecMESH, hecMAT, X, Y, COMMtime)
subroutine hecmw_xpay_r(n, alpha, X, Y)
subroutine hecmw_innerproduct_r_nocomm(hecMESH, ndof, X, Y, sum)
subroutine hecmw_innerproduct_r(hecMESH, ndof, X, Y, sum, COMMtime)
subroutine hecmw_axpy_r(n, alpha, X, Y)
subroutine hecmw_copy_r(n, X, Y)
subroutine hecmw_time_statistics(hecMESH, time, t_max, t_min, t_avg, t_sd)
subroutine, public hecmw_solver_scaling_fw(hecMESH, hecMAT, COMMtime)
subroutine, public hecmw_solver_scaling_bk(hecMAT)
integer(kind=kint), parameter hecmw_sum
integer(kind=4), parameter kreal
real(kind=kreal) function hecmw_wtime()
subroutine hecmw_update_r(hecMESH, val, n, m)
subroutine hecmw_allreduce_r(hecMESH, val, n, ntag)
subroutine hecmw_barrier(hecMESH)
integer(kind=kint), parameter hecmw_solver_error_diverge_pc
integer(kind=kint), parameter hecmw_solver_error_diverge_nan
integer(kind=kint), parameter hecmw_solver_error_noconv_maxit
integer(kind=kint), parameter hecmw_solver_error_diverge_mat