mle_layer_weights Subroutine

public pure subroutine mle_layer_weights(h_face, nz, h_vel, a)

Per-layer transport weights a(k) = mu(sigma_top) - mu(sigma_bot), walking surface (k=nz) -> bed (k=1). sum_k a(k) = mu(0)-mu(-1) = 0 (closed cell => conservation). Layers below the ML base get sigma <= -1 => mu=0 on both interfaces => a(k)=0 (ML-confinement).

h_vel is clamped to the column total inside the caller so the sigma walk reaches exactly -1 over the actual depth (guards the mld > column-depth case; mu(-1)=0 keeps sum a(k)=0 regardless).

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: h_face(nz)
integer, intent(in) :: nz
real(kind=wp), intent(in) :: h_vel
real(kind=wp), intent(out) :: a(nz)

Calls

proc~~mle_layer_weights~~CallsGraph proc~mle_layer_weights mle_layer_weights proc~mle_mu_shape mle_mu_shape proc~mle_layer_weights->proc~mle_mu_shape

Called by

proc~~mle_layer_weights~~CalledByGraph proc~mle_layer_weights mle_layer_weights proc~mle_compute_transports mle_compute_transports proc~mle_compute_transports->proc~mle_layer_weights proc~ocean_dyn_step_split ocean_dyn_step_split proc~ocean_dyn_step_split->proc~mle_compute_transports proc~engine_step engine_step proc~engine_step->proc~ocean_dyn_step_split proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_step proc~rdb_ocean_step rdb_ocean_step proc~rdb_ocean_step->proc~engine_step proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean

Variables

Type Visibility Attributes Name Initial
real(kind=wp), private :: ih_tot
integer, private :: k
real(kind=wp), private :: mu_bot
real(kind=wp), private :: mu_top
real(kind=wp), private :: sigma_bot
real(kind=wp), private :: sigma_top

Source Code

   pure subroutine mle_layer_weights(h_face, nz, h_vel, a)
      !$acc routine seq
      !! Per-layer transport weights a(k) = mu(sigma_top) - mu(sigma_bot),
      !! walking surface (k=nz) -> bed (k=1).  `sum_k a(k) = mu(0)-mu(-1) = 0`
      !! (closed cell => conservation).  Layers below the ML base get
      !! sigma <= -1 => mu=0 on both interfaces => a(k)=0 (ML-confinement).
      !!
      !! `h_vel` is clamped to the column total inside the caller so the
      !! sigma walk reaches exactly -1 over the actual depth (guards the
      !! mld > column-depth case; mu(-1)=0 keeps sum a(k)=0 regardless).
      integer, intent(in) :: nz
      real(wp), intent(in) :: h_face(nz)   ! k=1 bed .. k=nz surface
      real(wp), intent(in) :: h_vel
      real(wp), intent(out) :: a(nz)       ! k=1 bed .. k=nz surface
      integer :: k
      real(wp) :: ih_tot, sigma_top, sigma_bot, mu_top, mu_bot
      ih_tot = 1.0_wp/(h_vel + H_NEGLECT)
      sigma_top = 0.0_wp                   ! sigma=0 at surface (above k=nz)
      ! Walk surface -> bed.
      do k = nz, 1, -1
         sigma_bot = sigma_top - h_face(k)*ih_tot   ! more negative going down
         mu_top = mle_mu_shape(sigma_top)
         mu_bot = mle_mu_shape(sigma_bot)
         a(k) = mu_top - mu_bot
         sigma_top = sigma_bot
      end do
   end subroutine mle_layer_weights