build_grounded_mask Subroutine

private subroutine build_grounded_mask(nx, ny, nz, h_old, h_floor, mask, n_grounded)

ONE coalesced pass: mask(i,j,1) = 1.0 iff any layer of column (i,j) is strictly below the floor; n_grounded counts them (explicit OpenACC reduction — a sum() on a present-mapped array would run host-side under NVHPC non-managed mode and read the stale shadow).

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nx
integer, intent(in) :: ny
integer, intent(in) :: nz
real(kind=wp), intent(in) :: h_old(nx,ny,nz)
real(kind=wp), intent(in) :: h_floor
real(kind=wp), intent(out) :: mask(nx,ny,1)
integer, intent(out) :: n_grounded

Calls

proc~~build_grounded_mask~~CallsGraph proc~build_grounded_mask build_grounded_mask local local proc~build_grounded_mask->local reduce reduce proc~build_grounded_mask->reduce

Called by

proc~~build_grounded_mask~~CalledByGraph proc~build_grounded_mask build_grounded_mask proc~ocean_apply_conservative_min_thickness ocean_apply_conservative_min_thickness proc~ocean_apply_conservative_min_thickness->proc~build_grounded_mask proc~run_continuity_chain run_continuity_chain proc~run_continuity_chain->proc~ocean_apply_conservative_min_thickness proc~run_stage_split run_stage_split proc~run_stage_split->proc~run_continuity_chain 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

Variables

Type Visibility Attributes Name Initial
logical, private :: g
integer, private :: i
integer, private :: j
integer, private :: k
integer, private :: n

Source Code

   subroutine build_grounded_mask(nx, ny, nz, h_old, h_floor, mask, n_grounded)
      !! ONE coalesced pass: mask(i,j,1) = 1.0 iff any layer of column (i,j)
      !! is strictly below the floor; `n_grounded` counts them (explicit
      !! OpenACC reduction — a `sum()` on a present-mapped array would run
      !! host-side under NVHPC non-managed mode and read the stale shadow).
      integer, intent(in) :: nx, ny, nz
      real(wp), intent(in) :: h_old(nx, ny, nz)
      real(wp), intent(in) :: h_floor
      real(wp), intent(out) :: mask(nx, ny, 1)
      integer, intent(out) :: n_grounded

      integer :: i, j, k, n
      logical :: g

      n = 0
      do concurrent(j=1:ny, i=1:nx) local(g, k) reduce(+:n)
         g = .false.
         do k = 1, nz
            if (h_old(i, j, k) < h_floor) g = .true.
         end do
         if (g) then
            mask(i, j, 1) = 1.0_wp
            n = n + 1
         else
            mask(i, j, 1) = 0.0_wp
         end if
      end do
      n_grounded = n
   end subroutine build_grounded_mask