Updated prologs for Krylov subspace methods.

psblas3-type-indexed
Salvatore Filippone 17 years ago
parent ea8ff0d764
commit 07790aab16

@ -60,21 +60,36 @@
! This subroutine implements the BiCG method.
!
! Arguments:
! a - type(<psb_dspmat_type>). The sparse matrix containing A.
! prec - type(<psb_prec_type>). The data structure containing the preconditioner.
! b - real,dimension(:). The right hand side.
! x - real,dimension(:). The vector of unknowns.
! eps - real. The error tolerance.
! desc_a - type(<psb_desc_type>). The communication descriptor.
! info - integer. Return code
! itmax - integer(optional). The maximum number of iterations.
! iter - integer(optional). The number of iterations performed.
! err - real(optional). The error on return.
! itrace - integer(optional). The unit to write messages onto.
! istop - integer(optional). The stopping criterium.
!
subroutine psb_dbicg(a,prec,b,x,eps,desc_a,info,&
&itmax,iter,err, itrace,istop)
! a - type(<psb_dspmat_type>) Input: sparse matrix containing A.
! prec - type(<psb_dprec_type>) Input: preconditioner
! b - real,dimension(:) Input: vector containing the
! right hand side B
! x - real,dimension(:) Input/Output: vector containing the
! initial guess and final solution X.
! eps - real Input: Stopping tolerance; the iteration is
! stopped when the error estimate
! |err| <= eps
! desc_a - type(<psb_desc_type>). Input: The communication descriptor.
! info - integer. Output: Return code
!
! itmax - integer(optional) Input: maximum number of iterations to be
! performed.
! iter - integer(optional) Output: how many iterations have been
! performed.
! err - real (optional) Output: error estimate on exit
! itrace - integer(optional) Input: print an informational message
! with the error estimate every itrace
! iterations
! istop - integer(optional) Input: stopping criterion, or how
! to estimate the error.
! 1: err = |r|/|b|
! 2: err = |r|/(|a||x|+|b|)
! where r is the (preconditioned, recursive
! estimate of) residual
!
!
subroutine psb_dbicg(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop)
use psb_base_mod
use psb_prec_mod
implicit none
@ -168,11 +183,11 @@ subroutine psb_dbicg(a,prec,b,x,eps,desc_a,info,&
if (info == 0) call psb_geall(wwrk,desc_a,info,n=9)
if (info == 0) call psb_geasb(wwrk,desc_a,info)
if(info.ne.0) then
info=4011
ch_err='psb_asb'
err=info
call psb_errpush(info,name,a_err=ch_err)
goto 9999
info=4011
ch_err='psb_asb'
err=info
call psb_errpush(info,name,a_err=ch_err)
goto 9999
end if
q => wwrk(:,1)
@ -198,21 +213,21 @@ subroutine psb_dbicg(a,prec,b,x,eps,desc_a,info,&
end if
itx = 0
if (istop_ == 1) then
ani = psb_spnrmi(a,desc_a,info)
bni = psb_geamax(b,desc_a,info)
ani = psb_spnrmi(a,desc_a,info)
bni = psb_geamax(b,desc_a,info)
else if (istop_ == 2) then
bn2 = psb_genrm2(b,desc_a,info)
bn2 = psb_genrm2(b,desc_a,info)
endif
if(info.ne.0) then
info=4011
err=info
call psb_errpush(info,name,a_err=ch_err)
goto 9999
info=4011
err=info
call psb_errpush(info,name,a_err=ch_err)
goto 9999
end if
restart: do
!!$
!!$ r0 = b-ax0
@ -224,9 +239,9 @@ subroutine psb_dbicg(a,prec,b,x,eps,desc_a,info,&
if (debug) write(0,*) me,' Done spmm',info
if (info == 0) call psb_geaxpby(done,r,dzero,rt,desc_a,info)
if(info.ne.0) then
info=4011
call psb_errpush(info,name)
goto 9999
info=4011
call psb_errpush(info,name)
goto 9999
end if
rho = dzero
@ -238,9 +253,9 @@ subroutine psb_dbicg(a,prec,b,x,eps,desc_a,info,&
rni = psb_genrm2(r,desc_a,info)
endif
if(info.ne.0) then
info=4011
call psb_errpush(info,name)
goto 9999
info=4011
call psb_errpush(info,name)
goto 9999
end if
if (istop_ == 1) then
@ -251,11 +266,11 @@ subroutine psb_dbicg(a,prec,b,x,eps,desc_a,info,&
endif
if(info.ne.0) then
info=4011
call psb_errpush(info,name)
goto 9999
info=4011
call psb_errpush(info,name)
goto 9999
end if
if (rerr<=eps) then
exit restart
end if
@ -336,7 +351,7 @@ subroutine psb_dbicg(a,prec,b,x,eps,desc_a,info,&
If (itrace_ > 0) then
if (me == 0) write(*,'(a,i4,3(2x,es10.4))') 'bicg: ',itx,rerr
end If
if (present(err)) err=rerr
if (present(iter)) iter = itx
if (rerr>eps) then
@ -352,8 +367,8 @@ subroutine psb_dbicg(a,prec,b,x,eps,desc_a,info,&
call psb_restore_coher(ictxt,isvch)
if(info/=0) then
call psb_errpush(info,name)
goto 9999
call psb_errpush(info,name)
goto 9999
end if
call psb_erractionrestore(err_act)
@ -362,8 +377,8 @@ subroutine psb_dbicg(a,prec,b,x,eps,desc_a,info,&
9999 continue
call psb_erractionrestore(err_act)
if (err_act.eq.psb_act_abort_) then
call psb_error()
return
call psb_error()
return
end if
return

@ -59,22 +59,38 @@
! Subroutine: psb_dcg
! This subroutine implements the Conjugate Gradient method.
!
!
! Arguments:
! a - type(<psb_dspmat_type>). The sparse matrix containing A.
! prec - type(<psb_prec_type>). The data structure containing the preconditioner.
! b - real,dimension(:). The right hand side.
! x - real,dimension(:). The vector of unknowns.
! eps - real. The error tolerance.
! desc_a - type(<psb_desc_type>). The communication descriptor.
! info - integer. Return code
! itmax - integer(optional). The maximum number of iterations.
! iter - integer(optional). The number of iterations performed.
! err - real(optional). The error on return.
! itrace - integer(optional). The unit to write messages onto.
! istop - integer(optional). The stopping criterium.
!
Subroutine psb_dcg(a,prec,b,x,eps,desc_a,info,&
&itmax,iter,err, itrace, istop)
! a - type(<psb_dspmat_type>) Input: sparse matrix containing A.
! prec - type(<psb_dprec_type>) Input: preconditioner
! b - real,dimension(:) Input: vector containing the
! right hand side B
! x - real,dimension(:) Input/Output: vector containing the
! initial guess and final solution X.
! eps - real Input: Stopping tolerance; the iteration is
! stopped when the error estimate
! |err| <= eps
! desc_a - type(<psb_desc_type>). Input: The communication descriptor.
! info - integer. Output: Return code
!
! itmax - integer(optional) Input: maximum number of iterations to be
! performed.
! iter - integer(optional) Output: how many iterations have been
! performed.
! err - real (optional) Output: error estimate on exit
! itrace - integer(optional) Input: print an informational message
! with the error estimate every itrace
! iterations
! istop - integer(optional) Input: stopping criterion, or how
! to estimate the error.
! 1: err = |r|/|b|
! 2: err = |r|/(|a||x|+|b|)
! where r is the (preconditioned, recursive
! estimate of) residual
!
!
Subroutine psb_dcg(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop)
use psb_base_mod
use psb_prec_mod
implicit none

@ -56,20 +56,39 @@
! File: psb_dcgs.f90
!
! Subroutine: psb_dcgs
! Implements the Conjugate Gradient Squared method.
!
!
! Arguments:
! a - type(<psb_dspmat_type>). The sparse matrix containing A.
! prec - type(<psb_prec_type>). The data structure containing the preconditioner.
! b - real,dimension(:). The right hand side.
! x - real,dimension(:). The vector of unknowns.
! eps - real. The error tolerance.
! desc_a - type(<psb_desc_type>). The communication descriptor.
! info - integer. Return code
! itmax - integer(optional). The maximum number of iterations.
! iter - integer(optional). The number of iterations performed.
! err - real(optional). The error on return.
! itrace - integer(optional). The unit to write messages onto.
! istop - integer(optional). The stopping criterium.
!
! a - type(<psb_dspmat_type>) Input: sparse matrix containing A.
! prec - type(<psb_dprec_type>) Input: preconditioner
! b - real,dimension(:) Input: vector containing the
! right hand side B
! x - real,dimension(:) Input/Output: vector containing the
! initial guess and final solution X.
! eps - real Input: Stopping tolerance; the iteration is
! stopped when the error estimate
! |err| <= eps
! desc_a - type(<psb_desc_type>). Input: The communication descriptor.
! info - integer. Output: Return code
!
! itmax - integer(optional) Input: maximum number of iterations to be
! performed.
! iter - integer(optional) Output: how many iterations have been
! performed.
! err - real (optional) Output: error estimate on exit
! itrace - integer(optional) Input: print an informational message
! with the error estimate every itrace
! iterations
! istop - integer(optional) Input: stopping criterion, or how
! to estimate the error.
! 1: err = |r|/|b|
! 2: err = |r|/(|a||x|+|b|)
! where r is the (preconditioned, recursive
! estimate of) residual
!
!
!
Subroutine psb_dcgs(a,prec,b,x,eps,desc_a,info,&
&itmax,iter,err,itrace,istop)

@ -56,24 +56,41 @@
! File: psb_dcgstab.f90
!
! Subroutine: psb_dcgstab
! This subroutine implements the CG Stabilized method.
! This subroutine implements the BiCG Stabilized method.
!
!
! Arguments:
! a - type(<psb_dspmat_type>). The sparse matrix containing A.
! prec - type(<psb_prec_type>). The data structure containing the preconditioner.
! b - real,dimension(:). The right hand side.
! x - real,dimension(:). The vector of unknowns.
! eps - real. The error tolerance.
! desc_a - type(<psb_desc_type>). The communication descriptor.
! info - integer. Return code
! itmax - integer(optional). The maximum number of iterations.
! iter - integer(optional). The number of iterations performed.
! err - real(optional). The error on return.
! itrace - integer(optional). The unit to write messages onto.
! istop - integer(optional). The stopping criterium.
!
Subroutine psb_dcgstab(a,prec,b,x,eps,desc_a,info,&
&itmax,iter,err,itrace, istop)
! a - type(<psb_dspmat_type>) Input: sparse matrix containing A.
! prec - type(<psb_dprec_type>) Input: preconditioner
! b - real,dimension(:) Input: vector containing the
! right hand side B
! x - real,dimension(:) Input/Output: vector containing the
! initial guess and final solution X.
! eps - real Input: Stopping tolerance; the iteration is
! stopped when the error estimate
! |err| <= eps
! desc_a - type(<psb_desc_type>). Input: The communication descriptor.
! info - integer. Output: Return code
!
! itmax - integer(optional) Input: maximum number of iterations to be
! performed.
! iter - integer(optional) Output: how many iterations have been
! performed.
! err - real (optional) Output: error estimate on exit
! itrace - integer(optional) Input: print an informational message
! with the error estimate every itrace
! iterations
! istop - integer(optional) Input: stopping criterion, or how
! to estimate the error.
! 1: err = |r|/|b|
! 2: err = |r|/(|a||x|+|b|)
! where r is the (preconditioned, recursive
! estimate of) residual
!
!
!
Subroutine psb_dcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop)
use psb_base_mod
use psb_prec_mod
Implicit None

@ -63,23 +63,43 @@
! File: psb_dcgstabl.f90
!
! Subroutine: psb_dcgstabl
! Implements the BICGSTAB(L) method
!
!
! Arguments:
! a - type(<psb_dspmat_type>). The sparse matrix containing A.
! prec - type(<psb_prec_type>). The data structure containing the preconditioner.
! b - real,dimension(:). The right hand side.
! x - real,dimension(:). The vector of unknowns.
! eps - real. The error tolerance.
! desc_a - type(<psb_desc_type>). The communication descriptor.
! info - integer. Return code
! itmax - integer(optional). The maximum number of iterations.
! iter - integer(optional). The number of iterations performed.
! err - real(optional). The error on return.
! itrace - integer(optional). The unit to write messages onto.
! istop - integer(optional). The stopping criterium.
!
Subroutine psb_dcgstabl(a,prec,b,x,eps,desc_a,info,&
&itmax,iter,err,itrace,irst,istop)
! a - type(<psb_dspmat_type>) Input: sparse matrix containing A.
! prec - type(<psb_dprec_type>) Input: preconditioner
! b - real,dimension(:) Input: vector containing the
! right hand side B
! x - real,dimension(:) Input/Output: vector containing the
! initial guess and final solution X.
! eps - real Input: Stopping tolerance; the iteration is
! stopped when the error estimate
! |err| <= eps
! desc_a - type(<psb_desc_type>). Input: The communication descriptor.
! info - integer. Output: Return code
!
! itmax - integer(optional) Input: maximum number of iterations to be
! performed.
! iter - integer(optional) Output: how many iterations have been
! performed.
! err - real (optional) Output: error estimate on exit
! itrace - integer(optional) Input: print an informational message
! with the error estimate every itrace
! iterations
! irst - integer(optional) Input: restart parameter L
!
! istop - integer(optional) Input: stopping criterion, or how
! to estimate the error.
! 1: err = |r|/|b|
! 2: err = |r|/(|a||x|+|b|)
! where r is the (preconditioned, recursive
! estimate of) residual
!
!
!
Subroutine psb_dcgstabl(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,istop)
use psb_base_mod
use psb_prec_mod
implicit none

@ -70,23 +70,39 @@
! This subroutine implements the restarted GMRES method with right
! preconditioning.
!
!
! Arguments:
! a - type(<psb_dspmat_type>). The sparse matrix containing A.
! prec - type(<psb_prec_type>). The data structure containing the preconditioner.
! b - real,dimension(:). The right hand side.
! x - real,dimension(:). The vector of unknowns.
! eps - real. The error tolerance.
! desc_a - type(<psb_desc_type>). The communication descriptor.
! info - integer. Return code
! itmax - integer(optional). The maximum number of iterations.
! iter - integer(optional). The number of iterations performed.
! err - real(optional). The error on return.
! itrace - integer(optional). The unit to write messages onto.
! irst - integer(optional). The restart value.
! istop - integer(optional). The stopping criterium.
!
Subroutine psb_dgmresr(a,prec,b,x,eps,desc_a,info,&
&itmax,iter,err,itrace,irst,istop)
! a - type(<psb_dspmat_type>) Input: sparse matrix containing A.
! prec - type(<psb_dprec_type>) Input: preconditioner
! b - real,dimension(:) Input: vector containing the
! right hand side B
! x - real,dimension(:) Input/Output: vector containing the
! initial guess and final solution X.
! eps - real Input: Stopping tolerance; the iteration is
! stopped when the error estimate
! |err| <= eps
! desc_a - type(<psb_desc_type>). Input: The communication descriptor.
! info - integer. Output: Return code
!
! itmax - integer(optional) Input: maximum number of iterations to be
! performed.
! iter - integer(optional) Output: how many iterations have been
! performed.
! err - real (optional) Output: error estimate on exit
! itrace - integer(optional) Input: print an informational message
! with the error estimate every itrace
! iterations
! irst - integer(optional) Input: restart parameter
!
! istop - integer(optional) Input: stopping criterion, or how
! to estimate the error.
! 1: err = |r|/|b|
! 2: err = |r|/(|a||x|+|b|)
! where r is the (preconditioned, recursive
! estimate of) residual
!
Subroutine psb_dgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,istop)
use psb_base_mod
use psb_prec_mod
implicit none

@ -36,72 +36,72 @@ Module psb_krylov_mod
end interface
interface psb_cg
subroutine psb_dcg(a,prec,b,x,eps,&
& desc_a,info,itmax,iter,err,itrace,istop)
use psb_base_mod
use psb_prec_mod
type(psb_dspmat_type), intent(in) :: a
type(psb_desc_type), intent(in) :: desc_a
real(kind(1.d0)), intent(in) :: b(:)
real(kind(1.d0)), intent(inout) :: x(:)
real(kind(1.d0)), intent(in) :: eps
type(psb_dprec_type), intent(in) :: prec
integer, intent(out) :: info
integer, optional, intent(in) :: itmax, itrace,istop
integer, optional, intent(out) :: iter
real(kind(1.d0)), optional, intent(out) :: err
end subroutine psb_dcg
subroutine psb_dcg(a,prec,b,x,eps,&
& desc_a,info,itmax,iter,err,itrace,istop)
use psb_base_mod
use psb_prec_mod
type(psb_dspmat_type), intent(in) :: a
type(psb_desc_type), intent(in) :: desc_a
real(kind(1.d0)), intent(in) :: b(:)
real(kind(1.d0)), intent(inout) :: x(:)
real(kind(1.d0)), intent(in) :: eps
type(psb_dprec_type), intent(in) :: prec
integer, intent(out) :: info
integer, optional, intent(in) :: itmax, itrace,istop
integer, optional, intent(out) :: iter
real(kind(1.d0)), optional, intent(out) :: err
end subroutine psb_dcg
end interface
interface psb_bicg
subroutine psb_dbicg(a,prec,b,x,eps,&
& desc_a,info,itmax,iter,err,itrace,istop)
use psb_base_mod
use psb_prec_mod
type(psb_dspmat_type), intent(in) :: a
type(psb_desc_type), intent(in) :: desc_a
real(kind(1.d0)), intent(in) :: b(:)
real(kind(1.d0)), intent(inout) :: x(:)
real(kind(1.d0)), intent(in) :: eps
type(psb_dprec_type), intent(in) :: prec
integer, intent(out) :: info
integer, optional, intent(in) :: itmax, itrace,istop
integer, optional, intent(out) :: iter
real(kind(1.d0)), optional, intent(out) :: err
end subroutine psb_dbicg
subroutine psb_dbicg(a,prec,b,x,eps,&
& desc_a,info,itmax,iter,err,itrace,istop)
use psb_base_mod
use psb_prec_mod
type(psb_dspmat_type), intent(in) :: a
type(psb_desc_type), intent(in) :: desc_a
real(kind(1.d0)), intent(in) :: b(:)
real(kind(1.d0)), intent(inout) :: x(:)
real(kind(1.d0)), intent(in) :: eps
type(psb_dprec_type), intent(in) :: prec
integer, intent(out) :: info
integer, optional, intent(in) :: itmax, itrace,istop
integer, optional, intent(out) :: iter
real(kind(1.d0)), optional, intent(out) :: err
end subroutine psb_dbicg
end interface
interface psb_bicgstab
subroutine psb_dcgstab(a,prec,b,x,eps,&
& desc_a,info,itmax,iter,err,itrace,istop)
use psb_base_mod
use psb_prec_mod
type(psb_dspmat_type), intent(in) :: a
type(psb_desc_type), intent(in) :: desc_a
real(kind(1.d0)), intent(in) :: b(:)
real(kind(1.d0)), intent(inout) :: x(:)
real(kind(1.d0)), intent(in) :: eps
type(psb_dprec_type), intent(in) :: prec
integer, intent(out) :: info
integer, optional, intent(in) :: itmax, itrace,istop
integer, optional, intent(out) :: iter
real(kind(1.d0)), optional, intent(out) :: err
end subroutine psb_dcgstab
subroutine psb_zcgstab(a,prec,b,x,eps,&
& desc_a,info,itmax,iter,err,itrace,istop)
use psb_base_mod
use psb_prec_mod
type(psb_zspmat_type), intent(in) :: a
type(psb_desc_type), intent(in) :: desc_a
complex(kind(1.d0)), intent(in) :: b(:)
complex(kind(1.d0)), intent(inout) :: x(:)
real(kind(1.d0)), intent(in) :: eps
type(psb_zprec_type), intent(in) :: prec
integer, intent(out) :: info
integer, optional, intent(in) :: itmax, itrace,istop
integer, optional, intent(out) :: iter
real(kind(1.d0)), optional, intent(out) :: err
end subroutine psb_zcgstab
subroutine psb_dcgstab(a,prec,b,x,eps,&
& desc_a,info,itmax,iter,err,itrace,istop)
use psb_base_mod
use psb_prec_mod
type(psb_dspmat_type), intent(in) :: a
type(psb_desc_type), intent(in) :: desc_a
real(kind(1.d0)), intent(in) :: b(:)
real(kind(1.d0)), intent(inout) :: x(:)
real(kind(1.d0)), intent(in) :: eps
type(psb_dprec_type), intent(in) :: prec
integer, intent(out) :: info
integer, optional, intent(in) :: itmax, itrace,istop
integer, optional, intent(out) :: iter
real(kind(1.d0)), optional, intent(out) :: err
end subroutine psb_dcgstab
subroutine psb_zcgstab(a,prec,b,x,eps,&
& desc_a,info,itmax,iter,err,itrace,istop)
use psb_base_mod
use psb_prec_mod
type(psb_zspmat_type), intent(in) :: a
type(psb_desc_type), intent(in) :: desc_a
complex(kind(1.d0)), intent(in) :: b(:)
complex(kind(1.d0)), intent(inout) :: x(:)
real(kind(1.d0)), intent(in) :: eps
type(psb_zprec_type), intent(in) :: prec
integer, intent(out) :: info
integer, optional, intent(in) :: itmax, itrace,istop
integer, optional, intent(out) :: iter
real(kind(1.d0)), optional, intent(out) :: err
end subroutine psb_zcgstab
end interface
interface psb_bicgstabl
@ -171,25 +171,70 @@ Module psb_krylov_mod
integer, optional, intent(out) :: iter
real(kind(1.d0)), optional, intent(out) :: err
end subroutine psb_dcgs
subroutine psb_zcgs(a,prec,b,x,eps,&
& desc_a,info,itmax,iter,err,itrace,istop)
use psb_base_mod
use psb_prec_mod
type(psb_zspmat_type), intent(in) :: a
type(psb_desc_type), intent(in) :: desc_a
complex(kind(1.d0)), intent(in) :: b(:)
complex(kind(1.d0)), intent(inout) :: x(:)
real(kind(1.d0)), intent(in) :: eps
type(psb_zprec_type), intent(in) :: prec
integer, intent(out) :: info
integer, optional, intent(in) :: itmax, itrace,istop
integer, optional, intent(out) :: iter
real(kind(1.d0)), optional, intent(out) :: err
end subroutine psb_zcgs
subroutine psb_zcgs(a,prec,b,x,eps,&
& desc_a,info,itmax,iter,err,itrace,istop)
use psb_base_mod
use psb_prec_mod
type(psb_zspmat_type), intent(in) :: a
type(psb_desc_type), intent(in) :: desc_a
complex(kind(1.d0)), intent(in) :: b(:)
complex(kind(1.d0)), intent(inout) :: x(:)
real(kind(1.d0)), intent(in) :: eps
type(psb_zprec_type), intent(in) :: prec
integer, intent(out) :: info
integer, optional, intent(in) :: itmax, itrace,istop
integer, optional, intent(out) :: iter
real(kind(1.d0)), optional, intent(out) :: err
end subroutine psb_zcgs
end interface
contains
contains
!
! File: psb_krylov_mod.f90
!
! Subroutine: psb_dkrylov
!
! Front-end for the Krylov subspace iterations, real version
!
! Arguments:
!
! methd - character The specific method; can take the values:
! CG
! CGS
! BICG
! BICGSTAB
! BICGSTABL
! RGMRES
!
! a - type(<psb_dspmat_type>) Input: sparse matrix containing A.
! prec - type(<psb_dprec_type>) Input: preconditioner
! b - real,dimension(:) Input: vector containing the
! right hand side B
! x - real,dimension(:) Input/Output: vector containing the
! initial guess and final solution X.
! eps - real Input: Stopping tolerance; the iteration is
! stopped when the error estimate
! |err| <= eps
! desc_a - type(<psb_desc_type>). Input: The communication descriptor.
! info - integer. Output: Return code
!
! itmax - integer(optional) Input: maximum number of iterations to be
! performed.
! iter - integer(optional) Output: how many iterations have been
! performed.
! err - real (optional) Output: error estimate on exit
! itrace - integer(optional) Input: print an informational message
! with the error estimate every itrace
! iterations
! irst - integer(optional) Input: restart parameter for RGMRES and
! BICGSTAB(L) methods
! istop - integer(optional) Input: stopping criterion, or how
! to estimate the error.
! 1: err = |r|/|b|
! 2: err = |r|/(|a||x|+|b|)
! where r is the (preconditioned, recursive
! estimate of) residual
!
Subroutine psb_dkrylov(method,a,prec,b,x,eps,desc_a,info,&
&itmax,iter,err,itrace,irst,istop)
@ -218,53 +263,96 @@ contains
ictxt=psb_cd_get_context(desc_a)
call psb_info(ictxt, me, np)
select case(toupper(method))
case('CG')
call psb_cg(a,prec,b,x,eps,desc_a,info,&
&itmax,iter,err,itrace,istop)
&itmax,iter,err,itrace,istop)
case('CGS')
call psb_cgs(a,prec,b,x,eps,desc_a,info,&
&itmax,iter,err,itrace,istop)
&itmax,iter,err,itrace,istop)
case('BICG')
call psb_bicg(a,prec,b,x,eps,desc_a,info,&
&itmax,iter,err,itrace,istop)
&itmax,iter,err,itrace,istop)
case('BICGSTAB')
call psb_bicgstab(a,prec,b,x,eps,desc_a,info,&
&itmax,iter,err,itrace,istop)
&itmax,iter,err,itrace,istop)
case('RGMRES')
call psb_rgmres(a,prec,b,x,eps,desc_a,info,&
&itmax,iter,err,itrace,irst,istop)
&itmax,iter,err,itrace,irst,istop)
case('BICGSTABL')
call psb_bicgstabl(a,prec,b,x,eps,desc_a,info,&
&itmax,iter,err,itrace,irst,istop)
&itmax,iter,err,itrace,irst,istop)
case default
if (me==0) write(0,*) 'Warning: Unknown method ',method,&
& ' in PSB_KRYLOV, defaulting to BiCGSTAB'
call psb_bicgstab(a,prec,b,x,eps,desc_a,info,&
&itmax,iter,err,itrace,istop)
&itmax,iter,err,itrace,istop)
end select
if(info/=0) then
call psb_errpush(info,name)
goto 9999
end if
call psb_erractionrestore(err_act)
return
9999 continue
call psb_erractionrestore(err_act)
if (err_act.eq.psb_act_abort_) then
call psb_error(ictxt)
return
end if
end subroutine psb_dkrylov
!
! File: psb_krylov_mod.f90
!
! Subroutine: psb_zkrylov
!
! Front-end for the Krylov subspace iterations, complexversion
!
! Arguments:
!
! methd - character The specific method; can take the values:
! CGS
! BICGSTAB
! RGMRES
!
! a - type(<psb_zspmat_type>) Input: sparse matrix containing A.
! prec - type(<psb_zprec_type>) Input: preconditioner
! b - complex,dimension(:) Input: vector containing the
! right hand side B
! x - complex,dimension(:) Input/Output: vector containing the
! initial guess and final solution X.
! eps - real Input: Stopping tolerance; the iteration is
! stopped when the error estimate
! |err| <= eps
! desc_a - type(<psb_desc_type>). Input: The communication descriptor.
! info - integer. Output: Return code
!
! itmax - integer(optional) Input: maximum number of iterations to be
! performed.
! iter - integer(optional) Output: how many iterations have been
! performed.
! err - real (optional) Output: error estimate on exit
! itrace - integer(optional) Input: print an informational message
! with the error estimate every itrace
! iterations
! irst - integer(optional) Input: restart parameter for RGMRES and
! BICGSTAB(L) methods
! istop - integer(optional) Input: stopping criterion, or how
! to estimate the error.
! 1: err = |r|/|b|
! 2: err = |r|/(|a||x|+|b|)
! where r is the (preconditioned, recursive
! estimate of) residual
!
Subroutine psb_zkrylov(method,a,prec,b,x,eps,desc_a,info,&
&itmax,iter,err,itrace,irst,istop)
use psb_base_mod
@ -290,9 +378,9 @@ contains
ictxt=psb_cd_get_context(desc_a)
call psb_info(ictxt, me, np)
select case(toupper(method))
!!$ case('CG')
@ -300,7 +388,7 @@ contains
!!$ &itmax,iter,err,itrace,istop)
case('CGS')
call psb_cgs(a,prec,b,x,eps,desc_a,info,&
&itmax,iter,err,itrace,istop)
&itmax,iter,err,itrace,istop)
!!$ case('BICG')
!!$ call psb_bicg(a,prec,b,x,eps,desc_a,info,&
!!$ &itmax,iter,err,itrace,istop)
@ -317,24 +405,24 @@ contains
if (me==0) write(0,*) 'Warning: Unknown method ',method,&
& ' in PSB_KRYLOV, defaulting to BiCGSTAB'
call psb_bicgstab(a,prec,b,x,eps,desc_a,info,&
&itmax,iter,err,itrace,istop)
&itmax,iter,err,itrace,istop)
end select
if(info/=0) then
call psb_errpush(info,name)
goto 9999
end if
call psb_erractionrestore(err_act)
return
9999 continue
call psb_erractionrestore(err_act)
if (err_act.eq.psb_act_abort_) then
call psb_error(ictxt)
return
end if
end subroutine psb_zkrylov

@ -56,23 +56,43 @@
! File: psb_zcgs.f90
!
! Subroutine: psb_zcgs
!
! Implements the Conjugate Gradient Squared method.
!
! Arguments:
! a - type(<psb_zspmat_type>). The sparse matrix containing A.
! prec - type(<psb_prec_type>). The data structure containing the preconditioner.
! b - real,dimension(:). The right hand side.
! x - real,dimension(:). The vector of unknowns.
! eps - real. The error tolerance.
! desc_a - type(<psb_desc_type>). The communication descriptor.
! info - integer. Return code
! itmax - integer(optional). The maximum number of iterations.
! iter - integer(optional). The number of iterations performed.
! err - real(optional). The error on return.
! itrace - integer(optional). The unit to write messages onto.
! istop - integer(optional). The stopping criterium.
!
Subroutine psb_zcgs(a,prec,b,x,eps,desc_a,info,&
&itmax,iter,err,itrace,istop)
! methd - character The specific method; can take the values:
! CGS
! BICGSTAB
! RGMRES
!
! a - type(<psb_zspmat_type>) Input: sparse matrix containing A.
! prec - type(<psb_zprec_type>) Input: preconditioner
! b - complex,dimension(:) Input: vector containing the
! right hand side B
! x - complex,dimension(:) Input/Output: vector containing the
! initial guess and final solution X.
! eps - real Input: Stopping tolerance; the iteration is
! stopped when the error estimate
! |err| <= eps
! desc_a - type(<psb_desc_type>). Input: The communication descriptor.
! info - integer. Output: Return code
!
! itmax - integer(optional) Input: maximum number of iterations to be
! performed.
! iter - integer(optional) Output: how many iterations have been
! performed.
! err - real (optional) Output: error estimate on exit
! itrace - integer(optional) Input: print an informational message
! with the error estimate every itrace
! iterations
! istop - integer(optional) Input: stopping criterion, or how
! to estimate the error.
! 1: err = |r|/|b|
! 2: err = |r|/(|a||x|+|b|)
! where r is the (preconditioned, recursive
! estimate of) residual
!
Subroutine psb_zcgs(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop)
use psb_base_mod
use psb_prec_mod
implicit none
@ -123,17 +143,17 @@ Subroutine psb_zcgs(a,prec,b,x,eps,desc_a,info,&
Else
istop_ = 1
Endif
!
! istop_ = 1: normwise backward error, infinity norm
! istop_ = 2: ||r||/||b|| norm 2
!
!
! istop_ = 1: normwise backward error, infinity norm
! istop_ = 2: ||r||/||b|| norm 2
!
!!$
!!$ If ((prec%prec < 0).Or.(prec%prec > 6) ) Then
!!$ Write(0,*) 'f90_cgstab: invalid iprec',prec%prec
!!$ If (Present(ierr)) ierr=-1
!!$ Return
!!$ Endif
if ((istop_ < 1 ).or.(istop_ > 2 ) ) then
write(0,*) 'psb_cgs: invalid istop',istop_
info=5001
@ -161,9 +181,9 @@ Subroutine psb_zcgs(a,prec,b,x,eps,desc_a,info,&
if (info == 0) Call psb_geall(wwrk,desc_a,info,n=11)
if (info == 0) Call psb_geasb(wwrk,desc_a,info)
if (info.ne.0) Then
info=4011
call psb_errpush(info,name)
goto 9999
info=4011
call psb_errpush(info,name)
goto 9999
End If
q => wwrk(:,1)
@ -186,14 +206,14 @@ Subroutine psb_zcgs(a,prec,b,x,eps,desc_a,info,&
Endif
If (Present(itrace)) Then
itrace_ = itrace
itrace_ = itrace
Else
itrace_ = 0
itrace_ = 0
End If
! Ensure global coherence for convergence checks.
call psb_set_coher(ictxt,isvch)
itx = 0
if (istop_ == 1) then
@ -203,9 +223,9 @@ Subroutine psb_zcgs(a,prec,b,x,eps,desc_a,info,&
bn2 = psb_genrm2(b,desc_a,info)
endif
if(info/=0)then
info=4011
call psb_errpush(info,name)
goto 9999
info=4011
call psb_errpush(info,name)
goto 9999
end if
restart: Do
@ -218,11 +238,11 @@ Subroutine psb_zcgs(a,prec,b,x,eps,desc_a,info,&
Call psb_spmm(-zone,a,x,zone,r,desc_a,info,work=aux)
Call psb_geaxpby(zone,r,zzero,rt,desc_a,info)
if(info/=0)then
info=4011
call psb_errpush(info,name)
goto 9999
info=4011
call psb_errpush(info,name)
goto 9999
end if
rho = zzero
If (debug) Write(*,*) 'on entry to amax: b: ',Size(b)
@ -235,11 +255,11 @@ Subroutine psb_zcgs(a,prec,b,x,eps,desc_a,info,&
rerr = rni/bn2
endif
if(info/=0)then
info=4011
call psb_errpush(info,name)
goto 9999
info=4011
call psb_errpush(info,name)
goto 9999
end if
If (rerr<=eps) Then
Exit restart
End If
@ -255,7 +275,7 @@ Subroutine psb_zcgs(a,prec,b,x,eps,desc_a,info,&
rho_old = rho
rho = psb_gedot(rt,r,desc_a,info)
If (rho==zzero) Then
If (debug) Write(0,*) 'cgs iteration breakdown r',rho
If (debug) Write(0,*) 'cgs iteration breakdown r',rho
Exit iteration
Endif
@ -278,27 +298,27 @@ Subroutine psb_zcgs(a,prec,b,x,eps,desc_a,info,&
sigma = psb_gedot(rt,v,desc_a,info)
If (sigma==zzero) Then
If (debug) Write(0,*) 'cgs iteration breakdown s1', sigma
Exit iteration
If (debug) Write(0,*) 'cgs iteration breakdown s1', sigma
Exit iteration
Endif
alpha = rho/sigma
Call psb_geaxpby(zone,uv,zzero,q,desc_a,info)
Call psb_geaxpby(-alpha,v,zone,q,desc_a,info)
Call psb_geaxpby(zone,uv,zzero,s,desc_a,info)
Call psb_geaxpby(zone,q,zone,s,desc_a,info)
Call psb_precaply(prec,s,z,desc_a,info,work=aux)
Call psb_geaxpby(alpha,z,zone,x,desc_a,info)
Call psb_spmm(zone,a,z,zzero,qt,desc_a,info,&
& work=aux)
Call psb_geaxpby(-alpha,qt,zone,r,desc_a,info)
if (istop_ == 1) then
rni = psb_geamax(r,desc_a,info)
xni = psb_geamax(x,desc_a,info)
@ -317,7 +337,7 @@ Subroutine psb_zcgs(a,prec,b,x,eps,desc_a,info,&
if ((mod(itx,itrace_)==0).and.(me == 0))&
& write(*,'(a,i4,3(2x,es10.4))') 'cgs: ',itx,rerr
end If
End Do iteration
End Do restart
If (itrace_ > 0) then
@ -338,8 +358,8 @@ Subroutine psb_zcgs(a,prec,b,x,eps,desc_a,info,&
call psb_restore_coher(ictxt,isvch)
if(info/=0) then
call psb_errpush(info,name)
goto 9999
call psb_errpush(info,name)
goto 9999
end if
call psb_erractionrestore(err_act)
@ -348,8 +368,8 @@ Subroutine psb_zcgs(a,prec,b,x,eps,desc_a,info,&
9999 continue
call psb_erractionrestore(err_act)
if (err_act.eq.psb_act_abort_) then
call psb_error()
return
call psb_error()
return
end if
return

@ -56,25 +56,44 @@
! File: psb_zcgstab.f90
!
! Subroutine: psb_zcgstab
! This subroutine implements the CG Stabilized method.
! This subroutine implements the BiCG Stabilized method.
!
!
! Arguments:
! a - type(<psb_zspmat_type>). The sparse matrix containing A.
! prec - type(<psb_prec_type>). The data structure containing the
! preconditioner.
! b - real,dimension(:). The right hand side.
! x - real,dimension(:). The vector of unknowns.
! eps - real. The error tolerance.
! desc_a - type(<psb_desc_type>). The communication descriptor.
! info - integer. Return code
! itmax - integer(optional). The maximum number of iterations.
! iter - integer(optional). The number of iterations performed.
! err - real(optional). The error on return.
! itrace - integer(optional). The unit to write messages onto.
! istop - integer(optional). The stopping criterium.
!
Subroutine psb_zcgstab(a,prec,b,x,eps,desc_a,info,&
&itmax,iter,err,itrace, istop)
! methd - character The specific method; can take the values:
! CGS
! BICGSTAB
! RGMRES
!
! a - type(<psb_zspmat_type>) Input: sparse matrix containing A.
! prec - type(<psb_zprec_type>) Input: preconditioner
! b - complex,dimension(:) Input: vector containing the
! right hand side B
! x - complex,dimension(:) Input/Output: vector containing the
! initial guess and final solution X.
! eps - real Input: Stopping tolerance; the iteration is
! stopped when the error estimate
! |err| <= eps
! desc_a - type(<psb_desc_type>). Input: The communication descriptor.
! info - integer. Output: Return code
!
! itmax - integer(optional) Input: maximum number of iterations to be
! performed.
! iter - integer(optional) Output: how many iterations have been
! performed.
! err - real (optional) Output: error estimate on exit
! itrace - integer(optional) Input: print an informational message
! with the error estimate every itrace
! iterations
! istop - integer(optional) Input: stopping criterion, or how
! to estimate the error.
! 1: err = |r|/|b|
! 2: err = |r|/(|a||x|+|b|)
! where r is the (preconditioned, recursive
! estimate of) residual
!
Subroutine psb_zcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop)
use psb_base_mod
use psb_prec_mod
Implicit None

@ -71,22 +71,42 @@
! preconditioning.
!
! Arguments:
! a - type(<psb_dspmat_type>). The sparse matrix containing A.
! prec - type(<psb_prec_type>). The data structure containing the preconditioner.
! b - real,dimension(:). The right hand side.
! x - real,dimension(:). The vector of unknowns.
! eps - real. The error tolerance.
! desc_a - type(<psb_desc_type>). The communication descriptor.
! info - integer. Return code
! itmax - integer(optional). The maximum number of iterations.
! iter - integer(optional). The number of iterations performed.
! err - real(optional). The error on return.
! itrace - integer(optional). The unit to write messages onto.
! irst - integer(optional). The restart value.
! istop - integer(optional). The stopping criterium.
!
Subroutine psb_zgmresr(a,prec,b,x,eps,desc_a,info,&
& itmax,iter,err,itrace,irst,istop)
! methd - character The specific method; can take the values:
! CGS
! BICGSTAB
! RGMRES
!
! a - type(<psb_zspmat_type>) Input: sparse matrix containing A.
! prec - type(<psb_zprec_type>) Input: preconditioner
! b - complex,dimension(:) Input: vector containing the
! right hand side B
! x - complex,dimension(:) Input/Output: vector containing the
! initial guess and final solution X.
! eps - real Input: Stopping tolerance; the iteration is
! stopped when the error estimate
! |err| <= eps
! desc_a - type(<psb_desc_type>). Input: The communication descriptor.
! info - integer. Output: Return code
!
! itmax - integer(optional) Input: maximum number of iterations to be
! performed.
! iter - integer(optional) Output: how many iterations have been
! performed.
! err - real (optional) Output: error estimate on exit
! itrace - integer(optional) Input: print an informational message
! with the error estimate every itrace
! iterations
! irst - integer(optional) Input: restart parameter
!
! istop - integer(optional) Input: stopping criterion, or how
! to estimate the error.
! 1: err = |r|/|b|
! 2: err = |r|/(|a||x|+|b|)
! where r is the (preconditioned, recursive
! estimate of) residual
!
Subroutine psb_zgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,istop)
use psb_base_mod
use psb_prec_mod
implicit none

Loading…
Cancel
Save