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).
| Type | Intent | Optional | 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 |
| 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 |
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