apply_surface_restore_2d_impl Subroutine

private pure subroutine apply_surface_restore_2d_impl(hTr, budget, h_layer, wet_mask, dt_piston, tgt, h_min, nz, nx, ny)

Stamp the per-step restoring increment dt·p·(target - surf)· wet_mask onto the top layer (k = nz) of a tracer’s hTr array and mirror it into the matching budget contributor. Explicit-shape dummies so NVHPC stdpar compiles device kernels against static bounds.

dt_piston = dt·piston [m] is the column-invariant multiplier the caller derives from sf (the rho0·cp cancels — see the caller doc). The surface concentration is recovered as hTr(nz) / max(h_layer(nz), h_min); the h_min floor keeps the relaxation finite under a pinched top layer (rate p/h saturates rather than diverges).

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(inout) :: hTr(nx,ny,nz)
real(kind=wp), intent(inout) :: budget(nx,ny,nz)
real(kind=wp), intent(in) :: h_layer(nx,ny,nz)
real(kind=wp), intent(in) :: wet_mask(nx,ny)
real(kind=wp), intent(in) :: dt_piston
real(kind=wp), intent(in) :: tgt
real(kind=wp), intent(in) :: h_min
integer, intent(in) :: nz
integer, intent(in) :: nx
integer, intent(in) :: ny

Calls

proc~~apply_surface_restore_2d_impl~~CallsGraph proc~apply_surface_restore_2d_impl apply_surface_restore_2d_impl local local proc~apply_surface_restore_2d_impl->local

Called by

proc~~apply_surface_restore_2d_impl~~CalledByGraph proc~apply_surface_restore_2d_impl apply_surface_restore_2d_impl proc~ocean_surface_restore_apply_tracers ocean_surface_restore_apply_tracers proc~ocean_surface_restore_apply_tracers->proc~apply_surface_restore_2d_impl proc~apply_sw_and_restore apply_sw_and_restore proc~apply_sw_and_restore->proc~ocean_surface_restore_apply_tracers proc~run_stage run_stage proc~run_stage->proc~apply_sw_and_restore proc~run_stage_split run_stage_split proc~run_stage_split->proc~apply_sw_and_restore proc~ocean_dyn_step ocean_dyn_step proc~ocean_dyn_step->proc~run_stage 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 proc~engine_step->proc~ocean_dyn_step_split

Variables

Type Visibility Attributes Name Initial
integer, private :: i
real(kind=wp), private :: inc
integer, private :: j
real(kind=wp), private :: surf

Source Code

   pure subroutine apply_surface_restore_2d_impl(hTr, budget, h_layer, &
                                                 wet_mask, dt_piston, tgt, &
                                                 h_min, nz, nx, ny)
      !! Stamp the per-step restoring increment `dt·p·(target - surf)·
      !! wet_mask` onto the top layer (k = nz) of a tracer's hTr array
      !! and mirror it into the matching budget contributor.
      !! Explicit-shape dummies so NVHPC stdpar compiles device kernels
      !! against static bounds.
      !!
      !! `dt_piston` = dt·piston [m] is the column-invariant multiplier
      !! the caller derives from `sf` (the `rho0·cp` cancels — see the
      !! caller doc).  The surface concentration is recovered as
      !! `hTr(nz) / max(h_layer(nz), h_min)`; the `h_min` floor keeps the
      !! relaxation finite under a pinched top layer (rate `p/h`
      !! saturates rather than diverges).
      integer, intent(in)    :: nz, nx, ny
      real(wp), intent(inout) :: hTr(nx, ny, nz)
      real(wp), intent(inout) :: budget(nx, ny, nz)
      real(wp), intent(in)    :: h_layer(nx, ny, nz)
      real(wp), intent(in)    :: wet_mask(nx, ny)
      real(wp), intent(in)    :: dt_piston, tgt, h_min
      integer :: i, j
      real(wp) :: surf, inc
      do concurrent(j=1:ny, i=1:nx) local(surf, inc)
         surf = hTr(i, j, nz)/max(h_layer(i, j, nz), h_min)
         inc = dt_piston*(tgt - surf)*wet_mask(i, j)
         hTr(i, j, nz) = hTr(i, j, nz) + inc
         budget(i, j, nz) = budget(i, j, nz) + inc
      end do
   end subroutine apply_surface_restore_2d_impl