ocean_surface_stress_refresh_mag Subroutine

public pure subroutine ocean_surface_stress_refresh_mag(ss)

Recompute stress_mag from the CURRENT tau_x/tau_y, shape taken from the already-allocated arrays (no grid needed — this is the grid-free twin of ocean_surface_stress_set_derived, for callers that hold the slot but not the grid).

Runs where the data lives. ocean_surfstress_derived_impl is a plain do concurrent, so at configure time (before enter_data) this is a host loop over host arrays, and once the slot is device-mapped the SAME call is a device kernel over the mapped tau_x/tau_y/stress_mag. A per-step caller therefore pays no host round trip and no allocation — which is what lets the sea-ice stress coupler (ice_ocean_stress_flux, rdb_ice_ocean_coupler) refresh stress_mag in step with the ice-mediated tau it writes on the device every outer step. Without that refresh KPP (rdb_ocean_vmix) and EPBL (rdb_ocean_epbl) — whose only source of u_* is this field — keep mixing on the configure-time WIND under sea ice.

Arguments

Type IntentOptional Attributes Name
type(ocean_surface_stress_t), intent(inout) :: ss

Calls

proc~~ocean_surface_stress_refresh_mag~~CallsGraph proc~ocean_surface_stress_refresh_mag ocean_surface_stress_refresh_mag proc~ocean_surfstress_derived_impl ocean_surfstress_derived_impl proc~ocean_surface_stress_refresh_mag->proc~ocean_surfstress_derived_impl local local proc~ocean_surfstress_derived_impl->local

Called by

proc~~ocean_surface_stress_refresh_mag~~CalledByGraph proc~ocean_surface_stress_refresh_mag ocean_surface_stress_refresh_mag proc~ice_ocean_stress_flux ice_ocean_stress_flux proc~ice_ocean_stress_flux->proc~ocean_surface_stress_refresh_mag proc~ocean_seam_refresh_surface_stress ocean_seam_refresh_surface_stress proc~ice_ocean_stress_flux->proc~ocean_seam_refresh_surface_stress proc~ice_ocean_stress_resume_apply ice_ocean_stress_resume_apply proc~ice_ocean_stress_resume_apply->proc~ocean_surface_stress_refresh_mag proc~ocean_surface_stress_apply_cover ocean_surface_stress_apply_cover proc~ocean_surface_stress_apply_cover->proc~ocean_surface_stress_refresh_mag proc~ocean_surface_stress_set_derived ocean_surface_stress_set_derived proc~ocean_surface_stress_set_derived->proc~ocean_surface_stress_refresh_mag proc~ocean_surface_stress_set_derived->proc~ocean_surface_stress_apply_cover proc~ocean_surfstress_refresh_stress_mag ocean_surfstress_refresh_stress_mag proc~ocean_surfstress_refresh_stress_mag->proc~ocean_surface_stress_refresh_mag proc~configure_ocean_cavity configure_ocean_cavity proc~configure_ocean_cavity->proc~ocean_surface_stress_apply_cover proc~engine_setup engine_setup proc~engine_setup->proc~ice_ocean_stress_resume_apply proc~engine_setup->proc~configure_ocean_cavity proc~configure_ocean_forcing configure_ocean_forcing proc~engine_setup->proc~configure_ocean_forcing proc~ocean_data_forcing_configure ocean_data_forcing_configure proc~engine_setup->proc~ocean_data_forcing_configure proc~engine_step_ice engine_step_ice proc~engine_step_ice->proc~ice_ocean_stress_flux proc~ocean_seam_refresh_surface_stress->proc~ocean_surface_stress_set_derived proc~ocean_surfstress_set_2gyre ocean_surface_stress_t%ocean_surfstress_set_2gyre proc~ocean_surfstress_set_2gyre->proc~ocean_surfstress_refresh_stress_mag proc~ocean_surfstress_set_const ocean_surface_stress_t%ocean_surfstress_set_const proc~ocean_surfstress_set_const->proc~ocean_surfstress_refresh_stress_mag proc~ocean_surfstress_set_neverworld2 ocean_surface_stress_t%ocean_surfstress_set_neverworld2 proc~ocean_surfstress_set_neverworld2->proc~ocean_surfstress_refresh_stress_mag proc~complete_ocean_create complete_ocean_create proc~complete_ocean_create->proc~engine_setup proc~configure_ocean_forcing->proc~ocean_seam_refresh_surface_stress proc~configure_ocean_forcing->proc~ocean_surfstress_set_2gyre proc~configure_ocean_forcing->proc~ocean_surfstress_set_const proc~configure_ocean_forcing->proc~ocean_surfstress_set_neverworld2 proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_setup proc~driver_run_ocean->proc~engine_step_ice proc~engine_step engine_step proc~driver_run_ocean->proc~engine_step proc~driver_validate driver_validate proc~driver_validate->proc~engine_setup proc~ocean_data_forcing_apply ocean_data_forcing_apply proc~ocean_data_forcing_apply->proc~ocean_seam_refresh_surface_stress proc~ocean_data_forcing_configure->proc~ocean_seam_refresh_surface_stress proc~rdb_ocean_step rdb_ocean_step proc~rdb_ocean_step->proc~engine_step_ice proc~rdb_ocean_step->proc~engine_step proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean proc~engine_step->proc~ocean_data_forcing_apply 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 :: nx
integer, private :: ny

Source Code

   pure subroutine ocean_surface_stress_refresh_mag(ss)
      !! Recompute `stress_mag` from the CURRENT `tau_x`/`tau_y`, shape
      !! taken from the already-allocated arrays (no `grid` needed — this
      !! is the grid-free twin of `ocean_surface_stress_set_derived`, for
      !! callers that hold the slot but not the grid).
      !!
      !! **Runs where the data lives.**  `ocean_surfstress_derived_impl` is
      !! a plain `do concurrent`, so at configure time (before
      !! `enter_data`) this is a host loop over host arrays, and once the
      !! slot is device-mapped the SAME call is a device kernel over the
      !! mapped `tau_x`/`tau_y`/`stress_mag`.  A per-step caller therefore
      !! pays no host round trip and no allocation — which is what lets the
      !! sea-ice stress coupler (`ice_ocean_stress_flux`,
      !! `rdb_ice_ocean_coupler`) refresh `stress_mag` in step with the
      !! ice-mediated `tau` it writes on the device every outer step.
      !! Without that refresh KPP (`rdb_ocean_vmix`) and EPBL
      !! (`rdb_ocean_epbl`) — whose only source of `u_*` is this field —
      !! keep mixing on the configure-time WIND under sea ice.
      type(ocean_surface_stress_t), intent(inout) :: ss
      integer :: nx, ny
      nx = size(ss%tau_x, 1) - 1
      ny = size(ss%tau_x, 2)
      call ocean_surfstress_derived_impl(ss%tau_x, ss%tau_y, ss%stress_mag, nx, ny)
      ss%has_stress_mag = .true.
   end subroutine ocean_surface_stress_refresh_mag