ocean_geothermal_apply_tracers Subroutine

public subroutine ocean_geothermal_apply_tracers(grid, geo, ms, dt, active)

Add the geothermal bottom heat flux to the lowest massive tracer layer. Operates in hTr space (concentration thickness): d(hT_{k=1})/dt = Q_geo / (rho0 * cp) (units (W/m^2)/(kg/m^3 * J/kg/K) = Km/s, matching hTr).

No-op when geo is absent, .not. enable, q_geo_const == 0, no temperature tracer is registered, or ms%tracers is unallocated — preserving the default-off bit-identity contract.

Arguments

Type IntentOptional Attributes Name
type(hgrid_t), intent(in) :: grid
type(ocean_geothermal_t), intent(in), optional :: geo

Optional — when absent the kernel is a no-op (no geothermal forcing configured).

type(multilayer_state_t), intent(inout) :: ms
real(kind=wp), intent(in) :: dt
logical, intent(in), optional :: active

Optional gate (thermo cadence). Absent => kernel runs; present-and-false => early return.


Calls

proc~~ocean_geothermal_apply_tracers~~CallsGraph proc~ocean_geothermal_apply_tracers ocean_geothermal_apply_tracers proc~apply_geothermal_src_impl apply_geothermal_src_impl proc~ocean_geothermal_apply_tracers->proc~apply_geothermal_src_impl local local proc~apply_geothermal_src_impl->local

Called by

proc~~ocean_geothermal_apply_tracers~~CalledByGraph proc~ocean_geothermal_apply_tracers ocean_geothermal_apply_tracers proc~run_stage run_stage proc~run_stage->proc~ocean_geothermal_apply_tracers proc~run_stage_split run_stage_split proc~run_stage_split->proc~ocean_geothermal_apply_tracers 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 proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean

Variables

Type Visibility Attributes Name Initial
integer, private :: idx_T
integer, private :: nx
integer, private :: ny
integer, private :: nz
real(kind=wp), private :: src_T

Source Code

   subroutine ocean_geothermal_apply_tracers(grid, geo, ms, dt, active)
      !! Add the geothermal bottom heat flux to the lowest massive
      !! tracer layer.  Operates in `hTr` space (concentration*
      !! thickness):
      !!   d(hT_{k=1})/dt = Q_geo / (rho0 * cp)
      !! (units (W/m^2)/(kg/m^3 * J/kg/K) = K*m/s, matching `hTr`).
      !!
      !! No-op when `geo` is absent, `.not. enable`, `q_geo_const == 0`,
      !! no temperature tracer is registered, or `ms%tracers` is
      !! unallocated — preserving the default-off bit-identity contract.
      type(hgrid_t), intent(in) :: grid
      type(ocean_geothermal_t), intent(in), optional :: geo
         !! Optional — when absent the kernel is a no-op (no geothermal
         !! forcing configured).
      type(multilayer_state_t), intent(inout) :: ms
      real(wp), intent(in) :: dt
      logical, intent(in), optional :: active
         !! Optional gate (thermo cadence).  Absent => kernel runs;
         !! present-and-false => early return.

      integer :: nx, ny, nz, idx_T
      real(wp) :: src_T

      if (present(active)) then
         if (.not. active) return
      end if
      if (.not. present(geo)) return
      if (.not. geo%enable) return
      if (geo%q_geo_const == 0.0_wp) return
      if (.not. allocated(ms%tracers)) return

      idx_T = ms%idx_temperature
      if (idx_T <= 0) return

      nx = grid%nx_total
      ny = grid%ny_total
      nz = ms%nz_ml
      src_T = dt*geo%q_geo_const/(geo%rho0*geo%cp)

      ! Shim+_impl split keeps `tracers(idx)%hTr` deref on the host
      ! (array-of-DT registry indirection blocks NVHPC device codegen).
      call apply_geothermal_src_impl(ms%tracers(idx_T)%hTr, &
                                     ms%heat_budget_geothermal, &
                                     ms%wet_mask, ms%h_layer, ms%k_bot, src_T, nz, &
                                     geo%h_min)
   end subroutine ocean_geothermal_apply_tracers