From 29f72195eff925a5255c48fa910f12f97b147780 Mon Sep 17 00:00:00 2001 From: sfilippone Date: Wed, 13 Nov 2024 14:08:13 +0100 Subject: [PATCH] Fix GMRES convergence logs --- linsolve/impl/psb_crgmres.f90 | 9 +++------ linsolve/impl/psb_drgmres.f90 | 9 +++------ linsolve/impl/psb_srgmres.f90 | 9 +++------ linsolve/impl/psb_zrgmres.f90 | 9 +++------ 4 files changed, 12 insertions(+), 24 deletions(-) diff --git a/linsolve/impl/psb_crgmres.f90 b/linsolve/impl/psb_crgmres.f90 index e7799f70..bdba795d 100644 --- a/linsolve/impl/psb_crgmres.f90 +++ b/linsolve/impl/psb_crgmres.f90 @@ -344,19 +344,16 @@ subroutine psb_crgmres_vect(a,prec,b,x,eps,desc_a,info,& goto 9999 end if - if (errnum <= eps*errden) exit restart + if ((errnum <= eps*errden).or.(itx >= litmax)) exit restart if (itrace_ > 0) & & call log_conv(methdname,me,itx,itrace_,errnum,errden,deps) call v(1)%scal(scal) !v(1) = v(1) * scal - if (itx >= litmax) exit restart - ! ! inner iterations ! - inner: Do i=1,nl itx = itx + 1 @@ -446,6 +443,8 @@ subroutine psb_crgmres_vect(a,prec,b,x,eps,desc_a,info,& call psb_geaxpby(cone,w,cone,x,desc_a,info) end if + if (itrace_ > 0) & + & call log_conv(methdname,me,itx,ione,errnum,errden,deps) exit restart end if @@ -474,8 +473,6 @@ subroutine psb_crgmres_vect(a,prec,b,x,eps,desc_a,info,& end if end do restart - if (itrace_ > 0) & - & call log_conv(methdname,me,itx,ione,errnum,errden,deps) call log_end(methdname,me,itx,itrace_,errnum,errden,deps,err=derr,iter=iter) if (present(err)) err = derr diff --git a/linsolve/impl/psb_drgmres.f90 b/linsolve/impl/psb_drgmres.f90 index 373c7a70..e6ca506b 100644 --- a/linsolve/impl/psb_drgmres.f90 +++ b/linsolve/impl/psb_drgmres.f90 @@ -344,19 +344,16 @@ subroutine psb_drgmres_vect(a,prec,b,x,eps,desc_a,info,& goto 9999 end if - if (errnum <= eps*errden) exit restart + if ((errnum <= eps*errden).or.(itx >= litmax)) exit restart if (itrace_ > 0) & & call log_conv(methdname,me,itx,itrace_,errnum,errden,deps) call v(1)%scal(scal) !v(1) = v(1) * scal - if (itx >= litmax) exit restart - ! ! inner iterations ! - inner: Do i=1,nl itx = itx + 1 @@ -446,6 +443,8 @@ subroutine psb_drgmres_vect(a,prec,b,x,eps,desc_a,info,& call psb_geaxpby(done,w,done,x,desc_a,info) end if + if (itrace_ > 0) & + & call log_conv(methdname,me,itx,ione,errnum,errden,deps) exit restart end if @@ -474,8 +473,6 @@ subroutine psb_drgmres_vect(a,prec,b,x,eps,desc_a,info,& end if end do restart - if (itrace_ > 0) & - & call log_conv(methdname,me,itx,ione,errnum,errden,deps) call log_end(methdname,me,itx,itrace_,errnum,errden,deps,err=derr,iter=iter) if (present(err)) err = derr diff --git a/linsolve/impl/psb_srgmres.f90 b/linsolve/impl/psb_srgmres.f90 index 537d2f00..de5f9473 100644 --- a/linsolve/impl/psb_srgmres.f90 +++ b/linsolve/impl/psb_srgmres.f90 @@ -344,19 +344,16 @@ subroutine psb_srgmres_vect(a,prec,b,x,eps,desc_a,info,& goto 9999 end if - if (errnum <= eps*errden) exit restart + if ((errnum <= eps*errden).or.(itx >= litmax)) exit restart if (itrace_ > 0) & & call log_conv(methdname,me,itx,itrace_,errnum,errden,deps) call v(1)%scal(scal) !v(1) = v(1) * scal - if (itx >= litmax) exit restart - ! ! inner iterations ! - inner: Do i=1,nl itx = itx + 1 @@ -446,6 +443,8 @@ subroutine psb_srgmres_vect(a,prec,b,x,eps,desc_a,info,& call psb_geaxpby(sone,w,sone,x,desc_a,info) end if + if (itrace_ > 0) & + & call log_conv(methdname,me,itx,ione,errnum,errden,deps) exit restart end if @@ -474,8 +473,6 @@ subroutine psb_srgmres_vect(a,prec,b,x,eps,desc_a,info,& end if end do restart - if (itrace_ > 0) & - & call log_conv(methdname,me,itx,ione,errnum,errden,deps) call log_end(methdname,me,itx,itrace_,errnum,errden,deps,err=derr,iter=iter) if (present(err)) err = derr diff --git a/linsolve/impl/psb_zrgmres.f90 b/linsolve/impl/psb_zrgmres.f90 index 39985518..236b2620 100644 --- a/linsolve/impl/psb_zrgmres.f90 +++ b/linsolve/impl/psb_zrgmres.f90 @@ -344,19 +344,16 @@ subroutine psb_zrgmres_vect(a,prec,b,x,eps,desc_a,info,& goto 9999 end if - if (errnum <= eps*errden) exit restart + if ((errnum <= eps*errden).or.(itx >= litmax)) exit restart if (itrace_ > 0) & & call log_conv(methdname,me,itx,itrace_,errnum,errden,deps) call v(1)%scal(scal) !v(1) = v(1) * scal - if (itx >= litmax) exit restart - ! ! inner iterations ! - inner: Do i=1,nl itx = itx + 1 @@ -446,6 +443,8 @@ subroutine psb_zrgmres_vect(a,prec,b,x,eps,desc_a,info,& call psb_geaxpby(zone,w,zone,x,desc_a,info) end if + if (itrace_ > 0) & + & call log_conv(methdname,me,itx,ione,errnum,errden,deps) exit restart end if @@ -474,8 +473,6 @@ subroutine psb_zrgmres_vect(a,prec,b,x,eps,desc_a,info,& end if end do restart - if (itrace_ > 0) & - & call log_conv(methdname,me,itx,ione,errnum,errden,deps) call log_end(methdname,me,itx,itrace_,errnum,errden,deps,err=derr,iter=iter) if (present(err)) err = derr