sponge_add_band_x Subroutine

private pure subroutine sponge_add_band_x(idamp_h, idamp_u, idamp_v, wall_face, band, strength, side, j0, j1, ramp)

Add a cosine-ramp Idamp band for a west/east (x-normal) sponge edge into the three maps, SUMMING onto whatever is already there (§3.2 corner composition). Offsets reproduce rdb_ocean_sponge::ocean_sponge_apply{,_tracers} exactly: idamp_h/idamp_v share the cell-column offset; idamp_u (the x-normal face) sits one further column in for the west edge (side = +1) and shares the offset for the east edge (side = -1) — the legacy kernel’s own asymmetry (see Risk 2 of the plan), reproduced verbatim so damp_source="band" matches today’s band exactly.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(inout) :: idamp_h(:,:)
real(kind=wp), intent(inout) :: idamp_u(:,:)
real(kind=wp), intent(inout) :: idamp_v(:,:)
integer, intent(in) :: wall_face
integer, intent(in) :: band
real(kind=wp), intent(in) :: strength
integer, intent(in) :: side
integer, intent(in) :: j0
integer, intent(in) :: j1
integer, intent(in) :: ramp

SPONGE_RAMP_COSINE (default, the legacy shape, bit-identical) or SPONGE_RAMP_LINEAR (ISOMIP+ Eq. 20 at cell centres).


Calls

proc~~sponge_add_band_x~~CallsGraph proc~sponge_add_band_x sponge_add_band_x proc~sponge_band_alpha sponge_band_alpha proc~sponge_add_band_x->proc~sponge_band_alpha

Called by

proc~~sponge_add_band_x~~CalledByGraph proc~sponge_add_band_x sponge_add_band_x proc~configure_ocean_sponge configure_ocean_sponge proc~configure_ocean_sponge->proc~sponge_add_band_x proc~engine_setup engine_setup proc~engine_setup->proc~configure_ocean_sponge 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
real(kind=wp), private :: alpha
integer, private :: d
integer, private :: i_h
integer, private :: i_u
integer, private :: j
real(kind=wp), private :: rate

Source Code

   pure subroutine sponge_add_band_x(idamp_h, idamp_u, idamp_v, wall_face, band, &
                                     strength, side, j0, j1, ramp)
      !! Add a cosine-ramp `Idamp` band for a west/east (x-normal) sponge
      !! edge into the three maps, SUMMING onto whatever is already there
      !! (§3.2 corner composition). Offsets reproduce
      !! `rdb_ocean_sponge::ocean_sponge_apply{,_tracers}` exactly:
      !! `idamp_h`/`idamp_v` share the cell-column offset; `idamp_u` (the
      !! x-normal face) sits one further column in for the west edge (`side
      !! = +1`) and shares the offset for the east edge (`side = -1`) — the
      !! legacy kernel's own asymmetry (see Risk 2 of the plan), reproduced
      !! verbatim so `damp_source="band"` matches today's band exactly.
      real(wp), intent(inout) :: idamp_h(:, :), idamp_u(:, :), idamp_v(:, :)
      integer, intent(in) :: wall_face, band, side, j0, j1
      integer, intent(in) :: ramp
         !! `SPONGE_RAMP_COSINE` (default, the legacy shape, bit-identical)
         !! or `SPONGE_RAMP_LINEAR` (ISOMIP+ Eq. 20 at cell centres).
      real(wp), intent(in) :: strength

      integer :: d, j, i_h, i_u
      real(wp) :: rate, alpha

      do d = 0, band - 1
         ! `sponge_band_alpha` holds both shapes; its cosine branch keeps
         ! the legacy kernel's own `acos(-1.0_wp)` spelling of pi
         ! bit-for-bit (rather than `rdb_constants::PI`, a `4*atan(1)`
         ! formulation) — test 9.4 pins the band to 1e-14.
         alpha = sponge_band_alpha(d, band, ramp)
         rate = strength*alpha
         if (side > 0) then
            i_h = wall_face + d
            i_u = wall_face + d + 1
         else
            i_h = wall_face - d - 1
            i_u = wall_face - d - 1
         end if
         if (i_h >= 1 .and. i_h <= size(idamp_h, 1)) then
            do j = j0, j1
               idamp_h(i_h, j) = idamp_h(i_h, j) + rate
            end do
            do j = j0, j1 + 1
               idamp_v(i_h, j) = idamp_v(i_h, j) + rate
            end do
         end if
         if (i_u >= 1 .and. i_u <= size(idamp_u, 1)) then
            do j = j0, j1
               idamp_u(i_u, j) = idamp_u(i_u, j) + rate
            end do
         end if
      end do
   end subroutine sponge_add_band_x