surfstress_compute_impl Subroutine

private pure subroutine surfstress_compute_impl(h_layer, wet_mask, tau_x, tau_y, du_stress, dv_stress, rho0, h_min, nx, ny, nz)

Flat-array surface-stress kernel. Explicit-shape dummies so NVHPC stdpar can compile the device kernel against static bounds.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: h_layer(nx,ny,nz)
real(kind=wp), intent(in) :: wet_mask(nx,ny)
real(kind=wp), intent(in) :: tau_x(nx+1,ny)
real(kind=wp), intent(in) :: tau_y(nx,ny+1)
real(kind=wp), intent(inout) :: du_stress(nx+1,ny,nz)
real(kind=wp), intent(inout) :: dv_stress(nx,ny+1,nz)
real(kind=wp), intent(in) :: rho0
real(kind=wp), intent(in) :: h_min
integer, intent(in) :: nx
integer, intent(in) :: ny
integer, intent(in) :: nz

Calls

proc~~surfstress_compute_impl~~CallsGraph proc~surfstress_compute_impl surfstress_compute_impl local local proc~surfstress_compute_impl->local

Called by

proc~~surfstress_compute_impl~~CalledByGraph proc~surfstress_compute_impl surfstress_compute_impl proc~ocean_surface_stress_compute_tendencies ocean_surface_stress_compute_tendencies proc~ocean_surface_stress_compute_tendencies->proc~surfstress_compute_impl proc~run_stage run_stage proc~run_stage->proc~ocean_surface_stress_compute_tendencies proc~run_stage_split run_stage_split proc~run_stage_split->proc~ocean_surface_stress_compute_tendencies 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 proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_step proc~rdb_ocean_step rdb_ocean_step proc~rdb_ocean_step->proc~engine_step

Variables

Type Visibility Attributes Name Initial
real(kind=wp), private :: h_top_face
integer, private :: i
real(kind=wp), private :: inv_rho0
integer, private :: j
integer, private :: k

Source Code

   pure subroutine surfstress_compute_impl(h_layer, wet_mask, tau_x, tau_y, &
                                           du_stress, dv_stress, &
                                           rho0, h_min, nx, ny, nz)
      !! Flat-array surface-stress kernel.  Explicit-shape dummies so
      !! NVHPC stdpar can compile the device kernel against static
      !! bounds.
      integer, intent(in)    :: nx, ny, nz
      real(wp), intent(in)    :: h_layer(nx, ny, nz), wet_mask(nx, ny)
      real(wp), intent(in)    :: tau_x(nx + 1, ny), tau_y(nx, ny + 1)
      real(wp), intent(inout) :: du_stress(nx + 1, ny, nz), dv_stress(nx, ny + 1, nz)
      real(wp), intent(in)    :: rho0, h_min
      integer :: i, j, k
      real(wp) :: inv_rho0, h_top_face

      inv_rho0 = 1.0_wp/rho0

      do concurrent(k=1:nz, j=1:ny, i=1:nx + 1)
         du_stress(i, j, k) = 0.0_wp
      end do
      do concurrent(k=1:nz, j=1:ny + 1, i=1:nx)
         dv_stress(i, j, k) = 0.0_wp
      end do

      ! Face wet-mask: only apply stress at faces between two ocean
      ! cells.  `min(wet_left, wet_right)` zeros stress at any face
      ! that touches land.  Default mask (all 1.0) preserves the
      ! flat-bottom / analytical behaviour bit-identically.
      do concurrent(j=1:ny, i=2:nx) local(h_top_face)
         h_top_face = 0.5_wp*(h_layer(i - 1, j, nz) + h_layer(i, j, nz))
         h_top_face = max(h_top_face, h_min)
         du_stress(i, j, nz) = &
            min(wet_mask(i - 1, j), wet_mask(i, j))* &
            tau_x(i, j)*inv_rho0/h_top_face
      end do
      do concurrent(j=2:ny, i=1:nx) local(h_top_face)
         h_top_face = 0.5_wp*(h_layer(i, j - 1, nz) + h_layer(i, j, nz))
         h_top_face = max(h_top_face, h_min)
         dv_stress(i, j, nz) = &
            min(wet_mask(i, j - 1), wet_mask(i, j))* &
            tau_y(i, j)*inv_rho0/h_top_face
      end do
   end subroutine surfstress_compute_impl