set_draft_flat Subroutine

public pure subroutine set_draft_flat(z_draft, grid, draft, x0, x1, y0, y1)

Uniform draft draft inside the shelf box [x0,x1] x [y0,y1], zero outside it (open ocean, including everything beyond the calving front at x1). Any bound at or beyond CAVITY_BOUND_INF is ignored — the shelf is then open on that side, which is what the namelist defaults ask for.

Positions are in GRID coordinate units and are compared against the CELL-CENTRE position, built the same way every formula bathymetry setter builds it: x = (i - nghost + i_offset_global - 0.5)*dx. Because the offsets and the global extents come off grid, each rank fills its own window of ONE global shelf; on a single rank the offsets are 0 and this is the undecomposed formula.

FILLS THE FULL ARRAY INCLUDING GHOSTS, by evaluating the formula at the ghost index — the same rule the bathymetry setters follow. A ghost row left at its alloc-time zero would put a phantom calving front one cell outside every wall.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(inout) :: z_draft(:,:)
type(hgrid_t), intent(in) :: grid
real(kind=wp), intent(in) :: draft

Draft depth (m, positive down) inside the box.

real(kind=wp), intent(in) :: x0

Shelf box in GRID coordinate units; a bound at or beyond CAVITY_BOUND_INF is ignored (open on that side).

real(kind=wp), intent(in) :: x1

Shelf box in GRID coordinate units; a bound at or beyond CAVITY_BOUND_INF is ignored (open on that side).

real(kind=wp), intent(in) :: y0

Shelf box in GRID coordinate units; a bound at or beyond CAVITY_BOUND_INF is ignored (open on that side).

real(kind=wp), intent(in) :: y1

Shelf box in GRID coordinate units; a bound at or beyond CAVITY_BOUND_INF is ignored (open on that side).


Calls

proc~~set_draft_flat~~CallsGraph proc~set_draft_flat set_draft_flat proc~in_shelf_box in_shelf_box proc~set_draft_flat->proc~in_shelf_box

Called by

proc~~set_draft_flat~~CalledByGraph proc~set_draft_flat set_draft_flat proc~seed_cavity_draft seed_cavity_draft proc~seed_cavity_draft->proc~set_draft_flat proc~ocean_state_seed_from_cfg ocean_state_seed_from_cfg proc~ocean_state_seed_from_cfg->proc~seed_cavity_draft proc~engine_setup engine_setup proc~engine_setup->proc~ocean_state_seed_from_cfg 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 :: ioff
integer, private :: j
integer, private :: joff
integer, private :: ng
integer, private :: nxt
integer, private :: nyt
real(kind=wp), private :: x_phys
real(kind=wp), private :: y_phys

Source Code

   pure subroutine set_draft_flat(z_draft, grid, draft, x0, x1, y0, y1)
      !! Uniform draft `draft` inside the shelf box `[x0,x1] x [y0,y1]`,
      !! zero outside it (open ocean, including everything beyond the
      !! calving front at `x1`).  Any bound at or beyond
      !! `CAVITY_BOUND_INF` is ignored — the shelf is then open on that
      !! side, which is what the namelist defaults ask for.
      !!
      !! Positions are in GRID coordinate units and are compared against
      !! the CELL-CENTRE position, built the same way every formula
      !! bathymetry setter builds it:
      !! `x = (i - nghost + i_offset_global - 0.5)*dx`.  Because the
      !! offsets and the global extents come off `grid`, each rank fills
      !! its own window of ONE global shelf; on a single rank the offsets
      !! are 0 and this is the undecomposed formula.
      !!
      !! FILLS THE FULL ARRAY INCLUDING GHOSTS, by evaluating the formula
      !! at the ghost index — the same rule the bathymetry setters follow.
      !! A ghost row left at its alloc-time zero would put a phantom
      !! calving front one cell outside every wall.
      real(wp), intent(inout) :: z_draft(:, :)
      type(hgrid_t), intent(in) :: grid
      real(wp), intent(in) :: draft
         !! Draft depth (m, positive down) inside the box.
      real(wp), intent(in) :: x0, x1, y0, y1
         !! Shelf box in GRID coordinate units; a bound at or beyond
         !! `CAVITY_BOUND_INF` is ignored (open on that side).
      integer :: i, j, ng, nxt, nyt, ioff, joff
      real(wp) :: x_phys, y_phys

      ng = grid%nghost
      ioff = grid%i_offset_global
      joff = grid%j_offset_global
      nxt = size(z_draft, 1)
      nyt = size(z_draft, 2)

      do j = 1, nyt
         y_phys = (real(j - ng + joff, wp) - 0.5_wp)*grid%dy
         do i = 1, nxt
            x_phys = (real(i - ng + ioff, wp) - 0.5_wp)*grid%dx
            if (in_shelf_box(x_phys, y_phys, x0, x1, y0, y1)) then
               z_draft(i, j) = draft
            else
               z_draft(i, j) = 0.0_wp
            end if
         end do
      end do
   end subroutine set_draft_flat