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.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | lp_new |
|
||
| real(kind=wp), | intent(in) | :: | x |
The trial |
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