MOM6
mom_eos_wright Module Reference

Detailed Description

The equation of state using the Wright 1997 expressions.

Data Types

interface  calculate_density_derivs_wright
 For a given thermodynamic state, return the derivatives of density with temperature and salinity. More...
 
interface  calculate_density_second_derivs_wright
 For a given thermodynamic state, return the second derivatives of density with various combinations of temperature, salinity, and pressure. More...
 
interface  calculate_density_wright
 Compute the in situ density of sea water (in [kg m-3]), or its anomaly with respect to a reference density, from salinity (in psu), potential temperature (in deg C), and pressure [Pa], using the expressions from Wright, 1997, J. Atmos. Ocean. Tech., 14, 735-740. More...
 
interface  calculate_spec_vol_wright
 Compute the in situ specific volume of sea water (in [m3 kg-1]), or an anomaly with respect to a reference specific volume, from salinity (in psu), potential temperature (in deg C), and pressure [Pa], using the expressions from Wright, 1997, J. Atmos. Ocean. Tech., 14, 735-740. More...
 
real, parameter a0 = 7.057924e-4
 Parameters in the Wright equation of state. More...
 
real, parameter a1 = 3.480336e-7
 Parameters in the Wright equation of state. More...
 
real, parameter a2 = -1.112733e-7
 Parameters in the Wright equation of state. More...
 
real, parameter b0 = 5.790749e8
 Parameters in the Wright equation of state. More...
 
real, parameter b1 = 3.516535e6
 Parameters in the Wright equation of state. More...
 
real, parameter b2 = -4.002714e4
 Parameters in the Wright equation of state. More...
 
real, parameter b3 = 2.084372e2
 Parameters in the Wright equation of state. More...
 
real, parameter b4 = 5.944068e5
 Parameters in the Wright equation of state. More...
 
real, parameter b5 = -9.643486e3
 Parameters in the Wright equation of state. More...
 
real, parameter c0 = 1.704853e5
 Parameters in the Wright equation of state. More...
 
real, parameter c1 = 7.904722e2
 Parameters in the Wright equation of state. More...
 
real, parameter c2 = -7.984422
 Parameters in the Wright equation of state. More...
 
real, parameter c3 = 5.140652e-2
 Parameters in the Wright equation of state. More...
 
real, parameter c4 = -2.302158e2
 Parameters in the Wright equation of state. More...
 
real, parameter c5 = -3.079464
 Parameters in the Wright equation of state. More...
 
subroutine calculate_density_scalar_wright (T, S, pressure, rho, rho_ref)
 This subroutine computes the in situ density of sea water (rho in [kg m-3]) from salinity (S [PSU]), potential temperature (T [degC]), and pressure [Pa]. It uses the expression from Wright, 1997, J. Atmos. Ocean. Tech., 14, 735-740. More...
 
subroutine calculate_density_array_wright (T, S, pressure, rho, start, npts, rho_ref)
 This subroutine computes the in situ density of sea water (rho in [kg m-3]) from salinity (S [PSU]), potential temperature (T [degC]), and pressure [Pa]. It uses the expression from Wright, 1997, J. Atmos. Ocean. Tech., 14, 735-740. More...
 
subroutine calculate_spec_vol_scalar_wright (T, S, pressure, specvol, spv_ref)
 This subroutine computes the in situ specific volume of sea water (specvol in [m3 kg-1]) from salinity (S [PSU]), potential temperature (T [degC]) and pressure [Pa]. It uses the expression from Wright, 1997, J. Atmos. Ocean. Tech., 14, 735-740. If spv_ref is present, specvol is an anomaly from spv_ref. More...
 
subroutine calculate_spec_vol_array_wright (T, S, pressure, specvol, start, npts, spv_ref)
 This subroutine computes the in situ specific volume of sea water (specvol in [m3 kg-1]) from salinity (S [PSU]), potential temperature (T [degC]) and pressure [Pa]. It uses the expression from Wright, 1997, J. Atmos. Ocean. Tech., 14, 735-740. If spv_ref is present, specvol is an anomaly from spv_ref. More...
 
subroutine calculate_density_derivs_array_wright (T, S, pressure, drho_dT, drho_dS, start, npts)
 For a given thermodynamic state, return the thermal/haline expansion coefficients. More...
 
subroutine calculate_density_derivs_scalar_wright (T, S, pressure, drho_dT, drho_dS)
 The scalar version of calculate_density_derivs which promotes scalar inputs to a 1-element array and then demotes the output back to a scalar. More...
 
subroutine calculate_density_second_derivs_array_wright (T, S, P, drho_ds_ds, drho_ds_dt, drho_dt_dt, drho_ds_dp, drho_dt_dp, start, npts)
 Second derivatives of density with respect to temperature, salinity, and pressure. More...
 
subroutine calculate_density_second_derivs_scalar_wright (T, S, P, drho_ds_ds, drho_ds_dt, drho_dt_dt, drho_ds_dp, drho_dt_dp)
 Second derivatives of density with respect to temperature, salinity, and pressure for scalar inputs. Inputs promoted to 1-element array and output demoted to scalar. More...
 
subroutine, public calculate_specvol_derivs_wright (T, S, pressure, dSV_dT, dSV_dS, start, npts)
 For a given thermodynamic state, return the partial derivatives of specific volume with temperature and salinity. More...
 
subroutine, public calculate_compress_wright (T, S, pressure, rho, drho_dp, start, npts)
 This subroutine computes the in situ density of sea water (rho in [kg m-3]) and the compressibility (drho/dp = C_sound^-2) (drho_dp [s2 m-2]) from salinity (sal in psu), potential temperature (T [degC]), and pressure [Pa]. It uses the expressions from Wright, 1997, J. Atmos. Ocean. Tech., 14, 735-740. Coded by R. Hallberg, 1/01. More...
 
subroutine, public int_density_dz_wright (T, S, z_t, z_b, rho_ref, rho_0, G_e, HII, HIO, dpa, intz_dpa, intx_dpa, inty_dpa, bathyT, dz_neglect, useMassWghtInterp)
 This subroutine calculates analytical and nearly-analytical integrals of pressure anomalies across layers, which are required for calculating the finite-volume form pressure accelerations in a Boussinesq model. More...
 
subroutine, public int_spec_vol_dp_wright (T, S, p_t, p_b, spv_ref, HI, dza, intp_dza, intx_dza, inty_dza, halo_size, bathyP, dP_neglect, useMassWghtInterp)
 This subroutine calculates analytical and nearly-analytical integrals in pressure across layers of geopotential anomalies, which are required for calculating the finite-volume form pressure accelerations in a non-Boussinesq model. There are essentially no free assumptions, apart from the use of Bode's rule to do the horizontal integrals, and from a truncation in the series for log(1-eps/1+eps) that assumes that |eps| < 0.34. More...
 

Function/Subroutine Documentation

◆ calculate_compress_wright()

subroutine, public mom_eos_wright::calculate_compress_wright ( real, dimension(:), intent(in)  T,
real, dimension(:), intent(in)  S,
real, dimension(:), intent(in)  pressure,
real, dimension(:), intent(out)  rho,
real, dimension(:), intent(out)  drho_dp,
integer, intent(in)  start,
integer, intent(in)  npts 
)

This subroutine computes the in situ density of sea water (rho in [kg m-3]) and the compressibility (drho/dp = C_sound^-2) (drho_dp [s2 m-2]) from salinity (sal in psu), potential temperature (T [degC]), and pressure [Pa]. It uses the expressions from Wright, 1997, J. Atmos. Ocean. Tech., 14, 735-740. Coded by R. Hallberg, 1/01.

Parameters
[in]tPotential temperature relative to the surface [degC].
[in]sSalinity [PSU].
[in]pressurepressure [Pa].
[out]rhoIn situ density [kg m-3].
[out]drho_dpThe partial derivative of density with pressure (also the inverse of the square of sound speed) [s2 m-2].
[in]startThe starting point in the arrays.
[in]nptsThe number of values to calculate.

Definition at line 380 of file MOM_EOS_Wright.F90.

380  real, intent(in), dimension(:) :: T !< Potential temperature relative to the surface [degC].
381  real, intent(in), dimension(:) :: S !< Salinity [PSU].
382  real, intent(in), dimension(:) :: pressure !< pressure [Pa].
383  real, intent(out), dimension(:) :: rho !< In situ density [kg m-3].
384  real, intent(out), dimension(:) :: drho_dp !< The partial derivative of density with pressure
385  !! (also the inverse of the square of sound speed)
386  !! [s2 m-2].
387  integer, intent(in) :: start !< The starting point in the arrays.
388  integer, intent(in) :: npts !< The number of values to calculate.
389 
390  ! Coded by R. Hallberg, 1/01
391  ! Local variables
392  real :: al0, p0, lambda, I_denom
393  integer :: j
394 
395  do j=start,start+npts-1
396  al0 = (a0 + a1*t(j)) +a2*s(j)
397  p0 = (b0 + b4*s(j)) + t(j) * (b1 + t(j)*((b2 + b3*t(j))) + b5*s(j))
398  lambda = (c0 +c4*s(j)) + t(j) * (c1 + t(j)*((c2 + c3*t(j))) + c5*s(j))
399 
400  i_denom = 1.0 / (lambda + al0*(pressure(j) + p0))
401  rho(j) = (pressure(j) + p0) * i_denom
402  drho_dp(j) = lambda * i_denom * i_denom
403  enddo

References a0, a1, a2, b0, b1, b2, b3, b4, b5, c0, c1, c2, c3, c4, and c5.

◆ calculate_density_array_wright()

subroutine mom_eos_wright::calculate_density_array_wright ( real, dimension(:), intent(in)  T,
real, dimension(:), intent(in)  S,
real, dimension(:), intent(in)  pressure,
real, dimension(:), intent(out)  rho,
integer, intent(in)  start,
integer, intent(in)  npts,
real, intent(in), optional  rho_ref 
)
private

This subroutine computes the in situ density of sea water (rho in [kg m-3]) from salinity (S [PSU]), potential temperature (T [degC]), and pressure [Pa]. It uses the expression from Wright, 1997, J. Atmos. Ocean. Tech., 14, 735-740.

Parameters
[in]tpotential temperature relative to the surface [degC].
[in]ssalinity [PSU].
[in]pressurepressure [Pa].
[out]rhoin situ density [kg m-3].
[in]startthe starting point in the arrays.
[in]nptsthe number of values to calculate.
[in]rho_refA reference density [kg m-3].

Definition at line 111 of file MOM_EOS_Wright.F90.

111  real, dimension(:), intent(in) :: T !< potential temperature relative to the surface [degC].
112  real, dimension(:), intent(in) :: S !< salinity [PSU].
113  real, dimension(:), intent(in) :: pressure !< pressure [Pa].
114  real, dimension(:), intent(out) :: rho !< in situ density [kg m-3].
115  integer, intent(in) :: start !< the starting point in the arrays.
116  integer, intent(in) :: npts !< the number of values to calculate.
117  real, optional, intent(in) :: rho_ref !< A reference density [kg m-3].
118 
119  ! Original coded by R. Hallberg, 7/00, anomaly coded in 3/18.
120  ! Local variables
121  real :: al0, p0, lambda
122  real :: al_TS, p_TSp, lam_TS, pa_000
123  integer :: j
124 
125  if (present(rho_ref)) pa_000 = (b0*(1.0 - a0*rho_ref) - rho_ref*c0)
126  if (present(rho_ref)) then ; do j=start,start+npts-1
127  al_ts = a1*t(j) +a2*s(j)
128  al0 = a0 + al_ts
129  p_tsp = pressure(j) + (b4*s(j) + t(j) * (b1 + (t(j)*(b2 + b3*t(j)) + b5*s(j))))
130  lam_ts = c4*s(j) + t(j) * (c1 + (t(j)*(c2 + c3*t(j)) + c5*s(j)))
131 
132  ! The following two expressions are mathematically equivalent.
133  ! rho(j) = (b0 + p0_TSp) / ((c0 + lam_TS) + al0*(b0 + p0_TSp)) - rho_ref
134  rho(j) = (pa_000 + (p_tsp - rho_ref*(p_tsp*al0 + (b0*al_ts + lam_ts)))) / &
135  ( (c0 + lam_ts) + al0*(b0 + p_tsp) )
136  enddo ; else ; do j=start,start+npts-1
137  al0 = (a0 + a1*t(j)) +a2*s(j)
138  p0 = (b0 + b4*s(j)) + t(j) * (b1 + t(j)*(b2 + b3*t(j)) + b5*s(j))
139  lambda = (c0 +c4*s(j)) + t(j) * (c1 + t(j)*(c2 + c3*t(j)) + c5*s(j))
140  rho(j) = (pressure(j) + p0) / (lambda + al0*(pressure(j) + p0))
141  enddo ; endif
142 

References a0, a1, a2, b0, b1, b2, b3, b4, b5, c0, c1, c2, c3, c4, and c5.

Referenced by calculate_density_scalar_wright().

Here is the caller graph for this function:

◆ calculate_density_derivs_array_wright()

subroutine mom_eos_wright::calculate_density_derivs_array_wright ( real, dimension(:), intent(in)  T,
real, dimension(:), intent(in)  S,
real, dimension(:), intent(in)  pressure,
real, dimension(:), intent(out)  drho_dT,
real, dimension(:), intent(out)  drho_dS,
integer, intent(in)  start,
integer, intent(in)  npts 
)
private

For a given thermodynamic state, return the thermal/haline expansion coefficients.

Parameters
[in]tPotential temperature relative to the surface [degC].
[in]sSalinity [PSU].
[in]pressurepressure [Pa].
[out]drho_dtThe partial derivative of density with potential temperature [kg m-3 degC-1].
[out]drho_dsThe partial derivative of density with salinity, in [kg m-3 PSU-1].
[in]startThe starting point in the arrays.
[in]nptsThe number of values to calculate.

Definition at line 200 of file MOM_EOS_Wright.F90.

200  real, intent(in), dimension(:) :: T !< Potential temperature relative to the
201  !! surface [degC].
202  real, intent(in), dimension(:) :: S !< Salinity [PSU].
203  real, intent(in), dimension(:) :: pressure !< pressure [Pa].
204  real, intent(out), dimension(:) :: drho_dT !< The partial derivative of density with potential
205  !! temperature [kg m-3 degC-1].
206  real, intent(out), dimension(:) :: drho_dS !< The partial derivative of density with salinity,
207  !! in [kg m-3 PSU-1].
208  integer, intent(in) :: start !< The starting point in the arrays.
209  integer, intent(in) :: npts !< The number of values to calculate.
210 
211  ! Local variables
212  real :: al0, p0, lambda, I_denom2
213  integer :: j
214 
215  do j=start,start+npts-1
216  al0 = (a0 + a1*t(j)) + a2*s(j)
217  p0 = (b0 + b4*s(j)) + t(j) * (b1 + t(j)*((b2 + b3*t(j))) + b5*s(j))
218  lambda = (c0 +c4*s(j)) + t(j) * (c1 + t(j)*((c2 + c3*t(j))) + c5*s(j))
219 
220  i_denom2 = 1.0 / (lambda + al0*(pressure(j) + p0))
221  i_denom2 = i_denom2 *i_denom2
222  drho_dt(j) = i_denom2 * &
223  (lambda* (b1 + t(j)*(2.0*b2 + 3.0*b3*t(j)) + b5*s(j)) - &
224  (pressure(j)+p0) * ( (pressure(j)+p0)*a1 + &
225  (c1 + t(j)*(c2*2.0 + c3*3.0*t(j)) + c5*s(j)) ))
226  drho_ds(j) = i_denom2 * (lambda* (b4 + b5*t(j)) - &
227  (pressure(j)+p0) * ( (pressure(j)+p0)*a2 + (c4 + c5*t(j)) ))
228  enddo
229 

References a0, a1, a2, b0, b1, b2, b3, b4, b5, c0, c1, c2, c3, c4, and c5.

Referenced by calculate_density_derivs_scalar_wright().

Here is the caller graph for this function:

◆ calculate_density_derivs_scalar_wright()

subroutine mom_eos_wright::calculate_density_derivs_scalar_wright ( real, intent(in)  T,
real, intent(in)  S,
real, intent(in)  pressure,
real, intent(out)  drho_dT,
real, intent(out)  drho_dS 
)
private

The scalar version of calculate_density_derivs which promotes scalar inputs to a 1-element array and then demotes the output back to a scalar.

Parameters
[in]tPotential temperature relative to the surface [degC].
[in]sSalinity [PSU].
[in]pressurepressure [Pa].
[out]drho_dtThe partial derivative of density with potential temperature [kg m-3 degC-1].
[out]drho_dsThe partial derivative of density with salinity, in [kg m-3 PSU-1].

Definition at line 235 of file MOM_EOS_Wright.F90.

235  real, intent(in) :: T !< Potential temperature relative to the surface [degC].
236  real, intent(in) :: S !< Salinity [PSU].
237  real, intent(in) :: pressure !< pressure [Pa].
238  real, intent(out) :: drho_dT !< The partial derivative of density with potential
239  !! temperature [kg m-3 degC-1].
240  real, intent(out) :: drho_dS !< The partial derivative of density with salinity,
241  !! in [kg m-3 PSU-1].
242 
243  ! Local variables needed to promote the input/output scalars to 1-element arrays
244  real, dimension(1) :: T0, S0, P0
245  real, dimension(1) :: drdt0, drds0
246 
247  t0(1) = t
248  s0(1) = s
249  p0(1) = pressure
250  call calculate_density_derivs_array_wright(t0, s0, p0, drdt0, drds0, 1, 1)
251  drho_dt = drdt0(1)
252  drho_ds = drds0(1)
253 

References calculate_density_derivs_array_wright().

Here is the call graph for this function:

◆ calculate_density_scalar_wright()

subroutine mom_eos_wright::calculate_density_scalar_wright ( real, intent(in)  T,
real, intent(in)  S,
real, intent(in)  pressure,
real, intent(out)  rho,
real, intent(in), optional  rho_ref 
)
private

This subroutine computes the in situ density of sea water (rho in [kg m-3]) from salinity (S [PSU]), potential temperature (T [degC]), and pressure [Pa]. It uses the expression from Wright, 1997, J. Atmos. Ocean. Tech., 14, 735-740.

Parameters
[in]tPotential temperature relative to the surface [degC].
[in]sSalinity [PSU].
[in]pressurepressure [Pa].
[out]rhoIn situ density [kg m-3].
[in]rho_refA reference density [kg m-3].

Definition at line 81 of file MOM_EOS_Wright.F90.

81  real, intent(in) :: T !< Potential temperature relative to the surface [degC].
82  real, intent(in) :: S !< Salinity [PSU].
83  real, intent(in) :: pressure !< pressure [Pa].
84  real, intent(out) :: rho !< In situ density [kg m-3].
85  real, optional, intent(in) :: rho_ref !< A reference density [kg m-3].
86 
87 ! *====================================================================*
88 ! * This subroutine computes the in situ density of sea water (rho in *
89 ! * [kg m-3]) from salinity (S [PSU]), potential temperature *
90 ! * (T [degC]), and pressure [Pa]. It uses the expression from *
91 ! * Wright, 1997, J. Atmos. Ocean. Tech., 14, 735-740. *
92 ! * Coded by R. Hallberg, 7/00 *
93 ! *====================================================================*
94 
95  real, dimension(1) :: T0, S0, pressure0, rho0
96 
97  t0(1) = t
98  s0(1) = s
99  pressure0(1) = pressure
100 
101  call calculate_density_array_wright(t0, s0, pressure0, rho0, 1, 1, rho_ref)
102  rho = rho0(1)
103 

References calculate_density_array_wright().

Here is the call graph for this function:

◆ calculate_density_second_derivs_array_wright()

subroutine mom_eos_wright::calculate_density_second_derivs_array_wright ( real, dimension(:), intent(in)  T,
real, dimension(:), intent(in)  S,
real, dimension(:), intent(in)  P,
real, dimension(:), intent(out)  drho_ds_ds,
real, dimension(:), intent(out)  drho_ds_dt,
real, dimension(:), intent(out)  drho_dt_dt,
real, dimension(:), intent(out)  drho_ds_dp,
real, dimension(:), intent(out)  drho_dt_dp,
integer, intent(in)  start,
integer, intent(in)  npts 
)
private

Second derivatives of density with respect to temperature, salinity, and pressure.

Parameters
[in]tPotential temperature referenced to 0 dbar [degC]
[in]sSalinity [PSU]
[in]pPressure [Pa]
[out]drho_ds_dsPartial derivative of beta with respect to S [kg m-3 PSU-2]
[out]drho_ds_dtPartial derivative of beta with respcct to T [kg m-3 PSU-1 degC-1]
[out]drho_dt_dtPartial derivative of alpha with respect to T [kg m-3 degC-2]
[out]drho_ds_dpPartial derivative of beta with respect to pressure [kg m-3 PSU-1 Pa-1]
[out]drho_dt_dpPartial derivative of alpha with respect to pressure [kg m-3 degC-1 Pa-1]
[in]startStarting index in T,S,P
[in]nptsNumber of points to loop over

Definition at line 259 of file MOM_EOS_Wright.F90.

259  real, dimension(:), intent(in ) :: T !< Potential temperature referenced to 0 dbar [degC]
260  real, dimension(:), intent(in ) :: S !< Salinity [PSU]
261  real, dimension(:), intent(in ) :: P !< Pressure [Pa]
262  real, dimension(:), intent( out) :: drho_ds_ds !< Partial derivative of beta with respect
263  !! to S [kg m-3 PSU-2]
264  real, dimension(:), intent( out) :: drho_ds_dt !< Partial derivative of beta with respcct
265  !! to T [kg m-3 PSU-1 degC-1]
266  real, dimension(:), intent( out) :: drho_dt_dt !< Partial derivative of alpha with respect
267  !! to T [kg m-3 degC-2]
268  real, dimension(:), intent( out) :: drho_ds_dp !< Partial derivative of beta with respect
269  !! to pressure [kg m-3 PSU-1 Pa-1]
270  real, dimension(:), intent( out) :: drho_dt_dp !< Partial derivative of alpha with respect
271  !! to pressure [kg m-3 degC-1 Pa-1]
272  integer, intent(in ) :: start !< Starting index in T,S,P
273  integer, intent(in ) :: npts !< Number of points to loop over
274 
275  ! Local variables
276  real :: z0, z1, z2, z3, z4, z5, z6 ,z7, z8, z9, z10, z11, z2_2, z2_3
277  integer :: j
278  ! Based on the above expression with common terms factored, there probably exists a more numerically stable
279  ! and/or efficient expression
280 
281  do j = start,start+npts-1
282  z0 = t(j)*(b1 + b5*s(j) + t(j)*(b2 + b3*t(j)))
283  z1 = (b0 + p(j) + b4*s(j) + z0)
284  z3 = (b1 + b5*s(j) + t(j)*(2.*b2 + 2.*b3*t(j)))
285  z4 = (c0 + c4*s(j) + t(j)*(c1 + c5*s(j) + t(j)*(c2 + c3*t(j))))
286  z5 = (b1 + b5*s(j) + t(j)*(b2 + b3*t(j)) + t(j)*(b2 + 2.*b3*t(j)))
287  z6 = c1 + c5*s(j) + t(j)*(c2 + c3*t(j)) + t(j)*(c2 + 2.*c3*t(j))
288  z7 = (c4 + c5*t(j) + a2*z1)
289  z8 = (c1 + c5*s(j) + t(j)*(2.*c2 + 3.*c3*t(j)) + a1*z1)
290  z9 = (a0 + a2*s(j) + a1*t(j))
291  z10 = (b4 + b5*t(j))
292  z11 = (z10*z4 - z1*z7)
293  z2 = (c0 + c4*s(j) + t(j)*(c1 + c5*s(j) + t(j)*(c2 + c3*t(j))) + z9*z1)
294  z2_2 = z2*z2
295  z2_3 = z2_2*z2
296 
297  drho_ds_ds(j) = (z10*(c4 + c5*t(j)) - a2*z10*z1 - z10*z7)/z2_2 - (2.*(c4 + c5*t(j) + z9*z10 + a2*z1)*z11)/z2_3
298  drho_ds_dt(j) = (z10*z6 - z1*(c5 + a2*z5) + b5*z4 - z5*z7)/z2_2 - (2.*(z6 + z9*z5 + a1*z1)*z11)/z2_3
299  drho_dt_dt(j) = (z3*z6 - z1*(2.*c2 + 6.*c3*t(j) + a1*z5) + (2.*b2 + 4.*b3*t(j))*z4 - z5*z8)/z2_2 - &
300  (2.*(z6 + z9*z5 + a1*z1)*(z3*z4 - z1*z8))/z2_3
301  drho_ds_dp(j) = (-c4 - c5*t(j) - 2.*a2*z1)/z2_2 - (2.*z9*z11)/z2_3
302  drho_dt_dp(j) = (-c1 - c5*s(j) - t(j)*(2.*c2 + 3.*c3*t(j)) - 2.*a1*z1)/z2_2 - (2.*z9*(z3*z4 - z1*z8))/z2_3
303  enddo
304 

References a0, a1, a2, b0, b1, b2, b3, b4, b5, c0, c1, c2, c3, c4, and c5.

Referenced by calculate_density_second_derivs_scalar_wright().

Here is the caller graph for this function:

◆ calculate_density_second_derivs_scalar_wright()

subroutine mom_eos_wright::calculate_density_second_derivs_scalar_wright ( real, intent(in)  T,
real, intent(in)  S,
real, intent(in)  P,
real, intent(out)  drho_ds_ds,
real, intent(out)  drho_ds_dt,
real, intent(out)  drho_dt_dt,
real, intent(out)  drho_ds_dp,
real, intent(out)  drho_dt_dp 
)
private

Second derivatives of density with respect to temperature, salinity, and pressure for scalar inputs. Inputs promoted to 1-element array and output demoted to scalar.

Parameters
[in]tPotential temperature referenced to 0 dbar
[in]sSalinity [PSU]
[in]ppressure [Pa]
[out]drho_ds_dsPartial derivative of beta with respect to S [kg m-3 PSU-2]
[out]drho_ds_dtPartial derivative of beta with respcct to T [kg m-3 PSU-1 degC-1]
[out]drho_dt_dtPartial derivative of alpha with respect to T [kg m-3 degC-2]
[out]drho_ds_dpPartial derivative of beta with respect to pressure [kg m-3 PSU-1 Pa-1]
[out]drho_dt_dpPartial derivative of alpha with respect to pressure [kg m-3 degC-1 Pa-1]

Definition at line 311 of file MOM_EOS_Wright.F90.

311  real, intent(in ) :: T !< Potential temperature referenced to 0 dbar
312  real, intent(in ) :: S !< Salinity [PSU]
313  real, intent(in ) :: P !< pressure [Pa]
314  real, intent( out) :: drho_ds_ds !< Partial derivative of beta with respect
315  !! to S [kg m-3 PSU-2]
316  real, intent( out) :: drho_ds_dt !< Partial derivative of beta with respcct
317  !! to T [kg m-3 PSU-1 degC-1]
318  real, intent( out) :: drho_dt_dt !< Partial derivative of alpha with respect
319  !! to T [kg m-3 degC-2]
320  real, intent( out) :: drho_ds_dp !< Partial derivative of beta with respect
321  !! to pressure [kg m-3 PSU-1 Pa-1]
322  real, intent( out) :: drho_dt_dp !< Partial derivative of alpha with respect
323  !! to pressure [kg m-3 degC-1 Pa-1]
324  ! Local variables
325  real, dimension(1) :: T0, S0, P0
326  real, dimension(1) :: drdsds, drdsdt, drdtdt, drdsdp, drdtdp
327 
328  t0(1) = t
329  s0(1) = s
330  p0(1) = p
331  call calculate_density_second_derivs_array_wright(t0, s0, p0, drdsds, drdsdt, drdtdt, drdsdp, drdtdp, 1, 1)
332  drho_ds_ds = drdsds(1)
333  drho_ds_dt = drdsdt(1)
334  drho_dt_dt = drdtdt(1)
335  drho_ds_dp = drdsdp(1)
336  drho_dt_dp = drdtdp(1)
337 

References calculate_density_second_derivs_array_wright().

Here is the call graph for this function:

◆ calculate_spec_vol_array_wright()

subroutine mom_eos_wright::calculate_spec_vol_array_wright ( real, dimension(:), intent(in)  T,
real, dimension(:), intent(in)  S,
real, dimension(:), intent(in)  pressure,
real, dimension(:), intent(out)  specvol,
integer, intent(in)  start,
integer, intent(in)  npts,
real, intent(in), optional  spv_ref 
)
private

This subroutine computes the in situ specific volume of sea water (specvol in [m3 kg-1]) from salinity (S [PSU]), potential temperature (T [degC]) and pressure [Pa]. It uses the expression from Wright, 1997, J. Atmos. Ocean. Tech., 14, 735-740. If spv_ref is present, specvol is an anomaly from spv_ref.

Parameters
[in]tpotential temperature relative to the surface [degC].
[in]ssalinity [PSU].
[in]pressurepressure [Pa].
[out]specvolin situ specific volume [m3 kg-1].
[in]startthe starting point in the arrays.
[in]nptsthe number of values to calculate.
[in]spv_refA reference specific volume [m3 kg-1].

Definition at line 172 of file MOM_EOS_Wright.F90.

172  real, dimension(:), intent(in) :: T !< potential temperature relative to the
173  !! surface [degC].
174  real, dimension(:), intent(in) :: S !< salinity [PSU].
175  real, dimension(:), intent(in) :: pressure !< pressure [Pa].
176  real, dimension(:), intent(out) :: specvol !< in situ specific volume [m3 kg-1].
177  integer, intent(in) :: start !< the starting point in the arrays.
178  integer, intent(in) :: npts !< the number of values to calculate.
179  real, optional, intent(in) :: spv_ref !< A reference specific volume [m3 kg-1].
180 
181  ! Local variables
182  real :: al0, p0, lambda
183  integer :: j
184 
185  do j=start,start+npts-1
186  al0 = (a0 + a1*t(j)) +a2*s(j)
187  p0 = (b0 + b4*s(j)) + t(j) * (b1 + t(j)*((b2 + b3*t(j))) + b5*s(j))
188  lambda = (c0 +c4*s(j)) + t(j) * (c1 + t(j)*((c2 + c3*t(j))) + c5*s(j))
189 
190  if (present(spv_ref)) then
191  specvol(j) = (lambda + (al0 - spv_ref)*(pressure(j) + p0)) / (pressure(j) + p0)
192  else
193  specvol(j) = (lambda + al0*(pressure(j) + p0)) / (pressure(j) + p0)
194  endif
195  enddo

References a0, a1, a2, b0, b1, b2, b3, b4, b5, c0, c1, c2, c3, c4, and c5.

Referenced by calculate_spec_vol_scalar_wright().

Here is the caller graph for this function:

◆ calculate_spec_vol_scalar_wright()

subroutine mom_eos_wright::calculate_spec_vol_scalar_wright ( real, intent(in)  T,
real, intent(in)  S,
real, intent(in)  pressure,
real, intent(out)  specvol,
real, intent(in), optional  spv_ref 
)
private

This subroutine computes the in situ specific volume of sea water (specvol in [m3 kg-1]) from salinity (S [PSU]), potential temperature (T [degC]) and pressure [Pa]. It uses the expression from Wright, 1997, J. Atmos. Ocean. Tech., 14, 735-740. If spv_ref is present, specvol is an anomaly from spv_ref.

Parameters
[in]tpotential temperature relative to the surface [degC].
[in]ssalinity [PSU].
[in]pressurepressure [Pa].
[out]specvolin situ specific volume [m3 kg-1].
[in]spv_refA reference specific volume [m3 kg-1].

Definition at line 151 of file MOM_EOS_Wright.F90.

151  real, intent(in) :: T !< potential temperature relative to the surface [degC].
152  real, intent(in) :: S !< salinity [PSU].
153  real, intent(in) :: pressure !< pressure [Pa].
154  real, intent(out) :: specvol !< in situ specific volume [m3 kg-1].
155  real, optional, intent(in) :: spv_ref !< A reference specific volume [m3 kg-1].
156 
157  ! Local variables
158  real, dimension(1) :: T0, S0, pressure0, spv0
159 
160  t0(1) = t ; s0(1) = s ; pressure0(1) = pressure
161 
162  call calculate_spec_vol_array_wright(t0, s0, pressure0, spv0, 1, 1, spv_ref)
163  specvol = spv0(1)

References calculate_spec_vol_array_wright().

Here is the call graph for this function:

◆ calculate_specvol_derivs_wright()

subroutine, public mom_eos_wright::calculate_specvol_derivs_wright ( real, dimension(:), intent(in)  T,
real, dimension(:), intent(in)  S,
real, dimension(:), intent(in)  pressure,
real, dimension(:), intent(out)  dSV_dT,
real, dimension(:), intent(out)  dSV_dS,
integer, intent(in)  start,
integer, intent(in)  npts 
)

For a given thermodynamic state, return the partial derivatives of specific volume with temperature and salinity.

Parameters
[in]tPotential temperature relative to the surface [degC].
[in]sSalinity [PSU].
[in]pressurepressure [Pa].
[out]dsv_dtThe partial derivative of specific volume with potential temperature [m3 kg-1 degC-1].
[out]dsv_dsThe partial derivative of specific volume with salinity [m3 kg-1 / Pa].
[in]startThe starting point in the arrays.
[in]nptsThe number of values to calculate.

Definition at line 343 of file MOM_EOS_Wright.F90.

343  real, intent(in), dimension(:) :: T !< Potential temperature relative to the surface [degC].
344  real, intent(in), dimension(:) :: S !< Salinity [PSU].
345  real, intent(in), dimension(:) :: pressure !< pressure [Pa].
346  real, intent(out), dimension(:) :: dSV_dT !< The partial derivative of specific volume with
347  !! potential temperature [m3 kg-1 degC-1].
348  real, intent(out), dimension(:) :: dSV_dS !< The partial derivative of specific volume with
349  !! salinity [m3 kg-1 / Pa].
350  integer, intent(in) :: start !< The starting point in the arrays.
351  integer, intent(in) :: npts !< The number of values to calculate.
352 
353  ! Local variables
354  real :: al0, p0, lambda, I_denom
355  integer :: j
356 
357  do j=start,start+npts-1
358 ! al0 = (a0 + a1*T(j)) + a2*S(j)
359  p0 = (b0 + b4*s(j)) + t(j) * (b1 + t(j)*((b2 + b3*t(j))) + b5*s(j))
360  lambda = (c0 +c4*s(j)) + t(j) * (c1 + t(j)*((c2 + c3*t(j))) + c5*s(j))
361 
362  ! SV = al0 + lambda / (pressure(j) + p0)
363 
364  i_denom = 1.0 / (pressure(j) + p0)
365  dsv_dt(j) = (a1 + i_denom * (c1 + t(j)*((2.0*c2 + 3.0*c3*t(j))) + c5*s(j))) - &
366  (i_denom**2 * lambda) * (b1 + t(j)*((2.0*b2 + 3.0*b3*t(j))) + b5*s(j))
367  dsv_ds(j) = (a2 + i_denom * (c4 + c5*t(j))) - &
368  (i_denom**2 * lambda) * (b4 + b5*t(j))
369  enddo
370 

References a1, a2, b0, b1, b2, b3, b4, b5, c0, c1, c2, c3, c4, and c5.

◆ int_density_dz_wright()

subroutine, public mom_eos_wright::int_density_dz_wright ( real, dimension(hii%isd:hii%ied,hii%jsd:hii%jed), intent(in)  T,
real, dimension(hii%isd:hii%ied,hii%jsd:hii%jed), intent(in)  S,
real, dimension(hii%isd:hii%ied,hii%jsd:hii%jed), intent(in)  z_t,
real, dimension(hii%isd:hii%ied,hii%jsd:hii%jed), intent(in)  z_b,
real, intent(in)  rho_ref,
real, intent(in)  rho_0,
real, intent(in)  G_e,
type(hor_index_type), intent(in)  HII,
type(hor_index_type), intent(in)  HIO,
real, dimension(hio%isd:hio%ied,hio%jsd:hio%jed), intent(out)  dpa,
real, dimension(hio%isd:hio%ied,hio%jsd:hio%jed), intent(out), optional  intz_dpa,
real, dimension(hio%isdb:hio%iedb,hio%jsd:hio%jed), intent(out), optional  intx_dpa,
real, dimension(hio%isd:hio%ied,hio%jsdb:hio%jedb), intent(out), optional  inty_dpa,
real, dimension(hii%isd:hii%ied,hii%jsd:hii%jed), intent(in), optional  bathyT,
real, intent(in), optional  dz_neglect,
logical, intent(in), optional  useMassWghtInterp 
)

This subroutine calculates analytical and nearly-analytical integrals of pressure anomalies across layers, which are required for calculating the finite-volume form pressure accelerations in a Boussinesq model.

Parameters
[in]hiiThe horizontal index type for the input arrays.
[in]hioThe horizontal index type for the output arrays.
[in]tPotential temperature relative to the surface
[in]sSalinity [PSU].
[in]z_tHeight at the top of the layer in depth units [Z ~> m].
[in]z_bHeight at the top of the layer [Z ~> m].
[in]rho_refA mean density [kg m-3], that is subtracted out to reduce the magnitude of each of the integrals. (The pressure is calucated as p~=-z*rho_0*G_e.)
[in]rho_0Density [kg m-3], that is used to calculate the pressure (as p~=-z*rho_0*G_e) used in the equation of state.
[in]g_eThe Earth's gravitational acceleration [m2 Z-1 s-2 ~> m s-2].
[out]dpaThe change in the pressure anomaly across the
[out]intz_dpaThe integral through the thickness of the layer
[out]intx_dpaThe integral in x of the difference between the
[out]inty_dpaThe integral in y of the difference between the
[in]bathytThe depth of the bathymetry [Z ~> m].
[in]dz_neglectA miniscule thickness change [Z ~> m].
[in]usemasswghtinterpIf true, uses mass weighting to interpolate T/S for top and bottom integrals.

Definition at line 412 of file MOM_EOS_Wright.F90.

412  type(hor_index_type), intent(in) :: HII !< The horizontal index type for the input arrays.
413  type(hor_index_type), intent(in) :: HIO !< The horizontal index type for the output arrays.
414  real, dimension(HII%isd:HII%ied,HII%jsd:HII%jed), &
415  intent(in) :: T !< Potential temperature relative to the surface
416  !! [degC].
417  real, dimension(HII%isd:HII%ied,HII%jsd:HII%jed), &
418  intent(in) :: S !< Salinity [PSU].
419  real, dimension(HII%isd:HII%ied,HII%jsd:HII%jed), &
420  intent(in) :: z_t !< Height at the top of the layer in depth units [Z ~> m].
421  real, dimension(HII%isd:HII%ied,HII%jsd:HII%jed), &
422  intent(in) :: z_b !< Height at the top of the layer [Z ~> m].
423  real, intent(in) :: rho_ref !< A mean density [kg m-3], that is subtracted out
424  !! to reduce the magnitude of each of the integrals.
425  !! (The pressure is calucated as p~=-z*rho_0*G_e.)
426  real, intent(in) :: rho_0 !< Density [kg m-3], that is used to calculate the
427  !! pressure (as p~=-z*rho_0*G_e) used in the
428  !! equation of state.
429  real, intent(in) :: G_e !< The Earth's gravitational acceleration [m2 Z-1 s-2 ~> m s-2].
430  real, dimension(HIO%isd:HIO%ied,HIO%jsd:HIO%jed), &
431  intent(out) :: dpa !< The change in the pressure anomaly across the
432  !! layer [Pa].
433  real, dimension(HIO%isd:HIO%ied,HIO%jsd:HIO%jed), &
434  optional, intent(out) :: intz_dpa !< The integral through the thickness of the layer
435  !! of the pressure anomaly relative to the anomaly
436  !! at the top of the layer [Pa Z ~> Pa m].
437  real, dimension(HIO%IsdB:HIO%IedB,HIO%jsd:HIO%jed), &
438  optional, intent(out) :: intx_dpa !< The integral in x of the difference between the
439  !! pressure anomaly at the top and bottom of the
440  !! layer divided by the x grid spacing [Pa].
441  real, dimension(HIO%isd:HIO%ied,HIO%JsdB:HIO%JedB), &
442  optional, intent(out) :: inty_dpa !< The integral in y of the difference between the
443  !! pressure anomaly at the top and bottom of the
444  !! layer divided by the y grid spacing [Pa].
445  real, dimension(HII%isd:HII%ied,HII%jsd:HII%jed), &
446  optional, intent(in) :: bathyT !< The depth of the bathymetry [Z ~> m].
447  real, optional, intent(in) :: dz_neglect !< A miniscule thickness change [Z ~> m].
448  logical, optional, intent(in) :: useMassWghtInterp !< If true, uses mass weighting to
449  !! interpolate T/S for top and bottom integrals.
450 
451  ! Local variables
452  real, dimension(HII%isd:HII%ied,HII%jsd:HII%jed) :: al0_2d, p0_2d, lambda_2d
453  real :: al0, p0, lambda
454  real :: rho_anom ! The density anomaly from rho_ref [kg m-3].
455  real :: eps, eps2, rem
456  real :: GxRho, I_Rho
457  real :: p_ave, I_al0, I_Lzz
458  real :: dz ! The layer thickness [Z ~> m].
459  real :: hWght ! A pressure-thickness below topography [Z ~> m].
460  real :: hL, hR ! Pressure-thicknesses of the columns to the left and right [Z ~> m].
461  real :: iDenom ! The inverse of the denominator in the weights [Z-2 ~> m-2].
462  real :: hWt_LL, hWt_LR ! hWt_LA is the weighted influence of A on the left column [nondim].
463  real :: hWt_RL, hWt_RR ! hWt_RA is the weighted influence of A on the right column [nondim].
464  real :: wt_L, wt_R ! The linear weights of the left and right columns [nondim].
465  real :: wtT_L, wtT_R ! The weights for tracers from the left and right columns [nondim].
466  real :: intz(5) ! The integrals of density with height at the
467  ! 5 sub-column locations [Pa].
468  logical :: do_massWeight ! Indicates whether to do mass weighting.
469  real, parameter :: C1_3 = 1.0/3.0, c1_7 = 1.0/7.0 ! Rational constants.
470  real, parameter :: C1_9 = 1.0/9.0, c1_90 = 1.0/90.0 ! Rational constants.
471  integer :: is, ie, js, je, Isq, Ieq, Jsq, Jeq, i, j, ioff, joff, m
472 
473  ioff = hio%idg_offset - hii%idg_offset
474  joff = hio%jdg_offset - hii%jdg_offset
475 
476  ! These array bounds work for the indexing convention of the input arrays, but
477  ! on the computational domain defined for the output arrays.
478  isq = hio%IscB + ioff ; ieq = hio%IecB + ioff
479  jsq = hio%JscB + joff ; jeq = hio%JecB + joff
480  is = hio%isc + ioff ; ie = hio%iec + ioff
481  js = hio%jsc + joff ; je = hio%jec + joff
482 
483  gxrho = g_e * rho_0
484  i_rho = 1.0 / rho_0
485 
486  do_massweight = .false.
487  if (present(usemasswghtinterp)) then ; if (usemasswghtinterp) then
488  do_massweight = .true.
489  ! if (.not.present(bathyT)) call MOM_error(FATAL, "int_density_dz_generic: "//&
490  ! "bathyT must be present if useMassWghtInterp is present and true.")
491  ! if (.not.present(dz_neglect)) call MOM_error(FATAL, "int_density_dz_generic: "//&
492  ! "dz_neglect must be present if useMassWghtInterp is present and true.")
493  endif ; endif
494 
495  do j=jsq,jeq+1 ; do i=isq,ieq+1
496  al0_2d(i,j) = (a0 + a1*t(i,j)) + a2*s(i,j)
497  p0_2d(i,j) = (b0 + b4*s(i,j)) + t(i,j) * (b1 + t(i,j)*((b2 + b3*t(i,j))) + b5*s(i,j))
498  lambda_2d(i,j) = (c0 +c4*s(i,j)) + t(i,j) * (c1 + t(i,j)*((c2 + c3*t(i,j))) + c5*s(i,j))
499 
500  al0 = al0_2d(i,j) ; p0 = p0_2d(i,j) ; lambda = lambda_2d(i,j)
501 
502  dz = z_t(i,j) - z_b(i,j)
503  p_ave = -0.5*gxrho*(z_t(i,j)+z_b(i,j))
504 
505  i_al0 = 1.0 / al0
506  i_lzz = 1.0 / (p0 + (lambda * i_al0) + p_ave)
507  eps = 0.5*gxrho*dz*i_lzz ; eps2 = eps*eps
508 
509 ! rho(j) = (pressure(j) + p0) / (lambda + al0*(pressure(j) + p0))
510 
511  rho_anom = (p0 + p_ave)*(i_lzz*i_al0) - rho_ref
512  rem = i_rho * (lambda * i_al0**2) * eps2 * &
513  (c1_3 + eps2*(0.2 + eps2*(c1_7 + c1_9*eps2)))
514  dpa(i-ioff,j-joff) = g_e*rho_anom*dz - 2.0*eps*rem
515  if (present(intz_dpa)) &
516  intz_dpa(i-ioff,j-joff) = 0.5*g_e*rho_anom*dz**2 - dz*(1.0+eps)*rem
517  enddo ; enddo
518 
519  if (present(intx_dpa)) then ; do j=js,je ; do i=isq,ieq
520  ! hWght is the distance measure by which the cell is violation of
521  ! hydrostatic consistency. For large hWght we bias the interpolation of
522  ! T & S along the top and bottom integrals, akin to thickness weighting.
523  hwght = 0.0
524  if (do_massweight) &
525  hwght = max(0., -bathyt(i,j)-z_t(i+1,j), -bathyt(i+1,j)-z_t(i,j))
526  if (hwght > 0.) then
527  hl = (z_t(i,j) - z_b(i,j)) + dz_neglect
528  hr = (z_t(i+1,j) - z_b(i+1,j)) + dz_neglect
529  hwght = hwght * ( (hl-hr)/(hl+hr) )**2
530  idenom = 1.0 / ( hwght*(hr + hl) + hl*hr )
531  hwt_ll = (hwght*hl + hr*hl) * idenom ; hwt_lr = (hwght*hr) * idenom
532  hwt_rr = (hwght*hr + hr*hl) * idenom ; hwt_rl = (hwght*hl) * idenom
533  else
534  hwt_ll = 1.0 ; hwt_lr = 0.0 ; hwt_rr = 1.0 ; hwt_rl = 0.0
535  endif
536 
537  intz(1) = dpa(i-ioff,j-joff) ; intz(5) = dpa(i+1-ioff,j-joff)
538  do m=2,4
539  wt_l = 0.25*real(5-m) ; wt_r = 1.0-wt_l
540  wtt_l = wt_l*hwt_ll + wt_r*hwt_rl ; wtt_r = wt_l*hwt_lr + wt_r*hwt_rr
541 
542  al0 = wtt_l*al0_2d(i,j) + wtt_r*al0_2d(i+1,j)
543  p0 = wtt_l*p0_2d(i,j) + wtt_r*p0_2d(i+1,j)
544  lambda = wtt_l*lambda_2d(i,j) + wtt_r*lambda_2d(i+1,j)
545 
546  dz = wt_l*(z_t(i,j) - z_b(i,j)) + wt_r*(z_t(i+1,j) - z_b(i+1,j))
547  p_ave = -0.5*gxrho*(wt_l*(z_t(i,j)+z_b(i,j)) + &
548  wt_r*(z_t(i+1,j)+z_b(i+1,j)))
549 
550  i_al0 = 1.0 / al0
551  i_lzz = 1.0 / (p0 + (lambda * i_al0) + p_ave)
552  eps = 0.5*gxrho*dz*i_lzz ; eps2 = eps*eps
553 
554  intz(m) = g_e*dz*((p0 + p_ave)*(i_lzz*i_al0) - rho_ref) - 2.0*eps * &
555  i_rho * (lambda * i_al0**2) * eps2 * &
556  (c1_3 + eps2*(0.2 + eps2*(c1_7 + c1_9*eps2)))
557  enddo
558  ! Use Bode's rule to integrate the values.
559  intx_dpa(i-ioff,j-joff) = c1_90*(7.0*(intz(1)+intz(5)) + 32.0*(intz(2)+intz(4)) + &
560  12.0*intz(3))
561  enddo ; enddo ; endif
562 
563  if (present(inty_dpa)) then ; do j=jsq,jeq ; do i=is,ie
564  ! hWght is the distance measure by which the cell is violation of
565  ! hydrostatic consistency. For large hWght we bias the interpolation of
566  ! T & S along the top and bottom integrals, akin to thickness weighting.
567  hwght = 0.0
568  if (do_massweight) &
569  hwght = max(0., -bathyt(i,j)-z_t(i,j+1), -bathyt(i,j+1)-z_t(i,j))
570  if (hwght > 0.) then
571  hl = (z_t(i,j) - z_b(i,j)) + dz_neglect
572  hr = (z_t(i,j+1) - z_b(i,j+1)) + dz_neglect
573  hwght = hwght * ( (hl-hr)/(hl+hr) )**2
574  idenom = 1.0 / ( hwght*(hr + hl) + hl*hr )
575  hwt_ll = (hwght*hl + hr*hl) * idenom ; hwt_lr = (hwght*hr) * idenom
576  hwt_rr = (hwght*hr + hr*hl) * idenom ; hwt_rl = (hwght*hl) * idenom
577  else
578  hwt_ll = 1.0 ; hwt_lr = 0.0 ; hwt_rr = 1.0 ; hwt_rl = 0.0
579  endif
580 
581  intz(1) = dpa(i-ioff,j-joff) ; intz(5) = dpa(i-ioff,j+1-joff)
582  do m=2,4
583  wt_l = 0.25*real(5-m) ; wt_r = 1.0-wt_l
584  wtt_l = wt_l*hwt_ll + wt_r*hwt_rl ; wtt_r = wt_l*hwt_lr + wt_r*hwt_rr
585 
586  al0 = wtt_l*al0_2d(i,j) + wtt_r*al0_2d(i,j+1)
587  p0 = wtt_l*p0_2d(i,j) + wtt_r*p0_2d(i,j+1)
588  lambda = wtt_l*lambda_2d(i,j) + wtt_r*lambda_2d(i,j+1)
589 
590  dz = wt_l*(z_t(i,j) - z_b(i,j)) + wt_r*(z_t(i,j+1) - z_b(i,j+1))
591  p_ave = -0.5*gxrho*(wt_l*(z_t(i,j)+z_b(i,j)) + &
592  wt_r*(z_t(i,j+1)+z_b(i,j+1)))
593 
594  i_al0 = 1.0 / al0
595  i_lzz = 1.0 / (p0 + (lambda * i_al0) + p_ave)
596  eps = 0.5*gxrho*dz*i_lzz ; eps2 = eps*eps
597 
598  intz(m) = g_e*dz*((p0 + p_ave)*(i_lzz*i_al0) - rho_ref) - 2.0*eps * &
599  i_rho * (lambda * i_al0**2) * eps2 * &
600  (c1_3 + eps2*(0.2 + eps2*(c1_7 + c1_9*eps2)))
601  enddo
602  ! Use Bode's rule to integrate the values.
603  inty_dpa(i-ioff,j-joff) = c1_90*(7.0*(intz(1)+intz(5)) + 32.0*(intz(2)+intz(4)) + &
604  12.0*intz(3))
605  enddo ; enddo ; endif

References a0, a1, a2, b0, b1, b2, b3, b4, b5, c0, c1, c2, c3, c4, and c5.

◆ int_spec_vol_dp_wright()

subroutine, public mom_eos_wright::int_spec_vol_dp_wright ( real, dimension(hi%isd:hi%ied,hi%jsd:hi%jed), intent(in)  T,
real, dimension(hi%isd:hi%ied,hi%jsd:hi%jed), intent(in)  S,
real, dimension(hi%isd:hi%ied,hi%jsd:hi%jed), intent(in)  p_t,
real, dimension(hi%isd:hi%ied,hi%jsd:hi%jed), intent(in)  p_b,
real, intent(in)  spv_ref,
type(hor_index_type), intent(in)  HI,
real, dimension(hi%isd:hi%ied,hi%jsd:hi%jed), intent(out)  dza,
real, dimension(hi%isd:hi%ied,hi%jsd:hi%jed), intent(out), optional  intp_dza,
real, dimension(hi%isdb:hi%iedb,hi%jsd:hi%jed), intent(out), optional  intx_dza,
real, dimension(hi%isd:hi%ied,hi%jsdb:hi%jedb), intent(out), optional  inty_dza,
integer, intent(in), optional  halo_size,
real, dimension(hi%isd:hi%ied,hi%jsd:hi%jed), intent(in), optional  bathyP,
real, intent(in), optional  dP_neglect,
logical, intent(in), optional  useMassWghtInterp 
)

This subroutine calculates analytical and nearly-analytical integrals in pressure across layers of geopotential anomalies, which are required for calculating the finite-volume form pressure accelerations in a non-Boussinesq model. There are essentially no free assumptions, apart from the use of Bode's rule to do the horizontal integrals, and from a truncation in the series for log(1-eps/1+eps) that assumes that |eps| < 0.34.

Parameters
[in]hiThe ocean's horizontal index type.
[in]tPotential temperature relative to the surface
[in]sSalinity [PSU].
[in]p_tPressure at the top of the layer [Pa].
[in]p_bPressure at the top of the layer [Pa].
[in]spv_refA mean specific volume that is subtracted out to reduce the magnitude of each of the integrals [m3 kg-1]. The calculation is mathematically identical with different values of spv_ref, but this reduces the effects of roundoff.
[out]dzaThe change in the geopotential anomaly across
[out]intp_dzaThe integral in pressure through the layer of
[out]intx_dzaThe integral in x of the difference between the
[out]inty_dzaThe integral in y of the difference between the
[in]halo_sizeThe width of halo points on which to calculate dza.
[in]bathypThe pressure at the bathymetry [Pa]
[in]dp_neglectA miniscule pressure change with the same units as p_t [Pa]
[in]usemasswghtinterpIf true, uses mass weighting to interpolate T/S for top and bottom integrals.

Definition at line 617 of file MOM_EOS_Wright.F90.

617  type(hor_index_type), intent(in) :: HI !< The ocean's horizontal index type.
618  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
619  intent(in) :: T !< Potential temperature relative to the surface
620  !! [degC].
621  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
622  intent(in) :: S !< Salinity [PSU].
623  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
624  intent(in) :: p_t !< Pressure at the top of the layer [Pa].
625  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
626  intent(in) :: p_b !< Pressure at the top of the layer [Pa].
627  real, intent(in) :: spv_ref !< A mean specific volume that is subtracted out
628  !! to reduce the magnitude of each of the integrals [m3 kg-1]. The calculation is
629  !! mathematically identical with different values of spv_ref, but this reduces the
630  !! effects of roundoff.
631  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
632  intent(out) :: dza !< The change in the geopotential anomaly across
633  !! the layer [m2 s-2].
634  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
635  optional, intent(out) :: intp_dza !< The integral in pressure through the layer of
636  !! the geopotential anomaly relative to the anomaly
637  !! at the bottom of the layer [Pa m2 s-2].
638  real, dimension(HI%IsdB:HI%IedB,HI%jsd:HI%jed), &
639  optional, intent(out) :: intx_dza !< The integral in x of the difference between the
640  !! geopotential anomaly at the top and bottom of
641  !! the layer divided by the x grid spacing [m2 s-2].
642  real, dimension(HI%isd:HI%ied,HI%JsdB:HI%JedB), &
643  optional, intent(out) :: inty_dza !< The integral in y of the difference between the
644  !! geopotential anomaly at the top and bottom of
645  !! the layer divided by the y grid spacing [m2 s-2].
646  integer, optional, intent(in) :: halo_size !< The width of halo points on which to calculate
647  !! dza.
648  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
649  optional, intent(in) :: bathyP !< The pressure at the bathymetry [Pa]
650  real, optional, intent(in) :: dP_neglect !< A miniscule pressure change with
651  !! the same units as p_t [Pa]
652  logical, optional, intent(in) :: useMassWghtInterp !< If true, uses mass weighting
653  !! to interpolate T/S for top and bottom integrals.
654 
655  ! Local variables
656  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed) :: al0_2d, p0_2d, lambda_2d
657  real :: al0, p0, lambda
658  real :: p_ave
659  real :: rem, eps, eps2
660  real :: alpha_anom ! The depth averaged specific volume anomaly [m3 kg-1].
661  real :: dp ! The pressure change through a layer [Pa].
662  real :: hWght ! A pressure-thickness below topography [Pa].
663  real :: hL, hR ! Pressure-thicknesses of the columns to the left and right [Pa].
664  real :: iDenom ! The inverse of the denominator in the weights [Pa-2].
665  real :: hWt_LL, hWt_LR ! hWt_LA is the weighted influence of A on the left column [nondim].
666  real :: hWt_RL, hWt_RR ! hWt_RA is the weighted influence of A on the right column [nondim].
667  real :: wt_L, wt_R ! The linear weights of the left and right columns [nondim].
668  real :: wtT_L, wtT_R ! The weights for tracers from the left and right columns [nondim].
669  real :: intp(5) ! The integrals of specific volume with pressure at the
670  ! 5 sub-column locations [m2 s-2].
671  logical :: do_massWeight ! Indicates whether to do mass weighting.
672  real, parameter :: C1_3 = 1.0/3.0, c1_7 = 1.0/7.0 ! Rational constants.
673  real, parameter :: C1_9 = 1.0/9.0, c1_90 = 1.0/90.0 ! Rational constants.
674  integer :: Isq, Ieq, Jsq, Jeq, ish, ieh, jsh, jeh, i, j, m, halo
675 
676  isq = hi%IscB ; ieq = hi%IecB ; jsq = hi%JscB ; jeq = hi%JecB
677  halo = 0 ; if (present(halo_size)) halo = max(halo_size,0)
678  ish = hi%isc-halo ; ieh = hi%iec+halo ; jsh = hi%jsc-halo ; jeh = hi%jec+halo
679  if (present(intx_dza)) then ; ish = min(isq,ish) ; ieh = max(ieq+1,ieh); endif
680  if (present(inty_dza)) then ; jsh = min(jsq,jsh) ; jeh = max(jeq+1,jeh); endif
681 
682  do_massweight = .false.
683  if (present(usemasswghtinterp)) then ; if (usemasswghtinterp) then
684  do_massweight = .true.
685 ! if (.not.present(bathyP)) call MOM_error(FATAL, "int_spec_vol_dp_generic: "//&
686 ! "bathyP must be present if useMassWghtInterp is present and true.")
687 ! if (.not.present(dP_neglect)) call MOM_error(FATAL, "int_spec_vol_dp_generic: "//&
688 ! "dP_neglect must be present if useMassWghtInterp is present and true.")
689  endif ; endif
690 
691  do j=jsh,jeh ; do i=ish,ieh
692  al0_2d(i,j) = (a0 + a1*t(i,j)) + a2*s(i,j)
693  p0_2d(i,j) = (b0 + b4*s(i,j)) + t(i,j) * (b1 + t(i,j)*((b2 + b3*t(i,j))) + b5*s(i,j))
694  lambda_2d(i,j) = (c0 +c4*s(i,j)) + t(i,j) * (c1 + t(i,j)*((c2 + c3*t(i,j))) + c5*s(i,j))
695 
696  al0 = al0_2d(i,j) ; p0 = p0_2d(i,j) ; lambda = lambda_2d(i,j)
697  dp = p_b(i,j) - p_t(i,j)
698  p_ave = 0.5*(p_t(i,j)+p_b(i,j))
699 
700  eps = 0.5 * dp / (p0 + p_ave) ; eps2 = eps*eps
701  alpha_anom = al0 + lambda / (p0 + p_ave) - spv_ref
702  rem = lambda * eps2 * (c1_3 + eps2*(0.2 + eps2*(c1_7 + c1_9*eps2)))
703  dza(i,j) = alpha_anom*dp + 2.0*eps*rem
704  if (present(intp_dza)) &
705  intp_dza(i,j) = 0.5*alpha_anom*dp**2 - dp*(1.0-eps)*rem
706  enddo ; enddo
707 
708  if (present(intx_dza)) then ; do j=hi%jsc,hi%jec ; do i=isq,ieq
709  ! hWght is the distance measure by which the cell is violation of
710  ! hydrostatic consistency. For large hWght we bias the interpolation of
711  ! T & S along the top and bottom integrals, akin to thickness weighting.
712  hwght = 0.0
713  if (do_massweight) &
714  hwght = max(0., bathyp(i,j)-p_t(i+1,j), bathyp(i+1,j)-p_t(i,j))
715  if (hwght > 0.) then
716  hl = (p_b(i,j) - p_t(i,j)) + dp_neglect
717  hr = (p_b(i+1,j) - p_t(i+1,j)) + dp_neglect
718  hwght = hwght * ( (hl-hr)/(hl+hr) )**2
719  idenom = 1.0 / ( hwght*(hr + hl) + hl*hr )
720  hwt_ll = (hwght*hl + hr*hl) * idenom ; hwt_lr = (hwght*hr) * idenom
721  hwt_rr = (hwght*hr + hr*hl) * idenom ; hwt_rl = (hwght*hl) * idenom
722  else
723  hwt_ll = 1.0 ; hwt_lr = 0.0 ; hwt_rr = 1.0 ; hwt_rl = 0.0
724  endif
725 
726  intp(1) = dza(i,j) ; intp(5) = dza(i+1,j)
727  do m=2,4
728  wt_l = 0.25*real(5-m) ; wt_r = 1.0-wt_l
729  wtt_l = wt_l*hwt_ll + wt_r*hwt_rl ; wtt_r = wt_l*hwt_lr + wt_r*hwt_rr
730 
731  ! T, S, and p are interpolated in the horizontal. The p interpolation
732  ! is linear, but for T and S it may be thickness wekghted.
733  al0 = wtt_l*al0_2d(i,j) + wtt_r*al0_2d(i+1,j)
734  p0 = wtt_l*p0_2d(i,j) + wtt_r*p0_2d(i+1,j)
735  lambda = wtt_l*lambda_2d(i,j) + wtt_r*lambda_2d(i+1,j)
736 
737  dp = wt_l*(p_b(i,j) - p_t(i,j)) + wt_r*(p_b(i+1,j) - p_t(i+1,j))
738  p_ave = 0.5*(wt_l*(p_t(i,j)+p_b(i,j)) + wt_r*(p_t(i+1,j)+p_b(i+1,j)))
739 
740  eps = 0.5 * dp / (p0 + p_ave) ; eps2 = eps*eps
741  intp(m) = (al0 + lambda / (p0 + p_ave) - spv_ref)*dp + 2.0*eps* &
742  lambda * eps2 * (c1_3 + eps2*(0.2 + eps2*(c1_7 + c1_9*eps2)))
743  enddo
744  ! Use Bode's rule to integrate the values.
745  intx_dza(i,j) = c1_90*(7.0*(intp(1)+intp(5)) + 32.0*(intp(2)+intp(4)) + &
746  12.0*intp(3))
747  enddo ; enddo ; endif
748 
749  if (present(inty_dza)) then ; do j=jsq,jeq ; do i=hi%isc,hi%iec
750  ! hWght is the distance measure by which the cell is violation of
751  ! hydrostatic consistency. For large hWght we bias the interpolation of
752  ! T & S along the top and bottom integrals, akin to thickness weighting.
753  hwght = 0.0
754  if (do_massweight) &
755  hwght = max(0., bathyp(i,j)-p_t(i,j+1), bathyp(i,j+1)-p_t(i,j))
756  if (hwght > 0.) then
757  hl = (p_b(i,j) - p_t(i,j)) + dp_neglect
758  hr = (p_b(i,j+1) - p_t(i,j+1)) + dp_neglect
759  hwght = hwght * ( (hl-hr)/(hl+hr) )**2
760  idenom = 1.0 / ( hwght*(hr + hl) + hl*hr )
761  hwt_ll = (hwght*hl + hr*hl) * idenom ; hwt_lr = (hwght*hr) * idenom
762  hwt_rr = (hwght*hr + hr*hl) * idenom ; hwt_rl = (hwght*hl) * idenom
763  else
764  hwt_ll = 1.0 ; hwt_lr = 0.0 ; hwt_rr = 1.0 ; hwt_rl = 0.0
765  endif
766 
767  intp(1) = dza(i,j) ; intp(5) = dza(i,j+1)
768  do m=2,4
769  wt_l = 0.25*real(5-m) ; wt_r = 1.0-wt_l
770  wtt_l = wt_l*hwt_ll + wt_r*hwt_rl ; wtt_r = wt_l*hwt_lr + wt_r*hwt_rr
771 
772  ! T, S, and p are interpolated in the horizontal. The p interpolation
773  ! is linear, but for T and S it may be thickness wekghted.
774  al0 = wt_l*al0_2d(i,j) + wt_r*al0_2d(i,j+1)
775  p0 = wt_l*p0_2d(i,j) + wt_r*p0_2d(i,j+1)
776  lambda = wt_l*lambda_2d(i,j) + wt_r*lambda_2d(i,j+1)
777 
778  dp = wt_l*(p_b(i,j) - p_t(i,j)) + wt_r*(p_b(i,j+1) - p_t(i,j+1))
779  p_ave = 0.5*(wt_l*(p_t(i,j)+p_b(i,j)) + wt_r*(p_t(i,j+1)+p_b(i,j+1)))
780 
781  eps = 0.5 * dp / (p0 + p_ave) ; eps2 = eps*eps
782  intp(m) = (al0 + lambda / (p0 + p_ave) - spv_ref)*dp + 2.0*eps* &
783  lambda * eps2 * (c1_3 + eps2*(0.2 + eps2*(c1_7 + c1_9*eps2)))
784  enddo
785  ! Use Bode's rule to integrate the values.
786  inty_dza(i,j) = c1_90*(7.0*(intp(1)+intp(5)) + 32.0*(intp(2)+intp(4)) + &
787  12.0*intp(3))
788  enddo ; enddo ; endif

References a0, a1, a2, b0, b1, b2, b3, b4, b5, c0, c1, c2, c3, c4, and c5.

Variable Documentation

◆ a0

real, parameter mom_eos_wright::a0 = 7.057924e-4
private

Parameters in the Wright equation of state.

Definition at line 67 of file MOM_EOS_Wright.F90.

67 real, parameter :: a0 = 7.057924e-4, a1 = 3.480336e-7, a2 = -1.112733e-7 ! a0/a1 ~= 2028 ; a0/a2 ~= -6343

Referenced by calculate_compress_wright(), calculate_density_array_wright(), calculate_density_derivs_array_wright(), calculate_density_second_derivs_array_wright(), calculate_spec_vol_array_wright(), int_density_dz_wright(), and int_spec_vol_dp_wright().

◆ a1

◆ a2

◆ b0

real, parameter mom_eos_wright::b0 = 5.790749e8
private

Parameters in the Wright equation of state.

Definition at line 68 of file MOM_EOS_Wright.F90.

68 real, parameter :: b0 = 5.790749e8, b1 = 3.516535e6, b2 = -4.002714e4 ! b0/b1 ~= 165 ; b0/b4 ~= 974

Referenced by calculate_compress_wright(), calculate_density_array_wright(), calculate_density_derivs_array_wright(), calculate_density_second_derivs_array_wright(), calculate_spec_vol_array_wright(), calculate_specvol_derivs_wright(), int_density_dz_wright(), and int_spec_vol_dp_wright().

◆ b1

◆ b2

◆ b3

real, parameter mom_eos_wright::b3 = 2.084372e2
private

◆ b4

◆ b5

◆ c0

real, parameter mom_eos_wright::c0 = 1.704853e5
private

Parameters in the Wright equation of state.

Definition at line 70 of file MOM_EOS_Wright.F90.

70 real, parameter :: c0 = 1.704853e5, c1 = 7.904722e2, c2 = -7.984422 ! c0/c1 ~= 216 ; c0/c4 ~= -740

Referenced by calculate_compress_wright(), calculate_density_array_wright(), calculate_density_derivs_array_wright(), calculate_density_second_derivs_array_wright(), calculate_spec_vol_array_wright(), calculate_specvol_derivs_wright(), int_density_dz_wright(), and int_spec_vol_dp_wright().

◆ c1

◆ c2

◆ c3

real, parameter mom_eos_wright::c3 = 5.140652e-2
private

◆ c4

◆ c5