isomip_logistic Function

private pure function isomip_logistic(t) result(r)

1/(1 + exp(t)), saturated instead of overflowing.

The two logistic terms of Eq. (4) reach |t| ~ 34 over the ISOMIP+ box including ghost rows, but a caller with a much wider y_len (or a tiny f_c) would drive exp(t) past the real64 overflow at t ~ 709. Saturating at +/-T_SAT is exact to the last bit of r on both sides (1/(1+exp(500)) underflows to 0 and 1/(1+exp(-500)) rounds to 1 anyway), so this costs nothing and removes an Inf that would propagate as a NaN.

t is built from grid positions and the Table-1 constants, all finite by construction, so the CLAUDE.md “if/else clamps launder NaN” trap does not apply: there is no path that feeds this a NaN.

Arguments

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

Return Value real(kind=wp)


Called by

proc~~isomip_logistic~~CalledByGraph proc~isomip_logistic isomip_logistic proc~isomip_plus_by isomip_plus_by proc~isomip_plus_by->proc~isomip_logistic proc~set_bathymetry_isomip_plus set_bathymetry_isomip_plus proc~set_bathymetry_isomip_plus->proc~isomip_plus_by proc~ocean_state_seed_from_cfg ocean_state_seed_from_cfg proc~ocean_state_seed_from_cfg->proc~set_bathymetry_isomip_plus proc~engine_setup engine_setup proc~engine_setup->proc~ocean_state_seed_from_cfg proc~complete_ocean_create complete_ocean_create proc~complete_ocean_create->proc~engine_setup proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_setup proc~driver_validate driver_validate proc~driver_validate->proc~engine_setup

Variables

Type Visibility Attributes Name Initial
real(kind=wp), private, parameter :: T_SAT = 500.0_wp

Source Code

   pure function isomip_logistic(t) result(r)
      !! `1/(1 + exp(t))`, saturated instead of overflowing.
      !!
      !! The two logistic terms of Eq. (4) reach `|t| ~ 34` over the
      !! ISOMIP+ box including ghost rows, but a caller with a much wider
      !! `y_len` (or a tiny `f_c`) would drive `exp(t)` past the `real64`
      !! overflow at `t ~ 709`.  Saturating at +/-`T_SAT` is exact to the
      !! last bit of `r` on both sides (`1/(1+exp(500))` underflows to 0
      !! and `1/(1+exp(-500))` rounds to 1 anyway), so this costs nothing
      !! and removes an Inf that would propagate as a NaN.
      !!
      !! `t` is built from grid positions and the Table-1 constants, all
      !! finite by construction, so the CLAUDE.md "if/else clamps launder
      !! NaN" trap does not apply: there is no path that feeds this a NaN.
      real(wp), intent(in) :: t
      real(wp) :: r
      real(wp), parameter :: T_SAT = 500.0_wp
      if (t > T_SAT) then
         r = 0.0_wp
      else if (t < -T_SAT) then
         r = 1.0_wp
      else
         r = 1.0_wp/(1.0_wp + exp(t))
      end if
   end function isomip_logistic