dynamic_tol_sp Subroutine

public subroutine dynamic_tol_sp(tol, target_tol, rnorm, iter, info)

Abstract interface to define tolerance scheduler for the Newton iteration

Arguments

Type IntentOptional Attributes Name
real(kind=sp), intent(out) :: tol

Tolerance to be used

real(kind=sp), intent(in) :: target_tol

Target tolerance

real(kind=sp), intent(in) :: rnorm

Norm of the residual of the current iterate

integer, intent(in) :: iter

Newton iteration count

integer, intent(out) :: info

Information flag


Source Code

   subroutine dynamic_tol_sp(tol, target_tol, rnorm, iter, info)
      !! Abstract interface to define tolerance scheduler for the Newton iteration
      real(sp), intent(out) :: tol
      !! Tolerance to be used
      real(sp), intent(in) :: target_tol
      !! Target tolerance
      real(sp), intent(in)  :: rnorm
      !! Norm of the residual of the current iterate
      integer,  intent(in)  :: iter
      !! Newton iteration count
      integer,  intent(out)  :: info
      !! Information flag
      ! internals
      real(sp) :: tol_old
      character(len=256) :: msg
      
      tol_old = tol
      tol = max(0.1*rnorm, target_tol)

      if (tol /= tol_old) then
         if (tol == target_tol) then
            write(msg,'(A,E9.2)') 'Solver tolerance set to input target. tol= ', tol
         else
            write(msg,'(A,E9.2)') 'Solver tolerance set to tol= ', tol
         end if
         call logger%log_information(msg, module=this_module, procedure='dynamic_tol_sp')
      end if
      return
   end subroutine dynamic_tol_sp