ocean_stability_min_cell Subroutine

private pure subroutine ocean_stability_min_cell(metrics, grid, dx_min, i_at, j_at, is_x)

Smallest actual cell edge over the WET PHYSICAL domain (excludes ghosts and land), taken over BOTH dxT and dyT, with its (i,j) location and which axis (is_x) it came from — for actionable messages (“near j=110”). Host-side, configure time; the grid sizes here are at most a few 10^5 cells (a global tripolar config), trivial to scan once.

Wet cells only (metrics%wet_T > 0.5): no viscous or diffusive operator acts on a land cell, and on the 1° tripolar grid the smallest cell anywhere is a 362 m LAND cell at a land-locked bipole, which made the viscous-CFL check abort a configuration whose smallest OCEAN cell was comfortably inside the bound. Where the smallest cell is wet (every all-wet grid) the result is unchanged, value and location. No wet cell ⇒ dx_min = huge, which the caller already treats as “no constraint expressible”.

Arguments

Type IntentOptional Attributes Name
type(ocean_metrics_t), intent(in) :: metrics
type(hgrid_t), intent(in) :: grid
real(kind=wp), intent(out) :: dx_min
integer, intent(out) :: i_at
integer, intent(out) :: j_at
logical, intent(out) :: is_x

Called by

proc~~ocean_stability_min_cell~~CalledByGraph proc~ocean_stability_min_cell ocean_stability_min_cell proc~ocean_stability_audit ocean_stability_audit proc~ocean_stability_audit->proc~ocean_stability_min_cell proc~engine_setup engine_setup proc~engine_setup->proc~ocean_stability_audit 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 :: i0
integer, private :: i1
integer, private :: j
integer, private :: j0
integer, private :: j1
integer, private :: ng

Source Code

   pure subroutine ocean_stability_min_cell(metrics, grid, dx_min, i_at, j_at, is_x)
      !! Smallest actual cell edge over the WET PHYSICAL domain (excludes
      !! ghosts and land), taken over BOTH `dxT` and `dyT`, with its (i,j)
      !! location and which axis (`is_x`) it came from — for actionable
      !! messages ("near j=110"). Host-side, configure time; the grid
      !! sizes here are at most a few 10^5 cells (a global tripolar
      !! config), trivial to scan once.
      !!
      !! **Wet cells only** (`metrics%wet_T > 0.5`): no viscous or
      !! diffusive operator acts on a land cell, and on the 1° tripolar
      !! grid the smallest cell anywhere is a 362 m LAND cell at a
      !! land-locked bipole, which made the viscous-CFL check abort a
      !! configuration whose smallest OCEAN cell was comfortably inside
      !! the bound.  Where the smallest cell is wet (every all-wet grid)
      !! the result is unchanged, value and location.  No wet cell ⇒
      !! `dx_min = huge`, which the caller already treats as "no
      !! constraint expressible".
      type(ocean_metrics_t), intent(in) :: metrics
      type(hgrid_t), intent(in) :: grid
      real(wp), intent(out) :: dx_min
      integer, intent(out) :: i_at, j_at
      logical, intent(out) :: is_x
      integer :: i, j, ng, i0, i1, j0, j1

      ng = grid%nghost
      i0 = ng + 1
      i1 = ng + grid%nx_phys
      j0 = ng + 1
      j1 = ng + grid%ny_phys
      dx_min = huge(1.0_wp)
      i_at = i0
      j_at = j0
      is_x = .true.
      do j = j0, j1
         do i = i0, i1
            if (metrics%wet_T(i, j) <= 0.5_wp) cycle
            if (metrics%dxT(i, j) < dx_min) then
               dx_min = metrics%dxT(i, j)
               i_at = i
               j_at = j
               is_x = .true.
            end if
            if (metrics%dyT(i, j) < dx_min) then
               dx_min = metrics%dyT(i, j)
               i_at = i
               j_at = j
               is_x = .false.
            end if
         end do
      end do
   end subroutine ocean_stability_min_cell