refill_h_ghost_scaled Subroutine

private pure subroutine refill_h_ghost_scaled(h_layer, bt_H_ref, nx_total, ny_total, nz, i_w, i_e, j_s, j_n, nghost, bc_w, bc_e, bc_s, bc_n)

Overwrite open-edge h_layer ghost columns with the nearest interior column scaled so Σ_k h_ghost = bt_H_ref(ghost) + η_interior (η_interior = Σ_k h_int − bt_H_ref(int)). x-pass (west/east) over the full j extent (covers corner rows); y-pass (south/north) over the full i extent, reading the already x-filled corner columns — same corner-coverage order as fill_h_layer_ghosts.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(inout) :: h_layer(nx_total,ny_total,nz)
real(kind=wp), intent(in) :: bt_H_ref(nx_total,ny_total)
integer, intent(in) :: nx_total
integer, intent(in) :: ny_total
integer, intent(in) :: nz
integer, intent(in) :: i_w
integer, intent(in) :: i_e
integer, intent(in) :: j_s
integer, intent(in) :: j_n
integer, intent(in) :: nghost
integer, intent(in) :: bc_w
integer, intent(in) :: bc_e
integer, intent(in) :: bc_s
integer, intent(in) :: bc_n

Calls

proc~~refill_h_ghost_scaled~~CallsGraph proc~refill_h_ghost_scaled refill_h_ghost_scaled local local proc~refill_h_ghost_scaled->local proc~is_open_ish is_open_ish proc~refill_h_ghost_scaled->proc~is_open_ish

Called by

proc~~refill_h_ghost_scaled~~CalledByGraph proc~refill_h_ghost_scaled refill_h_ghost_scaled proc~ocean_obc_refill_ghost_ssh ocean_obc_refill_ghost_ssh proc~ocean_obc_refill_ghost_ssh->proc~refill_h_ghost_scaled proc~ocean_dyn_step_split ocean_dyn_step_split proc~ocean_dyn_step_split->proc~ocean_obc_refill_ghost_ssh 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 :: eta_ref
integer, private :: g
integer, private :: i
integer, private :: j
integer, private :: k
real(kind=wp), private :: sc
real(kind=wp), private :: sh_int

Source Code

   pure subroutine refill_h_ghost_scaled(h_layer, bt_H_ref, nx_total, ny_total, nz, &
                                         i_w, i_e, j_s, j_n, nghost, &
                                         bc_w, bc_e, bc_s, bc_n)
      !! Overwrite open-edge h_layer ghost columns with the nearest interior
      !! column scaled so `Σ_k h_ghost = bt_H_ref(ghost) + η_interior`
      !! (η_interior = `Σ_k h_int − bt_H_ref(int)`).  x-pass (west/east) over
      !! the full j extent (covers corner rows); y-pass (south/north) over the
      !! full i extent, reading the already x-filled corner columns — same
      !! corner-coverage order as `fill_h_layer_ghosts`.
      integer, intent(in) :: nx_total, ny_total, nz, nghost
      real(wp), intent(inout) :: h_layer(nx_total, ny_total, nz)
      real(wp), intent(in)    :: bt_H_ref(nx_total, ny_total)
      integer, intent(in) :: i_w, i_e, j_s, j_n
      integer, intent(in) :: bc_w, bc_e, bc_s, bc_n

      integer :: i, j, k, g
      real(wp) :: sh_int, eta_ref, sc

      ! West ghosts
      if (is_open_ish(bc_w)) then
         do concurrent(j=1:ny_total, g=1:nghost) local(k, sh_int, eta_ref, sc)
            sh_int = 0.0_wp
            do k = 1, nz
               sh_int = sh_int + h_layer(i_w, j, k)
            end do
            eta_ref = sh_int - bt_H_ref(i_w, j)
            sc = (bt_H_ref(g, j) + eta_ref)/max(sh_int, H_VANISHED)
            do k = 1, nz
               h_layer(g, j, k) = h_layer(i_w, j, k)*sc
            end do
         end do
      end if
      ! East ghosts
      if (is_open_ish(bc_e)) then
         do concurrent(j=1:ny_total, g=1:nghost) local(k, sh_int, eta_ref, sc)
            sh_int = 0.0_wp
            do k = 1, nz
               sh_int = sh_int + h_layer(i_e, j, k)
            end do
            eta_ref = sh_int - bt_H_ref(i_e, j)
            sc = (bt_H_ref(nx_total - g + 1, j) + eta_ref)/max(sh_int, H_VANISHED)
            do k = 1, nz
               h_layer(nx_total - g + 1, j, k) = h_layer(i_e, j, k)*sc
            end do
         end do
      end if
      ! South ghosts (read the x-filled corner columns)
      if (is_open_ish(bc_s)) then
         do concurrent(i=1:nx_total, g=1:nghost) local(k, sh_int, eta_ref, sc)
            sh_int = 0.0_wp
            do k = 1, nz
               sh_int = sh_int + h_layer(i, j_s, k)
            end do
            eta_ref = sh_int - bt_H_ref(i, j_s)
            sc = (bt_H_ref(i, g) + eta_ref)/max(sh_int, H_VANISHED)
            do k = 1, nz
               h_layer(i, g, k) = h_layer(i, j_s, k)*sc
            end do
         end do
      end if
      ! North ghosts (read the x-filled corner columns)
      if (is_open_ish(bc_n)) then
         do concurrent(i=1:nx_total, g=1:nghost) local(k, sh_int, eta_ref, sc)
            sh_int = 0.0_wp
            do k = 1, nz
               sh_int = sh_int + h_layer(i, j_n, k)
            end do
            eta_ref = sh_int - bt_H_ref(i, j_n)
            sc = (bt_H_ref(i, ny_total - g + 1) + eta_ref)/max(sh_int, H_VANISHED)
            do k = 1, nz
               h_layer(i, ny_total - g + 1, k) = h_layer(i, j_n, k)*sc
            end do
         end do
      end if
   end subroutine refill_h_ghost_scaled