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 :: z = 6
46 integer(kind=kint),
parameter :: l = 7
47 integer(kind=kint),
parameter :: m = 8
48 integer(kind=kint),
parameter :: s = 9
49 integer(kind=kint),
parameter :: wk = 10
51 integer(kind=kint) :: maxit
53 real(kind=
kreal) :: tol
54 integer(kind=kint) :: i
55 real(kind=
kreal) :: s_time, s1_time, e_time, e1_time
56 real(kind=
kreal) :: start_time, end_time
57 real(kind=
kreal) :: bnrm2, dnrm2
58 real(kind=
kreal) :: alpha, alpha1, beta
59 real(kind=
kreal) :: gamma, gamma1, delta, denom
60 real(kind=
kreal) :: cg(3)
61 real(kind=
kreal) :: t_max, t_min, t_avg, t_sd
62 integer(kind=kint) :: estcond
63 real(kind=
kreal),
allocatable :: d(:), e(:)
64 integer(kind=kint) :: n_indef_precond
66 integer(kind=kint) :: n_iter_recompute_r
67 integer(kind=kint),
parameter :: n_iter_recompute_r_default = 50
76 my_rank = hecmesh%my_rank
87 if (n_iter_recompute_r == 0) n_iter_recompute_r = n_iter_recompute_r_default
89 if (n_iter_recompute_r < 0) n_iter_recompute_r = maxit + 1
97 allocate(ww(ndof*np, 10))
107 if (estcond /= 0 .and. hecmesh%my_rank == 0)
then
108 allocate(d(maxit), e(maxit-1))
115 if (bnrm2.eq.0.0d0)
then
121 call hecmw_matvec(hecmesh, hecmat, ww(:,u), ww(:,v), tcomm)
125 if (timelog.eq.2)
then
127 if (hecmesh%my_rank.eq.0)
then
128 write(*,*)
'Time solver setup'
129 write(*,*)
' Max :', t_max
130 write(*,*)
' Min :', t_min
131 write(*,*)
' Avg :', t_avg
132 write(*,*)
' Std Dev :', t_sd
150 tcomm = tcomm + end_time-start_time
155 resid = dsqrt(dnrm2/bnrm2)
157 if (i.eq.1 .and. resid.le.tol)
exit
161 if (my_rank.eq.0 .and. iterlog.eq.1)
write(*,
'(i7, 1pe16.6)') iter, resid
162 if (resid.le.tol)
then
163 if (mod(iter,n_iter_recompute_r).eq.0)
exit
166 resid = dsqrt(dnrm2/bnrm2)
167 if (resid.le.tol)
exit
170 call hecmw_matvec(hecmesh, hecmat, ww(:,u), ww(:,v), tcomm)
177 tcomm = tcomm + end_time-start_time
181 resid = dsqrt(dnrm2/bnrm2)
185 if (gamma.eq.0.0d0)
exit
186 if (gamma.ne.gamma)
then
190 elseif (i.gt.1 .and. gamma*gamma1.le.0.0d0)
then
191 n_indef_precond = n_indef_precond + 1
192 if (n_indef_precond.ge.3)
then
200 call hecmw_matvec(hecmesh, hecmat, ww(:,m), ww(:,l), tcomm)
204 denom = delta-beta*gamma/alpha1
210 if (denom.le.0.0d0)
then
214 elseif (denom.ne.denom)
then
227 if (mod(i,n_iter_recompute_r).eq.0)
then
230 call hecmw_matvec(hecmesh, hecmat, ww(:,u), ww(:,v), tcomm)
238 if (estcond /= 0 .and. hecmesh%my_rank == 0)
then
242 d(i) = 1.0d0/alpha+beta/alpha1
243 e(i-1) = dsqrt(beta)/alpha1
254 resid = dsqrt(dnrm2/bnrm2)
255 if (my_rank.eq.0 .and. iterlog.eq.1)
write(*,
'(i7, 1pe16.6)') iter, resid
265 tcomm = tcomm + end_time-start_time
273 if (estcond /= 0 .and. hecmesh%my_rank == 0)
then
279 if (timelog.eq.2)
then
281 if (hecmesh%my_rank.eq.0)
then
282 write(*,*)
'Time solver iterations'
283 write(*,*)
' Max :', t_max
284 write(*,*)
' Min :', t_min
285 write(*,*)
' Avg :', t_avg
286 write(*,*)
' Std Dev :', t_sd
290 tsol = e1_time-s1_time
295 end module hecmw_solver_PipeCG
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_recompute_residual(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_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_time_statistics(hecMESH, time, t_max, t_min, t_avg, t_sd)
subroutine, public hecmw_solve_pipecg(hecMESH, hecMAT, ITER, RESID, error, Tset, Tsol, Tcomm)
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