59 subroutine cg(x, iter, res, b, A, tol, itmax, verb)
61 real(RP),
dimension(:),
intent(inout) :: x
62 integer ,
intent(out) :: iter
63 real(RP) ,
intent(out) :: res
64 real(RP),
dimension(:),
intent(in) :: b
65 procedure(rntorn) :: A
66 real(RP) ,
intent(in) :: tol
67 integer ,
intent(in) :: itmax, verb
70 real(RP),
dimension(size(x,1)) :: r, p, Ap
71 real(RP) :: alpha, beta, nb2
72 real(RP) :: ps_rr, ps_App, ps_rjrj
75 if (verb>1)
write(*,*)
'cg_mod : cg' 86 call axpy(-1._rp, r, b)
90 if (verb>2)
write(*,*)
' iter', iter,
', residual = ', res
103 alpha = ps_rr / ps_app
105 call xpay(x, alpha, p)
108 call xpay(r, -alpha, ap)
112 if (verb>2)
write(*,*)
' iter', iter,
', residual = ', res
118 call axpy(beta, p, r)
124 call warning(
"cg_mod: cg: not converged", verb-1)
154 subroutine pcg(x, iter, res, b, A, pc, tol, itmax, verb)
156 real(RP),
dimension(:),
intent(inout) :: x
157 integer ,
intent(out) :: iter
158 real(RP) ,
intent(out) :: res
159 real(RP),
dimension(:),
intent(in) :: b
160 procedure(rntorn) :: A, pc
161 real(RP) ,
intent(in) :: tol
162 integer ,
intent(in) :: itmax, verb
164 real(RP),
dimension(size(x,1)) :: r, p, Ap, z
166 real(RP) :: alpha, beta, nb2
167 real(RP) :: ps_rz, ps_App, ps_rjzj
170 if (verb>1)
write(*,*)
'cg_mod : pcg' 181 call axpy(-1._rp, r, b)
184 if (verb>2)
write(*,*)
' iter', iter,
', residual = ', res
199 alpha = ps_rz / ps_app
201 call xpay(x, alpha, p)
203 call xpay(r, -alpha, ap)
207 if (verb>2)
write(*,*)
' iter', iter,
' residual = ', res
215 call axpy(beta, p, z)
221 call warning(
"cg_mod: pcg: not converged", verb-1)
DEFINITION OF ABSTRACT_INTERFACES FOR THE LIBRARY CHORAL
subroutine, public pcg(x, iter, res, b, A, pc, tol, itmax, verb)
Preconditioned conjugate gradient.
subroutine, public cg(x, iter, res, b, A, tol, itmax, verb)
Conjugate gradient (no preconditioning)
conversion integers or rational to real
REAL NUMBERS PRECISION IN CHORAL: selects simple/double/quad
OPENMP OPERATIONS ON 1-DIMENSIONAL REAL ARRAYS
CG LINEAR SOLVER = Conjugate Gradient
x = x + b*y // OR // z = x + b*y
real(rp), parameter, public real_tol