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).
| Type | Intent | Optional | 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 |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private | :: | i | ||||
| real(kind=wp), | private | :: | inc | ||||
| integer, | private | :: | j | ||||
| real(kind=wp), | private | :: | surf |
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