cavity_outer_residual Function

private pure function cavity_outer_residual(lp_new, x) result(g)

Outer-iteration residual G(x) = ln(L+_new(x)) - x, with the destabilising branch folded in: a non-positive, non-finite or sentinel L+_new means the buoyancy flux at this iterate is destabilising (or zero), which every law treats as L+ = +infinity, so G = +infinity. Mapping it that way keeps the bisection bracket valid instead of taking log() of a negative number.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: lp_new

L+ re-diagnosed from the state this iterate produced.

real(kind=wp), intent(in) :: x

The trial ln(L+) it was produced at.

Return Value real(kind=wp)


Calls

proc~~cavity_outer_residual~~CallsGraph proc~cavity_outer_residual cavity_outer_residual proc~cavity_l_plus_is_neutral cavity_l_plus_is_neutral proc~cavity_outer_residual->proc~cavity_l_plus_is_neutral

Called by

proc~~cavity_outer_residual~~CalledByGraph proc~cavity_outer_residual cavity_outer_residual proc~cavity_solve_melt_f cavity_solve_melt_f proc~cavity_solve_melt_f->proc~cavity_outer_residual proc~cavity_melt_point_gamma_f cavity_melt_point_gamma_f proc~cavity_melt_point_gamma_f->proc~cavity_solve_melt_f proc~cavity_solve_melt cavity_solve_melt proc~cavity_solve_melt->proc~cavity_solve_melt_f proc~cavity_melt_columns_2d cavity_melt_columns_2d proc~cavity_melt_columns_2d->proc~cavity_melt_point_gamma_f proc~cavity_melt_point cavity_melt_point proc~cavity_melt_point->proc~cavity_solve_melt proc~cavity_melt_point_gamma cavity_melt_point_gamma proc~cavity_melt_point_gamma->proc~cavity_melt_point_gamma_f proc~cavity_melt_columns cavity_melt_columns proc~cavity_melt_columns->proc~cavity_melt_point proc~ocean_cavity_flux_step ocean_cavity_flux_step proc~ocean_cavity_flux_step->proc~cavity_melt_columns_2d proc~engine_step_finalize engine_step_finalize proc~engine_step_finalize->proc~ocean_cavity_flux_step

Source Code

   pure function cavity_outer_residual(lp_new, x) result(g)
      !! Outer-iteration residual `G(x) = ln(L+_new(x)) - x`, with the
      !! destabilising branch folded in: a non-positive, non-finite or
      !! sentinel `L+_new` means the buoyancy flux at this iterate is
      !! destabilising (or zero), which every law treats as
      !! `L+ = +infinity`, so `G = +infinity`.  Mapping it that way keeps
      !! the bisection bracket valid instead of taking `log()` of a
      !! negative number.
      !$acc routine seq
      real(wp), intent(in) :: lp_new
         !! `L+` re-diagnosed from the state this iterate produced.
      real(wp), intent(in) :: x
         !! The trial `ln(L+)` it was produced at.
      real(wp) :: g
      if (cavity_l_plus_is_neutral(lp_new)) then
         g = huge(1.0_wp)
      else
         g = log(lp_new) - x
      end if
   end function cavity_outer_residual