region_eta_uv Subroutine

private subroutine region_eta_uv(grid, ms, bt_work, j_lo, j_hi, eta_min, eta_max, usurf_max, ubed_max, vsurf_max, vbed_max, ke_mean)

Walk cells (interior x-range, j in [j_lo, j_hi]); collect η extremes, |u|/|v| extremes at surface + bed, and the cell-area-averaged BT KE.

Arguments

Type IntentOptional Attributes Name
type(hgrid_t), intent(in) :: grid
type(multilayer_state_t), intent(in) :: ms
type(barotropic_workstate_t), intent(in) :: bt_work
integer, intent(in) :: j_lo
integer, intent(in) :: j_hi
real(kind=wp), intent(out) :: eta_min
real(kind=wp), intent(out) :: eta_max
real(kind=wp), intent(out) :: usurf_max
real(kind=wp), intent(out) :: ubed_max
real(kind=wp), intent(out) :: vsurf_max
real(kind=wp), intent(out) :: vbed_max
real(kind=wp), intent(out) :: ke_mean

Called by

proc~~region_eta_uv~~CalledByGraph proc~region_eta_uv region_eta_uv proc~print_bt_budget print_bt_budget proc~print_bt_budget->proc~region_eta_uv proc~run_stage_split run_stage_split proc~run_stage_split->proc~print_bt_budget 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

Variables

Type Visibility Attributes Name Initial
integer, private :: i
integer, private :: ip_hi
integer, private :: ip_lo
integer, private :: j
real(kind=wp), private :: ke_sum
integer, private :: n
integer, private :: nz_top
real(kind=wp), private :: u_cell
real(kind=wp), private :: v_cell

Source Code

   subroutine region_eta_uv(grid, ms, bt_work, j_lo, j_hi, &
                            eta_min, eta_max, &
                            usurf_max, ubed_max, vsurf_max, vbed_max, ke_mean)
      !! Walk cells (interior x-range, j in [j_lo, j_hi]); collect
      !! η extremes, |u|/|v| extremes at surface + bed, and the
      !! cell-area-averaged BT KE.
      type(hgrid_t), intent(in) :: grid
      type(multilayer_state_t), intent(in) :: ms
      type(barotropic_workstate_t), intent(in) :: bt_work
      integer, intent(in) :: j_lo, j_hi
      real(wp), intent(out) :: eta_min, eta_max
      real(wp), intent(out) :: usurf_max, ubed_max, vsurf_max, vbed_max
      real(wp), intent(out) :: ke_mean

      integer :: i, j, ip_lo, ip_hi, nz_top, n
      real(wp) :: u_cell, v_cell, ke_sum

      ip_lo = grid%nghost + 1
      ip_hi = grid%nghost + grid%nx_phys
      nz_top = ms%nz_ml

      eta_min = huge(1.0_wp)
      eta_max = -huge(1.0_wp)
      usurf_max = 0.0_wp
      ubed_max = 0.0_wp
      vsurf_max = 0.0_wp
      vbed_max = 0.0_wp
      ke_sum = 0.0_wp
      n = 0
      do j = j_lo, j_hi
         do i = ip_lo, ip_hi
            eta_min = min(eta_min, bt_work%bt_eta(i, j))
            eta_max = max(eta_max, bt_work%bt_eta(i, j))
            ! Bed = each face's first LIVE layer (`k_bot_u/v`, 1 off z_fixed).
            ubed_max = max(ubed_max, abs(ms%u_face_x_layer(i, j, ms%k_bot_u(i, j))), &
                           abs(ms%u_face_x_layer(i + 1, j, ms%k_bot_u(i + 1, j))))
            usurf_max = max(usurf_max, abs(ms%u_face_x_layer(i, j, nz_top)), &
                            abs(ms%u_face_x_layer(i + 1, j, nz_top)))
            vbed_max = max(vbed_max, abs(ms%v_face_y_layer(i, j, ms%k_bot_v(i, j))), &
                           abs(ms%v_face_y_layer(i, j + 1, ms%k_bot_v(i, j + 1))))
            vsurf_max = max(vsurf_max, abs(ms%v_face_y_layer(i, j, nz_top)), &
                            abs(ms%v_face_y_layer(i, j + 1, nz_top)))
            u_cell = 0.5_wp*(bt_work%bt_ubt(i, j) + bt_work%bt_ubt(i + 1, j))
            v_cell = 0.5_wp*(bt_work%bt_vbt(i, j) + bt_work%bt_vbt(i, j + 1))
            ke_sum = ke_sum + 0.5_wp*(u_cell*u_cell + v_cell*v_cell)
            n = n + 1
         end do
      end do
      if (n > 0) then
         ke_mean = ke_sum/real(n, wp)
      else
         ke_mean = 0.0_wp
         eta_min = 0.0_wp
         eta_max = 0.0_wp
      end if
   end subroutine region_eta_uv