MOM6
MOM_EOS_linear.F90
Go to the documentation of this file.
2 
3 !***********************************************************************
4 !* GNU General Public License *
5 !* This file is a part of MOM. *
6 !* *
7 !* MOM is free software; you can redistribute it and/or modify it and *
8 !* are expected to follow the terms of the GNU General Public License *
9 !* as published by the Free Software Foundation; either version 2 of *
10 !* the License, or (at your option) any later version. *
11 !* *
12 !* MOM is distributed in the hope that it will be useful, but WITHOUT *
13 !* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
14 !* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public *
15 !* License for more details. *
16 !* *
17 !* For the full text of the GNU General Public License, *
18 !* write to: Free Software Foundation, Inc., *
19 !* 675 Mass Ave, Cambridge, MA 02139, USA. *
20 !* or see: http://www.gnu.org/licenses/gpl.html *
21 !***********************************************************************
22 
23 !***********************************************************************
24 !* The subroutines in this file implement a simple linear equation of *
25 !* state for sea water with constant coefficients set as parameters. *
26 !***********************************************************************
27 
28 use mom_hor_index, only : hor_index_type
29 
30 implicit none ; private
31 
32 #include <MOM_memory.h>
33 
38 
41 end interface calculate_density_linear
42 
43 contains
44 
45 !> This subroutine computes the density of sea water with a trivial
46 !! linear equation of state (in kg/m^3) from salinity (sal in psu),
47 !! potential temperature (T in deg C), and pressure in Pa.
48 subroutine calculate_density_scalar_linear(T, S, pressure, rho, &
49  Rho_T0_S0, dRho_dT, dRho_dS)
50  real, intent(in) :: T !< Potential temperature relative to the surface in C.
51  real, intent(in) :: S !< Salinity in PSU.
52  real, intent(in) :: pressure !< Pressure in Pa.
53  real, intent(out) :: rho !< In situ density in kg m-3.
54  real, intent(in) :: Rho_T0_S0 !< The density at T=0, S=0, in kg m-3.
55  real, intent(in) :: dRho_dT !< The derivatives of density with temperature and salinity,
56  !! in kg m-3 C-1 and kg m-3 psu-1.
57  real, intent(in) :: dRho_dS !< The derivatives of density with temperature and salinity,
58  !! in kg m-3 C-1 and kg m-3 psu-1.
59 
60 ! * This subroutine computes the density of sea water with a trivial *
61 ! * linear equation of state (in kg/m^3) from salinity (sal in psu), *
62 ! * potential temperature (T in deg C), and pressure in Pa. *
63 ! * *
64 ! * Arguments: T - potential temperature relative to the surface in C. *
65 ! * (in) S - salinity in PSU. *
66 ! * (in) pressure - pressure in Pa. *
67 ! * (out) rho - in situ density in kg m-3. *
68 ! * (in) start - the starting point in the arrays. *
69 ! * (in) npts - the number of values to calculate. *
70 ! * (in) Rho_T0_S0 - The density at T=0, S=0, in kg m-3. *
71 ! * (in) dRho_dT - The derivatives of density with temperature *
72 ! * (in) dRho_dS - and salinity, in kg m-3 C-1 and kg m-3 psu-1. *
73 
74  rho = rho_t0_s0 + drho_dt*t + drho_ds*s
75 
77 
78 !> This subroutine computes the density of sea water with a trivial
79 !! linear equation of state (in kg/m^3) from salinity (sal in psu),
80 !! potential temperature (T in deg C), and pressure in Pa.
81 subroutine calculate_density_array_linear(T, S, pressure, rho, start, npts, &
82  Rho_T0_S0, dRho_dT, dRho_dS)
83  real, intent(in), dimension(:) :: T !< Potential temperature relative to the surface
84  !! in C.
85  real, intent(in), dimension(:) :: S !< Salinity in PSU.
86  real, intent(in), dimension(:) :: pressure !< Pressure in Pa.
87  real, intent(out), dimension(:) :: rho !< In situ density in kg m-3.
88  integer, intent(in) :: start !< The starting point in the arrays.
89  integer, intent(in) :: npts !< The number of values to calculate.
90  real, intent(in) :: Rho_T0_S0 !< The density at T=0, S=0, in kg m-3.
91  real, intent(in) :: dRho_dT, dRho_dS !< The derivatives of density with
92  !! temperature and salinity, in kg m-3 C-1
93  !! and kg m-3 psu-1.
94 
95 ! * This subroutine computes the density of sea water with a trivial *
96 ! * linear equation of state (in kg/m^3) from salinity (sal in psu), *
97 ! * potential temperature (T in deg C), and pressure in Pa. *
98 ! * *
99 ! * Arguments: T - potential temperature relative to the surface in C. *
100 ! * (in) S - salinity in PSU. *
101 ! * (in) pressure - pressure in Pa. *
102 ! * (out) rho - in situ density in kg m-3. *
103 ! * (in) start - the starting point in the arrays. *
104 ! * (in) npts - the number of values to calculate. *
105 ! * (in) Rho_T0_S0 - The density at T=0, S=0, in kg m-3. *
106 ! * (in) dRho_dT - The derivatives of density with temperature *
107 ! * (in) dRho_dS - and salinity, in kg m-3 C-1 and kg m-3 psu-1. *
108  real :: al0, p0, lambda
109  integer :: j
110 
111  do j=start,start+npts-1
112  rho(j) = rho_t0_s0 + drho_dt*t(j) + drho_ds*s(j)
113  enddo
114 end subroutine calculate_density_array_linear
115 
116 !> This subroutine calculates the partial derivatives of density *
117 !! with potential temperature and salinity.
118 subroutine calculate_density_derivs_linear(T, S, pressure, drho_dT_out, &
119  drho_dS_out, start, npts, Rho_T0_S0, dRho_dT, dRho_dS)
120  real, intent(in), dimension(:) :: T !< Potential temperature relative to the surface
121  !! in C.
122  real, intent(in), dimension(:) :: S !< Salinity in PSU.
123  real, intent(in), dimension(:) :: pressure !< Pressure in Pa.
124  real, intent(out), dimension(:) :: drho_dT_out !< The partial derivative of density with
125  !! potential temperature, in kg m-3 K-1.
126  real, intent(out), dimension(:) :: drho_dS_out !< The partial derivative of density with
127  !! salinity, in kg m-3 psu-1.
128  integer, intent(in) :: start !< The starting point in the arrays.
129  integer, intent(in) :: npts !< The number of values to calculate.
130  real, intent(in) :: Rho_T0_S0 !< The density at T=0, S=0, in kg m-3.
131  real, intent(in) :: dRho_dT, dRho_dS !< The derivatives of density with
132  !! temperature and salinity, in kg m-3 C-1
133  !! and kg m-3 psu-1.
134 
135 ! * This subroutine calculates the partial derivatives of density *
136 ! * with potential temperature and salinity. *
137 ! * *
138 ! * Arguments: T - potential temperature relative to the surface in C. *
139 ! * (in) S - salinity in PSU. *
140 ! * (in) pressure - pressure in Pa. *
141 ! * (out) drho_dT_out - the partial derivative of density with *
142 ! * potential temperature, in kg m-3 K-1. *
143 ! * (out) drho_dS_out - the partial derivative of density with *
144 ! * salinity, in kg m-3 psu-1. *
145 ! * (in) start - the starting point in the arrays. *
146 ! * (in) npts - the number of values to calculate. *
147 ! * (in) Rho_T0_S0 - The density at T=0, S=0, in kg m-3. *
148 ! * (in) dRho_dT - The derivatives of density with temperature *
149 ! * (in) dRho_dS - and salinity, in kg m-3 C-1 and kg m-3 psu-1. *
150  integer :: j
151 
152  do j=start,start+npts-1
153  drho_dt_out(j) = drho_dt
154  drho_ds_out(j) = drho_ds
155  enddo
156 
157 end subroutine calculate_density_derivs_linear
158 
159 ! #@# This subroutine needs a doxygen description.
160 subroutine calculate_specvol_derivs_linear(T, S, pressure, dSV_dT, dSV_dS, &
161  start, npts, Rho_T0_S0, dRho_dT, dRho_dS)
162  real, intent(in), dimension(:) :: T !< Potential temperature relative to the surface
163  !! in C.
164  real, intent(in), dimension(:) :: S !< Salinity in g/kg.
165  real, intent(in), dimension(:) :: pressure !< Pressure in Pa.
166  real, intent(out), dimension(:) :: dSV_dS !< The partial derivative of specific volume with
167  !! salinity, in m3 kg-1 / (g/kg).
168  real, intent(out), dimension(:) :: dSV_dT !< The partial derivative of specific volume with
169  !! potential temperature, in m3 kg-1 K-1.
170  integer, intent(in) :: start !< The starting point in the arrays.
171  integer, intent(in) :: npts !< The number of values to calculate.
172  real, intent(in) :: Rho_T0_S0 !< The density at T=0, S=0, in kg m-3.
173  real, intent(in) :: dRho_dT, dRho_dS !< The derivatives of density with
174  !! temperature and salinity, in kg m-3 C-1
175  !! and kg m-3 psu-1.
176 
177 ! * Arguments: T - potential temperature relative to the surface in C. *
178 ! * (in) S - salinity in g/kg. *
179 ! * (in) pressure - pressure in Pa. *
180 ! * (out) dSV_dT - the partial derivative of specific volume with *
181 ! * potential temperature, in m3 kg-1 K-1. *
182 ! * (out) dSV_dS - the partial derivative of specific volume with *
183 ! * salinity, in m3 kg-1 / (g/kg). *
184 ! * (in) start - the starting point in the arrays. *
185 ! * (in) npts - the number of values to calculate. *
186  real :: I_rho2
187  integer :: j
188 
189  do j=start,start+npts-1
190  ! Sv = 1.0 / (Rho_T0_S0 + dRho_dT*T(j) + dRho_dS*S(j))
191  i_rho2 = 1.0 / (rho_t0_s0 + (drho_dt*t(j) + drho_ds*s(j)))**2
192  dsv_dt(j) = -drho_dt * i_rho2
193  dsv_ds(j) = -drho_ds * i_rho2
194  enddo
195 
196 end subroutine calculate_specvol_derivs_linear
197 
198 !> This subroutine computes the in situ density of sea water (rho)
199 !! and the compressibility (drho/dp == C_sound^-2) at the given
200 !! salinity, potential temperature, and pressure.
201 subroutine calculate_compress_linear(T, S, pressure, rho, drho_dp, start, npts,&
202  Rho_T0_S0, dRho_dT, dRho_dS)
203  real, intent(in), dimension(:) :: T !< Potential temperature relative to the surface
204  !! in C.
205  real, intent(in), dimension(:) :: S !< Salinity in PSU.
206  real, intent(in), dimension(:) :: pressure !< Pressure in Pa.
207  real, intent(out), dimension(:) :: rho !< In situ density in kg m-3.
208  real, intent(out), dimension(:) :: drho_dp !< The partial derivative of density with pressure
209  !! (also the inverse of the square of sound speed)
210  !! in s2 m-2.
211  integer, intent(in) :: start !< The starting point in the arrays.
212  integer, intent(in) :: npts !< The number of values to calculate.
213  real, intent(in) :: Rho_T0_S0 !< The density at T=0, S=0, in kg m-3.
214  real, intent(in) :: dRho_dT, dRho_dS !< The derivatives of density with
215  !! temperature and salinity, in kg m-3 C-1
216  !! and kg m-3 psu-1.
217 
218 ! * This subroutine computes the in situ density of sea water (rho) *
219 ! * and the compressibility (drho/dp == C_sound^-2) at the given *
220 ! * salinity, potential temperature, and pressure. *
221 ! * *
222 ! * Arguments: T - potential temperature relative to the surface in C. *
223 ! * (in) S - salinity in PSU. *
224 ! * (in) pressure - pressure in Pa. *
225 ! * (out) rho - in situ density in kg m-3. *
226 ! * (out) drho_dp - the partial derivative of density with *
227 ! * pressure (also the inverse of the square of *
228 ! * sound speed) in s2 m-2. *
229 ! * (in) start - the starting point in the arrays. *
230 ! * (in) npts - the number of values to calculate. *
231 ! * (in) Rho_T0_S0 - The density at T=0, S=0, in kg m-3. *
232 ! * (in) dRho_dT - The derivatives of density with temperature *
233 ! * (in) dRho_dS - and salinity, in kg m-3 C-1 and kg m-3 psu-1. *
234 
235  integer :: j
236 
237  do j=start,start+npts-1
238  rho(j) = rho_t0_s0 + drho_dt*t(j) + drho_ds*s(j)
239  drho_dp(j) = 0.0
240  enddo
241 end subroutine calculate_compress_linear
242 
243 !> This subroutine calculates analytical and nearly-analytical integrals of
244 !! pressure anomalies across layers, which are required for calculating the
245 !! finite-volume form pressure accelerations in a Boussinesq model.
246 subroutine int_density_dz_linear(T, S, z_t, z_b, rho_ref, rho_0_pres, G_e, HII, HIO, &
247  Rho_T0_S0, dRho_dT, dRho_dS, dpa, intz_dpa, intx_dpa, inty_dpa)
248  type(hor_index_type), intent(in) :: HII, HIO
249  real, dimension(HII%isd:HII%ied,HII%jsd:HII%jed), &
250  intent(in) :: T !< Potential temperature relative to the surface
251  !! in C.
252  real, dimension(HII%isd:HII%ied,HII%jsd:HII%jed), &
253  intent(in) :: S !< Salinity in PSU.
254  real, dimension(HII%isd:HII%ied,HII%jsd:HII%jed), &
255  intent(in) :: z_t !< Height at the top of the layer in m.
256  real, dimension(HII%isd:HII%ied,HII%jsd:HII%jed), &
257  intent(in) :: z_b !< Height at the top of the layer in m.
258  real, intent(in) :: rho_ref !< A mean density, in kg m-3, that is subtracted
259  !! out to reduce the magnitude of each of the
260  !! integrals.
261  real, intent(in) :: rho_0_pres !< A density, in kg m-3, that is used to calculate
262  !! the pressure (as p~=-z*rho_0_pres*G_e) used in
263  !! the equation of state. rho_0_pres is not used
264  !! here.
265  real, intent(in) :: G_e !< The Earth's gravitational acceleration,
266  !! in m s-2.
267  real, intent(in) :: Rho_T0_S0 !< The density at T=0, S=0, in kg m-3.
268  real, intent(in) :: dRho_dT !< The derivative of density with temperature,
269  !! in kg m-3 C-1.
270  real, intent(in) :: dRho_dS !< The derivative of density with salinity,
271  !! in kg m-3 psu-1.
272  real, dimension(HIO%isd:HIO%ied,HIO%jsd:HIO%jed), &
273  intent(out) :: dpa !< The change in the pressure anomaly across the
274  !! layer, in Pa.
275  real, dimension(HIO%isd:HIO%ied,HIO%jsd:HIO%jed), &
276  optional, intent(out) :: intz_dpa !< The integral through the thickness of the layer
277  !! of the pressure anomaly relative to the anomaly
278  !! at the top of the layer, in Pa m.
279  real, dimension(HIO%IsdB:HIO%IedB,HIO%jsd:HIO%jed), &
280  optional, intent(out) :: intx_dpa !< The integral in x of the difference between the
281  !! pressure anomaly at the top and bottom of the
282  !! layer divided by the x grid spacing, in Pa.
283  real, dimension(HIO%isd:HIO%ied,HIO%JsdB:HIO%JedB), &
284  optional, intent(out) :: inty_dpa !< The integral in y of the difference between the
285  !! pressure anomaly at the top and bottom of the
286  !! layer divided by the y grid spacing, in Pa.
287 
288 ! This subroutine calculates analytical and nearly-analytical integrals of
289 ! pressure anomalies across layers, which are required for calculating the
290 ! finite-volume form pressure accelerations in a Boussinesq model.
291 !
292 ! Arguments: T - potential temperature relative to the surface in C.
293 ! (in) S - salinity in PSU.
294 ! (in) z_t - height at the top of the layer in m.
295 ! (in) z_b - height at the top of the layer in m.
296 ! (in) rho_ref - A mean density, in kg m-3, that is subtracted out to reduce
297 ! the magnitude of each of the integrals.
298 ! (in) rho_0_pres - A density, in kg m-3, that is used to calculate the
299 ! pressure (as p~=-z*rho_0_pres*G_e) used in the equation of
300 ! state. rho_0_pres is not used here.
301 ! (in) G_e - The Earth's gravitational acceleration, in m s-2.
302 ! (in) G - The ocean's grid structure.
303 ! (in) Rho_T0_S0 - The density at T=0, S=0, in kg m-3.
304 ! (in) dRho_dT - The derivative of density with temperature in kg m-3 C-1.
305 ! (in) dRho_dS - The derivative of density with salinity, in kg m-3 psu-1.
306 ! (out) dpa - The change in the pressure anomaly across the layer, in Pa.
307 ! (out,opt) intz_dpa - The integral through the thickness of the layer of the
308 ! pressure anomaly relative to the anomaly at the top of
309 ! the layer, in Pa m.
310 ! (out,opt) intx_dpa - The integral in x of the difference between the
311 ! pressure anomaly at the top and bottom of the layer
312 ! divided by the x grid spacing, in Pa.
313 ! (out,opt) inty_dpa - The integral in y of the difference between the
314 ! pressure anomaly at the top and bottom of the layer
315 ! divided by the y grid spacing, in Pa.
316  real :: rho_anom ! The density anomaly from rho_ref, in kg m-3.
317  real :: raL, raR ! rho_anom to the left and right, in kg m-3.
318  real :: dz, dzL, dzR ! Layer thicknesses in m.
319  real :: C1_6
320  integer :: is, ie, js, je, Isq, Ieq, Jsq, Jeq, i, j, ioff, joff
321 
322  ioff = hio%idg_offset - hii%idg_offset
323  joff = hio%jdg_offset - hii%jdg_offset
324 
325  ! These array bounds work for the indexing convention of the input arrays, but
326  ! on the computational domain defined for the output arrays.
327  isq = hio%IscB + ioff ; ieq = hio%IecB + ioff
328  jsq = hio%JscB + joff ; jeq = hio%JecB + joff
329  is = hio%isc + ioff ; ie = hio%iec + ioff
330  js = hio%jsc + joff ; je = hio%jec + joff
331  c1_6 = 1.0 / 6.0
332 
333  do j=jsq,jeq+1 ; do i=isq,ieq+1
334  dz = z_t(i,j) - z_b(i,j)
335  rho_anom = (rho_t0_s0 - rho_ref) + drho_dt*t(i,j) + drho_ds*s(i,j)
336  dpa(i-ioff,j-joff) = g_e*rho_anom*dz
337  if (present(intz_dpa)) intz_dpa(i-ioff,j-joff) = 0.5*g_e*rho_anom*dz**2
338  enddo ; enddo
339 
340  if (present(intx_dpa)) then ; do j=js,je ; do i=isq,ieq
341  dzl = z_t(i,j) - z_b(i,j) ; dzr = z_t(i+1,j) - z_b(i+1,j)
342  ral = (rho_t0_s0 - rho_ref) + (drho_dt*t(i,j) + drho_ds*s(i,j))
343  rar = (rho_t0_s0 - rho_ref) + (drho_dt*t(i+1,j) + drho_ds*s(i+1,j))
344 
345  intx_dpa(i-ioff,j-joff) = g_e*c1_6 * (dzl*(2.0*ral + rar) + dzr*(2.0*rar + ral))
346  enddo ; enddo ; endif
347 
348  if (present(inty_dpa)) then ; do j=jsq,jeq ; do i=is,ie
349  dzl = z_t(i,j) - z_b(i,j) ; dzr = z_t(i,j+1) - z_b(i,j+1)
350  ral = (rho_t0_s0 - rho_ref) + (drho_dt*t(i,j) + drho_ds*s(i,j))
351  rar = (rho_t0_s0 - rho_ref) + (drho_dt*t(i,j+1) + drho_ds*s(i,j+1))
352 
353  inty_dpa(i-ioff,j-joff) = g_e*c1_6 * (dzl*(2.0*ral + rar) + dzr*(2.0*rar + ral))
354  enddo ; enddo ; endif
355 end subroutine int_density_dz_linear
356 
357 !> This subroutine calculates analytical and nearly-analytical integrals in
358 !! pressure across layers of geopotential anomalies, which are required for
359 !! calculating the finite-volume form pressure accelerations in a non-Boussinesq
360 !! model. Specific volume is assumed to vary linearly between adjacent points.
361 subroutine int_spec_vol_dp_linear(T, S, p_t, p_b, alpha_ref, HI, Rho_T0_S0, &
362  dRho_dT, dRho_dS, dza, intp_dza, intx_dza, inty_dza, halo_size)
363  type(hor_index_type), intent(in) :: HI !< The ocean's horizontal index type.
364  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
365  intent(in) :: T !< Potential temperature relative to the surface
366  !! in C.
367  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
368  intent(in) :: S !< Salinity in PSU.
369  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
370  intent(in) :: p_t !< Pressure at the top of the layer in Pa.
371  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
372  intent(in) :: p_b !< Pressure at the top of the layer in Pa.
373  real, intent(in) :: alpha_ref !< A mean specific volume that is subtracted out
374  !! to reduce the magnitude of each of the integrals, m3 kg-1. The calculation is
375  !! mathematically identical with different values of alpha_ref, but this reduces the
376  !! effects of roundoff.
377  real, intent(in) :: Rho_T0_S0 !< The density at T=0, S=0, in kg m-3.
378  real, intent(in) :: dRho_dT !< The derivative of density with temperature,
379  !! in kg m-3 C-1.
380  real, intent(in) :: dRho_dS !< The derivative of density with salinity,
381  !! in kg m-3 psu-1.
382  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
383  intent(out) :: dza !< The change in the geopotential anomaly across
384  !! the layer, in m2 s-2.
385  real, dimension(HI%isd:HI%ied,HI%jsd:HI%jed), &
386  optional, intent(out) :: intp_dza !< The integral in pressure through the layer of
387  !! the geopotential anomaly relative to the anomaly
388  !! at the bottom of the layer, in Pa m2 s-2.
389  real, dimension(HI%IsdB:HI%IedB,HI%jsd:HI%jed), &
390  optional, intent(out) :: intx_dza !< The integral in x of the difference between the
391  !! geopotential anomaly at the top and bottom of
392  !! the layer divided by the x grid spacing,
393  !! in m2 s-2.
394  real, dimension(HI%isd:HI%ied,HI%JsdB:HI%JedB), &
395  optional, intent(out) :: inty_dza !< The integral in y of the difference between the
396  !! geopotential anomaly at the top and bottom of
397  !! the layer divided by the y grid spacing,
398  !! in m2 s-2.
399  integer, optional, intent(in) :: halo_size
400 
401 ! This subroutine calculates analytical and nearly-analytical integrals in
402 ! pressure across layers of geopotential anomalies, which are required for
403 ! calculating the finite-volume form pressure accelerations in a non-Boussinesq
404 ! model. Specific volume is assumed to vary linearly between adjacent points.
405 !
406 ! Arguments: T - potential temperature relative to the surface in C.
407 ! (in) S - salinity in PSU.
408 ! (in) p_t - pressure at the top of the layer in Pa.
409 ! (in) p_b - pressure at the top of the layer in Pa.
410 ! (in) alpha_ref - A mean specific volume that is subtracted out to reduce
411 ! the magnitude of each of the integrals, m3 kg-1.
412 ! The calculation is mathematically identical with
413 ! different values of alpha_ref, but this reduces the
414 ! effects of roundoff.
415 ! (in) HI - The ocean's horizontal index type.
416 ! (in) Rho_T0_S0 - The density at T=0, S=0, in kg m-3.
417 ! (in) dRho_dT - The derivative of density with temperature in kg m-3 C-1.
418 ! (in) dRho_dS - The derivative of density with salinity, in kg m-3 psu-1.
419 ! (out) dza - The change in the geopotential anomaly across the layer,
420 ! in m2 s-2.
421 ! (out,opt) intp_dza - The integral in pressure through the layer of the
422 ! geopotential anomaly relative to the anomaly at the
423 ! bottom of the layer, in Pa m2 s-2.
424 ! (out,opt) intx_dza - The integral in x of the difference between the
425 ! geopotential anomaly at the top and bottom of the layer
426 ! divided by the x grid spacing, in m2 s-2.
427 ! (out,opt) inty_dza - The integral in y of the difference between the
428 ! geopotential anomaly at the top and bottom of the layer
429 ! divided by the y grid spacing, in m2 s-2.
430  real :: dRho_TS ! The density anomaly due to T and S, in kg m-3.
431  real :: alpha_anom ! The specific volume anomaly from 1/rho_ref, in m3 kg-1.
432  real :: aaL, aaR ! rho_anom to the left and right, in kg m-3.
433  real :: dp, dpL, dpR ! Layer pressure thicknesses in Pa.
434  real :: C1_6
435  integer :: Isq, Ieq, Jsq, Jeq, ish, ieh, jsh, jeh, i, j, halo
436 
437  isq = hi%IscB ; ieq = hi%IecB ; jsq = hi%JscB ; jeq = hi%JecB
438  halo = 0 ; if (present(halo_size)) halo = max(halo_size,0)
439  ish = hi%isc-halo ; ieh = hi%iec+halo ; jsh = hi%jsc-halo ; jeh = hi%jec+halo
440  if (present(intx_dza)) then ; ish = min(isq,ish) ; ieh = max(ieq+1,ieh); endif
441  if (present(inty_dza)) then ; jsh = min(jsq,jsh) ; jeh = max(jeq+1,jeh); endif
442  c1_6 = 1.0 / 6.0
443 
444  do j=jsh,jeh ; do i=ish,ieh
445  dp = p_b(i,j) - p_t(i,j)
446  drho_ts = drho_dt*t(i,j) + drho_ds*s(i,j)
447  ! alpha_anom = 1.0/(Rho_T0_S0 + dRho_TS)) - alpha_ref
448  alpha_anom = ((1.0-rho_t0_s0*alpha_ref) - drho_ts*alpha_ref) / (rho_t0_s0 + drho_ts)
449  dza(i,j) = alpha_anom*dp
450  if (present(intp_dza)) intp_dza(i,j) = 0.5*alpha_anom*dp**2
451  enddo ; enddo
452 
453  if (present(intx_dza)) then ; do j=hi%jsc,hi%jec ; do i=isq,ieq
454  dpl = p_b(i,j) - p_t(i,j) ; dpr = p_b(i+1,j) - p_t(i+1,j)
455  drho_ts = drho_dt*t(i,j) + drho_ds*s(i,j)
456  aal = ((1.0 - rho_t0_s0*alpha_ref) - drho_ts*alpha_ref) / (rho_t0_s0 + drho_ts)
457  drho_ts = drho_dt*t(i+1,j) + drho_ds*s(i+1,j)
458  aar = ((1.0 - rho_t0_s0*alpha_ref) - drho_ts*alpha_ref) / (rho_t0_s0 + drho_ts)
459 
460  intx_dza(i,j) = c1_6 * (2.0*(dpl*aal + dpr*aar) + (dpl*aar + dpr*aal))
461  enddo ; enddo ; endif
462 
463  if (present(inty_dza)) then ; do j=jsq,jeq ; do i=hi%isc,hi%iec
464  dpl = p_b(i,j) - p_t(i,j) ; dpr = p_b(i,j+1) - p_t(i,j+1)
465  drho_ts = drho_dt*t(i,j) + drho_ds*s(i,j)
466  aal = ((1.0 - rho_t0_s0*alpha_ref) - drho_ts*alpha_ref) / (rho_t0_s0 + drho_ts)
467  drho_ts = drho_dt*t(i,j+1) + drho_ds*s(i,j+1)
468  aar = ((1.0 - rho_t0_s0*alpha_ref) - drho_ts*alpha_ref) / (rho_t0_s0 + drho_ts)
469 
470  inty_dza(i,j) = c1_6 * (2.0*(dpl*aal + dpr*aar) + (dpl*aar + dpr*aal))
471  enddo ; enddo ; endif
472 end subroutine int_spec_vol_dp_linear
473 
474 end module mom_eos_linear
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)
This subroutine calculates analytical and nearly-analytical integrals in pressure across layers of ge...
subroutine, public calculate_density_scalar_linear(T, S, pressure, rho, Rho_T0_S0, dRho_dT, dRho_dS)
This subroutine computes the density of sea water with a trivial linear equation of state (in kg/m^3)...
Defines the horizontal index type (hor_index_type) used for providing index ranges.
subroutine, public calculate_density_array_linear(T, S, pressure, rho, start, npts, Rho_T0_S0, dRho_dT, dRho_dS)
This subroutine computes the density of sea water with a trivial linear equation of state (in kg/m^3)...
Container for horizontal index ranges for data, computational and global domains. ...
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...
subroutine, public int_density_dz_linear(T, S, z_t, z_b, rho_ref, rho_0_pres, G_e, HII, HIO, Rho_T0_S0, dRho_dT, dRho_dS, dpa, intz_dpa, intx_dpa, inty_dpa)
This subroutine calculates analytical and nearly-analytical integrals of pressure anomalies across la...
subroutine, public calculate_specvol_derivs_linear(T, S, pressure, dSV_dT, dSV_dS, start, npts, Rho_T0_S0, dRho_dT, dRho_dS)
subroutine, public calculate_density_derivs_linear(T, S, pressure, drho_dT_out, drho_dS_out, start, npts, Rho_T0_S0, dRho_dT, dRho_dS)
This subroutine calculates the partial derivatives of density * with potential temperature and salini...