cavity_state_at_x Subroutine

private pure subroutine cavity_state_at_x(x, par, f_cor, ice, eos, const, u_star, T_w, S_w, p_b, S_i, T_b, S_b, m_mass, gamma_t, gamma_s, b_flux, lp_new, ierr)

Evaluate the whole interface at a trial x = ln(L+): exchange velocities at that stratification, the closed-form three-equation solve, the buoyancy flux the answer implies and the L+ it re-diagnoses. The fixed point of x -> ln(L+_new) is the solution of the implicit system.

Arguments

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

Trial ln(L+). At or above CAVITY_LP_X_HI the trial L+ is the neutral sentinel.

type(ocean_cavity_exchange_t), intent(in) :: par

Exchange-law bundle (its f_cor member is NOT read).

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

Coriolis parameter (1/s) for this column.

type(ocean_cavity_ice_t), intent(in) :: ice

Ice-conduction bundle.

type(eos_t), intent(in) :: eos

Shared EOS handle — the liquidus.

type(ocean_cavity_const_t), intent(in) :: const

Constants bundle.

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

Friction velocity (m/s).

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

Far-field temperature (degC).

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

Far-field salinity (g/kg).

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

Interface pressure (Pa).

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

Ice salinity (g/kg).

real(kind=wp), intent(out) :: T_b

Interface temperature (degC).

real(kind=wp), intent(out) :: S_b

Interface salinity (g/kg).

real(kind=wp), intent(out) :: m_mass

Melt mass flux (kg/m^2/s).

real(kind=wp), intent(out) :: gamma_t

Heat exchange velocity (m/s) at this iterate.

real(kind=wp), intent(out) :: gamma_s

Salt exchange velocity (m/s) at this iterate.

real(kind=wp), intent(out) :: b_flux

Interfacial buoyancy flux (m^2/s^3) the answer implies.

real(kind=wp), intent(out) :: lp_new

L+ re-diagnosed from that buoyancy flux.

integer, intent(out) :: ierr

CAVITY_MELT_* status.


Calls

proc~~cavity_state_at_x~~CallsGraph proc~cavity_state_at_x cavity_state_at_x proc~cavity_buoyancy_flux cavity_buoyancy_flux proc~cavity_state_at_x->proc~cavity_buoyancy_flux proc~cavity_exchange_velocities_f cavity_exchange_velocities_f proc~cavity_state_at_x->proc~cavity_exchange_velocities_f proc~cavity_l_plus_from_state cavity_l_plus_from_state proc~cavity_state_at_x->proc~cavity_l_plus_from_state proc~cavity_safe_state cavity_safe_state proc~cavity_state_at_x->proc~cavity_safe_state proc~cavity_three_equation cavity_three_equation proc~cavity_state_at_x->proc~cavity_three_equation proc~cavity_gamma_hj99 cavity_gamma_hj99 proc~cavity_exchange_velocities_f->proc~cavity_gamma_hj99 proc~cavity_gamma_yung25 cavity_gamma_yung25 proc~cavity_exchange_velocities_f->proc~cavity_gamma_yung25 proc~eos_freezing_point eos_freezing_point proc~cavity_safe_state->proc~eos_freezing_point proc~cavity_three_equation->proc~cavity_safe_state proc~cavity_ice_terms cavity_ice_terms proc~cavity_three_equation->proc~cavity_ice_terms proc~cavity_t_ice cavity_t_ice proc~cavity_three_equation->proc~cavity_t_ice proc~cavity_three_equation->proc~eos_freezing_point proc~cavity_l_plus_is_neutral cavity_l_plus_is_neutral proc~cavity_gamma_hj99->proc~cavity_l_plus_is_neutral proc~cavity_gamma_yung25->proc~cavity_l_plus_is_neutral

Called by

proc~~cavity_state_at_x~~CalledByGraph proc~cavity_state_at_x cavity_state_at_x proc~cavity_solve_melt_f cavity_solve_melt_f proc~cavity_solve_melt_f->proc~cavity_state_at_x 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

Variables

Type Visibility Attributes Name Initial
real(kind=wp), private :: l_plus

Source Code

   pure subroutine cavity_state_at_x(x, par, f_cor, ice, eos, const, u_star, T_w, S_w, p_b, &
                                     S_i, T_b, S_b, m_mass, gamma_t, gamma_s, b_flux, &
                                     lp_new, ierr)
      !! Evaluate the whole interface at a trial `x = ln(L+)`: exchange
      !! velocities at that stratification, the closed-form three-equation
      !! solve, the buoyancy flux the answer implies and the `L+` it
      !! re-diagnoses.  The fixed point of `x -> ln(L+_new)` is the
      !! solution of the implicit system.
      !$acc routine seq
      real(wp), intent(in) :: x
         !! Trial `ln(L+)`.  At or above `CAVITY_LP_X_HI` the trial `L+`
         !! is the neutral sentinel.
      type(ocean_cavity_exchange_t), intent(in) :: par
         !! Exchange-law bundle (its `f_cor` member is NOT read).
      real(wp), intent(in) :: f_cor
         !! Coriolis parameter (1/s) for this column.
      type(ocean_cavity_ice_t), intent(in) :: ice
         !! Ice-conduction bundle.
      type(eos_t), intent(in) :: eos
         !! Shared EOS handle — the liquidus.
      type(ocean_cavity_const_t), intent(in) :: const
         !! Constants bundle.
      real(wp), intent(in) :: u_star
         !! Friction velocity (m/s).
      real(wp), intent(in) :: T_w
         !! Far-field temperature (degC).
      real(wp), intent(in) :: S_w
         !! Far-field salinity (g/kg).
      real(wp), intent(in) :: p_b
         !! Interface pressure (Pa).
      real(wp), intent(in) :: S_i
         !! Ice salinity (g/kg).
      real(wp), intent(out) :: T_b
         !! Interface temperature (degC).
      real(wp), intent(out) :: S_b
         !! Interface salinity (g/kg).
      real(wp), intent(out) :: m_mass
         !! Melt mass flux (kg/m^2/s).
      real(wp), intent(out) :: gamma_t
         !! Heat exchange velocity (m/s) at this iterate.
      real(wp), intent(out) :: gamma_s
         !! Salt exchange velocity (m/s) at this iterate.
      real(wp), intent(out) :: b_flux
         !! Interfacial buoyancy flux (m^2/s^3) the answer implies.
      real(wp), intent(out) :: lp_new
         !! `L+` re-diagnosed from that buoyancy flux.
      integer, intent(out) :: ierr
         !! `CAVITY_MELT_*` status.
      real(wp) :: l_plus

      b_flux = 0.0_wp
      lp_new = CAVITY_L_PLUS_NEUTRAL
      if (x >= CAVITY_LP_X_HI) then
         l_plus = CAVITY_L_PLUS_NEUTRAL
      else
         l_plus = exp(x)
      end if

      ! `T_b`/`S_b` are the RESERVED-law arguments here (only MK18 reads
      ! them); the trial interface state is not known yet, so the
      ! prototype's convention of passing `(0, S_w)` is kept.
      call cavity_exchange_velocities_f(par, f_cor, const, u_star, l_plus, T_w, S_w, &
                                        0.0_wp, S_w, gamma_t, gamma_s, ierr)
      if (ierr /= CAVITY_MELT_OK) then
         call cavity_safe_state(eos, S_w, p_b, T_b, S_b, m_mass)
         return
      end if

      call cavity_three_equation(T_w, S_w, p_b, gamma_t, gamma_s, S_i, ice, eos, &
                                 const, T_b, S_b, m_mass, ierr)
      if (ierr /= CAVITY_MELT_OK) return

      b_flux = cavity_buoyancy_flux(const, T_w, S_w, T_b, S_b, gamma_t, gamma_s)
      lp_new = cavity_l_plus_from_state(const, u_star, b_flux)
   end subroutine cavity_state_at_x