|
|
@ -121,15 +121,15 @@ subroutine psb_cfcg_vect(a,prec,b,x,eps,desc_a,info,&
|
|
|
|
integer(psb_ipk_), Optional, Intent(out) :: iter
|
|
|
|
integer(psb_ipk_), Optional, Intent(out) :: iter
|
|
|
|
real(psb_spk_), Optional, Intent(out) :: err,cond
|
|
|
|
real(psb_spk_), Optional, Intent(out) :: err,cond
|
|
|
|
! = Local data
|
|
|
|
! = Local data
|
|
|
|
type(psb_c_vect_type) :: v, w
|
|
|
|
type(psb_c_vect_type) :: v, w, d , q, r
|
|
|
|
type(psb_c_vect_type), dimension(0:1) :: d
|
|
|
|
complex(psb_spk_) :: alpha, beta, delta, gamma, theta
|
|
|
|
complex(psb_spk_) :: alpha, tau, tau1, beta, delta
|
|
|
|
|
|
|
|
real(psb_dpk_) :: derr
|
|
|
|
real(psb_dpk_) :: derr
|
|
|
|
integer(psb_ipk_) :: i, idx, nc2l, it, itx, istop_, itmax_, itrace_
|
|
|
|
integer(psb_ipk_) :: i, idx, nc2l, it, itx, istop_, itmax_, itrace_
|
|
|
|
integer(psb_ipk_) :: n_col, mglob, naux, err_act
|
|
|
|
integer(psb_ipk_) :: n_col, mglob, naux, err_act
|
|
|
|
integer(psb_ipk_) :: debug_level, debug_unit
|
|
|
|
integer(psb_ipk_) :: debug_level, debug_unit
|
|
|
|
integer(psb_ipk_) :: np, me, ictxt
|
|
|
|
integer(psb_ipk_) :: np, me, ictxt
|
|
|
|
complex(psb_spk_), allocatable, target :: aux(:)
|
|
|
|
complex(psb_spk_), allocatable, target :: aux(:)
|
|
|
|
|
|
|
|
complex(psb_spk_) :: vres(3)
|
|
|
|
character(len=20) :: name
|
|
|
|
character(len=20) :: name
|
|
|
|
type(psb_itconv_type) :: stopdat
|
|
|
|
type(psb_itconv_type) :: stopdat
|
|
|
|
character(len=*), parameter :: methdname='FCG'
|
|
|
|
character(len=*), parameter :: methdname='FCG'
|
|
|
@ -191,112 +191,113 @@ subroutine psb_cfcg_vect(a,prec,b,x,eps,desc_a,info,&
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!Assemble w, v
|
|
|
|
!Assemble w, v, d, q, r, u
|
|
|
|
|
|
|
|
call psb_geasb(w, desc_a,info,&
|
|
|
|
call psb_geasb(w,&
|
|
|
|
|
|
|
|
& desc_a,info,&
|
|
|
|
|
|
|
|
& scratch=.true.,mold=b%v)
|
|
|
|
|
|
|
|
call psb_geasb(v,&
|
|
|
|
|
|
|
|
& desc_a,info,&
|
|
|
|
|
|
|
|
& scratch=.true.,mold=b%v)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!Assemble d(0) and d(1)
|
|
|
|
|
|
|
|
call psb_geasb(d(0),&
|
|
|
|
|
|
|
|
& desc_a,info,&
|
|
|
|
|
|
|
|
& scratch=.true.,mold=x%v)
|
|
|
|
& scratch=.true.,mold=x%v)
|
|
|
|
call psb_geasb(d(1),&
|
|
|
|
call psb_geasb(v, desc_a,info,&
|
|
|
|
& desc_a,info,&
|
|
|
|
& scratch=.true.,mold=x%v)
|
|
|
|
|
|
|
|
call psb_geasb(d, desc_a,info,&
|
|
|
|
|
|
|
|
& scratch=.true.,mold=x%v)
|
|
|
|
|
|
|
|
call psb_geasb(q, desc_a,info,&
|
|
|
|
|
|
|
|
& scratch=.true.,mold=x%v)
|
|
|
|
|
|
|
|
call psb_geasb(r, desc_a,info,&
|
|
|
|
& scratch=.true.,mold=x%v)
|
|
|
|
& scratch=.true.,mold=x%v)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
call psb_init_conv(methdname,istop_,itrace_,itmax_,&
|
|
|
|
call psb_init_conv(methdname,istop_,itrace_,itmax_,a,x,b,eps,desc_a,stopdat,info)
|
|
|
|
& a,x,b,eps,desc_a,stopdat,info)
|
|
|
|
itx=0
|
|
|
|
itx = 0
|
|
|
|
|
|
|
|
|
|
|
|
restart: do
|
|
|
|
restart: do
|
|
|
|
if (itx>= itmax_) exit restart
|
|
|
|
if (itx>= itmax_) exit restart
|
|
|
|
|
|
|
|
|
|
|
|
! w=b
|
|
|
|
! r=b -Ax
|
|
|
|
call psb_geaxpby(cone,b,czero,w,&
|
|
|
|
call psb_geaxpby(cone,b,czero,r, desc_a,info)
|
|
|
|
& desc_a,info)
|
|
|
|
if (info == psb_success_) call psb_spmm(-cone,a,x,cone,r,desc_a,info)
|
|
|
|
|
|
|
|
if (info /= psb_success_) then
|
|
|
|
|
|
|
|
call psb_errpush(psb_err_internal_error_,name,&
|
|
|
|
|
|
|
|
& a_err='Error during residue')
|
|
|
|
|
|
|
|
goto 9999
|
|
|
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
|
|
if (psb_errstatus_fatal()) then
|
|
|
|
|
|
|
|
nc2l = desc_a%get_local_cols()
|
|
|
|
|
|
|
|
info=psb_err_alloc_request_
|
|
|
|
|
|
|
|
call psb_errpush(info,name,i_err=(/2*nc2l,izero,izero,izero,izero/),&
|
|
|
|
|
|
|
|
& a_err='complex(psb_spk_)')
|
|
|
|
|
|
|
|
goto 9999
|
|
|
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!Compute v = Ax
|
|
|
|
if (psb_check_conv(methdname,itx,x,r,desc_a,stopdat,info)) exit restart
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
call psb_spmm(cone,a,x,czero,v,desc_a,info)
|
|
|
|
! Apply the preconditioner v=Pr
|
|
|
|
|
|
|
|
! Compute w = Av
|
|
|
|
|
|
|
|
call prec%apply(r,v,desc_a,info,work=aux)
|
|
|
|
|
|
|
|
if (info == psb_success_) call psb_spmm(cone,a,v,czero,w,desc_a,info)
|
|
|
|
if (info /= psb_success_) then
|
|
|
|
if (info /= psb_success_) then
|
|
|
|
call psb_errpush(psb_err_internal_error_,name,&
|
|
|
|
call psb_errpush(psb_err_internal_error_,name,&
|
|
|
|
& a_err='Error during residue')
|
|
|
|
& a_err='Error during residue')
|
|
|
|
goto 9999
|
|
|
|
goto 9999
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
|
|
!Compute w = -Ax + b
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
call psb_geaxpby(-cone, v, cone, w, desc_a, info)
|
|
|
|
vres(1) = psb_gedot(r, v, desc_a, info, global = .false.)
|
|
|
|
|
|
|
|
vres(2) = psb_gedot(w, v, desc_a, info, global = .false.)
|
|
|
|
|
|
|
|
|
|
|
|
!Apply the preconditioner
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
idx=0
|
|
|
|
call psb_sum(ictxt, vres(1:2))
|
|
|
|
|
|
|
|
|
|
|
|
call prec%apply(w,d(idx),desc_a,info,work=aux)
|
|
|
|
alpha = vres(1)
|
|
|
|
|
|
|
|
beta = vres(2)
|
|
|
|
|
|
|
|
|
|
|
|
delta = psb_gedot(d(idx), w, desc_a, info)
|
|
|
|
! d = v
|
|
|
|
|
|
|
|
call psb_geaxpby(cone, v, czero, d, desc_a, info)
|
|
|
|
|
|
|
|
! q = w
|
|
|
|
|
|
|
|
call psb_geaxpby(cone, w, czero, q, desc_a, info)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
! compute delta=beta
|
|
|
|
|
|
|
|
! then
|
|
|
|
|
|
|
|
! x = x + (alpha/delta)*d
|
|
|
|
|
|
|
|
! r = r - (alpha/delta)*q
|
|
|
|
|
|
|
|
|
|
|
|
!Loop
|
|
|
|
delta = beta
|
|
|
|
|
|
|
|
theta = alpha/delta
|
|
|
|
|
|
|
|
call psb_geaxpby(theta, d, cone, x, desc_a, info)
|
|
|
|
|
|
|
|
call psb_geaxpby(-theta, q, cone, r, desc_a, info)
|
|
|
|
|
|
|
|
|
|
|
|
if (psb_check_conv(methdname,itx ,x,w,desc_a,stopdat,info)) exit restart
|
|
|
|
iteration: do
|
|
|
|
|
|
|
|
|
|
|
|
if (info /= psb_success_) Then
|
|
|
|
itx = itx + 1
|
|
|
|
call psb_errpush(psb_err_from_subroutine_non_,name)
|
|
|
|
|
|
|
|
goto 9999
|
|
|
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
iteration: do
|
|
|
|
if (psb_check_conv(methdname,itx,x,r,desc_a,stopdat,info)) exit restart
|
|
|
|
|
|
|
|
|
|
|
|
call psb_spmm(cone,a,d(idx),czero,v,desc_a,info)
|
|
|
|
! Apply the preconditioner v = Pr
|
|
|
|
|
|
|
|
! Compute w = Av
|
|
|
|
|
|
|
|
call prec%apply(r,v,desc_a,info,work=aux)
|
|
|
|
|
|
|
|
if (info == psb_success_) call psb_spmm(cone,a,v,czero,w,desc_a,info)
|
|
|
|
if (info /= psb_success_) then
|
|
|
|
if (info /= psb_success_) then
|
|
|
|
call psb_errpush(psb_err_internal_error_,name,&
|
|
|
|
call psb_errpush(psb_err_internal_error_,name,&
|
|
|
|
& a_err='Error during residue')
|
|
|
|
& a_err='Error during residual'); goto 9999
|
|
|
|
goto 9999
|
|
|
|
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
tau = psb_gedot(d(idx), v, desc_a, info)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
alpha = delta/tau
|
|
|
|
vres(1) = psb_gedot(r, v, desc_a, info, global = .false.)
|
|
|
|
!Update solution x
|
|
|
|
vres(2) = psb_gedot(w, v, desc_a, info, global = .false.)
|
|
|
|
call psb_geaxpby(alpha, d(idx), cone, x, desc_a, info)
|
|
|
|
vres(3) = psb_gedot(q, v, desc_a, info, global = .false.)
|
|
|
|
!Update residual w
|
|
|
|
|
|
|
|
call psb_geaxpby(-alpha, v, cone, w, desc_a, info)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
itx = itx + 1
|
|
|
|
|
|
|
|
idx=mod(itx ,2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
call d(idx)%set(czero)
|
|
|
|
call psb_sum(ictxt, vres(1:3))
|
|
|
|
call prec%apply(w,d(idx),desc_a,info,work=aux)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tau1= psb_gedot(d(idx), v, desc_a, info)
|
|
|
|
alpha = vres(1)
|
|
|
|
beta=tau1/tau
|
|
|
|
beta = vres(2)
|
|
|
|
|
|
|
|
gamma = vres(3)
|
|
|
|
|
|
|
|
|
|
|
|
if (idx == 1) then
|
|
|
|
! Compute d = v-(gamma/delta)*d
|
|
|
|
call psb_geaxpby(-beta, d(idx - 1), cone, d(idx), desc_a, info)
|
|
|
|
! q = w-(gamma/delta)*q
|
|
|
|
else
|
|
|
|
theta= gamma/delta
|
|
|
|
call psb_geaxpby(-beta, d(idx + 1), cone, d(idx), desc_a, info)
|
|
|
|
call psb_geaxpby(cone, v, -theta, d, desc_a, info)
|
|
|
|
endif
|
|
|
|
call psb_geaxpby(cone, w, -theta, q , desc_a, info)
|
|
|
|
|
|
|
|
|
|
|
|
delta = psb_gedot(w, d(idx), desc_a, info)
|
|
|
|
! update delta
|
|
|
|
|
|
|
|
delta = beta - (gamma*gamma)/delta
|
|
|
|
|
|
|
|
|
|
|
|
if (psb_check_conv(methdname,itx ,x,w,desc_a,stopdat,info)) exit restart
|
|
|
|
! update u and r
|
|
|
|
if (info /= psb_success_) Then
|
|
|
|
! u = u + (alpha/delta)*d
|
|
|
|
call psb_errpush(psb_err_from_subroutine_non_,name)
|
|
|
|
! r = r - (alpha/delta)*q
|
|
|
|
goto 9999
|
|
|
|
theta= alpha/delta
|
|
|
|
End If
|
|
|
|
call psb_geaxpby(theta, d, cone, x, desc_a, info)
|
|
|
|
|
|
|
|
call psb_geaxpby(-theta, q, cone, r, desc_a, info)
|
|
|
|
|
|
|
|
|
|
|
|
end do iteration
|
|
|
|
end do iteration
|
|
|
|
end do restart
|
|
|
|
end do restart
|
|
|
|