MOM6
mom_eos_linear Module Reference

Detailed Description

A simple linear equation of state for sea water with constant coefficients.

Data Types

interface  calculate_density_derivs_linear
 For a given thermodynamic state, return the derivatives of density with temperature and salinity using the simple linear equation of state. More...
 
interface  calculate_density_linear
 Compute the density of sea water (in kg/m^3), or its anomaly from a reference density, using a simple linear equation of state from salinity (in psu), potential temperature (in deg C) and pressure [Pa]. More...
 
interface  calculate_density_second_derivs_linear
 For a given thermodynamic state, return the second derivatives of density with various combinations of temperature, salinity, and pressure. Note that with a simple linear equation of state these second derivatives are all 0. More...
 
interface  calculate_spec_vol_linear
 Compute the specific volume of sea water (in m^3/kg), or its anomaly from a reference value, using a simple linear equation of state from salinity (in psu), potential temperature (in deg C) and pressure [Pa]. More...
 

Functions/Subroutines

subroutine, public calculate_density_scalar_linear (T, S, pressure, rho, Rho_T0_S0, dRho_dT, dRho_dS, rho_ref)
 This subroutine computes the density of sea water with a trivial linear equation of state (in [kg m-3]) from salinity (sal [PSU]), potential temperature (T [degC]), and pressure [Pa]. More...
 
subroutine, public calculate_density_array_linear (T, S, pressure, rho, start, npts, Rho_T0_S0, dRho_dT, dRho_dS, rho_ref)
 This subroutine computes the density of sea water with a trivial linear equation of state (in kg/m^3) from salinity (sal in psu), potential temperature (T [degC]), and pressure [Pa]. More...
 
subroutine calculate_spec_vol_scalar_linear (T, S, pressure, specvol, Rho_T0_S0, dRho_dT, dRho_dS, 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], using a trivial linear equation of state for density. If spv_ref is present, specvol is an anomaly from spv_ref. More...
 
subroutine calculate_spec_vol_array_linear (T, S, pressure, specvol, start, npts, Rho_T0_S0, dRho_dT, dRho_dS, 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], using a trivial linear equation of state for density. If spv_ref is present, specvol is an anomaly from spv_ref. More...
 
subroutine calculate_density_derivs_array_linear (T, S, pressure, drho_dT_out, drho_dS_out, Rho_T0_S0, dRho_dT, dRho_dS, start, npts)
 This subroutine calculates the partial derivatives of density * with potential temperature and salinity. More...
 
subroutine, public calculate_density_derivs_scalar_linear (T, S, pressure, drho_dT_out, drho_dS_out, Rho_T0_S0, dRho_dT, dRho_dS)
 This subroutine calculates the partial derivatives of density * with potential temperature and salinity for a single point. More...
 
subroutine calculate_density_second_derivs_scalar_linear (T, S, pressure, drho_dS_dS, drho_dS_dT, drho_dT_dT, drho_dS_dP, drho_dT_dP)
 This subroutine calculates the five, partial second derivatives of density w.r.t. potential temperature and salinity and pressure which for a linear equation of state should all be 0. More...
 
subroutine calculate_density_second_derivs_array_linear (T, S, pressure, drho_dS_dS, drho_dS_dT, drho_dT_dT, drho_dS_dP, drho_dT_dP, start, npts)
 This subroutine calculates the five, partial second derivatives of density w.r.t. potential temperature and salinity and pressure which for a linear equation of state should all be 0. More...
 
subroutine, public calculate_specvol_derivs_linear (T, S, pressure, dSV_dT, dSV_dS, start, npts, Rho_T0_S0, dRho_dT, dRho_dS)
 Calculate the derivatives of specific volume with temperature and salinity. More...
 
subroutine, public calculate_compress_linear (T, S, pressure, rho, drho_dp, start, npts, Rho_T0_S0, dRho_dT, dRho_dS)
 This subroutine computes the in situ density of sea water (rho) and the compressibility (drho/dp == C_sound^-2) at the given salinity, potential temperature, and pressure. More...
 
subroutine, public int_density_dz_linear (T, S, z_t, z_b, rho_ref, rho_0_pres, G_e, HI, Rho_T0_S0, dRho_dT, dRho_dS, 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_linear (T, S, p_t, p_b, alpha_ref, HI, Rho_T0_S0, dRho_dT, dRho_dS, dza, intp_dza, intx_dza, inty_dza, halo_size, bathyP, dP_neglect, useMassWghtInterp)
 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. Specific volume is assumed to vary linearly between adjacent points. More...
 

Function/Subroutine Documentation

◆ calculate_compress_linear()

subroutine, public mom_eos_linear::calculate_compress_linear ( 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,
real, intent(in)  Rho_T0_S0,
real, intent(in)  dRho_dT,
real, intent(in)  dRho_dS 
)

This subroutine computes the in situ density of sea water (rho) and the compressibility (drho/dp == C_sound^-2) at the given salinity, potential temperature, and pressure.

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.
[in]rho_t0_s0The density at T=0, S=0 [kg m-3].
[in]drho_dtThe derivative of density with temperature [kg m-3 degC-1].
[in]drho_dsThe derivative of density with salinity [kg m-3 ppt-1].

Definition at line 301 of file MOM_EOS_linear.F90.

301  real, intent(in), dimension(:) :: T !< Potential temperature relative to the surface
302  !! [degC].
303  real, intent(in), dimension(:) :: S !< Salinity [PSU].
304  real, intent(in), dimension(:) :: pressure !< pressure [Pa].
305  real, intent(out), dimension(:) :: rho !< In situ density [kg m-3].
306  real, intent(out), dimension(:) :: drho_dp !< The partial derivative of density with pressure
307  !! (also the inverse of the square of sound speed)
308  !! [s2 m-2].
309  integer, intent(in) :: start !< The starting point in the arrays.
310  integer, intent(in) :: npts !< The number of values to calculate.
311  real, intent(in) :: Rho_T0_S0 !< The density at T=0, S=0 [kg m-3].
312  real, intent(in) :: dRho_dT !< The derivative of density with
313  !! temperature [kg m-3 degC-1].
314  real, intent(in) :: dRho_dS !< The derivative of density with
315  !! salinity [kg m-3 ppt-1].
316  ! Local variables
317  integer :: j
318 
319  do j=start,start+npts-1
320  rho(j) = rho_t0_s0 + drho_dt*t(j) + drho_ds*s(j)
321  drho_dp(j) = 0.0
322  enddo

◆ calculate_density_array_linear()

subroutine, public mom_eos_linear::calculate_density_array_linear ( 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)  Rho_T0_S0,
real, intent(in)  dRho_dT,
real, intent(in)  dRho_dS,
real, intent(in), optional  rho_ref 
)

This subroutine computes the density of sea water with a trivial linear equation of state (in kg/m^3) from salinity (sal in psu), potential temperature (T [degC]), and pressure [Pa].

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_t0_s0The density at T=0, S=0 [kg m-3].
[in]drho_dtThe derivatives of density with temperature [kg m-3 degC-1].
[in]drho_dsThe derivatives of density with salinity in [kg m-3 ppt-1].
[in]rho_refA reference density [kg m-3].

Definition at line 82 of file MOM_EOS_linear.F90.

82  real, dimension(:), intent(in) :: T !< potential temperature relative to the surface [degC].
83  real, dimension(:), intent(in) :: S !< salinity [PSU].
84  real, dimension(:), intent(in) :: pressure !< pressure [Pa].
85  real, dimension(:), intent(out) :: rho !< in situ density [kg m-3].
86  integer, intent(in) :: start !< the starting point in the arrays.
87  integer, intent(in) :: npts !< the number of values to calculate.
88  real, intent(in) :: Rho_T0_S0 !< The density at T=0, S=0 [kg m-3].
89  real, intent(in) :: dRho_dT !< The derivatives of density with temperature
90  !! [kg m-3 degC-1].
91  real, intent(in) :: dRho_dS !< The derivatives of density with salinity
92  !! in [kg m-3 ppt-1].
93  real, optional, intent(in) :: rho_ref !< A reference density [kg m-3].
94  ! Local variables
95  integer :: j
96 
97  if (present(rho_ref)) then ; do j=start,start+npts-1
98  rho(j) = (rho_t0_s0 - rho_ref) + (drho_dt*t(j) + drho_ds*s(j))
99  enddo ; else ; do j=start,start+npts-1
100  rho(j) = rho_t0_s0 + drho_dt*t(j) + drho_ds*s(j)
101  enddo ; endif
102 

◆ calculate_density_derivs_array_linear()

subroutine mom_eos_linear::calculate_density_derivs_array_linear ( real, dimension(:), intent(in)  T,
real, dimension(:), intent(in)  S,
real, dimension(:), intent(in)  pressure,
real, dimension(:), intent(out)  drho_dT_out,
real, dimension(:), intent(out)  drho_dS_out,
real, intent(in)  Rho_T0_S0,
real, intent(in)  dRho_dT,
real, intent(in)  dRho_dS,
integer, intent(in)  start,
integer, intent(in)  npts 
)
private

This subroutine calculates the partial derivatives of density * with potential temperature and salinity.

Parameters
[in]tPotential temperature relative to the surface [degC].
[in]sSalinity [PSU].
[in]pressurePressure [Pa].
[out]drho_dt_outThe partial derivative of density with potential temperature [kg m-3 degC-1].
[out]drho_ds_outThe partial derivative of density with salinity [kg m-3 ppt-1].
[in]rho_t0_s0The density at T=0, S=0 [kg m-3].
[in]drho_dtThe derivative of density with temperature [kg m-3 degC-1].
[in]drho_dsThe derivative of density with salinity [kg m-3 ppt-1].
[in]startThe starting point in the arrays.
[in]nptsThe number of values to calculate.

Definition at line 165 of file MOM_EOS_linear.F90.

165  real, intent(in), dimension(:) :: T !< Potential temperature relative to the surface
166  !! [degC].
167  real, intent(in), dimension(:) :: S !< Salinity [PSU].
168  real, intent(in), dimension(:) :: pressure !< Pressure [Pa].
169  real, intent(out), dimension(:) :: drho_dT_out !< The partial derivative of density with
170  !! potential temperature [kg m-3 degC-1].
171  real, intent(out), dimension(:) :: drho_dS_out !< The partial derivative of density with
172  !! salinity [kg m-3 ppt-1].
173  real, intent(in) :: Rho_T0_S0 !< The density at T=0, S=0 [kg m-3].
174  real, intent(in) :: dRho_dT !< The derivative of density with temperature [kg m-3 degC-1].
175  real, intent(in) :: dRho_dS !< The derivative of density with salinity [kg m-3 ppt-1].
176  integer, intent(in) :: start !< The starting point in the arrays.
177  integer, intent(in) :: npts !< The number of values to calculate.
178  ! Local variables
179  integer :: j
180 
181  do j=start,start+npts-1
182  drho_dt_out(j) = drho_dt
183  drho_ds_out(j) = drho_ds
184  enddo
185 

◆ calculate_density_derivs_scalar_linear()

subroutine, public mom_eos_linear::calculate_density_derivs_scalar_linear ( real, intent(in)  T,
real, intent(in)  S,
real, intent(in)  pressure,
real, intent(out)  drho_dT_out,
real, intent(out)  drho_dS_out,
real, intent(in)  Rho_T0_S0,
real, intent(in)  dRho_dT,
real, intent(in)  dRho_dS 
)

This subroutine calculates the partial derivatives of density * with potential temperature and salinity for a single point.

Parameters
[in]tPotential temperature relative to the surface [degC].
[in]sSalinity [PSU].
[in]pressurepressure [Pa].
[out]drho_dt_outThe partial derivative of density with potential temperature [kg m-3 degC-1].
[out]drho_ds_outThe partial derivative of density with salinity [kg m-3 ppt-1].
[in]rho_t0_s0The density at T=0, S=0 [kg m-3].
[in]drho_dtThe derivatives of density with temperature [kg m-3 degC-1].
[in]drho_dsThe derivatives of density with salinity [kg m-3 ppt-1].

Definition at line 192 of file MOM_EOS_linear.F90.

192  real, intent(in) :: T !< Potential temperature relative to the surface
193  !! [degC].
194  real, intent(in) :: S !< Salinity [PSU].
195  real, intent(in) :: pressure !< pressure [Pa].
196  real, intent(out) :: drho_dT_out !< The partial derivative of density with
197  !! potential temperature [kg m-3 degC-1].
198  real, intent(out) :: drho_dS_out !< The partial derivative of density with
199  !! salinity [kg m-3 ppt-1].
200  real, intent(in) :: Rho_T0_S0 !< The density at T=0, S=0 [kg m-3].
201  real, intent(in) :: dRho_dT !< The derivatives of density with temperature [kg m-3 degC-1].
202  real, intent(in) :: dRho_dS !< The derivatives of density with salinity [kg m-3 ppt-1].
203  drho_dt_out = drho_dt
204  drho_ds_out = drho_ds
205 

◆ calculate_density_scalar_linear()

subroutine, public mom_eos_linear::calculate_density_scalar_linear ( real, intent(in)  T,
real, intent(in)  S,
real, intent(in)  pressure,
real, intent(out)  rho,
real, intent(in)  Rho_T0_S0,
real, intent(in)  dRho_dT,
real, intent(in)  dRho_dS,
real, intent(in), optional  rho_ref 
)

This subroutine computes the density of sea water with a trivial linear equation of state (in [kg m-3]) from salinity (sal [PSU]), potential temperature (T [degC]), and pressure [Pa].

Parameters
[in]tPotential temperature relative to the surface [degC].
[in]sSalinity [PSU].
[in]pressurepressure [Pa].
[out]rhoIn situ density [kg m-3].
[in]rho_t0_s0The density at T=0, S=0 [kg m-3].
[in]drho_dtThe derivatives of density with temperature [kg m-3 degC-1].
[in]drho_dsThe derivatives of density with salinity in [kg m-3 ppt-1].
[in]rho_refA reference density [kg m-3].

Definition at line 58 of file MOM_EOS_linear.F90.

58  real, intent(in) :: T !< Potential temperature relative to the surface [degC].
59  real, intent(in) :: S !< Salinity [PSU].
60  real, intent(in) :: pressure !< pressure [Pa].
61  real, intent(out) :: rho !< In situ density [kg m-3].
62  real, intent(in) :: Rho_T0_S0 !< The density at T=0, S=0 [kg m-3].
63  real, intent(in) :: dRho_dT !< The derivatives of density with temperature
64  !! [kg m-3 degC-1].
65  real, intent(in) :: dRho_dS !< The derivatives of density with salinity
66  !! in [kg m-3 ppt-1].
67  real, optional, intent(in) :: rho_ref !< A reference density [kg m-3].
68 
69  if (present(rho_ref)) then
70  rho = (rho_t0_s0 - rho_ref) + (drho_dt*t + drho_ds*s)
71  else
72  rho = rho_t0_s0 + drho_dt*t + drho_ds*s
73  endif
74 

◆ calculate_density_second_derivs_array_linear()

subroutine mom_eos_linear::calculate_density_second_derivs_array_linear ( real, dimension(:), intent(in)  T,
real, dimension(:), intent(in)  S,
real, dimension(:), intent(in)  pressure,
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

This subroutine calculates the five, partial second derivatives of density w.r.t. potential temperature and salinity and pressure which for a linear equation of state should all be 0.

Parameters
[in]tPotential temperature relative to the surface [degC].
[in]sSalinity [PSU].
[in]pressurepressure [Pa].
[out]drho_ds_dsThe second derivative of density with salinity [kg m-3 PSU-2].
[out]drho_ds_dtThe second derivative of density with temperature and salinity [kg m-3 ppt-1 degC-1].
[out]drho_dt_dtThe second derivative of density with temperature [kg m-3 degC-2].
[out]drho_ds_dpThe second derivative of density with salinity and pressure [kg m-3 PSU-1 Pa-1].
[out]drho_dt_dpThe second derivative of density with temperature and pressure [kg m-3 degC-1 Pa-1].
[in]startThe starting point in the arrays.
[in]nptsThe number of values to calculate.

Definition at line 238 of file MOM_EOS_linear.F90.

238  real, dimension(:), intent(in) :: T !< Potential temperature relative to the surface [degC].
239  real, dimension(:), intent(in) :: S !< Salinity [PSU].
240  real, dimension(:), intent(in) :: pressure !< pressure [Pa].
241  real, dimension(:), intent(out) :: drho_dS_dS !< The second derivative of density with
242  !! salinity [kg m-3 PSU-2].
243  real, dimension(:), intent(out) :: drho_dS_dT !< The second derivative of density with
244  !! temperature and salinity [kg m-3 ppt-1 degC-1].
245  real, dimension(:), intent(out) :: drho_dT_dT !< The second derivative of density with
246  !! temperature [kg m-3 degC-2].
247  real, dimension(:), intent(out) :: drho_dS_dP !< The second derivative of density with
248  !! salinity and pressure [kg m-3 PSU-1 Pa-1].
249  real, dimension(:), intent(out) :: drho_dT_dP !< The second derivative of density with
250  !! temperature and pressure [kg m-3 degC-1 Pa-1].
251  integer, intent(in) :: start !< The starting point in the arrays.
252  integer, intent(in) :: npts !< The number of values to calculate.
253  ! Local variables
254  integer :: j
255  do j=start,start+npts-1
256  drho_ds_ds(j) = 0.
257  drho_ds_dt(j) = 0.
258  drho_dt_dt(j) = 0.
259  drho_ds_dp(j) = 0.
260  drho_dt_dp(j) = 0.
261  enddo
262 

◆ calculate_density_second_derivs_scalar_linear()

subroutine mom_eos_linear::calculate_density_second_derivs_scalar_linear ( real, intent(in)  T,
real, intent(in)  S,
real, intent(in)  pressure,
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

This subroutine calculates the five, partial second derivatives of density w.r.t. potential temperature and salinity and pressure which for a linear equation of state should all be 0.

Parameters
[in]tPotential temperature relative to the surface [degC].
[in]sSalinity [PSU].
[in]pressurepressure [Pa].
[out]drho_ds_dsThe second derivative of density with salinity [kg m-3 PSU-2].
[out]drho_ds_dtThe second derivative of density with temperature and salinity [kg m-3 ppt-1 degC-1].
[out]drho_dt_dtThe second derivative of density with temperature [kg m-3 degC-2].
[out]drho_ds_dpThe second derivative of density with salinity and pressure [kg m-3 PSU-1 Pa-1].
[out]drho_dt_dpThe second derivative of density with temperature and pressure [kg m-3 degC-1 Pa-1].

Definition at line 212 of file MOM_EOS_linear.F90.

212  real, intent(in) :: T !< Potential temperature relative to the surface [degC].
213  real, intent(in) :: S !< Salinity [PSU].
214  real, intent(in) :: pressure !< pressure [Pa].
215  real, intent(out) :: drho_dS_dS !< The second derivative of density with
216  !! salinity [kg m-3 PSU-2].
217  real, intent(out) :: drho_dS_dT !< The second derivative of density with
218  !! temperature and salinity [kg m-3 ppt-1 degC-1].
219  real, intent(out) :: drho_dT_dT !< The second derivative of density with
220  !! temperature [kg m-3 degC-2].
221  real, intent(out) :: drho_dS_dP !< The second derivative of density with
222  !! salinity and pressure [kg m-3 PSU-1 Pa-1].
223  real, intent(out) :: drho_dT_dP !< The second derivative of density with
224  !! temperature and pressure [kg m-3 degC-1 Pa-1].
225 
226  drho_ds_ds = 0.
227  drho_ds_dt = 0.
228  drho_dt_dt = 0.
229  drho_ds_dp = 0.
230  drho_dt_dp = 0.
231 

◆ calculate_spec_vol_array_linear()

subroutine mom_eos_linear::calculate_spec_vol_array_linear ( 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)  Rho_T0_S0,
real, intent(in)  dRho_dT,
real, intent(in)  dRho_dS,
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], using a trivial linear equation of state for density. 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]rho_t0_s0The density at T=0, S=0 [kg m-3].
[in]drho_dtThe derivatives of density with temperature [kg m-3 degC-1].
[in]drho_dsThe derivatives of density with salinity [kg m-3 ppt-1].
[in]spv_refA reference specific volume [m3 kg-1].

Definition at line 138 of file MOM_EOS_linear.F90.

138  real, dimension(:), intent(in) :: T !< potential temperature relative to the surface
139  !! [degC].
140  real, dimension(:), intent(in) :: S !< Salinity [PSU].
141  real, dimension(:), intent(in) :: pressure !< Pressure [Pa].
142  real, dimension(:), intent(out) :: specvol !< in situ specific volume [m3 kg-1].
143  integer, intent(in) :: start !< the starting point in the arrays.
144  integer, intent(in) :: npts !< the number of values to calculate.
145  real, intent(in) :: Rho_T0_S0 !< The density at T=0, S=0 [kg m-3].
146  real, intent(in) :: dRho_dT !< The derivatives of density with temperature [kg m-3 degC-1].
147  real, intent(in) :: dRho_dS !< The derivatives of density with salinity [kg m-3 ppt-1].
148  real, optional, intent(in) :: spv_ref !< A reference specific volume [m3 kg-1].
149  ! Local variables
150  integer :: j
151 
152  if (present(spv_ref)) then ; do j=start,start+npts-1
153  specvol(j) = ((1.0 - rho_t0_s0*spv_ref) + spv_ref*(drho_dt*t(j) + drho_ds*s(j))) / &
154  ( rho_t0_s0 + (drho_dt*t(j) + drho_ds*s(j)))
155  enddo ; else ; do j=start,start+npts-1
156  specvol(j) = 1.0 / ( rho_t0_s0 + (drho_dt*t(j) + drho_ds*s(j)))
157  enddo ; endif
158 

◆ calculate_spec_vol_scalar_linear()

subroutine mom_eos_linear::calculate_spec_vol_scalar_linear ( real, intent(in)  T,
real, intent(in)  S,
real, intent(in)  pressure,
real, intent(out)  specvol,
real, intent(in)  Rho_T0_S0,
real, intent(in)  dRho_dT,
real, intent(in)  dRho_dS,
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], using a trivial linear equation of state for density. 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]rho_t0_s0The density at T=0, S=0 [kg m-3].
[in]drho_dtThe derivatives of density with temperature [kg m-3 degC-1].
[in]drho_dsThe derivatives of density with salinity [kg m-3 ppt-1].
[in]spv_refA reference specific volume [m3 kg-1].

Definition at line 111 of file MOM_EOS_linear.F90.

111  real, intent(in) :: T !< potential temperature relative to the surface
112  !! [degC].
113  real, intent(in) :: S !< Salinity [PSU].
114  real, intent(in) :: pressure !< Pressure [Pa].
115  real, intent(out) :: specvol !< In situ specific volume [m3 kg-1].
116  real, intent(in) :: Rho_T0_S0 !< The density at T=0, S=0 [kg m-3].
117  real, intent(in) :: dRho_dT !< The derivatives of density with temperature [kg m-3 degC-1].
118  real, intent(in) :: dRho_dS !< The derivatives of density with salinity [kg m-3 ppt-1].
119  real, optional, intent(in) :: spv_ref !< A reference specific volume [m3 kg-1].
120  ! Local variables
121  integer :: j
122 
123  if (present(spv_ref)) then
124  specvol = ((1.0 - rho_t0_s0*spv_ref) + spv_ref*(drho_dt*t + drho_ds*s)) / &
125  ( rho_t0_s0 + (drho_dt*t + drho_ds*s))
126  else
127  specvol = 1.0 / ( rho_t0_s0 + (drho_dt*t + drho_ds*s))
128  endif
129 

◆ calculate_specvol_derivs_linear()

subroutine, public mom_eos_linear::calculate_specvol_derivs_linear ( 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,
real, intent(in)  Rho_T0_S0,
real, intent(in)  dRho_dT,
real, intent(in)  dRho_dS 
)

Calculate the 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_dsThe partial derivative of specific volume with salinity [m3 kg-1 PSU-1].
[out]dsv_dtThe partial derivative of specific volume with potential temperature [m3 kg-1 degC-1].
[in]startThe starting point in the arrays.
[in]nptsThe number of values to calculate.
[in]rho_t0_s0The density at T=0, S=0 [kg m-3].
[in]drho_dtThe derivative of density with temperature, [kg m-3 degC-1].
[in]drho_dsThe derivative of density with salinity [kg m-3 ppt-1].

Definition at line 268 of file MOM_EOS_linear.F90.

268  real, intent(in), dimension(:) :: T !< Potential temperature relative to the surface
269  !! [degC].
270  real, intent(in), dimension(:) :: S !< Salinity [PSU].
271  real, intent(in), dimension(:) :: pressure !< pressure [Pa].
272  real, intent(out), dimension(:) :: dSV_dS !< The partial derivative of specific volume with
273  !! salinity [m3 kg-1 PSU-1].
274  real, intent(out), dimension(:) :: dSV_dT !< The partial derivative of specific volume with
275  !! potential temperature [m3 kg-1 degC-1].
276  integer, intent(in) :: start !< The starting point in the arrays.
277  integer, intent(in) :: npts !< The number of values to calculate.
278  real, intent(in) :: Rho_T0_S0 !< The density at T=0, S=0 [kg m-3].
279  real, intent(in) :: dRho_dT !< The derivative of density with
280  !! temperature, [kg m-3 degC-1].
281  real, intent(in) :: dRho_dS !< The derivative of density with
282  !! salinity [kg m-3 ppt-1].
283  ! Local variables
284  real :: I_rho2
285  integer :: j
286 
287  do j=start,start+npts-1
288  ! Sv = 1.0 / (Rho_T0_S0 + dRho_dT*T(j) + dRho_dS*S(j))
289  i_rho2 = 1.0 / (rho_t0_s0 + (drho_dt*t(j) + drho_ds*s(j)))**2
290  dsv_dt(j) = -drho_dt * i_rho2
291  dsv_ds(j) = -drho_ds * i_rho2
292  enddo
293 

◆ int_density_dz_linear()

subroutine, public mom_eos_linear::int_density_dz_linear ( 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)  z_t,
real, dimension(hi%isd:hi%ied,hi%jsd:hi%jed), intent(in)  z_b,
real, intent(in)  rho_ref,
real, intent(in)  rho_0_pres,
real, intent(in)  G_e,
type(hor_index_type), intent(in)  HI,
real, intent(in)  Rho_T0_S0,
real, intent(in)  dRho_dT,
real, intent(in)  dRho_dS,
real, dimension(hi%isd:hi%ied,hi%jsd:hi%jed), intent(out)  dpa,
real, dimension(hi%isd:hi%ied,hi%jsd:hi%jed), intent(out), optional  intz_dpa,
real, dimension(hi%isdb:hi%iedb,hi%jsd:hi%jed), intent(out), optional  intx_dpa,
real, dimension(hi%isd:hi%ied,hi%jsdb:hi%jedb), intent(out), optional  inty_dpa,
real, dimension(hi%isd:hi%ied,hi%jsd:hi%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]hiThe horizontal index type for the 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 [R ~> kg m-3] or [kg m-3], that is subtracted out to reduce the magnitude of each of the integrals.
[in]rho_0_presA density [R ~> kg m-3], used to calculate the pressure (as p~=-z*rho_0_pres*G_e) used in the equation of state. rho_0_pres is not used.
[in]g_eThe Earth's gravitational acceleration [L2 Z-1 T-2 ~> m s-2] or [m2 Z-1 s-2 ~> m s-2].
[in]rho_t0_s0The density at T=0, S=0 [R ~> kg m-3] or [kg m-3].
[in]drho_dtThe derivative of density with temperature, [R degC-1 ~> kg m-3 degC-1] or [kg m-3 degC-1].
[in]drho_dsThe derivative of density with salinity, in [R ppt-1 ~> kg m-3 ppt-1] or [kg m-3 ppt-1].
[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 331 of file MOM_EOS_linear.F90.

331  type(hor_index_type), intent(in) :: HI !< The horizontal index type for the arrays.
332  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
333  intent(in) :: T !< Potential temperature relative to the surface
334  !! [degC].
335  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
336  intent(in) :: S !< Salinity [PSU].
337  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
338  intent(in) :: z_t !< Height at the top of the layer in depth units [Z ~> m].
339  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
340  intent(in) :: z_b !< Height at the top of the layer [Z ~> m].
341  real, intent(in) :: rho_ref !< A mean density [R ~> kg m-3] or [kg m-3], that
342  !! is subtracted out to reduce the magnitude of
343  !! each of the integrals.
344  real, intent(in) :: rho_0_pres !< A density [R ~> kg m-3], used to calculate
345  !! the pressure (as p~=-z*rho_0_pres*G_e) used in
346  !! the equation of state. rho_0_pres is not used.
347  real, intent(in) :: G_e !< The Earth's gravitational acceleration
348  !! [L2 Z-1 T-2 ~> m s-2] or [m2 Z-1 s-2 ~> m s-2].
349  real, intent(in) :: Rho_T0_S0 !< The density at T=0, S=0 [R ~> kg m-3] or [kg m-3].
350  real, intent(in) :: dRho_dT !< The derivative of density with temperature,
351  !! [R degC-1 ~> kg m-3 degC-1] or [kg m-3 degC-1].
352  real, intent(in) :: dRho_dS !< The derivative of density with salinity,
353  !! in [R ppt-1 ~> kg m-3 ppt-1] or [kg m-3 ppt-1].
354  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
355  intent(out) :: dpa !< The change in the pressure anomaly across the
356  !! layer [R L2 T-2 ~> Pa] or [Pa].
357  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
358  optional, intent(out) :: intz_dpa !< The integral through the thickness of the layer
359  !! of the pressure anomaly relative to the anomaly
360  !! at the top of the layer [R L2 Z T-2 ~> Pa Z] or [Pa Z].
361  real, dimension(HI%IsdB:HI%IedB,HI%jsd:HI%jed), &
362  optional, intent(out) :: intx_dpa !< The integral in x of the difference between the
363  !! pressure anomaly at the top and bottom of the
364  !! layer divided by the x grid spacing [R L2 T-2 ~> Pa] or [Pa].
365  real, dimension(HI%isd:HI%ied,HI%JsdB:HI%JedB), &
366  optional, intent(out) :: inty_dpa !< The integral in y of the difference between the
367  !! pressure anomaly at the top and bottom of the
368  !! layer divided by the y grid spacing [R L2 T-2 ~> Pa] or [Pa].
369  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
370  optional, intent(in) :: bathyT !< The depth of the bathymetry [Z ~> m].
371  real, optional, intent(in) :: dz_neglect !< A miniscule thickness change [Z ~> m].
372  logical, optional, intent(in) :: useMassWghtInterp !< If true, uses mass weighting to
373  !! interpolate T/S for top and bottom integrals.
374 
375  ! Local variables
376  real :: rho_anom ! The density anomaly from rho_ref [R ~> kg m-3].
377  real :: raL, raR ! rho_anom to the left and right [R ~> kg m-3].
378  real :: dz, dzL, dzR ! Layer thicknesses [Z ~> m].
379  real :: hWght ! A pressure-thickness below topography [Z ~> m].
380  real :: hL, hR ! Pressure-thicknesses of the columns to the left and right [Z ~> m].
381  real :: iDenom ! The inverse of the denominator in the weights [Z-2 ~> m-2].
382  real :: hWt_LL, hWt_LR ! hWt_LA is the weighted influence of A on the left column [nondim].
383  real :: hWt_RL, hWt_RR ! hWt_RA is the weighted influence of A on the right column [nondim].
384  real :: wt_L, wt_R ! The linear weights of the left and right columns [nondim].
385  real :: wtT_L, wtT_R ! The weights for tracers from the left and right columns [nondim].
386  real :: intz(5) ! The integrals of density with height at the
387  ! 5 sub-column locations [R L2 T-2 ~> Pa] or [Pa].
388  logical :: do_massWeight ! Indicates whether to do mass weighting.
389  real, parameter :: C1_6 = 1.0/6.0, c1_90 = 1.0/90.0 ! Rational constants.
390  integer :: is, ie, js, je, Isq, Ieq, Jsq, Jeq, i, j, m
391 
392  ! These array bounds work for the indexing convention of the input arrays, but
393  ! on the computational domain defined for the output arrays.
394  isq = hi%IscB ; ieq = hi%IecB
395  jsq = hi%JscB ; jeq = hi%JecB
396  is = hi%isc ; ie = hi%iec
397  js = hi%jsc ; je = hi%jec
398 
399  do_massweight = .false.
400  if (present(usemasswghtinterp)) then ; if (usemasswghtinterp) then
401  do_massweight = .true.
402  ! if (.not.present(bathyT)) call MOM_error(FATAL, "int_density_dz_generic: "//&
403  ! "bathyT must be present if useMassWghtInterp is present and true.")
404  ! if (.not.present(dz_neglect)) call MOM_error(FATAL, "int_density_dz_generic: "//&
405  ! "dz_neglect must be present if useMassWghtInterp is present and true.")
406  endif ; endif
407 
408  do j=jsq,jeq+1 ; do i=isq,ieq+1
409  dz = z_t(i,j) - z_b(i,j)
410  rho_anom = (rho_t0_s0 - rho_ref) + drho_dt*t(i,j) + drho_ds*s(i,j)
411  dpa(i,j) = g_e*rho_anom*dz
412  if (present(intz_dpa)) intz_dpa(i,j) = 0.5*g_e*rho_anom*dz**2
413  enddo ; enddo
414 
415  if (present(intx_dpa)) then ; do j=js,je ; do i=isq,ieq
416  ! hWght is the distance measure by which the cell is violation of
417  ! hydrostatic consistency. For large hWght we bias the interpolation of
418  ! T & S along the top and bottom integrals, akin to thickness weighting.
419  hwght = 0.0
420  if (do_massweight) &
421  hwght = max(0., -bathyt(i,j)-z_t(i+1,j), -bathyt(i+1,j)-z_t(i,j))
422 
423  if (hwght <= 0.0) then
424  dzl = z_t(i,j) - z_b(i,j) ; dzr = z_t(i+1,j) - z_b(i+1,j)
425  ral = (rho_t0_s0 - rho_ref) + (drho_dt*t(i,j) + drho_ds*s(i,j))
426  rar = (rho_t0_s0 - rho_ref) + (drho_dt*t(i+1,j) + drho_ds*s(i+1,j))
427 
428  intx_dpa(i,j) = g_e*c1_6 * (dzl*(2.0*ral + rar) + dzr*(2.0*rar + ral))
429  else
430  hl = (z_t(i,j) - z_b(i,j)) + dz_neglect
431  hr = (z_t(i+1,j) - z_b(i+1,j)) + dz_neglect
432  hwght = hwght * ( (hl-hr)/(hl+hr) )**2
433  idenom = 1.0 / ( hwght*(hr + hl) + hl*hr )
434  hwt_ll = (hwght*hl + hr*hl) * idenom ; hwt_lr = (hwght*hr) * idenom
435  hwt_rr = (hwght*hr + hr*hl) * idenom ; hwt_rl = (hwght*hl) * idenom
436 
437  intz(1) = dpa(i,j) ; intz(5) = dpa(i+1,j)
438  do m=2,4
439  wt_l = 0.25*real(5-m) ; wt_R = 1.0-wt_l
440  wtt_l = wt_l*hwt_ll + wt_r*hwt_rl ; wtt_r = wt_l*hwt_lr + wt_r*hwt_rr
441 
442  dz = wt_l*(z_t(i,j) - z_b(i,j)) + wt_r*(z_t(i+1,j) - z_b(i+1,j))
443  rho_anom = (rho_t0_s0 - rho_ref) + &
444  (drho_dt * (wtt_l*t(i,j) + wtt_r*t(i+1,j)) + &
445  drho_ds * (wtt_l*s(i,j) + wtt_r*s(i+1,j)))
446  intz(m) = g_e*rho_anom*dz
447  enddo
448  ! Use Boole's rule to integrate the values.
449  intx_dpa(i,j) = c1_90*(7.0*(intz(1)+intz(5)) + 32.0*(intz(2)+intz(4)) + &
450  12.0*intz(3))
451  endif
452  enddo ; enddo ; endif
453 
454  if (present(inty_dpa)) then ; do j=jsq,jeq ; do i=is,ie
455  ! hWght is the distance measure by which the cell is violation of
456  ! hydrostatic consistency. For large hWght we bias the interpolation of
457  ! T & S along the top and bottom integrals, akin to thickness weighting.
458  hwght = 0.0
459  if (do_massweight) &
460  hwght = max(0., -bathyt(i,j)-z_t(i,j+1), -bathyt(i,j+1)-z_t(i,j))
461 
462  if (hwght <= 0.0) then
463  dzl = z_t(i,j) - z_b(i,j) ; dzr = z_t(i,j+1) - z_b(i,j+1)
464  ral = (rho_t0_s0 - rho_ref) + (drho_dt*t(i,j) + drho_ds*s(i,j))
465  rar = (rho_t0_s0 - rho_ref) + (drho_dt*t(i,j+1) + drho_ds*s(i,j+1))
466 
467  inty_dpa(i,j) = g_e*c1_6 * (dzl*(2.0*ral + rar) + dzr*(2.0*rar + ral))
468  else
469  hl = (z_t(i,j) - z_b(i,j)) + dz_neglect
470  hr = (z_t(i,j+1) - z_b(i,j+1)) + dz_neglect
471  hwght = hwght * ( (hl-hr)/(hl+hr) )**2
472  idenom = 1.0 / ( hwght*(hr + hl) + hl*hr )
473  hwt_ll = (hwght*hl + hr*hl) * idenom ; hwt_lr = (hwght*hr) * idenom
474  hwt_rr = (hwght*hr + hr*hl) * idenom ; hwt_rl = (hwght*hl) * idenom
475 
476  intz(1) = dpa(i,j) ; intz(5) = dpa(i,j+1)
477  do m=2,4
478  wt_l = 0.25*real(5-m) ; wt_R = 1.0-wt_l
479  wtt_l = wt_l*hwt_ll + wt_r*hwt_rl ; wtt_r = wt_l*hwt_lr + wt_r*hwt_rr
480 
481  dz = wt_l*(z_t(i,j) - z_b(i,j)) + wt_r*(z_t(i,j+1) - z_b(i,j+1))
482  rho_anom = (rho_t0_s0 - rho_ref) + &
483  (drho_dt * (wtt_l*t(i,j) + wtt_r*t(i,j+1)) + &
484  drho_ds * (wtt_l*s(i,j) + wtt_r*s(i,j+1)))
485  intz(m) = g_e*rho_anom*dz
486  enddo
487  ! Use Boole's rule to integrate the values.
488  inty_dpa(i,j) = c1_90*(7.0*(intz(1)+intz(5)) + 32.0*(intz(2)+intz(4)) + &
489  12.0*intz(3))
490  endif
491 
492  enddo ; enddo ; endif

◆ int_spec_vol_dp_linear()

subroutine, public mom_eos_linear::int_spec_vol_dp_linear ( 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)  alpha_ref,
type(hor_index_type), intent(in)  HI,
real, intent(in)  Rho_T0_S0,
real, intent(in)  dRho_dT,
real, intent(in)  dRho_dS,
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 
)

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. Specific volume is assumed to vary linearly between adjacent points.

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 [R L2 T-2 ~> Pa] or [Pa].
[in]p_bPressure at the top of the layer [R L2 T-2 ~> Pa] or [Pa].
[in]alpha_refA mean specific volume that is subtracted out to reduce the magnitude of each of the integrals [R-1 ~> m3 kg-1]. The calculation is mathematically identical with different values of alpha_ref, but this reduces the effects of roundoff.
[in]rho_t0_s0The density at T=0, S=0 [R ~> kg m-3] or [kg m-3].
[in]drho_dtThe derivative of density with temperature [R degC-1 ~> kg m-3 degC-1] or [kg m-3 degC-1].
[in]drho_dsThe derivative of density with salinity, in [R ppt-1 ~> kg m-3 ppt-1] or [kg m-3 ppt-1].
[out]dzaThe change in the geopotential anomaly across
[out]intp_dzaThe integral in pressure through the layer of the
[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 [R L2 T-2 ~> Pa] or [Pa]
[in]dp_neglectA miniscule pressure change with the same units as p_t [R L2 T-2 ~> Pa] or [Pa]
[in]usemasswghtinterpIf true, uses mass weighting to interpolate T/S for top and bottom integrals.

Definition at line 502 of file MOM_EOS_linear.F90.

502  type(hor_index_type), intent(in) :: HI !< The ocean's horizontal index type.
503  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
504  intent(in) :: T !< Potential temperature relative to the surface
505  !! [degC].
506  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
507  intent(in) :: S !< Salinity [PSU].
508  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
509  intent(in) :: p_t !< Pressure at the top of the layer [R L2 T-2 ~> Pa] or [Pa].
510  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
511  intent(in) :: p_b !< Pressure at the top of the layer [R L2 T-2 ~> Pa] or [Pa].
512  real, intent(in) :: alpha_ref !< A mean specific volume that is subtracted out
513  !! to reduce the magnitude of each of the integrals [R-1 ~> m3 kg-1].
514  !! The calculation is mathematically identical with different values of
515  !! alpha_ref, but this reduces the effects of roundoff.
516  real, intent(in) :: Rho_T0_S0 !< The density at T=0, S=0 [R ~> kg m-3] or [kg m-3].
517  real, intent(in) :: dRho_dT !< The derivative of density with temperature
518  !! [R degC-1 ~> kg m-3 degC-1] or [kg m-3 degC-1].
519  real, intent(in) :: dRho_dS !< The derivative of density with salinity,
520  !! in [R ppt-1 ~> kg m-3 ppt-1] or [kg m-3 ppt-1].
521  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
522  intent(out) :: dza !< The change in the geopotential anomaly across
523  !! the layer [L2 T-2 ~> m2 s-2] or [m2 s-2].
524  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
525  optional, intent(out) :: intp_dza !< The integral in pressure through the layer of the
526  !! geopotential anomaly relative to the anomaly at the
527  !! bottom of the layer [R L4 T-4 ~> Pa m2 s-2] or [Pa m2 s-2].
528  real, dimension(HI%IsdB:HI%IedB,HI%jsd:HI%jed), &
529  optional, intent(out) :: intx_dza !< The integral in x of the difference between the
530  !! geopotential anomaly at the top and bottom of
531  !! the layer divided by the x grid spacing
532  !! [L2 T-2 ~> m2 s-2] or [m2 s-2].
533  real, dimension(HI%isd:HI%ied,HI%JsdB:HI%JedB), &
534  optional, intent(out) :: inty_dza !< The integral in y of the difference between the
535  !! geopotential anomaly at the top and bottom of
536  !! the layer divided by the y grid spacing
537  !! [L2 T-2 ~> m2 s-2] or [m2 s-2].
538  integer, optional, intent(in) :: halo_size !< The width of halo points on which to calculate dza.
539  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
540  optional, intent(in) :: bathyP !< The pressure at the bathymetry [R L2 T-2 ~> Pa] or [Pa]
541  real, optional, intent(in) :: dP_neglect !< A miniscule pressure change with
542  !! the same units as p_t [R L2 T-2 ~> Pa] or [Pa]
543  logical, optional, intent(in) :: useMassWghtInterp !< If true, uses mass weighting
544  !! to interpolate T/S for top and bottom integrals.
545  ! Local variables
546  real :: dRho_TS ! The density anomaly due to T and S [R ~> kg m-3] or [kg m-3].
547  real :: alpha_anom ! The specific volume anomaly from 1/rho_ref [R-1 ~> m3 kg-1] or [m3 kg-1].
548  real :: aaL, aaR ! The specific volume anomaly to the left and right [R-1 ~> m3 kg-1] or [m3 kg-1].
549  real :: dp, dpL, dpR ! Layer pressure thicknesses [R L2 T-2 ~> Pa] or [Pa].
550  real :: hWght ! A pressure-thickness below topography [R L2 T-2 ~> Pa] or [Pa].
551  real :: hL, hR ! Pressure-thicknesses of the columns to the left and right [R L2 T-2 ~> Pa] or [Pa].
552  real :: iDenom ! The inverse of the denominator in the weights [T4 R-2 L-2 ~> Pa-2] or [Pa-2].
553  real :: hWt_LL, hWt_LR ! hWt_LA is the weighted influence of A on the left column [nondim].
554  real :: hWt_RL, hWt_RR ! hWt_RA is the weighted influence of A on the right column [nondim].
555  real :: wt_L, wt_R ! The linear weights of the left and right columns [nondim].
556  real :: wtT_L, wtT_R ! The weights for tracers from the left and right columns [nondim].
557  real :: intp(5) ! The integrals of specific volume with pressure at the
558  ! 5 sub-column locations [L2 T-2 ~> m2 s-2] or [m2 s-2].
559  logical :: do_massWeight ! Indicates whether to do mass weighting.
560  real, parameter :: C1_6 = 1.0/6.0, c1_90 = 1.0/90.0 ! Rational constants.
561  integer :: Isq, Ieq, Jsq, Jeq, ish, ieh, jsh, jeh, i, j, m, halo
562 
563  isq = hi%IscB ; ieq = hi%IecB ; jsq = hi%JscB ; jeq = hi%JecB
564  halo = 0 ; if (present(halo_size)) halo = max(halo_size,0)
565  ish = hi%isc-halo ; ieh = hi%iec+halo ; jsh = hi%jsc-halo ; jeh = hi%jec+halo
566  if (present(intx_dza)) then ; ish = min(isq,ish) ; ieh = max(ieq+1,ieh); endif
567  if (present(inty_dza)) then ; jsh = min(jsq,jsh) ; jeh = max(jeq+1,jeh); endif
568 
569  do_massweight = .false.
570  if (present(usemasswghtinterp)) then ; if (usemasswghtinterp) then
571  do_massweight = .true.
572 ! if (.not.present(bathyP)) call MOM_error(FATAL, "int_spec_vol_dp_generic: "//&
573 ! "bathyP must be present if useMassWghtInterp is present and true.")
574 ! if (.not.present(dP_neglect)) call MOM_error(FATAL, "int_spec_vol_dp_generic: "//&
575 ! "dP_neglect must be present if useMassWghtInterp is present and true.")
576  endif ; endif
577 
578  do j=jsh,jeh ; do i=ish,ieh
579  dp = p_b(i,j) - p_t(i,j)
580  drho_ts = drho_dt*t(i,j) + drho_ds*s(i,j)
581  ! alpha_anom = 1.0/(Rho_T0_S0 + dRho_TS)) - alpha_ref
582  alpha_anom = ((1.0-rho_t0_s0*alpha_ref) - drho_ts*alpha_ref) / (rho_t0_s0 + drho_ts)
583  dza(i,j) = alpha_anom*dp
584  if (present(intp_dza)) intp_dza(i,j) = 0.5*alpha_anom*dp**2
585  enddo ; enddo
586 
587  if (present(intx_dza)) then ; do j=hi%jsc,hi%jec ; do i=isq,ieq
588  ! hWght is the distance measure by which the cell is violation of
589  ! hydrostatic consistency. For large hWght we bias the interpolation of
590  ! T & S along the top and bottom integrals, akin to thickness weighting.
591  hwght = 0.0
592  if (do_massweight) &
593  hwght = max(0., bathyp(i,j)-p_t(i+1,j), bathyp(i+1,j)-p_t(i,j))
594 
595  if (hwght <= 0.0) then
596  dpl = p_b(i,j) - p_t(i,j) ; dpr = p_b(i+1,j) - p_t(i+1,j)
597  drho_ts = drho_dt*t(i,j) + drho_ds*s(i,j)
598  aal = ((1.0 - rho_t0_s0*alpha_ref) - drho_ts*alpha_ref) / (rho_t0_s0 + drho_ts)
599  drho_ts = drho_dt*t(i+1,j) + drho_ds*s(i+1,j)
600  aar = ((1.0 - rho_t0_s0*alpha_ref) - drho_ts*alpha_ref) / (rho_t0_s0 + drho_ts)
601 
602  intx_dza(i,j) = c1_6 * (2.0*(dpl*aal + dpr*aar) + (dpl*aar + dpr*aal))
603  else
604  hl = (p_b(i,j) - p_t(i,j)) + dp_neglect
605  hr = (p_b(i+1,j) - p_t(i+1,j)) + dp_neglect
606  hwght = hwght * ( (hl-hr)/(hl+hr) )**2
607  idenom = 1.0 / ( hwght*(hr + hl) + hl*hr )
608  hwt_ll = (hwght*hl + hr*hl) * idenom ; hwt_lr = (hwght*hr) * idenom
609  hwt_rr = (hwght*hr + hr*hl) * idenom ; hwt_rl = (hwght*hl) * idenom
610 
611  intp(1) = dza(i,j) ; intp(5) = dza(i+1,j)
612  do m=2,4
613  wt_l = 0.25*real(5-m) ; wt_R = 1.0-wt_l
614  wtt_l = wt_l*hwt_ll + wt_r*hwt_rl ; wtt_r = wt_l*hwt_lr + wt_r*hwt_rr
615 
616  ! T, S, and p are interpolated in the horizontal. The p interpolation
617  ! is linear, but for T and S it may be thickness wekghted.
618  dp = wt_l*(p_b(i,j) - p_t(i,j)) + wt_r*(p_b(i+1,j) - p_t(i+1,j))
619 
620  drho_ts = drho_dt*(wtt_l*t(i,j) + wtt_r*t(i+1,j)) + &
621  drho_ds*(wtt_l*s(i,j) + wtt_r*s(i+1,j))
622  ! alpha_anom = 1.0/(Rho_T0_S0 + dRho_TS)) - alpha_ref
623  alpha_anom = ((1.0-rho_t0_s0*alpha_ref) - drho_ts*alpha_ref) / (rho_t0_s0 + drho_ts)
624  intp(m) = alpha_anom*dp
625  enddo
626  ! Use Boole's rule to integrate the interface height anomaly values in y.
627  intx_dza(i,j) = c1_90*(7.0*(intp(1)+intp(5)) + 32.0*(intp(2)+intp(4)) + &
628  12.0*intp(3))
629  endif
630  enddo ; enddo ; endif
631 
632  if (present(inty_dza)) then ; do j=jsq,jeq ; do i=hi%isc,hi%iec
633  ! hWght is the distance measure by which the cell is violation of
634  ! hydrostatic consistency. For large hWght we bias the interpolation of
635  ! T & S along the top and bottom integrals, akin to thickness weighting.
636  hwght = 0.0
637  if (do_massweight) &
638  hwght = max(0., bathyp(i,j)-p_t(i,j+1), bathyp(i,j+1)-p_t(i,j))
639 
640  if (hwght <= 0.0) then
641  dpl = p_b(i,j) - p_t(i,j) ; dpr = p_b(i,j+1) - p_t(i,j+1)
642  drho_ts = drho_dt*t(i,j) + drho_ds*s(i,j)
643  aal = ((1.0 - rho_t0_s0*alpha_ref) - drho_ts*alpha_ref) / (rho_t0_s0 + drho_ts)
644  drho_ts = drho_dt*t(i,j+1) + drho_ds*s(i,j+1)
645  aar = ((1.0 - rho_t0_s0*alpha_ref) - drho_ts*alpha_ref) / (rho_t0_s0 + drho_ts)
646 
647  inty_dza(i,j) = c1_6 * (2.0*(dpl*aal + dpr*aar) + (dpl*aar + dpr*aal))
648  else
649  hl = (p_b(i,j) - p_t(i,j)) + dp_neglect
650  hr = (p_b(i,j+1) - p_t(i,j+1)) + dp_neglect
651  hwght = hwght * ( (hl-hr)/(hl+hr) )**2
652  idenom = 1.0 / ( hwght*(hr + hl) + hl*hr )
653  hwt_ll = (hwght*hl + hr*hl) * idenom ; hwt_lr = (hwght*hr) * idenom
654  hwt_rr = (hwght*hr + hr*hl) * idenom ; hwt_rl = (hwght*hl) * idenom
655 
656  intp(1) = dza(i,j) ; intp(5) = dza(i,j+1)
657  do m=2,4
658  wt_l = 0.25*real(5-m) ; wt_R = 1.0-wt_l
659  wtt_l = wt_l*hwt_ll + wt_r*hwt_rl ; wtt_r = wt_l*hwt_lr + wt_r*hwt_rr
660 
661  ! T, S, and p are interpolated in the horizontal. The p interpolation
662  ! is linear, but for T and S it may be thickness wekghted.
663  dp = wt_l*(p_b(i,j) - p_t(i,j)) + wt_r*(p_b(i,j+1) - p_t(i,j+1))
664 
665  drho_ts = drho_dt*(wtt_l*t(i,j) + wtt_r*t(i,j+1)) + &
666  drho_ds*(wtt_l*s(i,j) + wtt_r*s(i,j+1))
667  ! alpha_anom = 1.0/(Rho_T0_S0 + dRho_TS)) - alpha_ref
668  alpha_anom = ((1.0-rho_t0_s0*alpha_ref) - drho_ts*alpha_ref) / (rho_t0_s0 + drho_ts)
669  intp(m) = alpha_anom*dp
670  enddo
671  ! Use Boole's rule to integrate the interface height anomaly values in y.
672  inty_dza(i,j) = c1_90*(7.0*(intp(1)+intp(5)) + 32.0*(intp(2)+intp(4)) + &
673  12.0*intp(3))
674  endif
675  enddo ; enddo ; endif