fv_mom6_mass_weights Subroutine

private pure subroutine fv_mom6_mass_weights(mass_weight, e_bed_l, e_bed_r, e_top_l, e_top_r, h_l, h_r, h_neglect, hwt_ll, hwt_lr, hwt_rr, hwt_rl)

MOM6 near-bottom hWght mass-weighting fractions of one face (MASS_WEIGHT_IN_PRESSURE_GRADIENT): the distance by which the layer top of one column sits below the other column’s bed, scaled by the squared relative thickness contrast. Zero ⇒ plain linear interpolation (hwt_ll = hwt_rr = 1, hwt_lr = hwt_rl = 0).

Arguments

Type IntentOptional Attributes Name
logical, intent(in) :: mass_weight

Mass weighting on?

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

Bed heights of the left / right column (m).

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

Bed heights of the left / right column (m).

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

Layer top heights of the left / right column (m).

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

Layer top heights of the left / right column (m).

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

Layer thicknesses of the left / right column (m).

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

Layer thicknesses of the left / right column (m).

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

Negligible thickness (m).

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

MOM6 hWt_LL/LR/RR/RL.

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

MOM6 hWt_LL/LR/RR/RL.

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

MOM6 hWt_LL/LR/RR/RL.

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

MOM6 hWt_LL/LR/RR/RL.


Called by

proc~~fv_mom6_mass_weights~~CalledByGraph proc~fv_mom6_mass_weights fv_mom6_mass_weights proc~compute_fv_mom6_insitu_pcm_impl compute_fv_mom6_insitu_pcm_impl proc~compute_fv_mom6_insitu_pcm_impl->proc~fv_mom6_mass_weights proc~ocean_pressure_force_compute ocean_pressure_force_compute proc~ocean_pressure_force_compute->proc~compute_fv_mom6_insitu_pcm_impl proc~run_stage run_stage proc~run_stage->proc~ocean_pressure_force_compute proc~run_stage_split run_stage_split proc~run_stage_split->proc~ocean_pressure_force_compute proc~ocean_dyn_step ocean_dyn_step proc~ocean_dyn_step->proc~run_stage proc~ocean_dyn_step_split ocean_dyn_step_split proc~ocean_dyn_step_split->proc~run_stage_split proc~engine_step engine_step proc~engine_step->proc~ocean_dyn_step proc~engine_step->proc~ocean_dyn_step_split

Variables

Type Visibility Attributes Name Initial
real(kind=wp), private :: hwght
real(kind=wp), private :: hwl
real(kind=wp), private :: hwr
real(kind=wp), private :: idenom_hw
logical, private :: use_hw

Source Code

   pure subroutine fv_mom6_mass_weights(mass_weight, e_bed_l, e_bed_r, e_top_l, e_top_r, &
                                        h_l, h_r, h_neglect, &
                                        hwt_ll, hwt_lr, hwt_rr, hwt_rl)
      !$acc routine seq
      !! MOM6 near-bottom `hWght` mass-weighting fractions of one face
      !! (`MASS_WEIGHT_IN_PRESSURE_GRADIENT`): the distance by which the
      !! layer top of one column sits below the other column's bed, scaled
      !! by the squared relative thickness contrast.  Zero ⇒ plain linear
      !! interpolation (`hwt_ll = hwt_rr = 1`, `hwt_lr = hwt_rl = 0`).
      logical, intent(in)   :: mass_weight
         !! Mass weighting on?
      real(wp), intent(in)  :: e_bed_l, e_bed_r
         !! Bed heights of the left / right column (m).
      real(wp), intent(in)  :: e_top_l, e_top_r
         !! Layer top heights of the left / right column (m).
      real(wp), intent(in)  :: h_l, h_r
         !! Layer thicknesses of the left / right column (m).
      real(wp), intent(in)  :: h_neglect
         !! Negligible thickness (m).
      real(wp), intent(out) :: hwt_ll, hwt_lr, hwt_rr, hwt_rl
         !! MOM6 `hWt_LL/LR/RR/RL`.

      real(wp) :: hwght, hwl, hwr, idenom_hw
      logical  :: use_hw

      ! Branch-free: the weighted fractions are formed unconditionally and
      ! SELECTED where `hwght > 0` (else plain linear interpolation) -- the
      ! same numbers as the branched form, and a CPU compiler can vectorise
      ! the face loops that call this.  `h_neglect > 0` keeps the unselected
      ! arithmetic finite.
      hwght = 0.0_wp
      if (mass_weight) hwght = max(0.0_wp, e_bed_r - e_top_l, e_bed_l - e_top_r)
      use_hw = hwght > 0.0_wp
      hwl = h_l + h_neglect
      hwr = h_r + h_neglect
      hwght = hwght*((hwl - hwr)/(hwl + hwr))**2
      idenom_hw = 1.0_wp/(hwght*(hwr + hwl) + hwl*hwr)
      hwt_ll = merge((hwght*hwl + hwr*hwl)*idenom_hw, 1.0_wp, use_hw)
      hwt_lr = merge((hwght*hwr)*idenom_hw, 0.0_wp, use_hw)
      hwt_rr = merge((hwght*hwr + hwr*hwl)*idenom_hw, 1.0_wp, use_hw)
      hwt_rl = merge((hwght*hwl)*idenom_hw, 0.0_wp, use_hw)
   end subroutine fv_mom6_mass_weights