ocean_vcoord_count_ledges Function

public pure function ocean_vcoord_count_ledges(open_u, open_v, target_h, nx, ny, nz, h_vanished) result(n_ledge)

Count LEDGE cells: a cell that is LIVE at layer k but all four of whose own-layer faces are closed, i.e. water the mask has isolated. A ledge needs a one-cell-wide spike in the bed or the draft; it is inert by construction (no flux in or out, and its velocity is zeroed every stage), but a non-zero count is worth saying out loud once at configure, because it means the mask is walling off real water.

Interior cells only (2:nx-1, 2:ny-1) — the ghost ring has no four-face neighbourhood of its own.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: open_u(nx+1,ny,nz)
real(kind=wp), intent(in) :: open_v(nx,ny+1,nz)
real(kind=wp), intent(in) :: target_h(nx,ny,nz)
integer, intent(in) :: nx
integer, intent(in) :: ny
integer, intent(in) :: nz
real(kind=wp), intent(in) :: h_vanished

Return Value integer


Called by

proc~~ocean_vcoord_count_ledges~~CalledByGraph proc~ocean_vcoord_count_ledges ocean_vcoord_count_ledges proc~configure_ocean_closed_faces configure_ocean_closed_faces proc~configure_ocean_closed_faces->proc~ocean_vcoord_count_ledges proc~engine_setup engine_setup proc~engine_setup->proc~configure_ocean_closed_faces proc~complete_ocean_create complete_ocean_create proc~complete_ocean_create->proc~engine_setup proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_setup proc~driver_validate driver_validate proc~driver_validate->proc~engine_setup proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean proc~rdb_ocean_create_finalize rdb_ocean_create_finalize proc~rdb_ocean_create_finalize->proc~complete_ocean_create proc~rdb_ocean_create_from_string rdb_ocean_create_from_string proc~rdb_ocean_create_from_string->proc~complete_ocean_create

Variables

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

Source Code

   pure function ocean_vcoord_count_ledges(open_u, open_v, target_h, &
                                           nx, ny, nz, h_vanished) result(n_ledge)
      !! Count LEDGE cells: a cell that is LIVE at layer `k` but all four
      !! of whose own-layer faces are closed, i.e. water the mask has
      !! isolated.  A ledge needs a one-cell-wide spike in the bed or the
      !! draft; it is inert by construction (no flux in or out, and its
      !! velocity is zeroed every stage), but a non-zero count is worth
      !! saying out loud once at configure, because it means the mask is
      !! walling off real water.
      !!
      !! Interior cells only (`2:nx-1`, `2:ny-1`) — the ghost ring has no
      !! four-face neighbourhood of its own.
      integer, intent(in) :: nx, ny, nz
      real(wp), intent(in) :: open_u(nx + 1, ny, nz)
      real(wp), intent(in) :: open_v(nx, ny + 1, nz)
      real(wp), intent(in) :: target_h(nx, ny, nz)
      real(wp), intent(in) :: h_vanished
      integer :: n_ledge
      integer :: i, j, k

      n_ledge = 0
      do k = 1, nz
         do j = 2, ny - 1
            do i = 2, nx - 1
               if (target_h(i, j, k) <= h_vanished) cycle
               if (open_u(i, j, k) == 0.0_wp .and. &
                   open_u(i + 1, j, k) == 0.0_wp .and. &
                   open_v(i, j, k) == 0.0_wp .and. &
                   open_v(i, j + 1, k) == 0.0_wp) then
                  n_ledge = n_ledge + 1
               end if
            end do
         end do
      end do
   end function ocean_vcoord_count_ledges