ocean_eos_compute Subroutine

public subroutine ocean_eos_compute(eos, ms, active)

Compute ms%rho_layer from the registered (T, S) tracers. Outer-shim pattern: pulls the tracer hTr arrays off the registry on the host and forwards them as bare 3D arrays to a flat-impl chosen by eos%variant.

Supported variants: EOS_VARIANT_LINEAR — eos_linear_impl EOS_VARIANT_WRIGHT_97 — eos_wright_impl at eos%p_ref

ms%rho_layer is a POTENTIAL density at the single, horizontally uniform eos%p_ref (&ocean_eos_nml p_ref). It is deliberately NOT offset by the surface load ms%p_top: its consumers difference it along a layer and vertically, so a per-column reference pressure would manufacture a spurious along-layer density gradient — see the contract on eos_compute_arrays. The N² builders in rdb_ocean_vmix inherit that uniform reference and stay consistent with it.

The in-situ-pressure Wright branch lives in the FV-PGF column sweep (eos_wright_pgf_column_sweep_impl), which owns its own pressure/density column scratch on the PGF state — not an EOS field. THAT is where ms%p_top lands, because there the pressure is a true per-layer hydrostatic one.

Optional active lets the dyn-step driver call this unconditionally — when present and false (thermodynamics disabled or non-thermo substep) the kernel is a no-op.

Arguments

Type IntentOptional Attributes Name
type(eos_t), intent(in) :: eos
type(multilayer_state_t), intent(inout) :: ms
logical, intent(in), optional :: active

Calls

proc~~ocean_eos_compute~~CallsGraph proc~ocean_eos_compute ocean_eos_compute proc~eos_compute_arrays eos_compute_arrays proc~ocean_eos_compute->proc~eos_compute_arrays proc~eos_linear_impl eos_linear_impl proc~eos_compute_arrays->proc~eos_linear_impl proc~eos_roquet_spv_impl eos_roquet_spv_impl proc~eos_compute_arrays->proc~eos_roquet_spv_impl proc~eos_wright_impl eos_wright_impl proc~eos_compute_arrays->proc~eos_wright_impl local local proc~eos_linear_impl->local proc~eos_roquet_spv_impl->local proc~roquet_spv_value roquet_spv_value proc~eos_roquet_spv_impl->proc~roquet_spv_value proc~eos_wright_impl->local rdb_roq_spv_p rdb_roq_spv_p proc~roquet_spv_value->rdb_roq_spv_p rdb_roq_ts_coeffs rdb_roq_ts_coeffs proc~roquet_spv_value->rdb_roq_ts_coeffs

Called by

proc~~ocean_eos_compute~~CalledByGraph proc~ocean_eos_compute ocean_eos_compute proc~rdb_ocean_set_h rdb_ocean_set_h proc~rdb_ocean_set_h->proc~ocean_eos_compute proc~rdb_ocean_set_tracer rdb_ocean_set_tracer proc~rdb_ocean_set_tracer->proc~ocean_eos_compute proc~run_stage run_stage proc~run_stage->proc~ocean_eos_compute proc~run_stage_split run_stage_split proc~run_stage_split->proc~ocean_eos_compute 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 :: nx
integer, private :: ny
integer, private :: nz

Source Code

   subroutine ocean_eos_compute(eos, ms, active)
      !! Compute `ms%rho_layer` from the registered (T, S) tracers.
      !! Outer-shim pattern: pulls the tracer hTr arrays off the
      !! registry on the host and forwards them as bare 3D arrays
      !! to a flat-impl chosen by `eos%variant`.
      !!
      !! Supported variants:
      !!   EOS_VARIANT_LINEAR    — `eos_linear_impl`
      !!   EOS_VARIANT_WRIGHT_97 — `eos_wright_impl` at `eos%p_ref`
      !!
      !! `ms%rho_layer` is a POTENTIAL density at the single, horizontally
      !! uniform `eos%p_ref` (`&ocean_eos_nml p_ref`).  It is deliberately
      !! NOT offset by the surface load `ms%p_top`: its consumers
      !! difference it along a layer and vertically, so a per-column
      !! reference pressure would manufacture a spurious along-layer
      !! density gradient — see the contract on `eos_compute_arrays`.
      !! The N² builders in `rdb_ocean_vmix` inherit that uniform
      !! reference and stay consistent with it.
      !!
      !! The in-situ-pressure Wright branch lives in the FV-PGF
      !! column sweep (`eos_wright_pgf_column_sweep_impl`), which
      !! owns its own pressure/density column scratch on the PGF
      !! state — not an EOS field.  THAT is where `ms%p_top` lands,
      !! because there the pressure is a true per-layer hydrostatic one.
      !!
      !! Optional `active` lets the dyn-step driver call this
      !! unconditionally — when present and false (thermodynamics
      !! disabled or non-thermo substep) the kernel is a no-op.
      type(eos_t), intent(in) :: eos
      type(multilayer_state_t), intent(inout) :: ms
      logical, intent(in), optional :: active

      integer :: nx, ny, nz

      if (present(active)) then
         if (.not. active) return
      end if

      nx = size(ms%h_layer, 1)
      ny = size(ms%h_layer, 2)
      nz = ms%nz_ml

      if (ms%idx_salinity <= 0 .or. ms%idx_temperature <= 0) return

      call eos_compute_arrays(eos, ms%h_layer, &
                              ms%tracers(ms%idx_salinity)%hTr, &
                              ms%tracers(ms%idx_temperature)%hTr, &
                              ms%rho_layer, nx, ny, nz)
   end subroutine ocean_eos_compute