\hypertarget{namespacemom__eos__wright}{}\doxysection{mom\+\_\+eos\+\_\+wright Module Reference}
\label{namespacemom__eos__wright}\index{mom\_eos\_wright@{mom\_eos\_wright}}


\doxysubsection{Detailed Description}
The equation of state using the Wright 1997 expressions. \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
interface \mbox{\hyperlink{interfacemom__eos__wright_1_1calculate__density__derivs__wright}{calculate\+\_\+density\+\_\+derivs\+\_\+wright}}
\begin{DoxyCompactList}\small\item\em For a given thermodynamic state, return the derivatives of density with temperature and salinity. \end{DoxyCompactList}\item 
interface \mbox{\hyperlink{interfacemom__eos__wright_1_1calculate__density__second__derivs__wright}{calculate\+\_\+density\+\_\+second\+\_\+derivs\+\_\+wright}}
\begin{DoxyCompactList}\small\item\em For a given thermodynamic state, return the second derivatives of density with various combinations of temperature, salinity, and pressure. \end{DoxyCompactList}\item 
interface \mbox{\hyperlink{interfacemom__eos__wright_1_1calculate__density__wright}{calculate\+\_\+density\+\_\+wright}}
\begin{DoxyCompactList}\small\item\em Compute the in situ density of sea water (in \mbox{[}kg m-\/3\mbox{]}), or its anomaly with respect to a reference density, from salinity (in psu), potential temperature (in deg C), and pressure \mbox{[}Pa\mbox{]}, using the expressions from Wright, 1997, J. Atmos. Ocean. Tech., 14, 735-\/740. \end{DoxyCompactList}\item 
interface \mbox{\hyperlink{interfacemom__eos__wright_1_1calculate__spec__vol__wright}{calculate\+\_\+spec\+\_\+vol\+\_\+wright}}
\begin{DoxyCompactList}\small\item\em Compute the in situ specific volume of sea water (in \mbox{[}m3 kg-\/1\mbox{]}), or an anomaly with respect to a reference specific volume, from salinity (in psu), potential temperature (in deg C), and pressure \mbox{[}Pa\mbox{]}, using the expressions from Wright, 1997, J. Atmos. Ocean. Tech., 14, 735-\/740. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine \mbox{\hyperlink{namespacemom__eos__wright_a047725cee226bb5621080176aaff36d6}{calculate\+\_\+density\+\_\+scalar\+\_\+wright}} (T, S, pressure, rho, rho\+\_\+ref)
\begin{DoxyCompactList}\small\item\em This subroutine computes the in situ density of sea water (rho in \mbox{[}kg m-\/3\mbox{]}) from salinity (S \mbox{[}P\+SU\mbox{]}), potential temperature (T \mbox{[}degC\mbox{]}), and pressure \mbox{[}Pa\mbox{]}. It uses the expression from Wright, 1997, J. Atmos. Ocean. Tech., 14, 735-\/740. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__eos__wright_a9d96824061e9c3d438c3d909a00fb7ab}{calculate\+\_\+density\+\_\+array\+\_\+wright}} (T, S, pressure, rho, start, npts, rho\+\_\+ref)
\begin{DoxyCompactList}\small\item\em This subroutine computes the in situ density of sea water (rho in \mbox{[}kg m-\/3\mbox{]}) from salinity (S \mbox{[}P\+SU\mbox{]}), potential temperature (T \mbox{[}degC\mbox{]}), and pressure \mbox{[}Pa\mbox{]}. It uses the expression from Wright, 1997, J. Atmos. Ocean. Tech., 14, 735-\/740. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__eos__wright_aa1577bed7878372af9be62afea06cbf0}{calculate\+\_\+spec\+\_\+vol\+\_\+scalar\+\_\+wright}} (T, S, pressure, specvol, spv\+\_\+ref)
\begin{DoxyCompactList}\small\item\em This subroutine computes the in situ specific volume of sea water (specvol in \mbox{[}m3 kg-\/1\mbox{]}) from salinity (S \mbox{[}P\+SU\mbox{]}), potential temperature (T \mbox{[}degC\mbox{]}) and pressure \mbox{[}Pa\mbox{]}. 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. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__eos__wright_a0e1da760ed0fca53533430d0bd03ee6d}{calculate\+\_\+spec\+\_\+vol\+\_\+array\+\_\+wright}} (T, S, pressure, specvol, start, npts, spv\+\_\+ref)
\begin{DoxyCompactList}\small\item\em This subroutine computes the in situ specific volume of sea water (specvol in \mbox{[}m3 kg-\/1\mbox{]}) from salinity (S \mbox{[}P\+SU\mbox{]}), potential temperature (T \mbox{[}degC\mbox{]}) and pressure \mbox{[}Pa\mbox{]}. 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. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__eos__wright_a576d1ff13c93f4a3ffbd483d43a78ab7}{calculate\+\_\+density\+\_\+derivs\+\_\+array\+\_\+wright}} (T, S, pressure, drho\+\_\+dT, drho\+\_\+dS, start, npts)
\begin{DoxyCompactList}\small\item\em For a given thermodynamic state, return the thermal/haline expansion coefficients. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__eos__wright_a8264a21fbe5809d5290ea388e0b2e64f}{calculate\+\_\+density\+\_\+derivs\+\_\+scalar\+\_\+wright}} (T, S, pressure, drho\+\_\+dT, drho\+\_\+dS)
\begin{DoxyCompactList}\small\item\em 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. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__eos__wright_a218432c80512597414f0c1fe4ae2d97d}{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)
\begin{DoxyCompactList}\small\item\em Second derivatives of density with respect to temperature, salinity, and pressure. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__eos__wright_a74e1c5129ef4414337347a115bcdff10}{calculate\+\_\+density\+\_\+second\+\_\+derivs\+\_\+scalar\+\_\+wright}} (T, S, P, drho\+\_\+ds\+\_\+ds, drho\+\_\+ds\+\_\+dt, drho\+\_\+dt\+\_\+dt, drho\+\_\+ds\+\_\+dp, drho\+\_\+dt\+\_\+dp)
\begin{DoxyCompactList}\small\item\em 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. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__eos__wright_a890d098ddbdc76f6cfbf1b7cf19b6388}{calculate\+\_\+specvol\+\_\+derivs\+\_\+wright}} (T, S, pressure, d\+S\+V\+\_\+dT, d\+S\+V\+\_\+dS, start, npts)
\begin{DoxyCompactList}\small\item\em For a given thermodynamic state, return the partial derivatives of specific volume with temperature and salinity. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__eos__wright_ab5610ab6dd25f488ff5821dcbde78e0d}{calculate\+\_\+compress\+\_\+wright}} (T, S, pressure, rho, drho\+\_\+dp, start, npts)
\begin{DoxyCompactList}\small\item\em This subroutine computes the in situ density of sea water (rho in \mbox{[}kg m-\/3\mbox{]}) and the compressibility (drho/dp = C\+\_\+sound$^\wedge$-\/2) (drho\+\_\+dp \mbox{[}s2 m-\/2\mbox{]}) from salinity (sal in psu), potential temperature (T \mbox{[}degC\mbox{]}), and pressure \mbox{[}Pa\mbox{]}. It uses the expressions from Wright, 1997, J. Atmos. Ocean. Tech., 14, 735-\/740. Coded by R. Hallberg, 1/01. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__eos__wright_ac94eaa2504eb4ccb12b41add45e1301e}{int\+\_\+density\+\_\+dz\+\_\+wright}} (T, S, z\+\_\+t, z\+\_\+b, rho\+\_\+ref, rho\+\_\+0, G\+\_\+e, HI, dpa, intz\+\_\+dpa, intx\+\_\+dpa, inty\+\_\+dpa, bathyT, dz\+\_\+neglect, use\+Mass\+Wght\+Interp, rho\+\_\+scale, pres\+\_\+scale)
\begin{DoxyCompactList}\small\item\em 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. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__eos__wright_a35402f454f02a3fa680a6d7870931aa6}{int\+\_\+spec\+\_\+vol\+\_\+dp\+\_\+wright}} (T, S, p\+\_\+t, p\+\_\+b, spv\+\_\+ref, HI, dza, intp\+\_\+dza, intx\+\_\+dza, inty\+\_\+dza, halo\+\_\+size, bathyP, d\+P\+\_\+neglect, use\+Mass\+Wght\+Interp, S\+V\+\_\+scale, pres\+\_\+scale)
\begin{DoxyCompactList}\small\item\em 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 Boole\textquotesingle{}s rule to do the horizontal integrals, and from a truncation in the series for log(1-\/eps/1+eps) that assumes that $\vert$eps$\vert$ $<$ 0.\+34. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\textbf{ }\par
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacemom__eos__wright_a987d5c090f8875b3f847ffcedfcbbec3}\label{namespacemom__eos__wright_a987d5c090f8875b3f847ffcedfcbbec3}} 
real, parameter \mbox{\hyperlink{namespacemom__eos__wright_a987d5c090f8875b3f847ffcedfcbbec3}{a0}} = 7.\+057924e-\/4
\begin{DoxyCompactList}\small\item\em Parameters in the Wright equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos__wright_a7e7cc154421595caa7f3624fe1ca3673}\label{namespacemom__eos__wright_a7e7cc154421595caa7f3624fe1ca3673}} 
real, parameter \mbox{\hyperlink{namespacemom__eos__wright_a7e7cc154421595caa7f3624fe1ca3673}{a1}} = 3.\+480336e-\/7
\begin{DoxyCompactList}\small\item\em Parameters in the Wright equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos__wright_a4a32a06ae840315cf54baa44822e348d}\label{namespacemom__eos__wright_a4a32a06ae840315cf54baa44822e348d}} 
real, parameter \mbox{\hyperlink{namespacemom__eos__wright_a4a32a06ae840315cf54baa44822e348d}{a2}} = -\/1.\+112733e-\/7
\begin{DoxyCompactList}\small\item\em Parameters in the Wright equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos__wright_af4229fb5d51c0a7ff4728400c07f8b27}\label{namespacemom__eos__wright_af4229fb5d51c0a7ff4728400c07f8b27}} 
real, parameter \mbox{\hyperlink{namespacemom__eos__wright_af4229fb5d51c0a7ff4728400c07f8b27}{b0}} = 5.\+790749e8
\begin{DoxyCompactList}\small\item\em Parameters in the Wright equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos__wright_a50e15ae674d09fcbb22d050ba02d8a45}\label{namespacemom__eos__wright_a50e15ae674d09fcbb22d050ba02d8a45}} 
real, parameter \mbox{\hyperlink{namespacemom__eos__wright_a50e15ae674d09fcbb22d050ba02d8a45}{b1}} = 3.\+516535e6
\begin{DoxyCompactList}\small\item\em Parameters in the Wright equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos__wright_a7789c35566542d0531bec1e59bfb0142}\label{namespacemom__eos__wright_a7789c35566542d0531bec1e59bfb0142}} 
real, parameter \mbox{\hyperlink{namespacemom__eos__wright_a7789c35566542d0531bec1e59bfb0142}{b2}} = -\/4.\+002714e4
\begin{DoxyCompactList}\small\item\em Parameters in the Wright equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos__wright_a6d60b717365295a1cc748ca0952799dc}\label{namespacemom__eos__wright_a6d60b717365295a1cc748ca0952799dc}} 
real, parameter \mbox{\hyperlink{namespacemom__eos__wright_a6d60b717365295a1cc748ca0952799dc}{b3}} = 2.\+084372e2
\begin{DoxyCompactList}\small\item\em Parameters in the Wright equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos__wright_a56b4d3d9cbd8ef16485d99c207214806}\label{namespacemom__eos__wright_a56b4d3d9cbd8ef16485d99c207214806}} 
real, parameter \mbox{\hyperlink{namespacemom__eos__wright_a56b4d3d9cbd8ef16485d99c207214806}{b4}} = 5.\+944068e5
\begin{DoxyCompactList}\small\item\em Parameters in the Wright equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos__wright_a9db48983c2f40b67bc472fe5f9621a7e}\label{namespacemom__eos__wright_a9db48983c2f40b67bc472fe5f9621a7e}} 
real, parameter \mbox{\hyperlink{namespacemom__eos__wright_a9db48983c2f40b67bc472fe5f9621a7e}{b5}} = -\/9.\+643486e3
\begin{DoxyCompactList}\small\item\em Parameters in the Wright equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos__wright_a218345b2966cffd9e1ef2b17170e8525}\label{namespacemom__eos__wright_a218345b2966cffd9e1ef2b17170e8525}} 
real, parameter \mbox{\hyperlink{namespacemom__eos__wright_a218345b2966cffd9e1ef2b17170e8525}{c0}} = 1.\+704853e5
\begin{DoxyCompactList}\small\item\em Parameters in the Wright equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos__wright_a31d4375b948d86099cb395cab4b9a771}\label{namespacemom__eos__wright_a31d4375b948d86099cb395cab4b9a771}} 
real, parameter \mbox{\hyperlink{namespacemom__eos__wright_a31d4375b948d86099cb395cab4b9a771}{c1}} = 7.\+904722e2
\begin{DoxyCompactList}\small\item\em Parameters in the Wright equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos__wright_a8cac4a7420b6ac57f3c9e1abc251a110}\label{namespacemom__eos__wright_a8cac4a7420b6ac57f3c9e1abc251a110}} 
real, parameter \mbox{\hyperlink{namespacemom__eos__wright_a8cac4a7420b6ac57f3c9e1abc251a110}{c2}} = -\/7.\+984422
\begin{DoxyCompactList}\small\item\em Parameters in the Wright equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos__wright_a4cb9d874402c19becc87294045861267}\label{namespacemom__eos__wright_a4cb9d874402c19becc87294045861267}} 
real, parameter \mbox{\hyperlink{namespacemom__eos__wright_a4cb9d874402c19becc87294045861267}{c3}} = 5.\+140652e-\/2
\begin{DoxyCompactList}\small\item\em Parameters in the Wright equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos__wright_a946198aad59501f936a956f6f9da0861}\label{namespacemom__eos__wright_a946198aad59501f936a956f6f9da0861}} 
real, parameter \mbox{\hyperlink{namespacemom__eos__wright_a946198aad59501f936a956f6f9da0861}{c4}} = -\/2.\+302158e2
\begin{DoxyCompactList}\small\item\em Parameters in the Wright equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos__wright_a240d653273908c24302d935f94f32c4c}\label{namespacemom__eos__wright_a240d653273908c24302d935f94f32c4c}} 
real, parameter \mbox{\hyperlink{namespacemom__eos__wright_a240d653273908c24302d935f94f32c4c}{c5}} = -\/3.\+079464
\begin{DoxyCompactList}\small\item\em Parameters in the Wright equation of state. \end{DoxyCompactList}\end{DoxyCompactItemize}



\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__eos__wright_ab5610ab6dd25f488ff5821dcbde78e0d}\label{namespacemom__eos__wright_ab5610ab6dd25f488ff5821dcbde78e0d}} 
\index{mom\_eos\_wright@{mom\_eos\_wright}!calculate\_compress\_wright@{calculate\_compress\_wright}}
\index{calculate\_compress\_wright@{calculate\_compress\_wright}!mom\_eos\_wright@{mom\_eos\_wright}}
\doxysubsubsection{\texorpdfstring{calculate\_compress\_wright()}{calculate\_compress\_wright()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+eos\+\_\+wright\+::calculate\+\_\+compress\+\_\+wright (\begin{DoxyParamCaption}\item[{real, dimension(\+:), intent(in)}]{T,  }\item[{real, dimension(\+:), intent(in)}]{S,  }\item[{real, dimension(\+:), intent(in)}]{pressure,  }\item[{real, dimension(\+:), intent(inout)}]{rho,  }\item[{real, dimension(\+:), intent(inout)}]{drho\+\_\+dp,  }\item[{integer, intent(in)}]{start,  }\item[{integer, intent(in)}]{npts }\end{DoxyParamCaption})}



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


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em t} & Potential temperature relative to the surface \mbox{[}degC\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em s} & Salinity \mbox{[}P\+SU\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em pressure} & pressure \mbox{[}Pa\mbox{]}. \\
\hline
\mbox{\texttt{ in,out}}  & {\em rho} & In situ density \mbox{[}kg m-\/3\mbox{]}. \\
\hline
\mbox{\texttt{ in,out}}  & {\em drho\+\_\+dp} & The partial derivative of density with pressure (also the inverse of the square of sound speed) \mbox{[}s2 m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em start} & The starting point in the arrays. \\
\hline
\mbox{\texttt{ in}}  & {\em npts} & The number of values to calculate. \\
\hline
\end{DoxyParams}


Definition at line 379 of file M\+O\+M\+\_\+\+E\+O\+S\+\_\+\+Wright.\+F90.


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

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos__wright_a9d96824061e9c3d438c3d909a00fb7ab}\label{namespacemom__eos__wright_a9d96824061e9c3d438c3d909a00fb7ab}} 
\index{mom\_eos\_wright@{mom\_eos\_wright}!calculate\_density\_array\_wright@{calculate\_density\_array\_wright}}
\index{calculate\_density\_array\_wright@{calculate\_density\_array\_wright}!mom\_eos\_wright@{mom\_eos\_wright}}
\doxysubsubsection{\texorpdfstring{calculate\_density\_array\_wright()}{calculate\_density\_array\_wright()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+\_\+wright\+::calculate\+\_\+density\+\_\+array\+\_\+wright (\begin{DoxyParamCaption}\item[{real, dimension(\+:), intent(in)}]{T,  }\item[{real, dimension(\+:), intent(in)}]{S,  }\item[{real, dimension(\+:), intent(in)}]{pressure,  }\item[{real, dimension(\+:), intent(inout)}]{rho,  }\item[{integer, intent(in)}]{start,  }\item[{integer, intent(in)}]{npts,  }\item[{real, intent(in), optional}]{rho\+\_\+ref }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



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


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em t} & potential temperature relative to the surface \mbox{[}degC\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em s} & salinity \mbox{[}P\+SU\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em pressure} & pressure \mbox{[}Pa\mbox{]}. \\
\hline
\mbox{\texttt{ in,out}}  & {\em rho} & in situ density \mbox{[}kg m-\/3\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em start} & the starting point in the arrays. \\
\hline
\mbox{\texttt{ in}}  & {\em npts} & the number of values to calculate. \\
\hline
\mbox{\texttt{ in}}  & {\em rho\+\_\+ref} & A reference density \mbox{[}kg m-\/3\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 110 of file M\+O\+M\+\_\+\+E\+O\+S\+\_\+\+Wright.\+F90.


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

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos__wright_a576d1ff13c93f4a3ffbd483d43a78ab7}\label{namespacemom__eos__wright_a576d1ff13c93f4a3ffbd483d43a78ab7}} 
\index{mom\_eos\_wright@{mom\_eos\_wright}!calculate\_density\_derivs\_array\_wright@{calculate\_density\_derivs\_array\_wright}}
\index{calculate\_density\_derivs\_array\_wright@{calculate\_density\_derivs\_array\_wright}!mom\_eos\_wright@{mom\_eos\_wright}}
\doxysubsubsection{\texorpdfstring{calculate\_density\_derivs\_array\_wright()}{calculate\_density\_derivs\_array\_wright()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+\_\+wright\+::calculate\+\_\+density\+\_\+derivs\+\_\+array\+\_\+wright (\begin{DoxyParamCaption}\item[{real, dimension(\+:), intent(in)}]{T,  }\item[{real, dimension(\+:), intent(in)}]{S,  }\item[{real, dimension(\+:), intent(in)}]{pressure,  }\item[{real, dimension(\+:), intent(inout)}]{drho\+\_\+dT,  }\item[{real, dimension(\+:), intent(inout)}]{drho\+\_\+dS,  }\item[{integer, intent(in)}]{start,  }\item[{integer, intent(in)}]{npts }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



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


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em t} & Potential temperature relative to the surface \mbox{[}degC\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em s} & Salinity \mbox{[}P\+SU\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em pressure} & pressure \mbox{[}Pa\mbox{]}. \\
\hline
\mbox{\texttt{ in,out}}  & {\em drho\+\_\+dt} & The partial derivative of density with potential temperature \mbox{[}kg m-\/3 deg\+C-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in,out}}  & {\em drho\+\_\+ds} & The partial derivative of density with salinity, in \mbox{[}kg m-\/3 P\+S\+U-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em start} & The starting point in the arrays. \\
\hline
\mbox{\texttt{ in}}  & {\em npts} & The number of values to calculate. \\
\hline
\end{DoxyParams}


Definition at line 199 of file M\+O\+M\+\_\+\+E\+O\+S\+\_\+\+Wright.\+F90.


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

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos__wright_a8264a21fbe5809d5290ea388e0b2e64f}\label{namespacemom__eos__wright_a8264a21fbe5809d5290ea388e0b2e64f}} 
\index{mom\_eos\_wright@{mom\_eos\_wright}!calculate\_density\_derivs\_scalar\_wright@{calculate\_density\_derivs\_scalar\_wright}}
\index{calculate\_density\_derivs\_scalar\_wright@{calculate\_density\_derivs\_scalar\_wright}!mom\_eos\_wright@{mom\_eos\_wright}}
\doxysubsubsection{\texorpdfstring{calculate\_density\_derivs\_scalar\_wright()}{calculate\_density\_derivs\_scalar\_wright()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+\_\+wright\+::calculate\+\_\+density\+\_\+derivs\+\_\+scalar\+\_\+wright (\begin{DoxyParamCaption}\item[{real, intent(in)}]{T,  }\item[{real, intent(in)}]{S,  }\item[{real, intent(in)}]{pressure,  }\item[{real, intent(out)}]{drho\+\_\+dT,  }\item[{real, intent(out)}]{drho\+\_\+dS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [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. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em t} & Potential temperature relative to the surface \mbox{[}degC\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em s} & Salinity \mbox{[}P\+SU\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em pressure} & pressure \mbox{[}Pa\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em drho\+\_\+dt} & The partial derivative of density with potential temperature \mbox{[}kg m-\/3 deg\+C-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em drho\+\_\+ds} & The partial derivative of density with salinity, in \mbox{[}kg m-\/3 P\+S\+U-\/1\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 234 of file M\+O\+M\+\_\+\+E\+O\+S\+\_\+\+Wright.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{235 \textcolor{keywordtype}{  real},    \textcolor{keywordtype}{intent(in)}  :: T\textcolor{comment}{        !< Potential temperature relative to the surface [degC].}}
\DoxyCodeLine{236 \textcolor{keywordtype}{  real},    \textcolor{keywordtype}{intent(in)}  :: S\textcolor{comment}{        !< Salinity [PSU].}}
\DoxyCodeLine{237 \textcolor{keywordtype}{  real},    \textcolor{keywordtype}{intent(in)}  :: pressure\textcolor{comment}{ !< pressure [Pa].}}
\DoxyCodeLine{238 \textcolor{keywordtype}{  real},    \textcolor{keywordtype}{intent(out)} :: drho\_dT\textcolor{comment}{  !< The partial derivative of density with potential}}
\DoxyCodeLine{239 \textcolor{comment}{                                   !! temperature [kg m-\/3 degC-\/1].}}
\DoxyCodeLine{240 \textcolor{keywordtype}{  real},    \textcolor{keywordtype}{intent(out)} :: drho\_dS\textcolor{comment}{  !< The partial derivative of density with salinity,}}
\DoxyCodeLine{241 \textcolor{comment}{                                   !! in [kg m-\/3 PSU-\/1].}}
\DoxyCodeLine{242 }
\DoxyCodeLine{243   \textcolor{comment}{! Local variables needed to promote the input/output scalars to 1-\/element arrays}}
\DoxyCodeLine{244 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(1)} :: T0, S0, P0}
\DoxyCodeLine{245 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(1)} :: drdt0, drds0}
\DoxyCodeLine{246 }
\DoxyCodeLine{247   t0(1) = t}
\DoxyCodeLine{248   s0(1) = s}
\DoxyCodeLine{249   p0(1) = pressure}
\DoxyCodeLine{250   \textcolor{keyword}{call }calculate\_density\_derivs\_array\_wright(t0, s0, p0, drdt0, drds0, 1, 1)}
\DoxyCodeLine{251   drho\_dt = drdt0(1)}
\DoxyCodeLine{252   drho\_ds = drds0(1)}
\DoxyCodeLine{253 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos__wright_a047725cee226bb5621080176aaff36d6}\label{namespacemom__eos__wright_a047725cee226bb5621080176aaff36d6}} 
\index{mom\_eos\_wright@{mom\_eos\_wright}!calculate\_density\_scalar\_wright@{calculate\_density\_scalar\_wright}}
\index{calculate\_density\_scalar\_wright@{calculate\_density\_scalar\_wright}!mom\_eos\_wright@{mom\_eos\_wright}}
\doxysubsubsection{\texorpdfstring{calculate\_density\_scalar\_wright()}{calculate\_density\_scalar\_wright()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+\_\+wright\+::calculate\+\_\+density\+\_\+scalar\+\_\+wright (\begin{DoxyParamCaption}\item[{real, intent(in)}]{T,  }\item[{real, intent(in)}]{S,  }\item[{real, intent(in)}]{pressure,  }\item[{real, intent(out)}]{rho,  }\item[{real, intent(in), optional}]{rho\+\_\+ref }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



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


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em t} & Potential temperature relative to the surface \mbox{[}degC\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em s} & Salinity \mbox{[}P\+SU\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em pressure} & pressure \mbox{[}Pa\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em rho} & In situ density \mbox{[}kg m-\/3\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em rho\+\_\+ref} & A reference density \mbox{[}kg m-\/3\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 80 of file M\+O\+M\+\_\+\+E\+O\+S\+\_\+\+Wright.\+F90.


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

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos__wright_a218432c80512597414f0c1fe4ae2d97d}\label{namespacemom__eos__wright_a218432c80512597414f0c1fe4ae2d97d}} 
\index{mom\_eos\_wright@{mom\_eos\_wright}!calculate\_density\_second\_derivs\_array\_wright@{calculate\_density\_second\_derivs\_array\_wright}}
\index{calculate\_density\_second\_derivs\_array\_wright@{calculate\_density\_second\_derivs\_array\_wright}!mom\_eos\_wright@{mom\_eos\_wright}}
\doxysubsubsection{\texorpdfstring{calculate\_density\_second\_derivs\_array\_wright()}{calculate\_density\_second\_derivs\_array\_wright()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+\_\+wright\+::calculate\+\_\+density\+\_\+second\+\_\+derivs\+\_\+array\+\_\+wright (\begin{DoxyParamCaption}\item[{real, dimension(\+:), intent(in)}]{T,  }\item[{real, dimension(\+:), intent(in)}]{S,  }\item[{real, dimension(\+:), intent(in)}]{P,  }\item[{real, dimension(\+:), intent(inout)}]{drho\+\_\+ds\+\_\+ds,  }\item[{real, dimension(\+:), intent(inout)}]{drho\+\_\+ds\+\_\+dt,  }\item[{real, dimension(\+:), intent(inout)}]{drho\+\_\+dt\+\_\+dt,  }\item[{real, dimension(\+:), intent(inout)}]{drho\+\_\+ds\+\_\+dp,  }\item[{real, dimension(\+:), intent(inout)}]{drho\+\_\+dt\+\_\+dp,  }\item[{integer, intent(in)}]{start,  }\item[{integer, intent(in)}]{npts }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



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


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em t} & Potential temperature referenced to 0 dbar \mbox{[}degC\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em s} & Salinity \mbox{[}P\+SU\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em p} & Pressure \mbox{[}Pa\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em drho\+\_\+ds\+\_\+ds} & Partial derivative of beta with respect to S \mbox{[}kg m-\/3 P\+S\+U-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em drho\+\_\+ds\+\_\+dt} & Partial derivative of beta with respcct to T \mbox{[}kg m-\/3 P\+S\+U-\/1 deg\+C-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em drho\+\_\+dt\+\_\+dt} & Partial derivative of alpha with respect to T \mbox{[}kg m-\/3 deg\+C-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em drho\+\_\+ds\+\_\+dp} & Partial derivative of beta with respect to pressure \mbox{[}kg m-\/3 P\+S\+U-\/1 Pa-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em drho\+\_\+dt\+\_\+dp} & Partial derivative of alpha with respect to pressure \mbox{[}kg m-\/3 deg\+C-\/1 Pa-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em start} & Starting index in T,S,P \\
\hline
\mbox{\texttt{ in}}  & {\em npts} & Number of points to loop over \\
\hline
\end{DoxyParams}


Definition at line 257 of file M\+O\+M\+\_\+\+E\+O\+S\+\_\+\+Wright.\+F90.


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

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos__wright_a74e1c5129ef4414337347a115bcdff10}\label{namespacemom__eos__wright_a74e1c5129ef4414337347a115bcdff10}} 
\index{mom\_eos\_wright@{mom\_eos\_wright}!calculate\_density\_second\_derivs\_scalar\_wright@{calculate\_density\_second\_derivs\_scalar\_wright}}
\index{calculate\_density\_second\_derivs\_scalar\_wright@{calculate\_density\_second\_derivs\_scalar\_wright}!mom\_eos\_wright@{mom\_eos\_wright}}
\doxysubsubsection{\texorpdfstring{calculate\_density\_second\_derivs\_scalar\_wright()}{calculate\_density\_second\_derivs\_scalar\_wright()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+\_\+wright\+::calculate\+\_\+density\+\_\+second\+\_\+derivs\+\_\+scalar\+\_\+wright (\begin{DoxyParamCaption}\item[{real, intent(in)}]{T,  }\item[{real, intent(in)}]{S,  }\item[{real, intent(in)}]{P,  }\item[{real, intent(out)}]{drho\+\_\+ds\+\_\+ds,  }\item[{real, intent(out)}]{drho\+\_\+ds\+\_\+dt,  }\item[{real, intent(out)}]{drho\+\_\+dt\+\_\+dt,  }\item[{real, intent(out)}]{drho\+\_\+ds\+\_\+dp,  }\item[{real, intent(out)}]{drho\+\_\+dt\+\_\+dp }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [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. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em t} & Potential temperature referenced to 0 dbar \\
\hline
\mbox{\texttt{ in}}  & {\em s} & Salinity \mbox{[}P\+SU\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em p} & pressure \mbox{[}Pa\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em drho\+\_\+ds\+\_\+ds} & Partial derivative of beta with respect to S \mbox{[}kg m-\/3 P\+S\+U-\/2\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em drho\+\_\+ds\+\_\+dt} & Partial derivative of beta with respcct to T \mbox{[}kg m-\/3 P\+S\+U-\/1 deg\+C-\/1\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em drho\+\_\+dt\+\_\+dt} & Partial derivative of alpha with respect to T \mbox{[}kg m-\/3 deg\+C-\/2\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em drho\+\_\+ds\+\_\+dp} & Partial derivative of beta with respect to pressure \mbox{[}kg m-\/3 P\+S\+U-\/1 Pa-\/1\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em drho\+\_\+dt\+\_\+dp} & Partial derivative of alpha with respect to pressure \mbox{[}kg m-\/3 deg\+C-\/1 Pa-\/1\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 309 of file M\+O\+M\+\_\+\+E\+O\+S\+\_\+\+Wright.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{311 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in   )} :: T\textcolor{comment}{          !< Potential temperature referenced to 0 dbar}}
\DoxyCodeLine{312 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in   )} :: S\textcolor{comment}{          !< Salinity [PSU]}}
\DoxyCodeLine{313 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in   )} :: P\textcolor{comment}{          !< pressure [Pa]}}
\DoxyCodeLine{314 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(  out)} :: drho\_ds\_ds\textcolor{comment}{ !< Partial derivative of beta with respect}}
\DoxyCodeLine{315 \textcolor{comment}{                                    !! to S [kg m-\/3 PSU-\/2]}}
\DoxyCodeLine{316 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(  out)} :: drho\_ds\_dt\textcolor{comment}{ !< Partial derivative of beta with respcct}}
\DoxyCodeLine{317 \textcolor{comment}{                                    !! to T [kg m-\/3 PSU-\/1 degC-\/1]}}
\DoxyCodeLine{318 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(  out)} :: drho\_dt\_dt\textcolor{comment}{ !< Partial derivative of alpha with respect}}
\DoxyCodeLine{319 \textcolor{comment}{                                    !! to T [kg m-\/3 degC-\/2]}}
\DoxyCodeLine{320 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(  out)} :: drho\_ds\_dp\textcolor{comment}{ !< Partial derivative of beta with respect}}
\DoxyCodeLine{321 \textcolor{comment}{                                    !! to pressure [kg m-\/3 PSU-\/1 Pa-\/1]}}
\DoxyCodeLine{322 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(  out)} :: drho\_dt\_dp\textcolor{comment}{ !< Partial derivative of alpha with respect}}
\DoxyCodeLine{323 \textcolor{comment}{                                    !! to pressure [kg m-\/3 degC-\/1 Pa-\/1]}}
\DoxyCodeLine{324   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{325 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(1)} :: T0, S0, P0}
\DoxyCodeLine{326 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(1)} :: drdsds, drdsdt, drdtdt, drdsdp, drdtdp}
\DoxyCodeLine{327 }
\DoxyCodeLine{328   t0(1) = t}
\DoxyCodeLine{329   s0(1) = s}
\DoxyCodeLine{330   p0(1) = p}
\DoxyCodeLine{331   \textcolor{keyword}{call }calculate\_density\_second\_derivs\_array\_wright(t0, s0, p0, drdsds, drdsdt, drdtdt, drdsdp, drdtdp, 1, 1)}
\DoxyCodeLine{332   drho\_ds\_ds = drdsds(1)}
\DoxyCodeLine{333   drho\_ds\_dt = drdsdt(1)}
\DoxyCodeLine{334   drho\_dt\_dt = drdtdt(1)}
\DoxyCodeLine{335   drho\_ds\_dp = drdsdp(1)}
\DoxyCodeLine{336   drho\_dt\_dp = drdtdp(1)}
\DoxyCodeLine{337 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos__wright_a0e1da760ed0fca53533430d0bd03ee6d}\label{namespacemom__eos__wright_a0e1da760ed0fca53533430d0bd03ee6d}} 
\index{mom\_eos\_wright@{mom\_eos\_wright}!calculate\_spec\_vol\_array\_wright@{calculate\_spec\_vol\_array\_wright}}
\index{calculate\_spec\_vol\_array\_wright@{calculate\_spec\_vol\_array\_wright}!mom\_eos\_wright@{mom\_eos\_wright}}
\doxysubsubsection{\texorpdfstring{calculate\_spec\_vol\_array\_wright()}{calculate\_spec\_vol\_array\_wright()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+\_\+wright\+::calculate\+\_\+spec\+\_\+vol\+\_\+array\+\_\+wright (\begin{DoxyParamCaption}\item[{real, dimension(\+:), intent(in)}]{T,  }\item[{real, dimension(\+:), intent(in)}]{S,  }\item[{real, dimension(\+:), intent(in)}]{pressure,  }\item[{real, dimension(\+:), intent(inout)}]{specvol,  }\item[{integer, intent(in)}]{start,  }\item[{integer, intent(in)}]{npts,  }\item[{real, intent(in), optional}]{spv\+\_\+ref }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine computes the in situ specific volume of sea water (specvol in \mbox{[}m3 kg-\/1\mbox{]}) from salinity (S \mbox{[}P\+SU\mbox{]}), potential temperature (T \mbox{[}degC\mbox{]}) and pressure \mbox{[}Pa\mbox{]}. 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. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em t} & potential temperature relative to the surface \mbox{[}degC\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em s} & salinity \mbox{[}P\+SU\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em pressure} & pressure \mbox{[}Pa\mbox{]}. \\
\hline
\mbox{\texttt{ in,out}}  & {\em specvol} & in situ specific volume \mbox{[}m3 kg-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em start} & the starting point in the arrays. \\
\hline
\mbox{\texttt{ in}}  & {\em npts} & the number of values to calculate. \\
\hline
\mbox{\texttt{ in}}  & {\em spv\+\_\+ref} & A reference specific volume \mbox{[}m3 kg-\/1\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 171 of file M\+O\+M\+\_\+\+E\+O\+S\+\_\+\+Wright.\+F90.


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

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos__wright_aa1577bed7878372af9be62afea06cbf0}\label{namespacemom__eos__wright_aa1577bed7878372af9be62afea06cbf0}} 
\index{mom\_eos\_wright@{mom\_eos\_wright}!calculate\_spec\_vol\_scalar\_wright@{calculate\_spec\_vol\_scalar\_wright}}
\index{calculate\_spec\_vol\_scalar\_wright@{calculate\_spec\_vol\_scalar\_wright}!mom\_eos\_wright@{mom\_eos\_wright}}
\doxysubsubsection{\texorpdfstring{calculate\_spec\_vol\_scalar\_wright()}{calculate\_spec\_vol\_scalar\_wright()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+\_\+wright\+::calculate\+\_\+spec\+\_\+vol\+\_\+scalar\+\_\+wright (\begin{DoxyParamCaption}\item[{real, intent(in)}]{T,  }\item[{real, intent(in)}]{S,  }\item[{real, intent(in)}]{pressure,  }\item[{real, intent(out)}]{specvol,  }\item[{real, intent(in), optional}]{spv\+\_\+ref }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine computes the in situ specific volume of sea water (specvol in \mbox{[}m3 kg-\/1\mbox{]}) from salinity (S \mbox{[}P\+SU\mbox{]}), potential temperature (T \mbox{[}degC\mbox{]}) and pressure \mbox{[}Pa\mbox{]}. 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. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em t} & potential temperature relative to the surface \mbox{[}degC\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em s} & salinity \mbox{[}P\+SU\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em pressure} & pressure \mbox{[}Pa\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em specvol} & in situ specific volume \mbox{[}m3 kg-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em spv\+\_\+ref} & A reference specific volume \mbox{[}m3 kg-\/1\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 150 of file M\+O\+M\+\_\+\+E\+O\+S\+\_\+\+Wright.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{151 \textcolor{keywordtype}{  real},           \textcolor{keywordtype}{intent(in)}  :: T\textcolor{comment}{        !< potential temperature relative to the surface [degC].}}
\DoxyCodeLine{152 \textcolor{keywordtype}{  real},           \textcolor{keywordtype}{intent(in)}  :: S\textcolor{comment}{        !< salinity [PSU].}}
\DoxyCodeLine{153 \textcolor{keywordtype}{  real},           \textcolor{keywordtype}{intent(in)}  :: pressure\textcolor{comment}{ !< pressure [Pa].}}
\DoxyCodeLine{154 \textcolor{keywordtype}{  real},           \textcolor{keywordtype}{intent(out)} :: specvol\textcolor{comment}{  !< in situ specific volume [m3 kg-\/1].}}
\DoxyCodeLine{155 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: spv\_ref\textcolor{comment}{  !< A reference specific volume [m3 kg-\/1].}}
\DoxyCodeLine{156 }
\DoxyCodeLine{157   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{158 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(1)} :: T0, S0, pressure0, spv0}
\DoxyCodeLine{159 }
\DoxyCodeLine{160   t0(1) = t ; s0(1) = s ; pressure0(1) = pressure}
\DoxyCodeLine{161 }
\DoxyCodeLine{162   \textcolor{keyword}{call }calculate\_spec\_vol\_array\_wright(t0, s0, pressure0, spv0, 1, 1, spv\_ref)}
\DoxyCodeLine{163   specvol = spv0(1)}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos__wright_a890d098ddbdc76f6cfbf1b7cf19b6388}\label{namespacemom__eos__wright_a890d098ddbdc76f6cfbf1b7cf19b6388}} 
\index{mom\_eos\_wright@{mom\_eos\_wright}!calculate\_specvol\_derivs\_wright@{calculate\_specvol\_derivs\_wright}}
\index{calculate\_specvol\_derivs\_wright@{calculate\_specvol\_derivs\_wright}!mom\_eos\_wright@{mom\_eos\_wright}}
\doxysubsubsection{\texorpdfstring{calculate\_specvol\_derivs\_wright()}{calculate\_specvol\_derivs\_wright()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+eos\+\_\+wright\+::calculate\+\_\+specvol\+\_\+derivs\+\_\+wright (\begin{DoxyParamCaption}\item[{real, dimension(\+:), intent(in)}]{T,  }\item[{real, dimension(\+:), intent(in)}]{S,  }\item[{real, dimension(\+:), intent(in)}]{pressure,  }\item[{real, dimension(\+:), intent(inout)}]{d\+S\+V\+\_\+dT,  }\item[{real, dimension(\+:), intent(inout)}]{d\+S\+V\+\_\+dS,  }\item[{integer, intent(in)}]{start,  }\item[{integer, intent(in)}]{npts }\end{DoxyParamCaption})}



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


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em t} & Potential temperature relative to the surface \mbox{[}degC\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em s} & Salinity \mbox{[}P\+SU\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em pressure} & pressure \mbox{[}Pa\mbox{]}. \\
\hline
\mbox{\texttt{ in,out}}  & {\em dsv\+\_\+dt} & The partial derivative of specific volume with potential temperature \mbox{[}m3 kg-\/1 deg\+C-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in,out}}  & {\em dsv\+\_\+ds} & The partial derivative of specific volume with salinity \mbox{[}m3 kg-\/1 / Pa\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em start} & The starting point in the arrays. \\
\hline
\mbox{\texttt{ in}}  & {\em npts} & The number of values to calculate. \\
\hline
\end{DoxyParams}


Definition at line 342 of file M\+O\+M\+\_\+\+E\+O\+S\+\_\+\+Wright.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{343 \textcolor{keywordtype}{  real},    \textcolor{keywordtype}{intent(in)},    \textcolor{keywordtype}{dimension(:)} :: T\textcolor{comment}{        !< Potential temperature relative to the surface [degC].}}
\DoxyCodeLine{344 \textcolor{keywordtype}{  real},    \textcolor{keywordtype}{intent(in)},    \textcolor{keywordtype}{dimension(:)} :: S\textcolor{comment}{        !< Salinity [PSU].}}
\DoxyCodeLine{345 \textcolor{keywordtype}{  real},    \textcolor{keywordtype}{intent(in)},    \textcolor{keywordtype}{dimension(:)} :: pressure\textcolor{comment}{ !< pressure [Pa].}}
\DoxyCodeLine{346 \textcolor{keywordtype}{  real},    \textcolor{keywordtype}{intent(inout)}, \textcolor{keywordtype}{dimension(:)} :: dSV\_dT\textcolor{comment}{   !< The partial derivative of specific volume with}}
\DoxyCodeLine{347 \textcolor{comment}{                                                   !! potential temperature [m3 kg-\/1 degC-\/1].}}
\DoxyCodeLine{348 \textcolor{keywordtype}{  real},    \textcolor{keywordtype}{intent(inout)}, \textcolor{keywordtype}{dimension(:)} :: dSV\_dS\textcolor{comment}{   !< The partial derivative of specific volume with}}
\DoxyCodeLine{349 \textcolor{comment}{                                                   !! salinity [m3 kg-\/1 / Pa].}}
\DoxyCodeLine{350   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)}                  :: start\textcolor{comment}{    !< The starting point in the arrays.}}
\DoxyCodeLine{351   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)}                  :: npts\textcolor{comment}{     !< The number of values to calculate.}}
\DoxyCodeLine{352 }
\DoxyCodeLine{353   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{354 \textcolor{keywordtype}{  real} :: al0, p0, lambda, I\_denom}
\DoxyCodeLine{355   \textcolor{keywordtype}{integer} :: j}
\DoxyCodeLine{356 }
\DoxyCodeLine{357   \textcolor{keywordflow}{do} j=start,start+npts-\/1}
\DoxyCodeLine{358 \textcolor{comment}{!    al0 = (a0 + a1*T(j)) + a2*S(j)}}
\DoxyCodeLine{359     p0 = (b0 + b4*s(j)) + t(j) * (b1 + t(j)*((b2 + b3*t(j))) + b5*s(j))}
\DoxyCodeLine{360     lambda = (c0 +c4*s(j)) + t(j) * (c1 + t(j)*((c2 + c3*t(j))) + c5*s(j))}
\DoxyCodeLine{361 }
\DoxyCodeLine{362     \textcolor{comment}{! SV = al0 + lambda / (pressure(j) + p0)}}
\DoxyCodeLine{363 }
\DoxyCodeLine{364     i\_denom = 1.0 / (pressure(j) + p0)}
\DoxyCodeLine{365     dsv\_dt(j) = (a1 + i\_denom * (c1 + t(j)*((2.0*c2 + 3.0*c3*t(j))) + c5*s(j))) -\/ \&}
\DoxyCodeLine{366                 (i\_denom**2 * lambda) *  (b1 + t(j)*((2.0*b2 + 3.0*b3*t(j))) + b5*s(j))}
\DoxyCodeLine{367     dsv\_ds(j) = (a2 + i\_denom * (c4 + c5*t(j))) -\/ \&}
\DoxyCodeLine{368                 (i\_denom**2 * lambda) *  (b4 + b5*t(j))}
\DoxyCodeLine{369 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{370 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos__wright_ac94eaa2504eb4ccb12b41add45e1301e}\label{namespacemom__eos__wright_ac94eaa2504eb4ccb12b41add45e1301e}} 
\index{mom\_eos\_wright@{mom\_eos\_wright}!int\_density\_dz\_wright@{int\_density\_dz\_wright}}
\index{int\_density\_dz\_wright@{int\_density\_dz\_wright}!mom\_eos\_wright@{mom\_eos\_wright}}
\doxysubsubsection{\texorpdfstring{int\_density\_dz\_wright()}{int\_density\_dz\_wright()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+eos\+\_\+wright\+::int\+\_\+density\+\_\+dz\+\_\+wright (\begin{DoxyParamCaption}\item[{real, dimension(hi\%isd\+:hi\%ied,hi\%jsd\+:hi\%jed), intent(in)}]{T,  }\item[{real, dimension(hi\%isd\+:hi\%ied,hi\%jsd\+:hi\%jed), intent(in)}]{S,  }\item[{real, dimension(hi\%isd\+:hi\%ied,hi\%jsd\+:hi\%jed), intent(in)}]{z\+\_\+t,  }\item[{real, dimension(hi\%isd\+:hi\%ied,hi\%jsd\+:hi\%jed), intent(in)}]{z\+\_\+b,  }\item[{real, intent(in)}]{rho\+\_\+ref,  }\item[{real, intent(in)}]{rho\+\_\+0,  }\item[{real, intent(in)}]{G\+\_\+e,  }\item[{type(\mbox{\hyperlink{structmom__hor__index_1_1hor__index__type}{hor\+\_\+index\+\_\+type}}), intent(in)}]{HI,  }\item[{real, dimension(hi\%isd\+:hi\%ied,hi\%jsd\+:hi\%jed), intent(inout)}]{dpa,  }\item[{real, dimension(hi\%isd\+:hi\%ied,hi\%jsd\+:hi\%jed), intent(inout), optional}]{intz\+\_\+dpa,  }\item[{real, dimension(hi\%isdb\+:hi\%iedb,hi\%jsd\+:hi\%jed), intent(inout), optional}]{intx\+\_\+dpa,  }\item[{real, dimension(hi\%isd\+:hi\%ied,hi\%jsdb\+:hi\%jedb), intent(inout), optional}]{inty\+\_\+dpa,  }\item[{real, dimension(hi\%isd\+:hi\%ied,hi\%jsd\+:hi\%jed), intent(in), optional}]{bathyT,  }\item[{real, intent(in), optional}]{dz\+\_\+neglect,  }\item[{logical, intent(in), optional}]{use\+Mass\+Wght\+Interp,  }\item[{real, intent(in), optional}]{rho\+\_\+scale,  }\item[{real, intent(in), optional}]{pres\+\_\+scale }\end{DoxyParamCaption})}



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. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em hi} & The horizontal index type for the arrays. \\
\hline
\mbox{\texttt{ in}}  & {\em t} & Potential temperature relative to the surface \\
\hline
\mbox{\texttt{ in}}  & {\em s} & Salinity \mbox{[}P\+SU\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em z\+\_\+t} & Height at the top of the layer in depth units \mbox{[}Z $\sim$$>$ m\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em z\+\_\+b} & Height at the top of the layer \mbox{[}Z $\sim$$>$ m\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em rho\+\_\+ref} & A mean density \mbox{[}R $\sim$$>$ kg m-\/3\mbox{]} or \mbox{[}kg m-\/3\mbox{]}, that is subtracted out to reduce the magnitude of each of the integrals. (The pressure is calucated as p$\sim$=-\/z$\ast$rho\+\_\+0$\ast$\+G\+\_\+e.) \\
\hline
\mbox{\texttt{ in}}  & {\em rho\+\_\+0} & Density \mbox{[}R $\sim$$>$ kg m-\/3\mbox{]} or \mbox{[}kg m-\/3\mbox{]}, that is used to calculate the pressure (as p$\sim$=-\/z$\ast$rho\+\_\+0$\ast$\+G\+\_\+e) used in the equation of state. \\
\hline
\mbox{\texttt{ in}}  & {\em g\+\_\+e} & The Earth\textquotesingle{}s gravitational acceleration \mbox{[}L2 Z-\/1 T-\/2 $\sim$$>$ m s-\/2\mbox{]} or \mbox{[}m2 Z-\/1 s-\/2 $\sim$$>$ m s-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in,out}}  & {\em dpa} & The change in the pressure anomaly across the \\
\hline
\mbox{\texttt{ in,out}}  & {\em intz\+\_\+dpa} & The integral through the thickness of the layer \\
\hline
\mbox{\texttt{ in,out}}  & {\em intx\+\_\+dpa} & The integral in x of the difference between the \\
\hline
\mbox{\texttt{ in,out}}  & {\em inty\+\_\+dpa} & The integral in y of the difference between the \\
\hline
\mbox{\texttt{ in}}  & {\em bathyt} & The depth of the bathymetry \mbox{[}Z $\sim$$>$ m\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em dz\+\_\+neglect} & A miniscule thickness change \mbox{[}Z $\sim$$>$ m\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em usemasswghtinterp} & If true, uses mass weighting to interpolate T/S for top and bottom integrals. \\
\hline
\mbox{\texttt{ in}}  & {\em rho\+\_\+scale} & A multiplicative factor by which to scale density from kg m-\/3 to the desired units \mbox{[}R m3 kg-\/1 $\sim$$>$ 1\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em pres\+\_\+scale} & A multiplicative factor to convert pressure into Pa \mbox{[}Pa T2 R-\/1 L-\/2 $\sim$$>$ 1\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 409 of file M\+O\+M\+\_\+\+E\+O\+S\+\_\+\+Wright.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{412   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)}  :: HI\textcolor{comment}{       !< The horizontal index type for the arrays.}}
\DoxyCodeLine{413 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(HI\%isd:HI\%ied,HI\%jsd:HI\%jed)}, \&}
\DoxyCodeLine{414                         \textcolor{keywordtype}{intent(in)}  :: T\textcolor{comment}{        !< Potential temperature relative to the surface}}
\DoxyCodeLine{415 \textcolor{comment}{                                                !! [degC].}}
\DoxyCodeLine{416 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(HI\%isd:HI\%ied,HI\%jsd:HI\%jed)}, \&}
\DoxyCodeLine{417                         \textcolor{keywordtype}{intent(in)}  :: S\textcolor{comment}{        !< Salinity [PSU].}}
\DoxyCodeLine{418 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(HI\%isd:HI\%ied,HI\%jsd:HI\%jed)}, \&}
\DoxyCodeLine{419                         \textcolor{keywordtype}{intent(in)}  :: z\_t\textcolor{comment}{      !< Height at the top of the layer in depth units [Z \string~> m].}}
\DoxyCodeLine{420 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(HI\%isd:HI\%ied,HI\%jsd:HI\%jed)}, \&}
\DoxyCodeLine{421                         \textcolor{keywordtype}{intent(in)}  :: z\_b\textcolor{comment}{      !< Height at the top of the layer [Z \string~> m].}}
\DoxyCodeLine{422 \textcolor{keywordtype}{  real},                 \textcolor{keywordtype}{intent(in)}  :: rho\_ref\textcolor{comment}{  !< A mean density [R \string~> kg m-\/3] or [kg m-\/3], that is subtracted}}
\DoxyCodeLine{423 \textcolor{comment}{                                                !! out to reduce the magnitude of each of the integrals.}}
\DoxyCodeLine{424 \textcolor{comment}{                                                !! (The pressure is calucated as p\string~=-\/z*rho\_0*G\_e.)}}
\DoxyCodeLine{425 \textcolor{keywordtype}{  real},                 \textcolor{keywordtype}{intent(in)}  :: rho\_0\textcolor{comment}{    !< Density [R \string~> kg m-\/3] or [kg m-\/3], that is used}}
\DoxyCodeLine{426 \textcolor{comment}{                                                !! to calculate the pressure (as p\string~=-\/z*rho\_0*G\_e)}}
\DoxyCodeLine{427 \textcolor{comment}{                                                !! used in the equation of state.}}
\DoxyCodeLine{428 \textcolor{keywordtype}{  real},                 \textcolor{keywordtype}{intent(in)}  :: G\_e\textcolor{comment}{      !< The Earth's gravitational acceleration}}
\DoxyCodeLine{429 \textcolor{comment}{                                                !! [L2 Z-\/1 T-\/2 \string~> m s-\/2] or [m2 Z-\/1 s-\/2 \string~> m s-\/2].}}
\DoxyCodeLine{430 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(HI\%isd:HI\%ied,HI\%jsd:HI\%jed)}, \&}
\DoxyCodeLine{431                         \textcolor{keywordtype}{intent(inout)} :: dpa\textcolor{comment}{    !< The change in the pressure anomaly across the}}
\DoxyCodeLine{432 \textcolor{comment}{                                                !! layer [R L2 T-\/2 \string~> Pa] or [Pa].}}
\DoxyCodeLine{433 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(HI\%isd:HI\%ied,HI\%jsd:HI\%jed)}, \&}
\DoxyCodeLine{434               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: intz\_dpa\textcolor{comment}{ !< The integral through the thickness of the layer}}
\DoxyCodeLine{435 \textcolor{comment}{                                                !! of the pressure anomaly relative to the anomaly}}
\DoxyCodeLine{436 \textcolor{comment}{                                                !! at the top of the layer [R Z L2 T-\/2 \string~> Pa m].}}
\DoxyCodeLine{437 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(HI\%IsdB:HI\%IedB,HI\%jsd:HI\%jed)}, \&}
\DoxyCodeLine{438               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: intx\_dpa\textcolor{comment}{ !< The integral in x of the difference between the}}
\DoxyCodeLine{439 \textcolor{comment}{                                                !! pressure anomaly at the top and bottom of the}}
\DoxyCodeLine{440 \textcolor{comment}{                                                !! layer divided by the x grid spacing [R L2 T-\/2 \string~> Pa].}}
\DoxyCodeLine{441 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(HI\%isd:HI\%ied,HI\%JsdB:HI\%JedB)}, \&}
\DoxyCodeLine{442               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: inty\_dpa\textcolor{comment}{ !< The integral in y of the difference between the}}
\DoxyCodeLine{443 \textcolor{comment}{                                                !! pressure anomaly at the top and bottom of the}}
\DoxyCodeLine{444 \textcolor{comment}{                                                !! layer divided by the y grid spacing [R L2 T-\/2 \string~> Pa].}}
\DoxyCodeLine{445 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(HI\%isd:HI\%ied,HI\%jsd:HI\%jed)}, \&}
\DoxyCodeLine{446               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: bathyT\textcolor{comment}{   !< The depth of the bathymetry [Z \string~> m].}}
\DoxyCodeLine{447 \textcolor{keywordtype}{  real},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: dz\_neglect\textcolor{comment}{ !< A miniscule thickness change [Z \string~> m].}}
\DoxyCodeLine{448   \textcolor{keywordtype}{logical},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: useMassWghtInterp\textcolor{comment}{ !< If true, uses mass weighting to}}
\DoxyCodeLine{449 \textcolor{comment}{                                                !! interpolate T/S for top and bottom integrals.}}
\DoxyCodeLine{450 \textcolor{keywordtype}{  real},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: rho\_scale\textcolor{comment}{ !< A multiplicative factor by which to scale density}}
\DoxyCodeLine{451 \textcolor{comment}{                                                 !! from kg m-\/3 to the desired units [R m3 kg-\/1 \string~> 1]}}
\DoxyCodeLine{452 \textcolor{keywordtype}{  real},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: pres\_scale\textcolor{comment}{ !< A multiplicative factor to convert pressure}}
\DoxyCodeLine{453 \textcolor{comment}{                                                 !! into Pa [Pa T2 R-\/1 L-\/2 \string~> 1].}}
\DoxyCodeLine{454 }
\DoxyCodeLine{455   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{456 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(HI\%isd:HI\%ied,HI\%jsd:HI\%jed)} :: al0\_2d, p0\_2d, lambda\_2d}
\DoxyCodeLine{457 \textcolor{keywordtype}{  real} :: al0, p0, lambda}
\DoxyCodeLine{458 \textcolor{keywordtype}{  real} :: rho\_anom   \textcolor{comment}{! The density anomaly from rho\_ref [kg m-\/3].}}
\DoxyCodeLine{459 \textcolor{keywordtype}{  real} :: eps, eps2, rem}
\DoxyCodeLine{460 \textcolor{keywordtype}{  real} :: GxRho      \textcolor{comment}{! The gravitational acceleration times density and unit conversion factors [Pa Z-\/1 \string~> kg m-\/2 s-\/2]}}
\DoxyCodeLine{461 \textcolor{keywordtype}{  real} :: g\_Earth    \textcolor{comment}{! The gravitational acceleration [m2 Z-\/1 s-\/2 \string~> m s-\/2]}}
\DoxyCodeLine{462 \textcolor{keywordtype}{  real} :: I\_Rho      \textcolor{comment}{! The inverse of the Boussinesq density [m3 kg-\/1]}}
\DoxyCodeLine{463 \textcolor{keywordtype}{  real} :: rho\_ref\_mks \textcolor{comment}{! The reference density in MKS units, never rescaled from kg m-\/3 [kg m-\/3]}}
\DoxyCodeLine{464 \textcolor{keywordtype}{  real} :: p\_ave, I\_al0, I\_Lzz}
\DoxyCodeLine{465 \textcolor{keywordtype}{  real} :: dz         \textcolor{comment}{! The layer thickness [Z \string~> m].}}
\DoxyCodeLine{466 \textcolor{keywordtype}{  real} :: hWght      \textcolor{comment}{! A pressure-\/thickness below topography [Z \string~> m].}}
\DoxyCodeLine{467 \textcolor{keywordtype}{  real} :: hL, hR     \textcolor{comment}{! Pressure-\/thicknesses of the columns to the left and right [Z \string~> m].}}
\DoxyCodeLine{468 \textcolor{keywordtype}{  real} :: iDenom     \textcolor{comment}{! The inverse of the denominator in the weights [Z-\/2 \string~> m-\/2].}}
\DoxyCodeLine{469 \textcolor{keywordtype}{  real} :: hWt\_LL, hWt\_LR \textcolor{comment}{! hWt\_LA is the weighted influence of A on the left column [nondim].}}
\DoxyCodeLine{470 \textcolor{keywordtype}{  real} :: hWt\_RL, hWt\_RR \textcolor{comment}{! hWt\_RA is the weighted influence of A on the right column [nondim].}}
\DoxyCodeLine{471 \textcolor{keywordtype}{  real} :: wt\_L, wt\_R \textcolor{comment}{! The linear weights of the left and right columns [nondim].}}
\DoxyCodeLine{472 \textcolor{keywordtype}{  real} :: wtT\_L, wtT\_R \textcolor{comment}{! The weights for tracers from the left and right columns [nondim].}}
\DoxyCodeLine{473 \textcolor{keywordtype}{  real} :: intz(5)    \textcolor{comment}{! The integrals of density with height at the}}
\DoxyCodeLine{474                      \textcolor{comment}{! 5 sub-\/column locations [R L2 T-\/2 \string~> Pa].}}
\DoxyCodeLine{475 \textcolor{keywordtype}{  real} :: Pa\_to\_RL2\_T2 \textcolor{comment}{! A conversion factor of pressures from Pa to the output units indicated by}}
\DoxyCodeLine{476                        \textcolor{comment}{! pres\_scale [R L2 T-\/2 Pa-\/1 \string~> 1] or [1].}}
\DoxyCodeLine{477   \textcolor{keywordtype}{logical} :: do\_massWeight \textcolor{comment}{! Indicates whether to do mass weighting.}}
\DoxyCodeLine{478 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{parameter} :: C1\_3 = 1.0/3.0, c1\_7 = 1.0/7.0    \textcolor{comment}{! Rational constants.}}
\DoxyCodeLine{479 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{parameter} :: C1\_9 = 1.0/9.0, c1\_90 = 1.0/90.0  \textcolor{comment}{! Rational constants.}}
\DoxyCodeLine{480   \textcolor{keywordtype}{integer} :: is, ie, js, je, Isq, Ieq, Jsq, Jeq, i, j, m}
\DoxyCodeLine{481 }
\DoxyCodeLine{482   \textcolor{comment}{! These array bounds work for the indexing convention of the input arrays, but}}
\DoxyCodeLine{483   \textcolor{comment}{! on the computational domain defined for the output arrays.}}
\DoxyCodeLine{484   isq = hi\%IscB ; ieq = hi\%IecB}
\DoxyCodeLine{485   jsq = hi\%JscB ; jeq = hi\%JecB}
\DoxyCodeLine{486   is = hi\%isc ; ie = hi\%iec}
\DoxyCodeLine{487   js = hi\%jsc ; je = hi\%jec}
\DoxyCodeLine{488 }
\DoxyCodeLine{489   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(pres\_scale)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{490     gxrho = pres\_scale * g\_e * rho\_0 ; g\_earth = pres\_scale * g\_e}
\DoxyCodeLine{491     pa\_to\_rl2\_t2 = 1.0 / pres\_scale}
\DoxyCodeLine{492   \textcolor{keywordflow}{else}}
\DoxyCodeLine{493     gxrho = g\_e * rho\_0 ; g\_earth = g\_e}
\DoxyCodeLine{494     pa\_to\_rl2\_t2 = 1.0}
\DoxyCodeLine{495 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{496   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(rho\_scale)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{497     g\_earth = g\_earth * rho\_scale}
\DoxyCodeLine{498     rho\_ref\_mks = rho\_ref / rho\_scale ; i\_rho = rho\_scale / rho\_0}
\DoxyCodeLine{499   \textcolor{keywordflow}{else}}
\DoxyCodeLine{500     rho\_ref\_mks = rho\_ref ; i\_rho = 1.0 / rho\_0}
\DoxyCodeLine{501 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{502 }
\DoxyCodeLine{503   do\_massweight = .false.}
\DoxyCodeLine{504   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(usemasswghtinterp)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (usemasswghtinterp) \textcolor{keywordflow}{then}}
\DoxyCodeLine{505     do\_massweight = .true.}
\DoxyCodeLine{506   \textcolor{comment}{! if (.not.present(bathyT)) call MOM\_error(FATAL, "{}int\_density\_dz\_generic: "{}//\&}}
\DoxyCodeLine{507   \textcolor{comment}{!     "{}bathyT must be present if useMassWghtInterp is present and true."{})}}
\DoxyCodeLine{508   \textcolor{comment}{! if (.not.present(dz\_neglect)) call MOM\_error(FATAL, "{}int\_density\_dz\_generic: "{}//\&}}
\DoxyCodeLine{509   \textcolor{comment}{!     "{}dz\_neglect must be present if useMassWghtInterp is present and true."{})}}
\DoxyCodeLine{510 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{511 }
\DoxyCodeLine{512   \textcolor{keywordflow}{do} j=jsq,jeq+1 ; \textcolor{keywordflow}{do} i=isq,ieq+1}
\DoxyCodeLine{513     al0\_2d(i,j) = (a0 + a1*t(i,j)) + a2*s(i,j)}
\DoxyCodeLine{514     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))}
\DoxyCodeLine{515     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))}
\DoxyCodeLine{516 }
\DoxyCodeLine{517     al0 = al0\_2d(i,j) ; p0 = p0\_2d(i,j) ; lambda = lambda\_2d(i,j)}
\DoxyCodeLine{518 }
\DoxyCodeLine{519     dz = z\_t(i,j) -\/ z\_b(i,j)}
\DoxyCodeLine{520     p\_ave = -\/0.5*gxrho*(z\_t(i,j)+z\_b(i,j))}
\DoxyCodeLine{521 }
\DoxyCodeLine{522     i\_al0 = 1.0 / al0}
\DoxyCodeLine{523     i\_lzz = 1.0 / (p0 + (lambda * i\_al0) + p\_ave)}
\DoxyCodeLine{524     eps = 0.5*gxrho*dz*i\_lzz ; eps2 = eps*eps}
\DoxyCodeLine{525 }
\DoxyCodeLine{526 \textcolor{comment}{!     rho(j) = (pressure(j) + p0) / (lambda + al0*(pressure(j) + p0))}}
\DoxyCodeLine{527 }
\DoxyCodeLine{528     rho\_anom = (p0 + p\_ave)*(i\_lzz*i\_al0) -\/ rho\_ref\_mks}
\DoxyCodeLine{529     rem = i\_rho * (lambda * i\_al0**2) * eps2 * \&}
\DoxyCodeLine{530           (c1\_3 + eps2*(0.2 + eps2*(c1\_7 + c1\_9*eps2)))}
\DoxyCodeLine{531     dpa(i,j) = pa\_to\_rl2\_t2 * (g\_earth*rho\_anom*dz -\/ 2.0*eps*rem)}
\DoxyCodeLine{532     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(intz\_dpa)) \&}
\DoxyCodeLine{533       intz\_dpa(i,j) = pa\_to\_rl2\_t2 * (0.5*g\_earth*rho\_anom*dz**2 -\/ dz*(1.0+eps)*rem)}
\DoxyCodeLine{534 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{535 }
\DoxyCodeLine{536   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(intx\_dpa)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{537     \textcolor{comment}{! hWght is the distance measure by which the cell is violation of}}
\DoxyCodeLine{538     \textcolor{comment}{! hydrostatic consistency. For large hWght we bias the interpolation of}}
\DoxyCodeLine{539     \textcolor{comment}{! T \& S along the top and bottom integrals, akin to thickness weighting.}}
\DoxyCodeLine{540     hwght = 0.0}
\DoxyCodeLine{541     \textcolor{keywordflow}{if} (do\_massweight) \&}
\DoxyCodeLine{542       hwght = max(0., -\/bathyt(i,j)-\/z\_t(i+1,j), -\/bathyt(i+1,j)-\/z\_t(i,j))}
\DoxyCodeLine{543     \textcolor{keywordflow}{if} (hwght > 0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{544       hl = (z\_t(i,j) -\/ z\_b(i,j)) + dz\_neglect}
\DoxyCodeLine{545       hr = (z\_t(i+1,j) -\/ z\_b(i+1,j)) + dz\_neglect}
\DoxyCodeLine{546       hwght = hwght * ( (hl-\/hr)/(hl+hr) )**2}
\DoxyCodeLine{547       idenom = 1.0 / ( hwght*(hr + hl) + hl*hr )}
\DoxyCodeLine{548       hwt\_ll = (hwght*hl + hr*hl) * idenom ; hwt\_lr = (hwght*hr) * idenom}
\DoxyCodeLine{549       hwt\_rr = (hwght*hr + hr*hl) * idenom ; hwt\_rl = (hwght*hl) * idenom}
\DoxyCodeLine{550     \textcolor{keywordflow}{else}}
\DoxyCodeLine{551       hwt\_ll = 1.0 ; hwt\_lr = 0.0 ; hwt\_rr = 1.0 ; hwt\_rl = 0.0}
\DoxyCodeLine{552 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{553 }
\DoxyCodeLine{554     intz(1) = dpa(i,j) ; intz(5) = dpa(i+1,j)}
\DoxyCodeLine{555     \textcolor{keywordflow}{do} m=2,4}
\DoxyCodeLine{556       wt\_l = 0.25*real(5-\/m) ; wt\_r = 1.0-\/wt\_l}
\DoxyCodeLine{557       wtt\_l = wt\_l*hwt\_ll + wt\_r*hwt\_rl ; wtt\_r = wt\_l*hwt\_lr + wt\_r*hwt\_rr}
\DoxyCodeLine{558 }
\DoxyCodeLine{559       al0 = wtt\_l*al0\_2d(i,j) + wtt\_r*al0\_2d(i+1,j)}
\DoxyCodeLine{560       p0 = wtt\_l*p0\_2d(i,j) + wtt\_r*p0\_2d(i+1,j)}
\DoxyCodeLine{561       lambda = wtt\_l*lambda\_2d(i,j) + wtt\_r*lambda\_2d(i+1,j)}
\DoxyCodeLine{562 }
\DoxyCodeLine{563       dz = wt\_l*(z\_t(i,j) -\/ z\_b(i,j)) + wt\_r*(z\_t(i+1,j) -\/ z\_b(i+1,j))}
\DoxyCodeLine{564       p\_ave = -\/0.5*gxrho*(wt\_l*(z\_t(i,j)+z\_b(i,j)) + \&}
\DoxyCodeLine{565                           wt\_r*(z\_t(i+1,j)+z\_b(i+1,j)))}
\DoxyCodeLine{566 }
\DoxyCodeLine{567       i\_al0 = 1.0 / al0}
\DoxyCodeLine{568       i\_lzz = 1.0 / (p0 + (lambda * i\_al0) + p\_ave)}
\DoxyCodeLine{569       eps = 0.5*gxrho*dz*i\_lzz ; eps2 = eps*eps}
\DoxyCodeLine{570 }
\DoxyCodeLine{571       intz(m) = pa\_to\_rl2\_t2 * ( g\_earth*dz*((p0 + p\_ave)*(i\_lzz*i\_al0) -\/ rho\_ref\_mks) -\/ 2.0*eps * \&}
\DoxyCodeLine{572                 i\_rho * (lambda * i\_al0**2) * eps2 * (c1\_3 + eps2*(0.2 + eps2*(c1\_7 + c1\_9*eps2))) )}
\DoxyCodeLine{573 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{574     \textcolor{comment}{! Use Boole's rule to integrate the values.}}
\DoxyCodeLine{575     intx\_dpa(i,j) = c1\_90*(7.0*(intz(1)+intz(5)) + 32.0*(intz(2)+intz(4)) + 12.0*intz(3))}
\DoxyCodeLine{576 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{577 }
\DoxyCodeLine{578   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(inty\_dpa)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{579     \textcolor{comment}{! hWght is the distance measure by which the cell is violation of}}
\DoxyCodeLine{580     \textcolor{comment}{! hydrostatic consistency. For large hWght we bias the interpolation of}}
\DoxyCodeLine{581     \textcolor{comment}{! T \& S along the top and bottom integrals, akin to thickness weighting.}}
\DoxyCodeLine{582     hwght = 0.0}
\DoxyCodeLine{583     \textcolor{keywordflow}{if} (do\_massweight) \&}
\DoxyCodeLine{584       hwght = max(0., -\/bathyt(i,j)-\/z\_t(i,j+1), -\/bathyt(i,j+1)-\/z\_t(i,j))}
\DoxyCodeLine{585     \textcolor{keywordflow}{if} (hwght > 0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{586       hl = (z\_t(i,j) -\/ z\_b(i,j)) + dz\_neglect}
\DoxyCodeLine{587       hr = (z\_t(i,j+1) -\/ z\_b(i,j+1)) + dz\_neglect}
\DoxyCodeLine{588       hwght = hwght * ( (hl-\/hr)/(hl+hr) )**2}
\DoxyCodeLine{589       idenom = 1.0 / ( hwght*(hr + hl) + hl*hr )}
\DoxyCodeLine{590       hwt\_ll = (hwght*hl + hr*hl) * idenom ; hwt\_lr = (hwght*hr) * idenom}
\DoxyCodeLine{591       hwt\_rr = (hwght*hr + hr*hl) * idenom ; hwt\_rl = (hwght*hl) * idenom}
\DoxyCodeLine{592     \textcolor{keywordflow}{else}}
\DoxyCodeLine{593       hwt\_ll = 1.0 ; hwt\_lr = 0.0 ; hwt\_rr = 1.0 ; hwt\_rl = 0.0}
\DoxyCodeLine{594 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{595 }
\DoxyCodeLine{596     intz(1) = dpa(i,j) ; intz(5) = dpa(i,j+1)}
\DoxyCodeLine{597     \textcolor{keywordflow}{do} m=2,4}
\DoxyCodeLine{598       wt\_l = 0.25*real(5-\/m) ; wt\_r = 1.0-\/wt\_l}
\DoxyCodeLine{599       wtt\_l = wt\_l*hwt\_ll + wt\_r*hwt\_rl ; wtt\_r = wt\_l*hwt\_lr + wt\_r*hwt\_rr}
\DoxyCodeLine{600 }
\DoxyCodeLine{601       al0 = wtt\_l*al0\_2d(i,j) + wtt\_r*al0\_2d(i,j+1)}
\DoxyCodeLine{602       p0 = wtt\_l*p0\_2d(i,j) + wtt\_r*p0\_2d(i,j+1)}
\DoxyCodeLine{603       lambda = wtt\_l*lambda\_2d(i,j) + wtt\_r*lambda\_2d(i,j+1)}
\DoxyCodeLine{604 }
\DoxyCodeLine{605       dz = wt\_l*(z\_t(i,j) -\/ z\_b(i,j)) + wt\_r*(z\_t(i,j+1) -\/ z\_b(i,j+1))}
\DoxyCodeLine{606       p\_ave = -\/0.5*gxrho*(wt\_l*(z\_t(i,j)+z\_b(i,j)) + \&}
\DoxyCodeLine{607                           wt\_r*(z\_t(i,j+1)+z\_b(i,j+1)))}
\DoxyCodeLine{608 }
\DoxyCodeLine{609       i\_al0 = 1.0 / al0}
\DoxyCodeLine{610       i\_lzz = 1.0 / (p0 + (lambda * i\_al0) + p\_ave)}
\DoxyCodeLine{611       eps = 0.5*gxrho*dz*i\_lzz ; eps2 = eps*eps}
\DoxyCodeLine{612 }
\DoxyCodeLine{613       intz(m) = pa\_to\_rl2\_t2 * ( g\_earth*dz*((p0 + p\_ave)*(i\_lzz*i\_al0) -\/ rho\_ref\_mks) -\/ 2.0*eps * \&}
\DoxyCodeLine{614                 i\_rho * (lambda * i\_al0**2) * eps2 * (c1\_3 + eps2*(0.2 + eps2*(c1\_7 + c1\_9*eps2))) )}
\DoxyCodeLine{615 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{616     \textcolor{comment}{! Use Boole's rule to integrate the values.}}
\DoxyCodeLine{617     inty\_dpa(i,j) = c1\_90*(7.0*(intz(1)+intz(5)) + 32.0*(intz(2)+intz(4)) + 12.0*intz(3))}
\DoxyCodeLine{618 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{619 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos__wright_a35402f454f02a3fa680a6d7870931aa6}\label{namespacemom__eos__wright_a35402f454f02a3fa680a6d7870931aa6}} 
\index{mom\_eos\_wright@{mom\_eos\_wright}!int\_spec\_vol\_dp\_wright@{int\_spec\_vol\_dp\_wright}}
\index{int\_spec\_vol\_dp\_wright@{int\_spec\_vol\_dp\_wright}!mom\_eos\_wright@{mom\_eos\_wright}}
\doxysubsubsection{\texorpdfstring{int\_spec\_vol\_dp\_wright()}{int\_spec\_vol\_dp\_wright()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+eos\+\_\+wright\+::int\+\_\+spec\+\_\+vol\+\_\+dp\+\_\+wright (\begin{DoxyParamCaption}\item[{real, dimension(hi\%isd\+:hi\%ied,hi\%jsd\+:hi\%jed), intent(in)}]{T,  }\item[{real, dimension(hi\%isd\+:hi\%ied,hi\%jsd\+:hi\%jed), intent(in)}]{S,  }\item[{real, dimension(hi\%isd\+:hi\%ied,hi\%jsd\+:hi\%jed), intent(in)}]{p\+\_\+t,  }\item[{real, dimension(hi\%isd\+:hi\%ied,hi\%jsd\+:hi\%jed), intent(in)}]{p\+\_\+b,  }\item[{real, intent(in)}]{spv\+\_\+ref,  }\item[{type(\mbox{\hyperlink{structmom__hor__index_1_1hor__index__type}{hor\+\_\+index\+\_\+type}}), intent(in)}]{HI,  }\item[{real, dimension(hi\%isd\+:hi\%ied,hi\%jsd\+:hi\%jed), intent(inout)}]{dza,  }\item[{real, dimension(hi\%isd\+:hi\%ied,hi\%jsd\+:hi\%jed), intent(inout), optional}]{intp\+\_\+dza,  }\item[{real, dimension(hi\%isdb\+:hi\%iedb,hi\%jsd\+:hi\%jed), intent(inout), optional}]{intx\+\_\+dza,  }\item[{real, dimension(hi\%isd\+:hi\%ied,hi\%jsdb\+:hi\%jedb), intent(inout), optional}]{inty\+\_\+dza,  }\item[{integer, intent(in), optional}]{halo\+\_\+size,  }\item[{real, dimension(hi\%isd\+:hi\%ied,hi\%jsd\+:hi\%jed), intent(in), optional}]{bathyP,  }\item[{real, intent(in), optional}]{d\+P\+\_\+neglect,  }\item[{logical, intent(in), optional}]{use\+Mass\+Wght\+Interp,  }\item[{real, intent(in), optional}]{S\+V\+\_\+scale,  }\item[{real, intent(in), optional}]{pres\+\_\+scale }\end{DoxyParamCaption})}



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 Boole\textquotesingle{}s rule to do the horizontal integrals, and from a truncation in the series for log(1-\/eps/1+eps) that assumes that $\vert$eps$\vert$ $<$ 0.\+34. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em hi} & The ocean\textquotesingle{}s horizontal index type. \\
\hline
\mbox{\texttt{ in}}  & {\em t} & Potential temperature relative to the surface \\
\hline
\mbox{\texttt{ in}}  & {\em s} & Salinity \mbox{[}P\+SU\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em p\+\_\+t} & Pressure at the top of the layer \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]} or \mbox{[}Pa\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em p\+\_\+b} & Pressure at the top of the layer \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]} or \mbox{[}Pa\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em spv\+\_\+ref} & A mean specific volume that is subtracted out to reduce the magnitude of each of the integrals \mbox{[}R-\/1 $\sim$$>$ m3 kg-\/1\mbox{]}. The calculation is mathematically identical with different values of spv\+\_\+ref, but this reduces the effects of roundoff. \\
\hline
\mbox{\texttt{ in,out}}  & {\em dza} & The change in the geopotential anomaly across \\
\hline
\mbox{\texttt{ in,out}}  & {\em intp\+\_\+dza} & The integral in pressure through the layer of \\
\hline
\mbox{\texttt{ in,out}}  & {\em intx\+\_\+dza} & The integral in x of the difference between the \\
\hline
\mbox{\texttt{ in,out}}  & {\em inty\+\_\+dza} & The integral in y of the difference between the \\
\hline
\mbox{\texttt{ in}}  & {\em halo\+\_\+size} & The width of halo points on which to calculate dza. \\
\hline
\mbox{\texttt{ in}}  & {\em bathyp} & The pressure at the bathymetry \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]} or \mbox{[}Pa\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em dp\+\_\+neglect} & A miniscule pressure change with the same units as p\+\_\+t \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]} or \mbox{[}Pa\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em usemasswghtinterp} & If true, uses mass weighting to interpolate T/S for top and bottom integrals. \\
\hline
\mbox{\texttt{ in}}  & {\em sv\+\_\+scale} & A multiplicative factor by which to scale specific volume from m3 kg-\/1 to the desired units \mbox{[}kg m-\/3 R-\/1 $\sim$$>$ 1\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em pres\+\_\+scale} & A multiplicative factor to convert pressure into Pa \mbox{[}Pa T2 R-\/1 L-\/2 $\sim$$>$ 1\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 628 of file M\+O\+M\+\_\+\+E\+O\+S\+\_\+\+Wright.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{631   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)}  :: HI\textcolor{comment}{        !< The ocean's horizontal index type.}}
\DoxyCodeLine{632 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(HI\%isd:HI\%ied,HI\%jsd:HI\%jed)}, \&}
\DoxyCodeLine{633                         \textcolor{keywordtype}{intent(in)}  :: T\textcolor{comment}{         !< Potential temperature relative to the surface}}
\DoxyCodeLine{634 \textcolor{comment}{                                                 !! [degC].}}
\DoxyCodeLine{635 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(HI\%isd:HI\%ied,HI\%jsd:HI\%jed)}, \&}
\DoxyCodeLine{636                         \textcolor{keywordtype}{intent(in)}  :: S\textcolor{comment}{         !< Salinity [PSU].}}
\DoxyCodeLine{637 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(HI\%isd:HI\%ied,HI\%jsd:HI\%jed)}, \&}
\DoxyCodeLine{638                         \textcolor{keywordtype}{intent(in)}  :: p\_t\textcolor{comment}{       !< Pressure at the top of the layer [R L2 T-\/2 \string~> Pa] or [Pa].}}
\DoxyCodeLine{639 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(HI\%isd:HI\%ied,HI\%jsd:HI\%jed)}, \&}
\DoxyCodeLine{640                         \textcolor{keywordtype}{intent(in)}  :: p\_b\textcolor{comment}{       !< Pressure at the top of the layer [R L2 T-\/2 \string~> Pa] or [Pa].}}
\DoxyCodeLine{641 \textcolor{keywordtype}{  real},                 \textcolor{keywordtype}{intent(in)}  :: spv\_ref\textcolor{comment}{   !< A mean specific volume that is subtracted out}}
\DoxyCodeLine{642 \textcolor{comment}{                            !! to reduce the magnitude of each of the integrals [R-\/1 \string~> m3 kg-\/1].}}
\DoxyCodeLine{643 \textcolor{comment}{                            !! The calculation is mathematically identical with different values of}}
\DoxyCodeLine{644 \textcolor{comment}{                            !! spv\_ref, but this reduces the effects of roundoff.}}
\DoxyCodeLine{645 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(HI\%isd:HI\%ied,HI\%jsd:HI\%jed)}, \&}
\DoxyCodeLine{646                         \textcolor{keywordtype}{intent(inout)} :: dza\textcolor{comment}{     !< The change in the geopotential anomaly across}}
\DoxyCodeLine{647 \textcolor{comment}{                                                 !! the layer [T-\/2 \string~> m2 s-\/2] or [m2 s-\/2].}}
\DoxyCodeLine{648 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(HI\%isd:HI\%ied,HI\%jsd:HI\%jed)}, \&}
\DoxyCodeLine{649               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: intp\_dza\textcolor{comment}{ !< The integral in pressure through the layer of}}
\DoxyCodeLine{650 \textcolor{comment}{                                                 !! the geopotential anomaly relative to the anomaly}}
\DoxyCodeLine{651 \textcolor{comment}{                                                 !! at the bottom of the layer [R L4 T-\/4 \string~> Pa m2 s-\/2]}}
\DoxyCodeLine{652 \textcolor{comment}{                                                 !! or [Pa m2 s-\/2].}}
\DoxyCodeLine{653 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(HI\%IsdB:HI\%IedB,HI\%jsd:HI\%jed)}, \&}
\DoxyCodeLine{654               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: intx\_dza\textcolor{comment}{ !< The integral in x of the difference between the}}
\DoxyCodeLine{655 \textcolor{comment}{                                                 !! geopotential anomaly at the top and bottom of}}
\DoxyCodeLine{656 \textcolor{comment}{                                                 !! the layer divided by the x grid spacing}}
\DoxyCodeLine{657 \textcolor{comment}{                                                 !! [L2 T-\/2 \string~> m2 s-\/2] or [m2 s-\/2].}}
\DoxyCodeLine{658 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(HI\%isd:HI\%ied,HI\%JsdB:HI\%JedB)}, \&}
\DoxyCodeLine{659               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: inty\_dza\textcolor{comment}{ !< The integral in y of the difference between the}}
\DoxyCodeLine{660 \textcolor{comment}{                                                 !! geopotential anomaly at the top and bottom of}}
\DoxyCodeLine{661 \textcolor{comment}{                                                 !! the layer divided by the y grid spacing}}
\DoxyCodeLine{662 \textcolor{comment}{                                                 !! [L2 T-\/2 \string~> m2 s-\/2] or [m2 s-\/2].}}
\DoxyCodeLine{663   \textcolor{keywordtype}{integer},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: halo\_size\textcolor{comment}{ !< The width of halo points on which to calculate}}
\DoxyCodeLine{664 \textcolor{comment}{                                                 !! dza.}}
\DoxyCodeLine{665 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(HI\%isd:HI\%ied,HI\%jsd:HI\%jed)}, \&}
\DoxyCodeLine{666               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: bathyP\textcolor{comment}{    !< The pressure at the bathymetry [R L2 T-\/2 \string~> Pa] or [Pa]}}
\DoxyCodeLine{667 \textcolor{keywordtype}{  real},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: dP\_neglect\textcolor{comment}{ !< A miniscule pressure change with}}
\DoxyCodeLine{668 \textcolor{comment}{                                                 !! the same units as p\_t [R L2 T-\/2 \string~> Pa] or [Pa]}}
\DoxyCodeLine{669   \textcolor{keywordtype}{logical},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: useMassWghtInterp\textcolor{comment}{ !< If true, uses mass weighting}}
\DoxyCodeLine{670 \textcolor{comment}{                            !! to interpolate T/S for top and bottom integrals.}}
\DoxyCodeLine{671 \textcolor{keywordtype}{  real},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: SV\_scale\textcolor{comment}{  !< A multiplicative factor by which to scale specific}}
\DoxyCodeLine{672 \textcolor{comment}{                            !! volume from m3 kg-\/1 to the desired units [kg m-\/3 R-\/1 \string~> 1]}}
\DoxyCodeLine{673 \textcolor{keywordtype}{  real},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: pres\_scale\textcolor{comment}{ !< A multiplicative factor to convert pressure}}
\DoxyCodeLine{674 \textcolor{comment}{                            !! into Pa [Pa T2 R-\/1 L-\/2 \string~> 1].}}
\DoxyCodeLine{675 }
\DoxyCodeLine{676   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{677 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(HI\%isd:HI\%ied,HI\%jsd:HI\%jed)} :: al0\_2d, p0\_2d, lambda\_2d}
\DoxyCodeLine{678 \textcolor{keywordtype}{  real} :: al0        \textcolor{comment}{! A term in the Wright EOS [R-\/1 \string~> m3 kg-\/1]}}
\DoxyCodeLine{679 \textcolor{keywordtype}{  real} :: p0         \textcolor{comment}{! A term in the Wright EOS [R L2 T-\/2 \string~> Pa]}}
\DoxyCodeLine{680 \textcolor{keywordtype}{  real} :: lambda     \textcolor{comment}{! A term in the Wright EOS [L2 T-\/2 \string~> m2 s-\/2]}}
\DoxyCodeLine{681 \textcolor{keywordtype}{  real} :: al0\_scale  \textcolor{comment}{! Scaling factor to convert al0 from MKS units [R-\/1 kg m-\/3 \string~> 1]}}
\DoxyCodeLine{682 \textcolor{keywordtype}{  real} :: p0\_scale   \textcolor{comment}{! Scaling factor to convert p0 from MKS units [R L2 T-\/2 Pa-\/1 \string~> 1]}}
\DoxyCodeLine{683 \textcolor{keywordtype}{  real} :: lam\_scale  \textcolor{comment}{! Scaling factor to convert lambda from MKS units [L2 s2 T-\/2 m-\/2 \string~> 1]}}
\DoxyCodeLine{684 \textcolor{keywordtype}{  real} :: p\_ave      \textcolor{comment}{! The layer average pressure [R L2 T-\/2 \string~> Pa]}}
\DoxyCodeLine{685 \textcolor{keywordtype}{  real} :: rem        \textcolor{comment}{! [L2 T-\/2 \string~> m2 s-\/2]}}
\DoxyCodeLine{686 \textcolor{keywordtype}{  real} :: eps, eps2  \textcolor{comment}{! A nondimensional ratio and its square [nondim]}}
\DoxyCodeLine{687 \textcolor{keywordtype}{  real} :: alpha\_anom \textcolor{comment}{! The depth averaged specific volume anomaly [R-\/1 \string~> m3 kg-\/1].}}
\DoxyCodeLine{688 \textcolor{keywordtype}{  real} :: dp         \textcolor{comment}{! The pressure change through a layer [R L2 T-\/2 \string~> Pa].}}
\DoxyCodeLine{689 \textcolor{keywordtype}{  real} :: hWght      \textcolor{comment}{! A pressure-\/thickness below topography [R L2 T-\/2 \string~> Pa].}}
\DoxyCodeLine{690 \textcolor{keywordtype}{  real} :: hL, hR     \textcolor{comment}{! Pressure-\/thicknesses of the columns to the left and right [R L2 T-\/2 \string~> Pa].}}
\DoxyCodeLine{691 \textcolor{keywordtype}{  real} :: iDenom     \textcolor{comment}{! The inverse of the denominator in the weights [T4 R-\/2 L-\/4 \string~> Pa-\/2].}}
\DoxyCodeLine{692 \textcolor{keywordtype}{  real} :: hWt\_LL, hWt\_LR \textcolor{comment}{! hWt\_LA is the weighted influence of A on the left column [nondim].}}
\DoxyCodeLine{693 \textcolor{keywordtype}{  real} :: hWt\_RL, hWt\_RR \textcolor{comment}{! hWt\_RA is the weighted influence of A on the right column [nondim].}}
\DoxyCodeLine{694 \textcolor{keywordtype}{  real} :: wt\_L, wt\_R \textcolor{comment}{! The linear weights of the left and right columns [nondim].}}
\DoxyCodeLine{695 \textcolor{keywordtype}{  real} :: wtT\_L, wtT\_R \textcolor{comment}{! The weights for tracers from the left and right columns [nondim].}}
\DoxyCodeLine{696 \textcolor{keywordtype}{  real} :: intp(5)    \textcolor{comment}{! The integrals of specific volume with pressure at the}}
\DoxyCodeLine{697                      \textcolor{comment}{! 5 sub-\/column locations [L2 T-\/2 \string~> m2 s-\/2].}}
\DoxyCodeLine{698   \textcolor{keywordtype}{logical} :: do\_massWeight \textcolor{comment}{! Indicates whether to do mass weighting.}}
\DoxyCodeLine{699 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{parameter} :: C1\_3 = 1.0/3.0, c1\_7 = 1.0/7.0    \textcolor{comment}{! Rational constants.}}
\DoxyCodeLine{700 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{parameter} :: C1\_9 = 1.0/9.0, c1\_90 = 1.0/90.0  \textcolor{comment}{! Rational constants.}}
\DoxyCodeLine{701   \textcolor{keywordtype}{integer} :: Isq, Ieq, Jsq, Jeq, ish, ieh, jsh, jeh, i, j, m, halo}
\DoxyCodeLine{702 }
\DoxyCodeLine{703   isq = hi\%IscB ; ieq = hi\%IecB ; jsq = hi\%JscB ; jeq = hi\%JecB}
\DoxyCodeLine{704   halo = 0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(halo\_size)) halo = max(halo\_size,0)}
\DoxyCodeLine{705   ish = hi\%isc-\/halo ; ieh = hi\%iec+halo ; jsh = hi\%jsc-\/halo ; jeh = hi\%jec+halo}
\DoxyCodeLine{706   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(intx\_dza)) \textcolor{keywordflow}{then} ; ish = min(isq,ish) ; ieh = max(ieq+1,ieh);\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{707   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(inty\_dza)) \textcolor{keywordflow}{then} ; jsh = min(jsq,jsh) ; jeh = max(jeq+1,jeh);\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{708 }
\DoxyCodeLine{709 }
\DoxyCodeLine{710   al0\_scale = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(sv\_scale)) al0\_scale = sv\_scale}
\DoxyCodeLine{711   p0\_scale = 1.0}
\DoxyCodeLine{712   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(pres\_scale)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (pres\_scale /= 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{713     p0\_scale = 1.0 / pres\_scale}
\DoxyCodeLine{714 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{715   lam\_scale = al0\_scale * p0\_scale}
\DoxyCodeLine{716 }
\DoxyCodeLine{717   do\_massweight = .false.}
\DoxyCodeLine{718   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(usemasswghtinterp)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (usemasswghtinterp) \textcolor{keywordflow}{then}}
\DoxyCodeLine{719     do\_massweight = .true.}
\DoxyCodeLine{720 \textcolor{comment}{!    if (.not.present(bathyP)) call MOM\_error(FATAL, "{}int\_spec\_vol\_dp\_generic: "{}//\&}}
\DoxyCodeLine{721 \textcolor{comment}{!        "{}bathyP must be present if useMassWghtInterp is present and true."{})}}
\DoxyCodeLine{722 \textcolor{comment}{!    if (.not.present(dP\_neglect)) call MOM\_error(FATAL, "{}int\_spec\_vol\_dp\_generic: "{}//\&}}
\DoxyCodeLine{723 \textcolor{comment}{!        "{}dP\_neglect must be present if useMassWghtInterp is present and true."{})}}
\DoxyCodeLine{724 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{725 }
\DoxyCodeLine{726   \textcolor{comment}{!  alpha(j) = (lambda + al0*(pressure(j) + p0)) / (pressure(j) + p0)}}
\DoxyCodeLine{727   \textcolor{keywordflow}{do} j=jsh,jeh ; \textcolor{keywordflow}{do} i=ish,ieh}
\DoxyCodeLine{728     al0\_2d(i,j) = al0\_scale * ( (a0 + a1*t(i,j)) + a2*s(i,j) )}
\DoxyCodeLine{729     p0\_2d(i,j) = p0\_scale * ( (b0 + b4*s(i,j)) + t(i,j) * (b1 + t(i,j)*((b2 + b3*t(i,j))) + b5*s(i,j)) )}
\DoxyCodeLine{730     lambda\_2d(i,j) = lam\_scale * ( (c0 + c4*s(i,j)) + t(i,j) * (c1 + t(i,j)*((c2 + c3*t(i,j))) + c5*s(i,j)) )}
\DoxyCodeLine{731 }
\DoxyCodeLine{732     al0 = al0\_2d(i,j) ; p0 = p0\_2d(i,j) ; lambda = lambda\_2d(i,j)}
\DoxyCodeLine{733     dp = p\_b(i,j) -\/ p\_t(i,j)}
\DoxyCodeLine{734     p\_ave = 0.5*(p\_t(i,j)+p\_b(i,j))}
\DoxyCodeLine{735 }
\DoxyCodeLine{736     eps = 0.5 * dp / (p0 + p\_ave) ; eps2 = eps*eps}
\DoxyCodeLine{737     alpha\_anom = al0 + lambda / (p0 + p\_ave) -\/ spv\_ref}
\DoxyCodeLine{738     rem = lambda * eps2 * (c1\_3 + eps2*(0.2 + eps2*(c1\_7 + c1\_9*eps2)))}
\DoxyCodeLine{739     dza(i,j) = alpha\_anom*dp + 2.0*eps*rem}
\DoxyCodeLine{740     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(intp\_dza)) \&}
\DoxyCodeLine{741       intp\_dza(i,j) = 0.5*alpha\_anom*dp**2 -\/ dp*(1.0-\/eps)*rem}
\DoxyCodeLine{742 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{743 }
\DoxyCodeLine{744   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(intx\_dza)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=hi\%jsc,hi\%jec ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{745     \textcolor{comment}{! hWght is the distance measure by which the cell is violation of}}
\DoxyCodeLine{746     \textcolor{comment}{! hydrostatic consistency. For large hWght we bias the interpolation of}}
\DoxyCodeLine{747     \textcolor{comment}{! T \& S along the top and bottom integrals, akin to thickness weighting.}}
\DoxyCodeLine{748     hwght = 0.0}
\DoxyCodeLine{749     \textcolor{keywordflow}{if} (do\_massweight) \&}
\DoxyCodeLine{750       hwght = max(0., bathyp(i,j)-\/p\_t(i+1,j), bathyp(i+1,j)-\/p\_t(i,j))}
\DoxyCodeLine{751     \textcolor{keywordflow}{if} (hwght > 0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{752       hl = (p\_b(i,j) -\/ p\_t(i,j)) + dp\_neglect}
\DoxyCodeLine{753       hr = (p\_b(i+1,j) -\/ p\_t(i+1,j)) + dp\_neglect}
\DoxyCodeLine{754       hwght = hwght * ( (hl-\/hr)/(hl+hr) )**2}
\DoxyCodeLine{755       idenom = 1.0 / ( hwght*(hr + hl) + hl*hr )}
\DoxyCodeLine{756       hwt\_ll = (hwght*hl + hr*hl) * idenom ; hwt\_lr = (hwght*hr) * idenom}
\DoxyCodeLine{757       hwt\_rr = (hwght*hr + hr*hl) * idenom ; hwt\_rl = (hwght*hl) * idenom}
\DoxyCodeLine{758     \textcolor{keywordflow}{else}}
\DoxyCodeLine{759       hwt\_ll = 1.0 ; hwt\_lr = 0.0 ; hwt\_rr = 1.0 ; hwt\_rl = 0.0}
\DoxyCodeLine{760 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{761 }
\DoxyCodeLine{762     intp(1) = dza(i,j) ; intp(5) = dza(i+1,j)}
\DoxyCodeLine{763     \textcolor{keywordflow}{do} m=2,4}
\DoxyCodeLine{764       wt\_l = 0.25*real(5-\/m) ; wt\_r = 1.0-\/wt\_l}
\DoxyCodeLine{765       wtt\_l = wt\_l*hwt\_ll + wt\_r*hwt\_rl ; wtt\_r = wt\_l*hwt\_lr + wt\_r*hwt\_rr}
\DoxyCodeLine{766 }
\DoxyCodeLine{767       \textcolor{comment}{! T, S, and p are interpolated in the horizontal.  The p interpolation}}
\DoxyCodeLine{768       \textcolor{comment}{! is linear, but for T and S it may be thickness wekghted.}}
\DoxyCodeLine{769       al0 = wtt\_l*al0\_2d(i,j) + wtt\_r*al0\_2d(i+1,j)}
\DoxyCodeLine{770       p0 = wtt\_l*p0\_2d(i,j) + wtt\_r*p0\_2d(i+1,j)}
\DoxyCodeLine{771       lambda = wtt\_l*lambda\_2d(i,j) + wtt\_r*lambda\_2d(i+1,j)}
\DoxyCodeLine{772 }
\DoxyCodeLine{773       dp = wt\_l*(p\_b(i,j) -\/ p\_t(i,j)) + wt\_r*(p\_b(i+1,j) -\/ p\_t(i+1,j))}
\DoxyCodeLine{774       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)))}
\DoxyCodeLine{775 }
\DoxyCodeLine{776       eps = 0.5 * dp / (p0 + p\_ave) ; eps2 = eps*eps}
\DoxyCodeLine{777       intp(m) = (al0 + lambda / (p0 + p\_ave) -\/ spv\_ref)*dp + 2.0*eps* \&}
\DoxyCodeLine{778                lambda * eps2 * (c1\_3 + eps2*(0.2 + eps2*(c1\_7 + c1\_9*eps2)))}
\DoxyCodeLine{779 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{780     \textcolor{comment}{! Use Boole's rule to integrate the values.}}
\DoxyCodeLine{781     intx\_dza(i,j) = c1\_90*(7.0*(intp(1)+intp(5)) + 32.0*(intp(2)+intp(4)) + \&}
\DoxyCodeLine{782                            12.0*intp(3))}
\DoxyCodeLine{783 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{784 }
\DoxyCodeLine{785   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(inty\_dza)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=hi\%isc,hi\%iec}
\DoxyCodeLine{786     \textcolor{comment}{! hWght is the distance measure by which the cell is violation of}}
\DoxyCodeLine{787     \textcolor{comment}{! hydrostatic consistency. For large hWght we bias the interpolation of}}
\DoxyCodeLine{788     \textcolor{comment}{! T \& S along the top and bottom integrals, akin to thickness weighting.}}
\DoxyCodeLine{789     hwght = 0.0}
\DoxyCodeLine{790     \textcolor{keywordflow}{if} (do\_massweight) \&}
\DoxyCodeLine{791       hwght = max(0., bathyp(i,j)-\/p\_t(i,j+1), bathyp(i,j+1)-\/p\_t(i,j))}
\DoxyCodeLine{792     \textcolor{keywordflow}{if} (hwght > 0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{793       hl = (p\_b(i,j) -\/ p\_t(i,j)) + dp\_neglect}
\DoxyCodeLine{794       hr = (p\_b(i,j+1) -\/ p\_t(i,j+1)) + dp\_neglect}
\DoxyCodeLine{795       hwght = hwght * ( (hl-\/hr)/(hl+hr) )**2}
\DoxyCodeLine{796       idenom = 1.0 / ( hwght*(hr + hl) + hl*hr )}
\DoxyCodeLine{797       hwt\_ll = (hwght*hl + hr*hl) * idenom ; hwt\_lr = (hwght*hr) * idenom}
\DoxyCodeLine{798       hwt\_rr = (hwght*hr + hr*hl) * idenom ; hwt\_rl = (hwght*hl) * idenom}
\DoxyCodeLine{799     \textcolor{keywordflow}{else}}
\DoxyCodeLine{800       hwt\_ll = 1.0 ; hwt\_lr = 0.0 ; hwt\_rr = 1.0 ; hwt\_rl = 0.0}
\DoxyCodeLine{801 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{802 }
\DoxyCodeLine{803     intp(1) = dza(i,j) ; intp(5) = dza(i,j+1)}
\DoxyCodeLine{804     \textcolor{keywordflow}{do} m=2,4}
\DoxyCodeLine{805       wt\_l = 0.25*real(5-\/m) ; wt\_r = 1.0-\/wt\_l}
\DoxyCodeLine{806       wtt\_l = wt\_l*hwt\_ll + wt\_r*hwt\_rl ; wtt\_r = wt\_l*hwt\_lr + wt\_r*hwt\_rr}
\DoxyCodeLine{807 }
\DoxyCodeLine{808       \textcolor{comment}{! T, S, and p are interpolated in the horizontal.  The p interpolation}}
\DoxyCodeLine{809       \textcolor{comment}{! is linear, but for T and S it may be thickness wekghted.}}
\DoxyCodeLine{810       al0 = wt\_l*al0\_2d(i,j) + wt\_r*al0\_2d(i,j+1)}
\DoxyCodeLine{811       p0 = wt\_l*p0\_2d(i,j) + wt\_r*p0\_2d(i,j+1)}
\DoxyCodeLine{812       lambda = wt\_l*lambda\_2d(i,j) + wt\_r*lambda\_2d(i,j+1)}
\DoxyCodeLine{813 }
\DoxyCodeLine{814       dp = wt\_l*(p\_b(i,j) -\/ p\_t(i,j)) + wt\_r*(p\_b(i,j+1) -\/ p\_t(i,j+1))}
\DoxyCodeLine{815       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)))}
\DoxyCodeLine{816 }
\DoxyCodeLine{817       eps = 0.5 * dp / (p0 + p\_ave) ; eps2 = eps*eps}
\DoxyCodeLine{818       intp(m) = (al0 + lambda / (p0 + p\_ave) -\/ spv\_ref)*dp + 2.0*eps* \&}
\DoxyCodeLine{819                lambda * eps2 * (c1\_3 + eps2*(0.2 + eps2*(c1\_7 + c1\_9*eps2)))}
\DoxyCodeLine{820 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{821     \textcolor{comment}{! Use Boole's rule to integrate the values.}}
\DoxyCodeLine{822     inty\_dza(i,j) = c1\_90*(7.0*(intp(1)+intp(5)) + 32.0*(intp(2)+intp(4)) + \&}
\DoxyCodeLine{823                            12.0*intp(3))}
\DoxyCodeLine{824 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}}

\end{DoxyCode}
