face_depth_mean_v Subroutine

public pure subroutine face_depth_mean_v(grid, F_3d, h_layer, F_mean_2d, nz, metrics, href, scheme)

Symmetric v-face counterpart of face_depth_mean_u.

Arguments

Type IntentOptional Attributes Name
type(hgrid_t), intent(in) :: grid
real(kind=wp), intent(in) :: F_3d(:,:,:)
real(kind=wp), intent(in) :: h_layer(:,:,:)
real(kind=wp), intent(out) :: F_mean_2d(:,:)
integer, intent(in) :: nz
type(ocean_metrics_t), intent(in) :: metrics

REQUIRED. See face_depth_mean_u for the argument and for why it is not optional; knob off ⇒ the ORIGINAL loop, byte-identical.

real(kind=wp), intent(in) :: href(:,:)
integer, intent(in) :: scheme

A FRHAT_* constant. See face_depth_mean_u.


Calls

proc~~face_depth_mean_v~~CallsGraph proc~face_depth_mean_v face_depth_mean_v frhat_h_face_step frhat_h_face_step proc~face_depth_mean_v->frhat_h_face_step local local proc~face_depth_mean_v->local

Called by

proc~~face_depth_mean_v~~CalledByGraph proc~face_depth_mean_v face_depth_mean_v proc~compute_bt_rem_from_visc_rem compute_bt_rem_from_visc_rem proc~compute_bt_rem_from_visc_rem->proc~face_depth_mean_v proc~run_stage_split run_stage_split proc~run_stage_split->proc~face_depth_mean_v proc~run_stage_split->proc~compute_bt_rem_from_visc_rem proc~set_cor_ref_velocity set_cor_ref_velocity proc~run_stage_split->proc~set_cor_ref_velocity proc~set_cor_ref_velocity->proc~face_depth_mean_v 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_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 :: denom
real(kind=wp), private :: e_prev
integer, private :: eff_scheme
real(kind=wp), private :: h_face
real(kind=wp), private :: href_l
real(kind=wp), private :: href_r
integer, private :: i
integer, private :: j
integer, private :: jl
integer, private :: jr
integer, private :: k
real(kind=wp), private :: num
integer, private :: nv
integer, private :: nx
integer, private :: ny_cells
logical, private :: use_open

Source Code

   pure subroutine face_depth_mean_v(grid, F_3d, h_layer, F_mean_2d, nz, metrics, href, scheme)
      !! Symmetric v-face counterpart of `face_depth_mean_u`.
      type(hgrid_t), intent(in) :: grid
      ! assumed-shape-ok: face arrays have shape (nx,ny+1,nz); a single (nx,ny,nz)
      ! explicit-shape triplet would mis-bound the face axis.
      real(wp), intent(in) :: F_3d(:, :, :)
      real(wp), intent(in) :: h_layer(:, :, :)  ! assumed-shape-ok: face-sized array; size() derives loop bounds
      real(wp), intent(out) :: F_mean_2d(:, :)  ! assumed-shape-ok: face-sized array; size() derives loop bounds
      integer, intent(in) :: nz
      type(ocean_metrics_t), intent(in) :: metrics
         !! REQUIRED.  See `face_depth_mean_u` for the argument and for
         !! why it is not optional; knob off ⇒ the ORIGINAL loop,
         !! byte-identical.
      real(wp), intent(in) :: href(:, :)  ! assumed-shape-ok: cell-centred (nx,ny); see face_depth_mean_u
      integer, intent(in) :: scheme
         !! A `FRHAT_*` constant.  See `face_depth_mean_u`.
      integer :: i, j, k, nx, nv, ny_cells, jl, jr
      real(wp) :: h_face, num, denom, href_l, href_r, e_prev
      logical :: use_open
      integer :: eff_scheme

      nx = size(F_3d, 1)
      nv = size(F_3d, 2)
      ny_cells = grid%ny_total
      use_open = metrics%use_closed_faces
      ! FRHAT_HYBRID only under closed faces -- see `derive_bt_from_layers`'
      ! matching comment.
      eff_scheme = merge(scheme, FRHAT_ARITHMETIC, use_open)

      if (use_open) then
         do concurrent(j=1:nv, i=1:nx) local(k, jl, jr, href_l, href_r, e_prev, h_face, num, denom)
            jl = max(1, j - 1)
            jr = min(ny_cells, j)
            href_l = href(i, jl)
            href_r = href(i, jr)
            e_prev = -0.5_wp*(href_l + href_r)
            num = 0.0_wp
            denom = 0.0_wp
            do k = 1, nz
               call frhat_h_face_step(h_layer(i, jl, k), h_layer(i, jr, k), &
                                      href_l, href_r, eff_scheme, e_prev, h_face)
               h_face = h_face*metrics%open_v(i, j, k)
               num = num + F_3d(i, j, k)*h_face
               denom = denom + h_face
            end do
            if (denom > 0.0_wp) then
               F_mean_2d(i, j) = num/denom
            else
               F_mean_2d(i, j) = 0.0_wp
            end if
         end do
      else
         do concurrent(j=1:nv, i=1:nx) local(k, jl, jr, href_l, href_r, e_prev, h_face, num, denom)
            jl = max(1, j - 1)
            jr = min(ny_cells, j)
            href_l = href(i, jl)
            href_r = href(i, jr)
            e_prev = -0.5_wp*(href_l + href_r)
            num = 0.0_wp
            denom = 0.0_wp
            do k = 1, nz
               call frhat_h_face_step(h_layer(i, jl, k), h_layer(i, jr, k), &
                                      href_l, href_r, eff_scheme, e_prev, h_face)
               num = num + F_3d(i, j, k)*h_face
               denom = denom + h_face
            end do
            if (denom > 0.0_wp) then
               F_mean_2d(i, j) = num/denom
            else
               F_mean_2d(i, j) = 0.0_wp
            end if
         end do
      end if
   end subroutine face_depth_mean_v