From 4facb7505ff24c6a4d5cee73eedbb6b4d5b163c6 Mon Sep 17 00:00:00 2001 From: Salvatore Filippone Date: Fri, 18 Jan 2008 14:37:49 +0000 Subject: [PATCH] Krylov methods. Fixed header for convergence tracing messages. --- krylov/psb_dbicg.f90 | 2 +- krylov/psb_dcg.f90 | 2 +- krylov/psb_dcgs.f90 | 2 +- krylov/psb_dcgstab.F90 | 2 +- krylov/psb_krylov_mod.f90 | 55 +++++++++++++++++++++++++++++++-------- krylov/psb_zcgs.f90 | 2 +- krylov/psb_zcgstab.f90 | 2 +- 7 files changed, 50 insertions(+), 17 deletions(-) diff --git a/krylov/psb_dbicg.f90 b/krylov/psb_dbicg.f90 index b9bde507..0e5bcbaf 100644 --- a/krylov/psb_dbicg.f90 +++ b/krylov/psb_dbicg.f90 @@ -215,7 +215,7 @@ subroutine psb_dbicg(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) itx = 0 - call psb_init_conv(istop_,itrace_,a,b,eps,desc_a,stopdat,info) + call psb_init_conv(methdname,istop_,itrace_,a,b,eps,desc_a,stopdat,info) if (info /= 0) Then call psb_errpush(4011,name) goto 9999 diff --git a/krylov/psb_dcg.f90 b/krylov/psb_dcg.f90 index 84bd1bb7..7be51987 100644 --- a/krylov/psb_dcg.f90 +++ b/krylov/psb_dcg.f90 @@ -202,7 +202,7 @@ subroutine psb_dcg(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) rho = dzero - call psb_init_conv(istop_,itrace_,a,b,eps,desc_a,stopdat,info) + call psb_init_conv(methdname,istop_,itrace_,a,b,eps,desc_a,stopdat,info) if (info /= 0) Then call psb_errpush(4011,name) goto 9999 diff --git a/krylov/psb_dcgs.f90 b/krylov/psb_dcgs.f90 index 7a27be28..52afedbd 100644 --- a/krylov/psb_dcgs.f90 +++ b/krylov/psb_dcgs.f90 @@ -193,7 +193,7 @@ Subroutine psb_dcgs(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) itx = 0 - call psb_init_conv(istop_,itrace_,a,b,eps,desc_a,stopdat,info) + call psb_init_conv(methdname,istop_,itrace_,a,b,eps,desc_a,stopdat,info) if (info /= 0) Then call psb_errpush(4011,name) goto 9999 diff --git a/krylov/psb_dcgstab.F90 b/krylov/psb_dcgstab.F90 index 2b6a326a..94854215 100644 --- a/krylov/psb_dcgstab.F90 +++ b/krylov/psb_dcgstab.F90 @@ -223,7 +223,7 @@ Subroutine psb_dcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) call psb_set_coher(ictxt,isvch) itx = 0 - call psb_init_conv(istop_,itrace_,a,b,eps,desc_a,stopdat,info) + call psb_init_conv(methdname,istop_,itrace_,a,b,eps,desc_a,stopdat,info) if (info /= 0) Then call psb_errpush(4011,name) goto 9999 diff --git a/krylov/psb_krylov_mod.f90 b/krylov/psb_krylov_mod.f90 index 1a884972..275ebfa3 100644 --- a/krylov/psb_krylov_mod.f90 +++ b/krylov/psb_krylov_mod.f90 @@ -488,9 +488,10 @@ contains - subroutine psb_d_init_conv(stopc,trace,a,b,eps,desc_a,stopdat,info) + subroutine psb_d_init_conv(methdname,stopc,trace,a,b,eps,desc_a,stopdat,info) use psb_base_mod implicit none + character(len=*), intent(in) :: methdname integer, intent(in) :: stopc, trace type(psb_dspmat_type), intent(in) :: a real(kind(1.d0)), intent(in) :: b(:), eps @@ -499,6 +500,10 @@ contains integer, intent(out) :: info integer :: ictxt, me, np, err_act + character(len=*), parameter :: fmt='(a18,1x,A4,3(2x,A10))' + integer, parameter :: outlen=18 + character(len=len(methdname)) :: mname + character(len=outlen) :: outname character(len=20) :: name info = 0 @@ -537,8 +542,14 @@ contains stopdat%values(eps_) = eps stopdat%values(errnum_) = dzero stopdat%values(errden_) = done - + if (stopdat%controls(trace_) > 0) then + if (me == 0) then + mname = adjustl(trim(methdname)) + write(outname,'(a)') mname(1:min(len_trim(mname),outlen-1))//':' + write(*,fmt) adjustl(outname),'Iter','Conv. Ind.','Epsilon' + endif + end if call psb_erractionrestore(err_act) return @@ -551,9 +562,10 @@ contains end subroutine psb_d_init_conv - subroutine psb_z_init_conv(stopc,trace,a,b,eps,desc_a,stopdat,info) + subroutine psb_z_init_conv(methdname,stopc,trace,a,b,eps,desc_a,stopdat,info) use psb_base_mod implicit none + character(len=*), intent(in) :: methdname integer, intent(in) :: stopc, trace type(psb_zspmat_type), intent(in) :: a complex(kind(1.d0)), intent(in) :: b(:) @@ -563,6 +575,10 @@ contains integer, intent(out) :: info integer :: ictxt, me, np, err_act + character(len=*), parameter :: fmt='(a18,1x,A4,3(2x,A10))' + integer, parameter :: outlen=18 + character(len=len(methdname)) :: mname + character(len=outlen) :: outname character(len=20) :: name info = 0 @@ -603,6 +619,13 @@ contains stopdat%values(errden_) = done + if (stopdat%controls(trace_) > 0) then + if (me == 0) then + mname = adjustl(trim(methdname)) + write(outname,'(a)') mname(1:min(len_trim(mname),outlen-1))//':' + write(*,fmt) adjustl(outname),'Iter','Conv. Ind.','Epsilon' + endif + end if call psb_erractionrestore(err_act) return @@ -629,7 +652,10 @@ contains integer :: ictxt, me, np, err_act real(kind(1.d0)) :: errnum, errden - character(len=*), parameter :: fmt='(a,i4,3(2x,es10.4))' + character(len=*), parameter :: fmt='(a18,1x,i4,3(2x,es10.4))' + integer, parameter :: outlen=18 + character(len=len(methdname)) :: mname + character(len=outlen) :: outname character(len=20) :: name info = 0 @@ -673,11 +699,13 @@ contains if (((stopdat%controls(trace_) > 0).and.(mod(it,stopdat%controls(trace_))==0))& & .or.psb_d_check_conv) then if (me == 0) then + mname = adjustl(trim(methdname)) + write(outname,'(a)') mname(1:min(len_trim(mname),outlen-1))//':' if (stopdat%values(errden_) > dzero ) then - write(*,fmt) trim(methdname)//': ',it,& + write(*,fmt) adjustl(outname),it,& & stopdat%values(errnum_)/stopdat%values(errden_),stopdat%values(eps_) else - write(*,fmt) trim(methdname)//': ',it,& + write(*,fmt) adjustl(outname),it,& & stopdat%values(errnum_),stopdat%values(eps_) end if Endif @@ -710,7 +738,10 @@ contains integer :: ictxt, me, np, err_act real(kind(1.d0)) :: errnum, errden - character(len=*), parameter :: fmt='(a,i4,3(2x,es10.4))' + character(len=*), parameter :: fmt='(a18,1x,i4,3(2x,es10.4))' + integer, parameter :: outlen=18 + character(len=len(methdname)) :: mname + character(len=outlen) :: outname character(len=20) :: name info = 0 @@ -754,11 +785,13 @@ contains if (((stopdat%controls(trace_) > 0).and.(mod(it,stopdat%controls(trace_))==0))& & .or.psb_z_check_conv) then if (me == 0) then + mname = adjustl(trim(methdname)) + write(outname,'(a)') mname(1:min(len_trim(mname),outlen-1))//':' if (stopdat%values(errden_) > dzero ) then - write(*,fmt) trim(methdname)//': ',it,& + write(*,fmt) adjustl(outname),it,& & stopdat%values(errnum_)/stopdat%values(errden_),stopdat%values(eps_) else - write(*,fmt) trim(methdname)//': ',it,& + write(*,fmt) adjustl(outname),it,& & stopdat%values(errnum_),stopdat%values(eps_) end if Endif @@ -812,7 +845,7 @@ contains if (errnum > eps) then if (me==0) then - write(*,fmt) methdname//' failed to converge to ',eps,& + write(*,fmt) trim(methdname)//' failed to converge to ',eps,& & ' in ',it,' iterations. ' write(*,fmt1) 'Last iteration convergence indicator: ',& & errnum @@ -823,7 +856,7 @@ contains if (errnum > eps) then if (me==0) then - write(*,fmt) methdname//' failed to converge to ',eps,& + write(*,fmt) trim(methdname)//' failed to converge to ',eps,& & ' in ',it,' iterations. ' write(*,fmt1) 'Last iteration convergence indicator: ',& & errnum/errden diff --git a/krylov/psb_zcgs.f90 b/krylov/psb_zcgs.f90 index ef0b5f44..e46a97a2 100644 --- a/krylov/psb_zcgs.f90 +++ b/krylov/psb_zcgs.f90 @@ -191,7 +191,7 @@ Subroutine psb_zcgs(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) itx = 0 - call psb_init_conv(istop_,itrace_,a,b,eps,desc_a,stopdat,info) + call psb_init_conv(methdname,istop_,itrace_,a,b,eps,desc_a,stopdat,info) if (info /= 0) Then call psb_errpush(4011,name) goto 9999 diff --git a/krylov/psb_zcgstab.f90 b/krylov/psb_zcgstab.f90 index e4b7e8db..b3fe6f7c 100644 --- a/krylov/psb_zcgstab.f90 +++ b/krylov/psb_zcgstab.f90 @@ -194,7 +194,7 @@ subroutine psb_zcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) itx = 0 - call psb_init_conv(istop_,itrace_,a,b,eps,desc_a,stopdat,info) + call psb_init_conv(methdname,istop_,itrace_,a,b,eps,desc_a,stopdat,info) if (info /= 0) Then call psb_errpush(4011,name) goto 9999