eos_density_point Function

public pure function eos_density_point(eos, T, S, p) result(rho)

Scalar density evaluation at a point — the same formulas the 3D eos_*_impl kernels apply, exposed for finite-difference verification of eos_specvol_derivs and for host-side diagnostics. Takes the shared eos_t handle by value. The else is unreachable-by-contract (see eos_validate).

Arguments

Type IntentOptional Attributes Name
type(eos_t), intent(in) :: eos
real(kind=wp), intent(in) :: T
real(kind=wp), intent(in) :: S
real(kind=wp), intent(in) :: p

Return Value real(kind=wp)


Calls

proc~~eos_density_point~~CallsGraph proc~eos_density_point eos_density_point proc~roquet_spv_value roquet_spv_value proc~eos_density_point->proc~roquet_spv_value 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~~eos_density_point~~CalledByGraph proc~eos_density_point eos_density_point proc~boole_dpa_intz_layer boole_dpa_intz_layer proc~boole_dpa_intz_layer->proc~eos_density_point proc~ocean_vcoord_rho_target_column ocean_vcoord_rho_target_column proc~ocean_vcoord_rho_target_column->proc~eos_density_point proc~remap_layer_to_density_impl remap_layer_to_density_impl proc~remap_layer_to_density_impl->proc~eos_density_point proc~boole_dpa_face boole_dpa_face proc~boole_dpa_face->proc~boole_dpa_intz_layer proc~boole_dpa_face_pcm boole_dpa_face_pcm proc~boole_dpa_face_pcm->proc~boole_dpa_intz_layer proc~compute_fv_mom6_reconstruct_impl compute_fv_mom6_reconstruct_impl proc~compute_fv_mom6_reconstruct_impl->proc~boole_dpa_intz_layer proc~compute_fv_mom6_reconstruct_impl->proc~boole_dpa_face proc~ocean_vcoord_rho_target ocean_vcoord_rho_target proc~ocean_vcoord_rho_target->proc~ocean_vcoord_rho_target_column proc~remap_layer_to_density remap_layer_to_density proc~remap_layer_to_density->proc~remap_layer_to_density_impl proc~ocean_pressure_force_compute ocean_pressure_force_compute proc~ocean_pressure_force_compute->proc~compute_fv_mom6_reconstruct_impl proc~ocean_vcoord_compute_target_h_rho_impl ocean_vcoord_compute_target_h_rho_impl proc~ocean_vcoord_compute_target_h_rho_impl->proc~ocean_vcoord_rho_target proc~ocean_vcoord_compute_target_h_rho ocean_vcoord_t%ocean_vcoord_compute_target_h_rho proc~ocean_vcoord_compute_target_h_rho->proc~ocean_vcoord_compute_target_h_rho_impl proc~run_stage run_stage proc~run_stage->proc~ocean_pressure_force_compute proc~run_stage_split run_stage_split proc~run_stage_split->proc~ocean_pressure_force_compute proc~ocean_apply_ale_remap_centres ocean_apply_ale_remap_centres proc~ocean_apply_ale_remap_centres->proc~ocean_vcoord_compute_target_h_rho proc~ocean_apply_ale_remap_step ocean_apply_ale_remap_step proc~ocean_apply_ale_remap_step->proc~ocean_vcoord_compute_target_h_rho 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

Variables

Type Visibility Attributes Name Initial
real(kind=wp), private :: T_sq
real(kind=wp), private :: alpha_0
real(kind=wp), private :: lambda
real(kind=wp), private :: p_0
real(kind=wp), private :: p_plus_p0

Source Code

   pure function eos_density_point(eos, T, S, p) result(rho)
      !! Scalar density evaluation at a point — the same formulas the
      !! 3D `eos_*_impl` kernels apply, exposed for finite-difference
      !! verification of `eos_specvol_derivs` and for host-side
      !! diagnostics.  Takes the shared `eos_t` handle by value.
      !! The `else` is unreachable-by-contract (see
      !! `eos_validate`).
      !$acc routine seq
      type(eos_t), intent(in) :: eos
      real(wp), intent(in) :: T, S, p
      real(wp) :: rho

      real(wp) :: T_sq, alpha_0, p_0, lambda, p_plus_p0

      if (eos%variant == EOS_VARIANT_ROQUET_SPV) then
         ! Value-only: no discarded derivative work.
         rho = 1.0_wp/roquet_spv_value(T, S, p)
      else if (eos%variant == EOS_VARIANT_WRIGHT_97) then
         T_sq = T*T
         alpha_0 = WRIGHT_A0 + WRIGHT_A1*T + WRIGHT_A2*S
         p_0 = WRIGHT_B0 + WRIGHT_B1*T + WRIGHT_B2*T_sq + WRIGHT_B3*T_sq*T + &
               WRIGHT_B4*S + WRIGHT_B5*S*T
         lambda = WRIGHT_C0 + WRIGHT_C1*T + WRIGHT_C2*T_sq + WRIGHT_C3*T_sq*T + &
                  WRIGHT_C4*S + WRIGHT_C5*S*T
         p_plus_p0 = p + p_0
         rho = p_plus_p0/(lambda + alpha_0*p_plus_p0)
      else
         rho = eos%rho0 + eos%beta_S*(S - eos%S_ref) - eos%alpha_T*(T - eos%T_ref)
      end if
   end function eos_density_point