\hypertarget{namespacemom__eos}{}\section{mom\+\_\+eos Module Reference}
\label{namespacemom__eos}\index{mom\+\_\+eos@{mom\+\_\+eos}}


\subsection{Detailed Description}
Provides subroutines for quantities specific to the equation of state. 

The M\+O\+M\+\_\+\+E\+OS module is a wrapper for various equations of state (e.\+g. Linear, Wright, U\+N\+E\+S\+CO) and provides a uniform interface to the rest of the model independent of which equation of state is being used. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
interface \hyperlink{interfacemom__eos_1_1calculate__compress}{calculate\+\_\+compress}
\begin{DoxyCompactList}\small\item\em Calculates the compressibility of water from T, S, and P. \end{DoxyCompactList}\item 
interface \hyperlink{interfacemom__eos_1_1calculate__density}{calculate\+\_\+density}
\begin{DoxyCompactList}\small\item\em Calculates density of sea water from T, S and P. \end{DoxyCompactList}\item 
interface \hyperlink{interfacemom__eos_1_1calculate__density__derivs}{calculate\+\_\+density\+\_\+derivs}
\begin{DoxyCompactList}\small\item\em Calculate the derivatives of density with temperature and salinity from T, S, and P. \end{DoxyCompactList}\item 
interface \hyperlink{interfacemom__eos_1_1calculate__density__second__derivs}{calculate\+\_\+density\+\_\+second\+\_\+derivs}
\begin{DoxyCompactList}\small\item\em Calculates the second derivatives of density with various combinations of temperature, salinity, and pressure from T, S and P. \end{DoxyCompactList}\item 
interface \hyperlink{interfacemom__eos_1_1calculate__spec__vol}{calculate\+\_\+spec\+\_\+vol}
\begin{DoxyCompactList}\small\item\em Calculates specific volume of sea water from T, S and P. \end{DoxyCompactList}\item 
interface \hyperlink{interfacemom__eos_1_1calculate__specific__vol__derivs}{calculate\+\_\+specific\+\_\+vol\+\_\+derivs}
\begin{DoxyCompactList}\small\item\em Calculate the derivatives of specific volume with temperature and salinity from T, S, and P. \end{DoxyCompactList}\item 
interface \hyperlink{interfacemom__eos_1_1calculate__tfreeze}{calculate\+\_\+tfreeze}
\begin{DoxyCompactList}\small\item\em Calculates the freezing point of sea water from T, S and P. \end{DoxyCompactList}\item 
type \hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}
\begin{DoxyCompactList}\small\item\em A control structure for the equation of state. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine \hyperlink{namespacemom__eos_ac3bdab784e3535d661c47d1ec8a624fd}{calculate\+\_\+density\+\_\+scalar} (T, S, pressure, rho, E\+OS, rho\+\_\+ref, scale)
\begin{DoxyCompactList}\small\item\em Calls the appropriate subroutine to calculate density of sea water for scalar inputs. If rho\+\_\+ref is present, the anomaly with respect to rho\+\_\+ref is returned. The pressure and density can be rescaled with the US. If both the US and scale arguments are present the density scaling uses the product of the two scaling factors. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__eos_a66d40148737ef1a3b1ae44917c7fe0c3}{calculate\+\_\+stanley\+\_\+density\+\_\+scalar} (T, S, pressure, Tvar, T\+Scov, Svar, rho, E\+OS, rho\+\_\+ref, scale)
\begin{DoxyCompactList}\small\item\em Calls the appropriate subroutine to calculate density of sea water for scalar inputs including the variance of T, S and covariance of T-\/S. The calculation uses only the second order correction in a series as discussed in Stanley et al., 2020. If rho\+\_\+ref is present, the anomaly with respect to rho\+\_\+ref is returned. The density can be rescaled using rho\+\_\+ref. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__eos_a3be8289c391088bdd3af78d272b92521}{calculate\+\_\+density\+\_\+array} (T, S, pressure, rho, start, npts, E\+OS, rho\+\_\+ref, scale)
\begin{DoxyCompactList}\small\item\em Calls the appropriate subroutine to calculate the density of sea water for 1-\/D array inputs. If rho\+\_\+ref is present, the anomaly with respect to rho\+\_\+ref is returned. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__eos_a102df91898d116a6b4346f00dc818612}{calculate\+\_\+stanley\+\_\+density\+\_\+array} (T, S, pressure, Tvar, T\+Scov, Svar, rho, start, npts, E\+OS, rho\+\_\+ref, scale)
\begin{DoxyCompactList}\small\item\em Calls the appropriate subroutine to calculate the density of sea water for 1-\/D array inputs including the variance of T, S and covariance of T-\/S. The calculation uses only the second order correction in a series as discussed in Stanley et al., 2020. If rho\+\_\+ref is present, the anomaly with respect to rho\+\_\+ref is returned. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__eos_a2e78ade3bcba817406479cbbe3941a5f}{calculate\+\_\+density\+\_\+1d} (T, S, pressure, rho, E\+OS, dom, rho\+\_\+ref, scale)
\begin{DoxyCompactList}\small\item\em Calls the appropriate subroutine to calculate the density of sea water for 1-\/D array inputs, potentially limiting the domain of indices that are worked on. If rho\+\_\+ref is present, the anomaly with respect to rho\+\_\+ref is returned. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__eos_a58b52a452d779c53e6421aaa3eac6e8b}{calculate\+\_\+stanley\+\_\+density\+\_\+1d} (T, S, pressure, Tvar, T\+Scov, Svar, rho, E\+OS, dom, rho\+\_\+ref, scale)
\begin{DoxyCompactList}\small\item\em Calls the appropriate subroutine to calculate the density of sea water for 1-\/D array inputs including the variance of T, S and covariance of T-\/S, potentially limiting the domain of indices that are worked on. The calculation uses only the second order correction in a series as discussed in Stanley et al., 2020. If rho\+\_\+ref is present, the anomaly with respect to rho\+\_\+ref is returned. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__eos_a43d417da1636adb2cd184f76223afded}{calculate\+\_\+spec\+\_\+vol\+\_\+array} (T, S, pressure, specvol, start, npts, E\+OS, spv\+\_\+ref, scale)
\begin{DoxyCompactList}\small\item\em Calls the appropriate subroutine to calculate the specific volume of sea water for 1-\/D array inputs. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__eos_a246056e557a08ce1c697256cd718d99a}{calc\+\_\+spec\+\_\+vol\+\_\+scalar} (T, S, pressure, specvol, E\+OS, spv\+\_\+ref, scale)
\begin{DoxyCompactList}\small\item\em Calls the appropriate subroutine to calculate specific volume of sea water for scalar inputs. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__eos_afbb6a11d3b826308ddb1ffe0c5cf32d1}{calc\+\_\+spec\+\_\+vol\+\_\+1d} (T, S, pressure, specvol, E\+OS, dom, spv\+\_\+ref, scale)
\begin{DoxyCompactList}\small\item\em Calls the appropriate subroutine to calculate the specific volume of sea water for 1-\/D array inputs, potentially limiting the domain of indices that are worked on. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__eos_ad46af8402aba49dbdd73817d33e83270}{calculate\+\_\+tfreeze\+\_\+scalar} (S, pressure, T\+\_\+fr, E\+OS, pres\+\_\+scale)
\begin{DoxyCompactList}\small\item\em Calls the appropriate subroutine to calculate the freezing point for scalar inputs. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__eos_ab9669ca4a2e4f3507be7efe047c18ab7}{calculate\+\_\+tfreeze\+\_\+array} (S, pressure, T\+\_\+fr, start, npts, E\+OS, pres\+\_\+scale)
\begin{DoxyCompactList}\small\item\em Calls the appropriate subroutine to calculate the freezing point for a 1-\/D array. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__eos_a27ec57cbbd2e673d542ba2c8dd44053a}{calculate\+\_\+density\+\_\+derivs\+\_\+array} (T, S, pressure, drho\+\_\+dT, drho\+\_\+dS, start, npts, E\+OS, scale)
\begin{DoxyCompactList}\small\item\em Calls the appropriate subroutine to calculate density derivatives for 1-\/D array inputs. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__eos_aed3bb20f32c038dbe84bc44442c6e724}{calculate\+\_\+density\+\_\+derivs\+\_\+1d} (T, S, pressure, drho\+\_\+dT, drho\+\_\+dS, E\+OS, dom, scale)
\begin{DoxyCompactList}\small\item\em Calls the appropriate subroutine to calculate density derivatives for 1-\/D array inputs. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__eos_a06d9d6680e838b965666986e63c980e7}{calculate\+\_\+density\+\_\+derivs\+\_\+scalar} (T, S, pressure, drho\+\_\+dT, drho\+\_\+dS, E\+OS, scale)
\begin{DoxyCompactList}\small\item\em Calls the appropriate subroutines to calculate density derivatives by promoting a scalar to a one-\/element array. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__eos_a8c0fa67a7a4911eb5fa33c5d17b997f9}{calculate\+\_\+density\+\_\+second\+\_\+derivs\+\_\+array} (T, S, pressure, drho\+\_\+d\+S\+\_\+dS, drho\+\_\+d\+S\+\_\+dT, drho\+\_\+d\+T\+\_\+dT, drho\+\_\+d\+S\+\_\+dP, drho\+\_\+d\+T\+\_\+dP, start, npts, E\+OS, scale)
\begin{DoxyCompactList}\small\item\em Calls the appropriate subroutine to calculate density second derivatives for 1-\/D array inputs. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__eos_a2d7a984ed1c48d9e0ea1046de3eac886}{calculate\+\_\+density\+\_\+second\+\_\+derivs\+\_\+scalar} (T, S, pressure, drho\+\_\+d\+S\+\_\+dS, drho\+\_\+d\+S\+\_\+dT, drho\+\_\+d\+T\+\_\+dT, drho\+\_\+d\+S\+\_\+dP, drho\+\_\+d\+T\+\_\+dP, E\+OS, scale)
\begin{DoxyCompactList}\small\item\em Calls the appropriate subroutine to calculate density second derivatives for scalar nputs. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__eos_a35f9c33d1aeffbf9986349463bab3b9c}{calculate\+\_\+spec\+\_\+vol\+\_\+derivs\+\_\+array} (T, S, pressure, d\+S\+V\+\_\+dT, d\+S\+V\+\_\+dS, start, npts, E\+OS)
\begin{DoxyCompactList}\small\item\em Calls the appropriate subroutine to calculate specific volume derivatives for an array. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__eos_a640c3b2292afd3266caa11243549bbf0}{calc\+\_\+spec\+\_\+vol\+\_\+derivs\+\_\+1d} (T, S, pressure, d\+S\+V\+\_\+dT, d\+S\+V\+\_\+dS, E\+OS, dom, scale)
\begin{DoxyCompactList}\small\item\em Calls the appropriate subroutine to calculate specific volume derivatives for 1-\/d array inputs, potentially limiting the domain of indices that are worked on. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__eos_a3296609bd60bfe7ed2c5eac1170d07a3}{calculate\+\_\+compress\+\_\+array} (T, S, press, rho, drho\+\_\+dp, start, npts, E\+OS)
\begin{DoxyCompactList}\small\item\em Calls the appropriate subroutine to calculate the density and compressibility for 1-\/D array inputs. If US is present, the units of the inputs and outputs are rescaled. \end{DoxyCompactList}\item 
subroutine \hyperlink{namespacemom__eos_ad0986d800c26414dbd19d2b3a541e613}{calculate\+\_\+compress\+\_\+scalar} (T, S, pressure, rho, drho\+\_\+dp, E\+OS)
\begin{DoxyCompactList}\small\item\em Calculate density and compressibility for a scalar. This just promotes the scalar to an array with a singleton dimension and calls calculate\+\_\+compress\+\_\+array. If US is present, the units of the inputs and outputs are rescaled. \end{DoxyCompactList}\item 
integer function, dimension(2), public \hyperlink{namespacemom__eos_a782d326108e390902e520efc078e8296}{eos\+\_\+domain} (HI, halo)
\begin{DoxyCompactList}\small\item\em This subroutine returns a two point integer array indicating the domain of i-\/indices to work on in E\+OS calls based on information from a hor\+\_\+index type. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__eos_a09b6cb637246b8aa287ef7cdb482aaea}{analytic\+\_\+int\+\_\+specific\+\_\+vol\+\_\+dp} (T, S, p\+\_\+t, p\+\_\+b, alpha\+\_\+ref, HI, E\+OS, dza, intp\+\_\+dza, intx\+\_\+dza, inty\+\_\+dza, halo\+\_\+size, bathyP, d\+P\+\_\+tiny, use\+Mass\+Wght\+Interp)
\begin{DoxyCompactList}\small\item\em Calls the appropriate subroutine to calculate 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}\item 
subroutine, public \hyperlink{namespacemom__eos_a2787233a5f7a0935206ba2cf4c278aab}{analytic\+\_\+int\+\_\+density\+\_\+dz} (T, S, z\+\_\+t, z\+\_\+b, rho\+\_\+ref, rho\+\_\+0, G\+\_\+e, HI, E\+OS, dpa, intz\+\_\+dpa, intx\+\_\+dpa, inty\+\_\+dpa, bathyT, dz\+\_\+neglect, use\+Mass\+Wght\+Interp)
\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 
logical function, public \hyperlink{namespacemom__eos_aee169aee0e4cbed420782d772282bb69}{query\+\_\+compressible} (E\+OS)
\begin{DoxyCompactList}\small\item\em Returns true if the equation of state is compressible (i.\+e. has pressure dependence) \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__eos_a3ab220b9c98dac3b8f6b7c1606b811cf}{eos\+\_\+init} (param\+\_\+file, E\+OS, US)
\begin{DoxyCompactList}\small\item\em Initializes E\+O\+S\+\_\+type by allocating and reading parameters. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__eos_a949f5bb0744c827bf11cca01316ceed4}{eos\+\_\+manual\+\_\+init} (E\+OS, form\+\_\+of\+\_\+\+E\+OS, form\+\_\+of\+\_\+\+T\+Freeze, E\+O\+S\+\_\+quadrature, Compressible, Rho\+\_\+\+T0\+\_\+\+S0, drho\+\_\+dT, d\+Rho\+\_\+dS, T\+Fr\+\_\+\+S0\+\_\+\+P0, d\+T\+Fr\+\_\+dS, d\+T\+Fr\+\_\+dp)
\begin{DoxyCompactList}\small\item\em Manually initialized an E\+OS type (intended for unit testing of routines which need a specific E\+OS) \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__eos_a1108fb5de7a69d01746df3995f7e3f0d}{eos\+\_\+allocate} (E\+OS)
\begin{DoxyCompactList}\small\item\em Allocates E\+O\+S\+\_\+type. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__eos_acab6a23bef0a98f15f0a479bdd1ec63c}{eos\+\_\+end} (E\+OS)
\begin{DoxyCompactList}\small\item\em Deallocates E\+O\+S\+\_\+type. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__eos_ae608600501a98f8f317d8f27a054327e}{eos\+\_\+use\+\_\+linear} (Rho\+\_\+\+T0\+\_\+\+S0, d\+Rho\+\_\+dT, d\+Rho\+\_\+dS, E\+OS, use\+\_\+quadrature)
\begin{DoxyCompactList}\small\item\em Set equation of state structure (E\+OS) to linear with given coefficients. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__eos_a5b1ff89023e9d7da4074c7c1a71c9a85}{convert\+\_\+temp\+\_\+salt\+\_\+for\+\_\+teos10} (T, S, HI, kd, mask\+\_\+z, E\+OS)
\begin{DoxyCompactList}\small\item\em Convert T\&S to Absolute Salinity and Conservative Temperature if using T\+E\+O\+S10. \end{DoxyCompactList}\item 
logical function, public \hyperlink{namespacemom__eos_aad531f2540628368c33198bb31d51201}{eos\+\_\+quadrature} (E\+OS)
\begin{DoxyCompactList}\small\item\em Return value of E\+O\+S\+\_\+quadrature. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacemom__eos_a5e15d4f5b758ab149421c33145b0444c}{extract\+\_\+member\+\_\+eos} (E\+OS, form\+\_\+of\+\_\+\+E\+OS, form\+\_\+of\+\_\+\+T\+Freeze, E\+O\+S\+\_\+quadrature, Compressible, Rho\+\_\+\+T0\+\_\+\+S0, drho\+\_\+dT, d\+Rho\+\_\+dS, T\+Fr\+\_\+\+S0\+\_\+\+P0, d\+T\+Fr\+\_\+dS, d\+T\+Fr\+\_\+dp)
\begin{DoxyCompactList}\small\item\em Extractor routine for the E\+OS type if the members need to be accessed outside this module. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacemom__eos_a230a2f280b1e27ee913e1b3cf4c412b8}\label{namespacemom__eos_a230a2f280b1e27ee913e1b3cf4c412b8}} 
integer, parameter, public \hyperlink{namespacemom__eos_a230a2f280b1e27ee913e1b3cf4c412b8}{eos\+\_\+linear} = 1
\begin{DoxyCompactList}\small\item\em A named integer specifying an equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos_a9eacc16ba79dc66131b54bf31114f35a}\label{namespacemom__eos_a9eacc16ba79dc66131b54bf31114f35a}} 
integer, parameter, public \hyperlink{namespacemom__eos_a9eacc16ba79dc66131b54bf31114f35a}{eos\+\_\+unesco} = 2
\begin{DoxyCompactList}\small\item\em A named integer specifying an equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos_a4bbd0f276fe3878bd01b3ff180fb41c5}\label{namespacemom__eos_a4bbd0f276fe3878bd01b3ff180fb41c5}} 
integer, parameter, public \hyperlink{namespacemom__eos_a4bbd0f276fe3878bd01b3ff180fb41c5}{eos\+\_\+wright} = 3
\begin{DoxyCompactList}\small\item\em A named integer specifying an equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos_afcd60f98ea35c6044d38eb4409b0a083}\label{namespacemom__eos_afcd60f98ea35c6044d38eb4409b0a083}} 
integer, parameter, public \hyperlink{namespacemom__eos_afcd60f98ea35c6044d38eb4409b0a083}{eos\+\_\+teos10} = 4
\begin{DoxyCompactList}\small\item\em A named integer specifying an equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos_ac37477f774acf511e88e96c036fa8292}\label{namespacemom__eos_ac37477f774acf511e88e96c036fa8292}} 
integer, parameter, public \hyperlink{namespacemom__eos_ac37477f774acf511e88e96c036fa8292}{eos\+\_\+nemo} = 5
\begin{DoxyCompactList}\small\item\em A named integer specifying an equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos_adba0a32cc2c8f110e58447a29bf885d3}\label{namespacemom__eos_adba0a32cc2c8f110e58447a29bf885d3}} 
character $\ast$(10), parameter \hyperlink{namespacemom__eos_adba0a32cc2c8f110e58447a29bf885d3}{eos\+\_\+linear\+\_\+string} = \char`\"{}L\+I\+N\+E\+AR\char`\"{}
\begin{DoxyCompactList}\small\item\em A string for specifying the equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos_aa725e4d064e1dd5cb0c6208096ad05fe}\label{namespacemom__eos_aa725e4d064e1dd5cb0c6208096ad05fe}} 
character $\ast$(10), parameter \hyperlink{namespacemom__eos_aa725e4d064e1dd5cb0c6208096ad05fe}{eos\+\_\+unesco\+\_\+string} = \char`\"{}U\+N\+E\+S\+CO\char`\"{}
\begin{DoxyCompactList}\small\item\em A string for specifying the equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos_acacee5907ae295a83b1a9b65175d5a1e}\label{namespacemom__eos_acacee5907ae295a83b1a9b65175d5a1e}} 
character $\ast$(10), parameter \hyperlink{namespacemom__eos_acacee5907ae295a83b1a9b65175d5a1e}{eos\+\_\+wright\+\_\+string} = \char`\"{}W\+R\+I\+G\+HT\char`\"{}
\begin{DoxyCompactList}\small\item\em A string for specifying the equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos_a9dc2b7c2c67a47b336de4db21b0c9cf5}\label{namespacemom__eos_a9dc2b7c2c67a47b336de4db21b0c9cf5}} 
character $\ast$(10), parameter \hyperlink{namespacemom__eos_a9dc2b7c2c67a47b336de4db21b0c9cf5}{eos\+\_\+teos10\+\_\+string} = \char`\"{}T\+E\+O\+S10\char`\"{}
\begin{DoxyCompactList}\small\item\em A string for specifying the equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos_a9348dc6c296a8dad0fe5cf27e47119a5}\label{namespacemom__eos_a9348dc6c296a8dad0fe5cf27e47119a5}} 
character $\ast$(10), parameter \hyperlink{namespacemom__eos_a9348dc6c296a8dad0fe5cf27e47119a5}{eos\+\_\+nemo\+\_\+string} = \char`\"{}N\+E\+MO\char`\"{}
\begin{DoxyCompactList}\small\item\em A string for specifying the equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos_a3d4e14a920e46cac8cec72c79690de7c}\label{namespacemom__eos_a3d4e14a920e46cac8cec72c79690de7c}} 
character $\ast$(10), parameter \hyperlink{namespacemom__eos_a3d4e14a920e46cac8cec72c79690de7c}{eos\+\_\+default} = E\+O\+S\+\_\+\+W\+R\+I\+G\+H\+T\+\_\+\+S\+T\+R\+I\+NG
\begin{DoxyCompactList}\small\item\em The default equation of state. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos_adcc45ec5c82aaef0aa4d330fa8cbc5c5}\label{namespacemom__eos_adcc45ec5c82aaef0aa4d330fa8cbc5c5}} 
integer, parameter \hyperlink{namespacemom__eos_adcc45ec5c82aaef0aa4d330fa8cbc5c5}{tfreeze\+\_\+linear} = 1
\begin{DoxyCompactList}\small\item\em A named integer specifying a freezing point expression. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos_a7f361d35806d25ac361fea713b7f0b6f}\label{namespacemom__eos_a7f361d35806d25ac361fea713b7f0b6f}} 
integer, parameter \hyperlink{namespacemom__eos_a7f361d35806d25ac361fea713b7f0b6f}{tfreeze\+\_\+millero} = 2
\begin{DoxyCompactList}\small\item\em A named integer specifying a freezing point expression. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos_abf1f6edc79b67730c9f47e5645069eda}\label{namespacemom__eos_abf1f6edc79b67730c9f47e5645069eda}} 
integer, parameter \hyperlink{namespacemom__eos_abf1f6edc79b67730c9f47e5645069eda}{tfreeze\+\_\+teos10} = 3
\begin{DoxyCompactList}\small\item\em A named integer specifying a freezing point expression. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos_ae3ee69a3e4a38b6925b121e3f34d8a15}\label{namespacemom__eos_ae3ee69a3e4a38b6925b121e3f34d8a15}} 
character $\ast$(10), parameter \hyperlink{namespacemom__eos_ae3ee69a3e4a38b6925b121e3f34d8a15}{tfreeze\+\_\+linear\+\_\+string} = \char`\"{}L\+I\+N\+E\+AR\char`\"{}
\begin{DoxyCompactList}\small\item\em A string for specifying the freezing point expression. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos_a3922b6088618d34983c6125e0aa553ad}\label{namespacemom__eos_a3922b6088618d34983c6125e0aa553ad}} 
character $\ast$(10), parameter \hyperlink{namespacemom__eos_a3922b6088618d34983c6125e0aa553ad}{tfreeze\+\_\+millero\+\_\+string} = \char`\"{}M\+I\+L\+L\+E\+R\+O\+\_\+78\char`\"{}
\begin{DoxyCompactList}\small\item\em A string for specifying freezing point expression. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos_ad96b484fe337e2c37b2b11bcd3cbd7af}\label{namespacemom__eos_ad96b484fe337e2c37b2b11bcd3cbd7af}} 
character $\ast$(10), parameter \hyperlink{namespacemom__eos_ad96b484fe337e2c37b2b11bcd3cbd7af}{tfreeze\+\_\+teos10\+\_\+string} = \char`\"{}T\+E\+O\+S10\char`\"{}
\begin{DoxyCompactList}\small\item\em A string for specifying the freezing point expression. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__eos_a26afc0610c00badaeedddf818c0dc48c}\label{namespacemom__eos_a26afc0610c00badaeedddf818c0dc48c}} 
character $\ast$(10), parameter \hyperlink{namespacemom__eos_a26afc0610c00badaeedddf818c0dc48c}{tfreeze\+\_\+default} = T\+F\+R\+E\+E\+Z\+E\+\_\+\+L\+I\+N\+E\+A\+R\+\_\+\+S\+T\+R\+I\+NG
\begin{DoxyCompactList}\small\item\em The default freezing point expression. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__eos_a2787233a5f7a0935206ba2cf4c278aab}\label{namespacemom__eos_a2787233a5f7a0935206ba2cf4c278aab}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!analytic\+\_\+int\+\_\+density\+\_\+dz@{analytic\+\_\+int\+\_\+density\+\_\+dz}}
\index{analytic\+\_\+int\+\_\+density\+\_\+dz@{analytic\+\_\+int\+\_\+density\+\_\+dz}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{analytic\+\_\+int\+\_\+density\+\_\+dz()}{analytic\_int\_density\_dz()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+eos\+::analytic\+\_\+int\+\_\+density\+\_\+dz (\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(hor\+\_\+index\+\_\+type), intent(in)}]{HI,  }\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS,  }\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 }\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{\tt in}  & {\em hi} & Ocean horizontal index structure\\
\hline
\mbox{\tt in}  & {\em t} & Potential temperature referenced to the surface \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em s} & Salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em z\+\_\+t} & Height at the top of the layer in depth units \mbox{[}Z $\sim$$>$ m\mbox{]}\\
\hline
\mbox{\tt in}  & {\em z\+\_\+b} & Height at the bottom of the layer \mbox{[}Z $\sim$$>$ m\mbox{]}\\
\hline
\mbox{\tt 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.\\
\hline
\mbox{\tt in}  & {\em rho\+\_\+0} & A 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{\tt 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
 & {\em eos} & Equation of state structure\\
\hline
\mbox{\tt in,out}  & {\em dpa} & The change in the pressure anomaly\\
\hline
\mbox{\tt in,out}  & {\em intz\+\_\+dpa} & The integral through the thickness of the\\
\hline
\mbox{\tt in,out}  & {\em intx\+\_\+dpa} & The integral in x of the difference between\\
\hline
\mbox{\tt in,out}  & {\em inty\+\_\+dpa} & The integral in y of the difference between\\
\hline
\mbox{\tt in}  & {\em bathyt} & The depth of the bathymetry \mbox{[}Z $\sim$$>$ m\mbox{]}\\
\hline
\mbox{\tt in}  & {\em dz\+\_\+neglect} & A miniscule thickness change \mbox{[}Z $\sim$$>$ m\mbox{]}\\
\hline
\mbox{\tt in}  & {\em usemasswghtinterp} & If true, uses mass weighting to interpolate T/S for top and bottom integrals. \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
1257   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)}  :: hi\textcolor{comment}{ !< Ocean horizontal index structure}
1258   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
1259                         \textcolor{keywordtype}{intent(in)}  :: t\textcolor{comment}{   !< Potential temperature referenced to the surface [degC]}
1260   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
1261                         \textcolor{keywordtype}{intent(in)}  :: s\textcolor{comment}{   !< Salinity [ppt]}
1262   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
1263                         \textcolor{keywordtype}{intent(in)}  :: z\_t\textcolor{comment}{ !< Height at the top of the layer in depth units [Z ~> m]}
1264   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
1265                         \textcolor{keywordtype}{intent(in)}  :: z\_b\textcolor{comment}{ !< Height at the bottom of the layer [Z ~> m]}
1266   \textcolor{keywordtype}{real},                 \textcolor{keywordtype}{intent(in)}  :: rho\_ref\textcolor{comment}{ !< A mean density [R ~> kg m-3] or [kg m-3], that is}
1267 \textcolor{comment}{                                           !! subtracted out to reduce the magnitude of each of the}
1268 \textcolor{comment}{                                           !! integrals.}
1269   \textcolor{keywordtype}{real},                 \textcolor{keywordtype}{intent(in)}  :: rho\_0\textcolor{comment}{ !< A density [R ~> kg m-3] or [kg m-3], that is used}
1270 \textcolor{comment}{                                           !! to calculate the pressure (as p~=-z*rho\_0*G\_e)}
1271 \textcolor{comment}{                                           !! used in the equation of state.}
1272   \textcolor{keywordtype}{real},                 \textcolor{keywordtype}{intent(in)}  :: g\_e\textcolor{comment}{ !< The Earth's gravitational acceleration}
1273 \textcolor{comment}{                                           !! [L2 Z-1 T-2 ~> m s-2] or [m2 Z-1 s-2 ~> m s-2]}
1274   \textcolor{keywordtype}{type}(eos\_type),       \textcolor{keywordtype}{pointer}     :: eos\textcolor{comment}{ !< Equation of state structure}
1275   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
1276                       \textcolor{keywordtype}{intent(inout)} :: dpa\textcolor{comment}{ !< The change in the pressure anomaly}
1277 \textcolor{comment}{                                           !! across the layer [R L2 T-2 ~> Pa] or [Pa]}
1278   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
1279             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: intz\_dpa\textcolor{comment}{ !< The integral through the thickness of the}
1280 \textcolor{comment}{                                           !! layer of the pressure anomaly relative to the}
1281 \textcolor{comment}{                                           !! anomaly at the top of the layer [R L2 Z T-2 ~> Pa m]}
1282   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%IsdB:HI%IedB,HI%jsd:HI%jed)}, &
1283             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: intx\_dpa\textcolor{comment}{ !< The integral in x of the difference between}
1284 \textcolor{comment}{                                          !! the pressure anomaly at the top and bottom of the}
1285 \textcolor{comment}{                                          !! layer divided by the x grid spacing [R L2 T-2 ~> Pa]}
1286   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%JsdB:HI%JedB)}, &
1287             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: inty\_dpa\textcolor{comment}{ !< The integral in y of the difference between}
1288 \textcolor{comment}{                                          !! the pressure anomaly at the top and bottom of the}
1289 \textcolor{comment}{                                          !! layer divided by the y grid spacing [R L2 T-2 ~> Pa]}
1290   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
1291               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: bathyt\textcolor{comment}{ !< The depth of the bathymetry [Z ~> m]}
1292   \textcolor{keywordtype}{real},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: dz\_neglect\textcolor{comment}{ !< A miniscule thickness change [Z ~> m]}
1293   \textcolor{keywordtype}{logical},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: usemasswghtinterp\textcolor{comment}{ !< If true, uses mass weighting to}
1294 \textcolor{comment}{                                           !! interpolate T/S for top and bottom integrals.}
1295   \textcolor{comment}{! Local variables}
1296   \textcolor{keywordtype}{real} :: rho\_scale  \textcolor{comment}{! A multiplicative factor by which to scale density from kg m-3 to the}
1297                      \textcolor{comment}{! desired units [R m3 kg-1 ~> 1]}
1298   \textcolor{keywordtype}{real} :: pres\_scale \textcolor{comment}{! A multiplicative factor to convert pressure into Pa [Pa T2 R-1 L-2 ~> 1]}
1299 
1300   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
1301     \textcolor{stringliteral}{"int\_density\_dz called with an unassociated EOS\_type EOS."})
1302 
1303   \textcolor{comment}{! We should never reach this point with quadrature. EOS\_quadrature indicates that numerical}
1304   \textcolor{comment}{! integration be used instead of analytic. This is a safety check.}
1305   \textcolor{keywordflow}{if} (eos%EOS\_quadrature) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"EOS\_quadrature is set!"})
1306 
1307   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
1308     \textcolor{keywordflow}{case} (eos\_linear)
1309       rho\_scale = eos%kg\_m3\_to\_R
1310       \textcolor{keywordflow}{if} (rho\_scale /= 1.0) \textcolor{keywordflow}{then}
1311         \textcolor{keyword}{call }int\_density\_dz\_linear(t, s, z\_t, z\_b, rho\_ref, rho\_0, g\_e, hi, &
1312                          rho\_scale*eos%Rho\_T0\_S0, rho\_scale*eos%dRho\_dT, rho\_scale*eos%dRho\_dS, &
1313                          dpa, intz\_dpa, intx\_dpa, inty\_dpa, bathyt, dz\_neglect, usemasswghtinterp)
1314       \textcolor{keywordflow}{else}
1315         \textcolor{keyword}{call }int\_density\_dz\_linear(t, s, z\_t, z\_b, rho\_ref, rho\_0, g\_e, hi, &
1316                          eos%Rho\_T0\_S0, eos%dRho\_dT, eos%dRho\_dS, &
1317                          dpa, intz\_dpa, intx\_dpa, inty\_dpa, bathyt, dz\_neglect, usemasswghtinterp)
1318 \textcolor{keywordflow}{      endif}
1319     \textcolor{keywordflow}{case} (eos\_wright)
1320       rho\_scale = eos%kg\_m3\_to\_R
1321       pres\_scale = eos%RL2\_T2\_to\_Pa
1322       \textcolor{keywordflow}{if} ((rho\_scale /= 1.0) .or. (pres\_scale /= 1.0)) \textcolor{keywordflow}{then}
1323         \textcolor{keyword}{call }int\_density\_dz\_wright(t, s, z\_t, z\_b, rho\_ref, rho\_0, g\_e, hi, &
1324                                    dpa, intz\_dpa, intx\_dpa, inty\_dpa, bathyt, &
1325                                    dz\_neglect, usemasswghtinterp, rho\_scale, pres\_scale)
1326       \textcolor{keywordflow}{else}
1327         \textcolor{keyword}{call }int\_density\_dz\_wright(t, s, z\_t, z\_b, rho\_ref, rho\_0, g\_e, hi, &
1328                                    dpa, intz\_dpa, intx\_dpa, inty\_dpa, bathyt, &
1329                                    dz\_neglect, usemasswghtinterp)
1330 \textcolor{keywordflow}{      endif}
1331 \textcolor{keywordflow}{    case default}
1332       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"No analytic integration option is available with this EOS!"})
1333 \textcolor{keywordflow}{  end select}
1334 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_a09b6cb637246b8aa287ef7cdb482aaea}\label{namespacemom__eos_a09b6cb637246b8aa287ef7cdb482aaea}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!analytic\+\_\+int\+\_\+specific\+\_\+vol\+\_\+dp@{analytic\+\_\+int\+\_\+specific\+\_\+vol\+\_\+dp}}
\index{analytic\+\_\+int\+\_\+specific\+\_\+vol\+\_\+dp@{analytic\+\_\+int\+\_\+specific\+\_\+vol\+\_\+dp}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{analytic\+\_\+int\+\_\+specific\+\_\+vol\+\_\+dp()}{analytic\_int\_specific\_vol\_dp()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+eos\+::analytic\+\_\+int\+\_\+specific\+\_\+vol\+\_\+dp (\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)}]{alpha\+\_\+ref,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in)}]{HI,  }\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS,  }\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\+\_\+tiny,  }\item[{logical, intent(in), optional}]{use\+Mass\+Wght\+Interp }\end{DoxyParamCaption})}



Calls the appropriate subroutine to calculate 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{\tt in}  & {\em hi} & The horizontal index structure\\
\hline
\mbox{\tt in}  & {\em t} & Potential temperature referenced to the surface \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em s} & Salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt 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{\tt in}  & {\em p\+\_\+b} & Pressure at the bottom of the layer \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]} or \mbox{[}Pa\mbox{]}\\
\hline
\mbox{\tt in}  & {\em alpha\+\_\+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 alpha\+\_\+ref, but this reduces the effects of roundoff.\\
\hline
 & {\em eos} & Equation of state structure\\
\hline
\mbox{\tt in,out}  & {\em dza} & The change in the geopotential anomaly across\\
\hline
\mbox{\tt in,out}  & {\em intp\+\_\+dza} & The integral in pressure through the layer of the\\
\hline
\mbox{\tt in,out}  & {\em intx\+\_\+dza} & The integral in x of the difference between the\\
\hline
\mbox{\tt in,out}  & {\em inty\+\_\+dza} & The integral in y of the difference between the\\
\hline
\mbox{\tt in}  & {\em halo\+\_\+size} & The width of halo points on which to calculate dza.\\
\hline
\mbox{\tt in}  & {\em bathyp} & The pressure at the bathymetry \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]} or \mbox{[}Pa\mbox{]}\\
\hline
\mbox{\tt in}  & {\em dp\+\_\+tiny} & 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{\tt in}  & {\em usemasswghtinterp} & If true, uses mass weighting to interpolate T/S for top and bottom integrals. \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
1188   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)}  :: hi\textcolor{comment}{  !< The horizontal index structure}
1189   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
1190                         \textcolor{keywordtype}{intent(in)}  :: t\textcolor{comment}{   !< Potential temperature referenced to the surface [degC]}
1191   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
1192                         \textcolor{keywordtype}{intent(in)}  :: s\textcolor{comment}{   !< Salinity [ppt]}
1193   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
1194                         \textcolor{keywordtype}{intent(in)}  :: p\_t\textcolor{comment}{ !< Pressure at the top of the layer [R L2 T-2 ~> Pa] or [Pa]}
1195   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
1196                         \textcolor{keywordtype}{intent(in)}  :: p\_b\textcolor{comment}{ !< Pressure at the bottom of the layer [R L2 T-2 ~> Pa] or [Pa]}
1197   \textcolor{keywordtype}{real},                 \textcolor{keywordtype}{intent(in)}  :: alpha\_ref\textcolor{comment}{ !< A mean specific volume that is subtracted out}
1198 \textcolor{comment}{                            !! to reduce the magnitude of each of the integrals [R-1 ~> m3 kg-1]}
1199 \textcolor{comment}{                            !! The calculation is mathematically identical with different values of}
1200 \textcolor{comment}{                            !! alpha\_ref, but this reduces the effects of roundoff.}
1201   \textcolor{keywordtype}{type}(eos\_type),       \textcolor{keywordtype}{pointer}     :: eos\textcolor{comment}{ !< Equation of state structure}
1202   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
1203                         \textcolor{keywordtype}{intent(inout)} :: dza\textcolor{comment}{ !< The change in the geopotential anomaly across}
1204 \textcolor{comment}{                            !! the layer [L2 T-2 ~> m2 s-2] or [m2 s-2]}
1205   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
1206               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: intp\_dza\textcolor{comment}{ !< The integral in pressure through the layer of the}
1207 \textcolor{comment}{                            !! geopotential anomaly relative to the anomaly at the bottom of the}
1208 \textcolor{comment}{                            !! layer [R L4 T-4 ~> Pa m2 s-2] or [Pa m2 s-2]}
1209   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%IsdB:HI%IedB,HI%jsd:HI%jed)}, &
1210               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: intx\_dza\textcolor{comment}{ !< The integral in x of the difference between the}
1211 \textcolor{comment}{                            !! geopotential anomaly at the top and bottom of the layer divided by}
1212 \textcolor{comment}{                            !! the x grid spacing [L2 T-2 ~> m2 s-2] or [m2 s-2]}
1213   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%JsdB:HI%JedB)}, &
1214               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: inty\_dza\textcolor{comment}{ !< The integral in y of the difference between the}
1215 \textcolor{comment}{                            !! geopotential anomaly at the top and bottom of the layer divided by}
1216 \textcolor{comment}{                            !! the y grid spacing [L2 T-2 ~> m2 s-2] or [m2 s-2]}
1217   \textcolor{keywordtype}{integer},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: halo\_size\textcolor{comment}{ !< The width of halo points on which to calculate dza.}
1218   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
1219               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: bathyp\textcolor{comment}{  !< The pressure at the bathymetry [R L2 T-2 ~> Pa] or [Pa]}
1220   \textcolor{keywordtype}{real},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: dp\_tiny\textcolor{comment}{ !< A miniscule pressure change with}
1221 \textcolor{comment}{                            !! the same units as p\_t [R L2 T-2 ~> Pa] or [Pa]}
1222   \textcolor{keywordtype}{logical},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: usemasswghtinterp\textcolor{comment}{ !< If true, uses mass weighting}
1223 \textcolor{comment}{                            !! to interpolate T/S for top and bottom integrals.}
1224   \textcolor{comment}{! Local variables}
1225   \textcolor{keywordtype}{real} :: pres\_scale    \textcolor{comment}{! A unit conversion factor from the rescaled units of pressure to Pa [Pa T2 R-1 L-2
       ~> 1]}
1226   \textcolor{keywordtype}{real} :: sv\_scale      \textcolor{comment}{! A multiplicative factor by which to scale specific}
1227                         \textcolor{comment}{! volume from m3 kg-1 to the desired units [kg m-3 R-1 ~> 1]}
1228 
1229   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
1230     \textcolor{stringliteral}{"int\_specific\_vol\_dp called with an unassociated EOS\_type EOS."})
1231 
1232   \textcolor{comment}{! We should never reach this point with quadrature. EOS\_quadrature indicates that numerical}
1233   \textcolor{comment}{! integration be used instead of analytic. This is a safety check.}
1234   \textcolor{keywordflow}{if} (eos%EOS\_quadrature) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"EOS\_quadrature is set!"})
1235 
1236   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
1237     \textcolor{keywordflow}{case} (eos\_linear)
1238       \textcolor{keyword}{call }int\_spec\_vol\_dp\_linear(t, s, p\_t, p\_b, alpha\_ref, hi, eos%kg\_m3\_to\_R*eos%Rho\_T0\_S0, &
1239                                 eos%kg\_m3\_to\_R*eos%dRho\_dT, eos%kg\_m3\_to\_R*eos%dRho\_dS, dza, &
1240                                 intp\_dza, intx\_dza, inty\_dza, halo\_size, &
1241                                 bathyp, dp\_tiny, usemasswghtinterp)
1242     \textcolor{keywordflow}{case} (eos\_wright)
1243       \textcolor{keyword}{call }int\_spec\_vol\_dp\_wright(t, s, p\_t, p\_b, alpha\_ref, hi, dza, intp\_dza, intx\_dza, &
1244                                   inty\_dza, halo\_size, bathyp, dp\_tiny, usemasswghtinterp, &
1245                                   sv\_scale=eos%R\_to\_kg\_m3, pres\_scale=eos%RL2\_T2\_to\_Pa)
1246 \textcolor{keywordflow}{    case default}
1247       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"No analytic integration option is available with this EOS!"})
1248 \textcolor{keywordflow}{  end select}
1249 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_afbb6a11d3b826308ddb1ffe0c5cf32d1}\label{namespacemom__eos_afbb6a11d3b826308ddb1ffe0c5cf32d1}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!calc\+\_\+spec\+\_\+vol\+\_\+1d@{calc\+\_\+spec\+\_\+vol\+\_\+1d}}
\index{calc\+\_\+spec\+\_\+vol\+\_\+1d@{calc\+\_\+spec\+\_\+vol\+\_\+1d}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{calc\+\_\+spec\+\_\+vol\+\_\+1d()}{calc\_spec\_vol\_1d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calc\+\_\+spec\+\_\+vol\+\_\+1d (\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[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS,  }\item[{integer, dimension(2), intent(in), optional}]{dom,  }\item[{real, intent(in), optional}]{spv\+\_\+ref,  }\item[{real, intent(in), optional}]{scale }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calls the appropriate subroutine to calculate the specific volume of sea water for 1-\/D array inputs, potentially limiting the domain of indices that are worked on. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em t} & Potential temperature referenced to the surface \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em s} & Salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em pressure} & Pressure \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em specvol} & In situ specific volume \mbox{[}R-\/1 $\sim$$>$ m3 kg-\/1\mbox{]}\\
\hline
 & {\em eos} & Equation of state structure\\
\hline
\mbox{\tt in}  & {\em dom} & The domain of indices to work on, taking into account that arrays start at 1.\\
\hline
\mbox{\tt in}  & {\em spv\+\_\+ref} & A reference specific volume \mbox{[}R-\/1 $\sim$$>$ m3 kg-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em scale} & A multiplicative factor by which to scale output specific volume in combination with scaling given by US \mbox{[}various\mbox{]} \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
571   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: t\textcolor{comment}{        !< Potential temperature referenced to the surface
       [degC]}
572   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: s\textcolor{comment}{        !< Salinity [ppt]}
573   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< Pressure [R L2 T-2 ~> Pa]}
574   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(inout)} :: specvol\textcolor{comment}{  !< In situ specific volume [R-1 ~> m3 kg-1]}
575   \textcolor{keywordtype}{type}(eos\_type),        \textcolor{keywordtype}{pointer}       :: eos\textcolor{comment}{      !< Equation of state structure}
576   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: dom\textcolor{comment}{   !< The domain of indices to work on, taking}
577 \textcolor{comment}{                                                       !! into account that arrays start at 1.}
578   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: spv\_ref\textcolor{comment}{ !< A reference specific volume [R-1 ~> m3 kg-1]}
579   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{ !< A multiplicative factor by which to scale}
580 \textcolor{comment}{                                                       !! output specific volume in combination with}
581 \textcolor{comment}{                                                       !! scaling given by US [various]}
582   \textcolor{comment}{! Local variables}
583   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(specvol))} :: pres  \textcolor{comment}{! Pressure converted to [Pa]}
584   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
585   \textcolor{keywordtype}{real} :: spv\_unscale \textcolor{comment}{! A factor to convert specific volume from R-1 to m3 kg-1 [m3 kg-1 R ~> 1]}
586   \textcolor{keywordtype}{real} :: spv\_scale \textcolor{comment}{! A factor to convert specific volume from m3 kg-1 to the desired units [kg m-3 R-1 ~>
       1]}
587   \textcolor{keywordtype}{real} :: spv\_reference \textcolor{comment}{! spv\_ref converted to [m3 kg-1]}
588   \textcolor{keywordtype}{integer} :: i, is, ie, npts
589 
590   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
591     \textcolor{stringliteral}{"calc\_spec\_vol\_1d called with an unassociated EOS\_type EOS."})
592 
593   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dom)) \textcolor{keywordflow}{then}
594     is = dom(1) ; ie = dom(2) ; npts = 1 + ie - is
595   \textcolor{keywordflow}{else}
596     is = 1 ; ie = \textcolor{keyword}{size}(specvol) ; npts = 1 + ie - is
597 \textcolor{keywordflow}{  endif}
598 
599   p\_scale = eos%RL2\_T2\_to\_Pa
600   spv\_unscale = eos%kg\_m3\_to\_R
601 
602   \textcolor{keywordflow}{if} ((p\_scale == 1.0) .and. (spv\_unscale == 1.0)) \textcolor{keywordflow}{then}
603     \textcolor{keyword}{call }calculate\_spec\_vol\_array(t, s, pressure, specvol, is, npts, eos, spv\_ref)
604   \textcolor{keywordflow}{elseif} (\textcolor{keyword}{present}(spv\_ref)) \textcolor{keywordflow}{then} \textcolor{comment}{! This is the same as above, but with some extra work to rescale
       variables.}
605     \textcolor{keywordflow}{do} i=is,ie ; pres(i) = p\_scale * pressure(i) ;\textcolor{keywordflow}{ enddo}
606     spv\_reference = spv\_unscale*spv\_ref
607     \textcolor{keyword}{call }calculate\_spec\_vol\_array(t, s, pres, specvol, is, npts, eos, spv\_reference)
608   \textcolor{keywordflow}{else}  \textcolor{comment}{! There is rescaling of variables, but spv\_ref is not present. Passing a 0 value of spv\_ref}
609         \textcolor{comment}{! changes answers at roundoff for some equations of state, like Wright and UNESCO.}
610     \textcolor{keywordflow}{do} i=is,ie ; pres(i) = p\_scale * pressure(i) ;\textcolor{keywordflow}{ enddo}
611     \textcolor{keyword}{call }calculate\_spec\_vol\_array(t, s, pres, specvol, is, npts, eos)
612 \textcolor{keywordflow}{  endif}
613 
614   spv\_scale = eos%R\_to\_kg\_m3
615   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) spv\_scale = spv\_scale * scale
616   \textcolor{keywordflow}{if} (spv\_scale /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} i=is,ie
617     specvol(i) = spv\_scale * specvol(i)
618 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif}
619 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_a640c3b2292afd3266caa11243549bbf0}\label{namespacemom__eos_a640c3b2292afd3266caa11243549bbf0}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!calc\+\_\+spec\+\_\+vol\+\_\+derivs\+\_\+1d@{calc\+\_\+spec\+\_\+vol\+\_\+derivs\+\_\+1d}}
\index{calc\+\_\+spec\+\_\+vol\+\_\+derivs\+\_\+1d@{calc\+\_\+spec\+\_\+vol\+\_\+derivs\+\_\+1d}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{calc\+\_\+spec\+\_\+vol\+\_\+derivs\+\_\+1d()}{calc\_spec\_vol\_derivs\_1d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calc\+\_\+spec\+\_\+vol\+\_\+derivs\+\_\+1d (\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[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS,  }\item[{integer, dimension(2), intent(in), optional}]{dom,  }\item[{real, intent(in), optional}]{scale }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calls the appropriate subroutine to calculate specific volume derivatives for 1-\/d array inputs, potentially limiting the domain of indices that are worked on. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em t} & Potential temperature referenced to the surface \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em s} & Salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em pressure} & Pressure \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em dsv\+\_\+dt} & The partial derivative of specific volume with potential temperature \mbox{[}R-\/1 deg\+C-\/1 $\sim$$>$ m3 kg-\/1 deg\+C-\/1\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em dsv\+\_\+ds} & The partial derivative of specific volume with salinity \mbox{[}R-\/1 ppt-\/1 $\sim$$>$ m3 kg-\/1 ppt-\/1\mbox{]}\\
\hline
 & {\em eos} & Equation of state structure\\
\hline
\mbox{\tt in}  & {\em dom} & The domain of indices to work on, taking into account that arrays start at 1.\\
\hline
\mbox{\tt in}  & {\em scale} & A multiplicative factor by which to scale specific volume in combination with scaling given by US \mbox{[}various\mbox{]} \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
1040   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: t\textcolor{comment}{        !< Potential temperature referenced to the surface [degC]}
1041   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: s\textcolor{comment}{        !< Salinity [ppt]}
1042   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< Pressure [R L2 T-2 ~> Pa]}
1043   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: dsv\_dt\textcolor{comment}{   !< The partial derivative of specific volume with potential}
1044 \textcolor{comment}{                                                !! temperature [R-1 degC-1 ~> m3 kg-1 degC-1]}
1045   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: dsv\_ds\textcolor{comment}{   !< The partial derivative of specific volume with salinity}
1046 \textcolor{comment}{                                                !! [R-1 ppt-1 ~> m3 kg-1 ppt-1]}
1047   \textcolor{keywordtype}{type}(eos\_type),     \textcolor{keywordtype}{pointer}       :: eos\textcolor{comment}{      !< Equation of state structure}
1048   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: dom\textcolor{comment}{   !< The domain of indices to work on, taking}
1049 \textcolor{comment}{                                                       !! into account that arrays start at 1.}
1050   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{ !< A multiplicative factor by which to scale
       specific}
1051 \textcolor{comment}{                                                !! volume in combination with scaling given by US [various]}
1052 
1053   \textcolor{comment}{! Local variables}
1054   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(dSV\_dT))} :: press   \textcolor{comment}{! Pressure converted to [Pa]}
1055   \textcolor{keywordtype}{real} :: spv\_scale \textcolor{comment}{! A factor to convert specific volume from m3 kg-1 to the desired units [kg R-1 m-3 ~>
       1]}
1056   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
1057   \textcolor{keywordtype}{integer} :: i, is, ie, npts
1058 
1059   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
1060     \textcolor{stringliteral}{"calculate\_spec\_vol\_derivs\_1d called with an unassociated EOS\_type EOS."})
1061 
1062   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dom)) \textcolor{keywordflow}{then}
1063     is = dom(1) ; ie = dom(2) ; npts = 1 + ie - is
1064   \textcolor{keywordflow}{else}
1065     is = 1 ; ie = \textcolor{keyword}{size}(dsv\_dt) ; npts = 1 + ie - is
1066 \textcolor{keywordflow}{  endif}
1067   p\_scale = eos%RL2\_T2\_to\_Pa
1068 
1069   \textcolor{keywordflow}{if} (p\_scale == 1.0) \textcolor{keywordflow}{then}
1070     \textcolor{keyword}{call }calculate\_spec\_vol\_derivs\_array(t, s, pressure, dsv\_dt, dsv\_ds, is, npts, eos)
1071   \textcolor{keywordflow}{else}
1072     \textcolor{keywordflow}{do} i=is,ie ; press(i) = p\_scale * pressure(i) ;\textcolor{keywordflow}{ enddo}
1073     \textcolor{keyword}{call }calculate\_spec\_vol\_derivs\_array(t, s, press, dsv\_dt, dsv\_ds, is, npts, eos)
1074 \textcolor{keywordflow}{  endif}
1075 
1076   spv\_scale = eos%R\_to\_kg\_m3
1077   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) spv\_scale = spv\_scale * scale
1078   \textcolor{keywordflow}{if} (spv\_scale /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} i=is,ie
1079     dsv\_dt(i) = spv\_scale * dsv\_dt(i)
1080     dsv\_ds(i) = spv\_scale * dsv\_ds(i)
1081 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif}
1082 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_a246056e557a08ce1c697256cd718d99a}\label{namespacemom__eos_a246056e557a08ce1c697256cd718d99a}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!calc\+\_\+spec\+\_\+vol\+\_\+scalar@{calc\+\_\+spec\+\_\+vol\+\_\+scalar}}
\index{calc\+\_\+spec\+\_\+vol\+\_\+scalar@{calc\+\_\+spec\+\_\+vol\+\_\+scalar}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{calc\+\_\+spec\+\_\+vol\+\_\+scalar()}{calc\_spec\_vol\_scalar()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calc\+\_\+spec\+\_\+vol\+\_\+scalar (\begin{DoxyParamCaption}\item[{real, intent(in)}]{T,  }\item[{real, intent(in)}]{S,  }\item[{real, intent(in)}]{pressure,  }\item[{real, intent(out)}]{specvol,  }\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS,  }\item[{real, intent(in), optional}]{spv\+\_\+ref,  }\item[{real, intent(in), optional}]{scale }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calls the appropriate subroutine to calculate specific volume of sea water for scalar inputs. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em t} & Potential temperature referenced to the surface \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em s} & Salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em pressure} & Pressure \mbox{[}Pa\mbox{]} or \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}\\
\hline
\mbox{\tt out}  & {\em specvol} & In situ? specific volume \mbox{[}m3 kg-\/1\mbox{]} or \mbox{[}R-\/1 $\sim$$>$ m3 kg-\/1\mbox{]}\\
\hline
 & {\em eos} & Equation of state structure\\
\hline
\mbox{\tt in}  & {\em spv\+\_\+ref} & A reference specific volume \mbox{[}m3 kg-\/1\mbox{]} or \mbox{[}R-\/1 m3 kg-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em scale} & A multiplicative factor by which to scale specific volume in combination with scaling given by US \mbox{[}various\mbox{]} \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
533   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: t\textcolor{comment}{        !< Potential temperature referenced to the surface [degC]}
534   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: s\textcolor{comment}{        !< Salinity [ppt]}
535   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: pressure\textcolor{comment}{ !< Pressure [Pa] or [R L2 T-2 ~> Pa]}
536   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(out)} :: specvol\textcolor{comment}{  !< In situ? specific volume [m3 kg-1] or [R-1 ~> m3 kg-1]}
537   \textcolor{keywordtype}{type}(eos\_type), \textcolor{keywordtype}{pointer}     :: eos\textcolor{comment}{      !< Equation of state structure}
538   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: spv\_ref\textcolor{comment}{  !< A reference specific volume [m3 kg-1] or [R-1 m3 kg-1]}
539   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: scale\textcolor{comment}{    !< A multiplicative factor by which to scale specific}
540 \textcolor{comment}{                                          !! volume in combination with scaling given by US [various]}
541 
542   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(1)} :: ta, sa, pres, spv  \textcolor{comment}{! Rescaled single element array versions of the arguments.}
543   \textcolor{keywordtype}{real} :: spv\_reference \textcolor{comment}{! spv\_ref converted to [m3 kg-1]}
544   \textcolor{keywordtype}{real} :: spv\_scale \textcolor{comment}{! A factor to convert specific volume from m3 kg-1 to the desired units [kg R-1 m-3 ~>
       1]}
545 
546   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
547     \textcolor{stringliteral}{"calc\_spec\_vol\_scalar called with an unassociated EOS\_type EOS."})
548 
549   pres(1) = eos%RL2\_T2\_to\_Pa*pressure
550   ta(1) = t ; sa(1) = s
551 
552   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(spv\_ref)) \textcolor{keywordflow}{then}
553     spv\_reference = eos%kg\_m3\_to\_R*spv\_ref
554     \textcolor{keyword}{call }calculate\_spec\_vol\_array(ta, sa, pres, spv, 1, 1, eos, spv\_reference)
555   \textcolor{keywordflow}{else}
556     \textcolor{keyword}{call }calculate\_spec\_vol\_array(ta, sa, pres, spv, 1, 1, eos)
557 \textcolor{keywordflow}{  endif}
558   specvol = spv(1)
559 
560   spv\_scale = eos%R\_to\_kg\_m3
561   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) spv\_scale = spv\_scale * scale
562   \textcolor{keywordflow}{if} (spv\_scale /= 1.0) \textcolor{keywordflow}{then}
563     specvol = spv\_scale * specvol
564 \textcolor{keywordflow}{  endif}
565 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_a3296609bd60bfe7ed2c5eac1170d07a3}\label{namespacemom__eos_a3296609bd60bfe7ed2c5eac1170d07a3}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!calculate\+\_\+compress\+\_\+array@{calculate\+\_\+compress\+\_\+array}}
\index{calculate\+\_\+compress\+\_\+array@{calculate\+\_\+compress\+\_\+array}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{calculate\+\_\+compress\+\_\+array()}{calculate\_compress\_array()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calculate\+\_\+compress\+\_\+array (\begin{DoxyParamCaption}\item[{real, dimension(\+:), intent(in)}]{T,  }\item[{real, dimension(\+:), intent(in)}]{S,  }\item[{real, dimension(\+:), intent(in)}]{press,  }\item[{real, dimension(\+:), intent(inout)}]{rho,  }\item[{real, dimension(\+:), intent(inout)}]{drho\+\_\+dp,  }\item[{integer, intent(in)}]{start,  }\item[{integer, intent(in)}]{npts,  }\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calls the appropriate subroutine to calculate the density and compressibility for 1-\/D array inputs. If US is present, the units of the inputs and outputs are rescaled. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em t} & Potential temperature referenced to the surface \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em s} & Salinity \mbox{[}P\+SU\mbox{]}\\
\hline
\mbox{\tt in}  & {\em press} & Pressure \mbox{[}Pa\mbox{]} or \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em rho} & In situ density \mbox{[}kg m-\/3\mbox{]} or \mbox{[}R $\sim$$>$ kg m-\/3\mbox{]}\\
\hline
\mbox{\tt 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{]} or \mbox{[}T2 L-\/2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em start} & Starting index within the array\\
\hline
\mbox{\tt in}  & {\em npts} & The number of values to calculate\\
\hline
 & {\em eos} & Equation of state structure \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
1089   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}  :: t\textcolor{comment}{        !< Potential temperature referenced to the surface [degC]}
1090   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}  :: s\textcolor{comment}{        !< Salinity [PSU]}
1091   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}  :: press\textcolor{comment}{    !< Pressure [Pa] or [R L2 T-2 ~> Pa]}
1092   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: rho\textcolor{comment}{      !< In situ density [kg m-3] or [R ~> kg m-3]}
1093   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: drho\_dp\textcolor{comment}{  !< The partial derivative of density with pressure}
1094 \textcolor{comment}{                                                !! (also the inverse of the square of sound speed)}
1095 \textcolor{comment}{                                                !! [s2 m-2] or [T2 L-2]}
1096   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}  :: start\textcolor{comment}{    !< Starting index within the array}
1097   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}  :: npts\textcolor{comment}{     !< The number of values to calculate}
1098   \textcolor{keywordtype}{type}(eos\_type),     \textcolor{keywordtype}{pointer}     :: eos\textcolor{comment}{      !< Equation of state structure}
1099 
1100   \textcolor{comment}{! Local variables}
1101   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(press))} :: pressure  \textcolor{comment}{! Pressure converted to [Pa]}
1102   \textcolor{keywordtype}{integer} :: i, is, ie
1103 
1104   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
1105     \textcolor{stringliteral}{"calculate\_compress called with an unassociated EOS\_type EOS."})
1106 
1107   is = start ; ie = is + npts - 1
1108   \textcolor{keywordflow}{do} i=is,ie ; pressure(i) = eos%RL2\_T2\_to\_Pa * press(i) ;\textcolor{keywordflow}{ enddo}
1109 
1110   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
1111     \textcolor{keywordflow}{case} (eos\_linear)
1112       \textcolor{keyword}{call }calculate\_compress\_linear(t, s, pressure, rho, drho\_dp, start, npts, &
1113                                      eos%Rho\_T0\_S0, eos%dRho\_dT, eos%dRho\_dS)
1114     \textcolor{keywordflow}{case} (eos\_unesco)
1115       \textcolor{keyword}{call }calculate\_compress\_unesco(t, s, pressure, rho, drho\_dp, start, npts)
1116     \textcolor{keywordflow}{case} (eos\_wright)
1117       \textcolor{keyword}{call }calculate\_compress\_wright(t, s, pressure, rho, drho\_dp, start, npts)
1118     \textcolor{keywordflow}{case} (eos\_teos10)
1119       \textcolor{keyword}{call }calculate\_compress\_teos10(t, s, pressure, rho, drho\_dp, start, npts)
1120     \textcolor{keywordflow}{case} (eos\_nemo)
1121       \textcolor{keyword}{call }calculate\_compress\_nemo(t, s, pressure, rho, drho\_dp, start, npts)
1122 \textcolor{keywordflow}{    case default}
1123       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_compress: EOS%form\_of\_EOS is not valid."})
1124 \textcolor{keywordflow}{  end select}
1125 
1126   \textcolor{keywordflow}{if} (eos%kg\_m3\_to\_R /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} i=is,ie
1127     rho(i) = eos%kg\_m3\_to\_R * rho(i)
1128 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif}
1129   \textcolor{keywordflow}{if} (eos%L\_T\_to\_m\_s /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} i=is,ie
1130     drho\_dp(i) = eos%L\_T\_to\_m\_s**2 * drho\_dp(i)
1131 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif}
1132 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_ad0986d800c26414dbd19d2b3a541e613}\label{namespacemom__eos_ad0986d800c26414dbd19d2b3a541e613}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!calculate\+\_\+compress\+\_\+scalar@{calculate\+\_\+compress\+\_\+scalar}}
\index{calculate\+\_\+compress\+\_\+scalar@{calculate\+\_\+compress\+\_\+scalar}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{calculate\+\_\+compress\+\_\+scalar()}{calculate\_compress\_scalar()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calculate\+\_\+compress\+\_\+scalar (\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(out)}]{drho\+\_\+dp,  }\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calculate density and compressibility for a scalar. This just promotes the scalar to an array with a singleton dimension and calls calculate\+\_\+compress\+\_\+array. If US is present, the units of the inputs and outputs are rescaled. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em t} & Potential temperature referenced to the surface \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em s} & Salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em pressure} & Pressure \mbox{[}Pa\mbox{]} or \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}\\
\hline
\mbox{\tt out}  & {\em rho} & In situ density \mbox{[}kg m-\/3\mbox{]} or \mbox{[}R $\sim$$>$ kg m-\/3\mbox{]}\\
\hline
\mbox{\tt 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{]} or \mbox{[}T2 L-\/2\mbox{]}\\
\hline
 & {\em eos} & Equation of state structure \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
1139   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}        :: t\textcolor{comment}{        !< Potential temperature referenced to the surface [degC]}
1140   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}        :: s\textcolor{comment}{        !< Salinity [ppt]}
1141   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}        :: pressure\textcolor{comment}{ !< Pressure [Pa] or [R L2 T-2 ~> Pa]}
1142   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)}       :: rho\textcolor{comment}{      !< In situ density [kg m-3] or [R ~> kg m-3]}
1143   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)}       :: drho\_dp\textcolor{comment}{  !< The partial derivative of density with pressure (also the}
1144 \textcolor{comment}{                                      !! inverse of the square of sound speed) [s2 m-2] or [T2 L-2]}
1145   \textcolor{keywordtype}{type}(eos\_type), \textcolor{keywordtype}{pointer} :: eos\textcolor{comment}{      !< Equation of state structure}
1146 
1147   \textcolor{comment}{! Local variables}
1148   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(1)} :: ta, sa, pa, rhoa, drho\_dpa
1149 
1150   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
1151     \textcolor{stringliteral}{"calculate\_compress called with an unassociated EOS\_type EOS."})
1152   ta(1) = t ; sa(1) = s; pa(1) = pressure
1153 
1154   \textcolor{keyword}{call }calculate\_compress\_array(ta, sa, pa, rhoa, drho\_dpa, 1, 1, eos)
1155   rho = rhoa(1) ; drho\_dp = drho\_dpa(1)
1156 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_a2e78ade3bcba817406479cbbe3941a5f}\label{namespacemom__eos_a2e78ade3bcba817406479cbbe3941a5f}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!calculate\+\_\+density\+\_\+1d@{calculate\+\_\+density\+\_\+1d}}
\index{calculate\+\_\+density\+\_\+1d@{calculate\+\_\+density\+\_\+1d}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{calculate\+\_\+density\+\_\+1d()}{calculate\_density\_1d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calculate\+\_\+density\+\_\+1d (\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[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS,  }\item[{integer, dimension(2), intent(in), optional}]{dom,  }\item[{real, intent(in), optional}]{rho\+\_\+ref,  }\item[{real, intent(in), optional}]{scale }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calls the appropriate subroutine to calculate the density of sea water for 1-\/D array inputs, potentially limiting the domain of indices that are worked on. If rho\+\_\+ref is present, the anomaly with respect to rho\+\_\+ref is returned. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em t} & Potential temperature referenced to the surface \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em s} & Salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em pressure} & Pressure \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em rho} & Density (in-\/situ if pressure is local) \mbox{[}R $\sim$$>$ kg m-\/3\mbox{]}\\
\hline
 & {\em eos} & Equation of state structure\\
\hline
\mbox{\tt in}  & {\em dom} & The domain of indices to work on, taking into account that arrays start at 1.\\
\hline
\mbox{\tt in}  & {\em rho\+\_\+ref} & A reference density \mbox{[}kg m-\/3\mbox{]}\\
\hline
\mbox{\tt in}  & {\em scale} & A multiplicative factor by which to scale density in combination with scaling given by US \mbox{[}various\mbox{]} \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
360   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: t\textcolor{comment}{        !< Potential temperature referenced to the surface
       [degC]}
361   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: s\textcolor{comment}{        !< Salinity [ppt]}
362   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< Pressure [R L2 T-2 ~> Pa]}
363   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(inout)} :: rho\textcolor{comment}{      !< Density (in-situ if pressure is local) [R ~> kg m-3]}
364   \textcolor{keywordtype}{type}(eos\_type),        \textcolor{keywordtype}{pointer}       :: eos\textcolor{comment}{      !< Equation of state structure}
365   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: dom\textcolor{comment}{   !< The domain of indices to work on, taking}
366 \textcolor{comment}{                                                       !! into account that arrays start at 1.}
367   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: rho\_ref\textcolor{comment}{ !< A reference density [kg m-3]}
368   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{ !< A multiplicative factor by which to scale density}
369 \textcolor{comment}{                                                   !! in combination with scaling given by US [various]}
370   \textcolor{comment}{! Local variables}
371   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
372   \textcolor{keywordtype}{real} :: rho\_scale \textcolor{comment}{! A factor to convert density from kg m-3 to the desired units [R m3 kg-1 ~> 1]}
373   \textcolor{keywordtype}{real} :: rho\_unscale \textcolor{comment}{! A factor to convert density from R to kg m-3 [kg m-3 R-1 ~> 1]}
374   \textcolor{keywordtype}{real} :: rho\_reference \textcolor{comment}{! rho\_ref converted to [kg m-3]}
375   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(rho))} :: pres  \textcolor{comment}{! Pressure converted to [Pa]}
376   \textcolor{keywordtype}{integer} :: i, is, ie, npts
377 
378   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
379     \textcolor{stringliteral}{"calculate\_density\_1d called with an unassociated EOS\_type EOS."})
380 
381   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dom)) \textcolor{keywordflow}{then}
382     is = dom(1) ; ie = dom(2) ; npts = 1 + ie - is
383   \textcolor{keywordflow}{else}
384     is = 1 ; ie = \textcolor{keyword}{size}(rho) ; npts = 1 + ie - is
385 \textcolor{keywordflow}{  endif}
386 
387   p\_scale = eos%RL2\_T2\_to\_Pa
388   rho\_unscale = eos%R\_to\_kg\_m3
389 
390   \textcolor{keywordflow}{if} ((p\_scale == 1.0) .and. (rho\_unscale == 1.0)) \textcolor{keywordflow}{then}
391     \textcolor{keyword}{call }calculate\_density\_array(t, s, pressure, rho, is, npts, eos, rho\_ref=rho\_ref)
392   \textcolor{keywordflow}{elseif} (\textcolor{keyword}{present}(rho\_ref)) \textcolor{keywordflow}{then} \textcolor{comment}{! This is the same as above, but with some extra work to rescale
       variables.}
393     \textcolor{keywordflow}{do} i=is,ie ; pres(i) = p\_scale * pressure(i) ;\textcolor{keywordflow}{ enddo}
394     rho\_reference = rho\_unscale*rho\_ref
395     \textcolor{keyword}{call }calculate\_density\_array(t, s, pres, rho, is, npts, eos, rho\_ref=rho\_reference)
396   \textcolor{keywordflow}{else}  \textcolor{comment}{! There is rescaling of variables, but rho\_ref is not present. Passing a 0 value of rho\_ref}
397         \textcolor{comment}{! changes answers at roundoff for some equations of state, like Wright and UNESCO.}
398     \textcolor{keywordflow}{do} i=is,ie ; pres(i) = p\_scale * pressure(i) ;\textcolor{keywordflow}{ enddo}
399     \textcolor{keyword}{call }calculate\_density\_array(t, s, pres, rho, is, npts, eos)
400 \textcolor{keywordflow}{  endif}
401 
402   rho\_scale = eos%kg\_m3\_to\_R
403   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) rho\_scale = rho\_scale * scale
404   \textcolor{keywordflow}{if} (rho\_scale /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} i=is,ie
405     rho(i) = rho\_scale * rho(i)
406 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif}
407 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_a3be8289c391088bdd3af78d272b92521}\label{namespacemom__eos_a3be8289c391088bdd3af78d272b92521}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!calculate\+\_\+density\+\_\+array@{calculate\+\_\+density\+\_\+array}}
\index{calculate\+\_\+density\+\_\+array@{calculate\+\_\+density\+\_\+array}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{calculate\+\_\+density\+\_\+array()}{calculate\_density\_array()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calculate\+\_\+density\+\_\+array (\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[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS,  }\item[{real, intent(in), optional}]{rho\+\_\+ref,  }\item[{real, intent(in), optional}]{scale }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calls the appropriate subroutine to calculate the density of sea water for 1-\/D array inputs. If rho\+\_\+ref is present, the anomaly with respect to rho\+\_\+ref is returned. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em t} & Potential temperature referenced to the surface \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em s} & Salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em pressure} & Pressure \mbox{[}Pa\mbox{]} or \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em rho} & Density (in-\/situ if pressure is local) \mbox{[}kg m-\/3\mbox{]} or \mbox{[}R $\sim$$>$ kg m-\/3\mbox{]}\\
\hline
\mbox{\tt in}  & {\em start} & Start index for computation\\
\hline
\mbox{\tt in}  & {\em npts} & Number of point to compute\\
\hline
 & {\em eos} & Equation of state structure\\
\hline
\mbox{\tt in}  & {\em rho\+\_\+ref} & A reference density \mbox{[}kg m-\/3\mbox{]}\\
\hline
\mbox{\tt in}  & {\em scale} & A multiplicative factor by which to scale density in combination with scaling given by US \mbox{[}various\mbox{]} \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
263   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: t\textcolor{comment}{        !< Potential temperature referenced to the surface [degC]}
264   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: s\textcolor{comment}{        !< Salinity [ppt]}
265   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< Pressure [Pa] or [R L2 T-2 ~> Pa]}
266   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: rho\textcolor{comment}{      !< Density (in-situ if pressure is local) [kg m-3] or [R ~>
       kg m-3]}
267   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: start\textcolor{comment}{    !< Start index for computation}
268   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: npts\textcolor{comment}{     !< Number of point to compute}
269   \textcolor{keywordtype}{type}(eos\_type),     \textcolor{keywordtype}{pointer}       :: eos\textcolor{comment}{      !< Equation of state structure}
270   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: rho\_ref\textcolor{comment}{  !< A reference density [kg m-3]}
271   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{    !< A multiplicative factor by which to scale
       density}
272 \textcolor{comment}{                                                !! in combination with scaling given by US [various]}
273   \textcolor{keywordtype}{integer} :: j
274 
275   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
276     \textcolor{stringliteral}{"calculate\_density\_array called with an unassociated EOS\_type EOS."})
277 
278   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
279     \textcolor{keywordflow}{case} (eos\_linear)
280       \textcolor{keyword}{call }calculate\_density\_linear(t, s, pressure, rho, start, npts, &
281                                     eos%Rho\_T0\_S0, eos%dRho\_dT, eos%dRho\_dS, rho\_ref)
282     \textcolor{keywordflow}{case} (eos\_unesco)
283       \textcolor{keyword}{call }calculate\_density\_unesco(t, s, pressure, rho, start, npts, rho\_ref)
284     \textcolor{keywordflow}{case} (eos\_wright)
285       \textcolor{keyword}{call }calculate\_density\_wright(t, s, pressure, rho, start, npts, rho\_ref)
286     \textcolor{keywordflow}{case} (eos\_teos10)
287       \textcolor{keyword}{call }calculate\_density\_teos10(t, s, pressure, rho, start, npts, rho\_ref)
288     \textcolor{keywordflow}{case} (eos\_nemo)
289     \textcolor{keyword}{call }calculate\_density\_nemo(t, s, pressure, rho, start, npts, rho\_ref)
290 \textcolor{keywordflow}{    case default}
291       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_density\_array: EOS%form\_of\_EOS is not valid."})
292 \textcolor{keywordflow}{  end select}
293 
294   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (scale /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=start,start+npts-1
295     rho(j) = scale * rho(j)
296 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif} ;\textcolor{keywordflow}{ endif}
297 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_aed3bb20f32c038dbe84bc44442c6e724}\label{namespacemom__eos_aed3bb20f32c038dbe84bc44442c6e724}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!calculate\+\_\+density\+\_\+derivs\+\_\+1d@{calculate\+\_\+density\+\_\+derivs\+\_\+1d}}
\index{calculate\+\_\+density\+\_\+derivs\+\_\+1d@{calculate\+\_\+density\+\_\+derivs\+\_\+1d}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{calculate\+\_\+density\+\_\+derivs\+\_\+1d()}{calculate\_density\_derivs\_1d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calculate\+\_\+density\+\_\+derivs\+\_\+1d (\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[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS,  }\item[{integer, dimension(2), intent(in), optional}]{dom,  }\item[{real, intent(in), optional}]{scale }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calls the appropriate subroutine to calculate density derivatives for 1-\/D array inputs. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em t} & Potential temperature referenced to the surface \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em s} & Salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em pressure} & Pressure \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em drho\+\_\+dt} & The partial derivative of density with potential temperature \mbox{[}R deg\+C-\/1 $\sim$$>$ kg m-\/3 deg\+C-\/1\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em drho\+\_\+ds} & The partial derivative of density with salinity \mbox{[}R deg\+C-\/1 $\sim$$>$ kg m-\/3 ppt-\/1\mbox{]}\\
\hline
 & {\em eos} & Equation of state structure\\
\hline
\mbox{\tt in}  & {\em dom} & The domain of indices to work on, taking into account that arrays start at 1.\\
\hline
\mbox{\tt in}  & {\em scale} & A multiplicative factor by which to scale density in combination with scaling given by US \mbox{[}various\mbox{]} \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
751   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: t\textcolor{comment}{        !< Potential temperature referenced to the surface
       [degC]}
752   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: s\textcolor{comment}{        !< Salinity [ppt]}
753   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< Pressure [R L2 T-2 ~> Pa]}
754   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(inout)} :: drho\_dt\textcolor{comment}{  !< The partial derivative of density with potential}
755 \textcolor{comment}{                                                   !! temperature [R degC-1 ~> kg m-3 degC-1]}
756   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(inout)} :: drho\_ds\textcolor{comment}{  !< The partial derivative of density with salinity}
757 \textcolor{comment}{                                                   !! [R degC-1 ~> kg m-3 ppt-1]}
758   \textcolor{keywordtype}{type}(eos\_type),        \textcolor{keywordtype}{pointer}       :: eos\textcolor{comment}{      !< Equation of state structure}
759   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: dom\textcolor{comment}{   !< The domain of indices to work on, taking}
760 \textcolor{comment}{                                                       !! into account that arrays start at 1.}
761   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{ !< A multiplicative factor by which to scale density}
762 \textcolor{comment}{                                                       !! in combination with scaling given by US [various]}
763   \textcolor{comment}{! Local variables}
764   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(drho\_dT))} :: pres  \textcolor{comment}{! Pressure converted to [Pa]}
765   \textcolor{keywordtype}{real} :: rho\_scale \textcolor{comment}{! A factor to convert density from kg m-3 to the desired units [R m3 kg-1 ~> 1]}
766   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
767   \textcolor{keywordtype}{integer} :: i, is, ie, npts
768 
769   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
770     \textcolor{stringliteral}{"calculate\_density\_derivs called with an unassociated EOS\_type EOS."})
771 
772   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dom)) \textcolor{keywordflow}{then}
773     is = dom(1) ; ie = dom(2) ; npts = 1 + ie - is
774   \textcolor{keywordflow}{else}
775     is = 1 ; ie = \textcolor{keyword}{size}(drho\_dt) ; npts = 1 + ie - is
776 \textcolor{keywordflow}{  endif}
777 
778   p\_scale = eos%RL2\_T2\_to\_Pa
779 
780   \textcolor{keywordflow}{if} (p\_scale == 1.0) \textcolor{keywordflow}{then}
781     \textcolor{keyword}{call }calculate\_density\_derivs\_array(t, s, pressure, drho\_dt, drho\_ds, is, npts, eos)
782   \textcolor{keywordflow}{else}
783     \textcolor{keywordflow}{do} i=is,ie ; pres(i) = p\_scale * pressure(i) ;\textcolor{keywordflow}{ enddo}
784     \textcolor{keyword}{call }calculate\_density\_derivs\_array(t, s, pres, drho\_dt, drho\_ds, is, npts, eos)
785 \textcolor{keywordflow}{  endif}
786 
787   rho\_scale = eos%kg\_m3\_to\_R
788   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) rho\_scale = rho\_scale * scale
789   \textcolor{keywordflow}{if} (rho\_scale /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} i=is,ie
790     drho\_dt(i) = rho\_scale * drho\_dt(i)
791     drho\_ds(i) = rho\_scale * drho\_ds(i)
792 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif}
793 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_a27ec57cbbd2e673d542ba2c8dd44053a}\label{namespacemom__eos_a27ec57cbbd2e673d542ba2c8dd44053a}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!calculate\+\_\+density\+\_\+derivs\+\_\+array@{calculate\+\_\+density\+\_\+derivs\+\_\+array}}
\index{calculate\+\_\+density\+\_\+derivs\+\_\+array@{calculate\+\_\+density\+\_\+derivs\+\_\+array}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{calculate\+\_\+density\+\_\+derivs\+\_\+array()}{calculate\_density\_derivs\_array()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calculate\+\_\+density\+\_\+derivs\+\_\+array (\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,  }\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS,  }\item[{real, intent(in), optional}]{scale }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calls the appropriate subroutine to calculate density derivatives for 1-\/D array inputs. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em t} & Potential temperature referenced to the surface \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em s} & Salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em pressure} & Pressure \mbox{[}Pa\mbox{]} or \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em drho\+\_\+dt} & The partial derivative of density with potential temperature \mbox{[}kg m-\/3 deg\+C-\/1\mbox{]} or \mbox{[}R deg\+C-\/1 $\sim$$>$ kg m-\/3 deg\+C-\/1\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em drho\+\_\+ds} & The partial derivative of density with salinity, in \mbox{[}kg m-\/3 ppt-\/1\mbox{]} or \mbox{[}R deg\+C-\/1 $\sim$$>$ kg m-\/3 ppt-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em start} & Starting index within the array\\
\hline
\mbox{\tt in}  & {\em npts} & The number of values to calculate\\
\hline
 & {\em eos} & Equation of state structure\\
\hline
\mbox{\tt in}  & {\em scale} & A multiplicative factor by which to scale density in combination with scaling given by US \mbox{[}various\mbox{]} \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
706   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: t\textcolor{comment}{        !< Potential temperature referenced to the surface [degC]}
707   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: s\textcolor{comment}{        !< Salinity [ppt]}
708   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< Pressure [Pa] or [R L2 T-2 ~> Pa]}
709   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: drho\_dt\textcolor{comment}{  !< The partial derivative of density with potential}
710 \textcolor{comment}{                                                !! temperature [kg m-3 degC-1] or [R degC-1 ~> kg m-3
       degC-1]}
711   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: drho\_ds\textcolor{comment}{  !< The partial derivative of density with salinity,}
712 \textcolor{comment}{                                                !! in [kg m-3 ppt-1] or [R degC-1 ~> kg m-3 ppt-1]}
713   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: start\textcolor{comment}{    !< Starting index within the array}
714   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: npts\textcolor{comment}{     !< The number of values to calculate}
715   \textcolor{keywordtype}{type}(eos\_type),     \textcolor{keywordtype}{pointer}       :: eos\textcolor{comment}{      !< Equation of state structure}
716   \textcolor{keywordtype}{real},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{ !< A multiplicative factor by which to scale density}
717 \textcolor{comment}{                                                !! in combination with scaling given by US [various]}
718 
719   \textcolor{comment}{! Local variables}
720   \textcolor{keywordtype}{integer} :: j
721 
722   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
723     \textcolor{stringliteral}{"calculate\_density\_derivs called with an unassociated EOS\_type EOS."})
724 
725   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
726     \textcolor{keywordflow}{case} (eos\_linear)
727       \textcolor{keyword}{call }calculate\_density\_derivs\_linear(t, s, pressure, drho\_dt, drho\_ds, eos%Rho\_T0\_S0, &
728                                            eos%dRho\_dT, eos%dRho\_dS, start, npts)
729     \textcolor{keywordflow}{case} (eos\_unesco)
730       \textcolor{keyword}{call }calculate\_density\_derivs\_unesco(t, s, pressure, drho\_dt, drho\_ds, start, npts)
731     \textcolor{keywordflow}{case} (eos\_wright)
732       \textcolor{keyword}{call }calculate\_density\_derivs\_wright(t, s, pressure, drho\_dt, drho\_ds, start, npts)
733     \textcolor{keywordflow}{case} (eos\_teos10)
734       \textcolor{keyword}{call }calculate\_density\_derivs\_teos10(t, s, pressure, drho\_dt, drho\_ds, start, npts)
735     \textcolor{keywordflow}{case} (eos\_nemo)
736       \textcolor{keyword}{call }calculate\_density\_derivs\_nemo(t, s, pressure, drho\_dt, drho\_ds, start, npts)
737 \textcolor{keywordflow}{    case default}
738       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_density\_derivs\_array: EOS%form\_of\_EOS is not valid."})
739 \textcolor{keywordflow}{  end select}
740 
741   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (scale /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=start,start+npts-1
742     drho\_dt(j) = scale * drho\_dt(j)
743     drho\_ds(j) = scale * drho\_ds(j)
744 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif} ;\textcolor{keywordflow}{ endif}
745 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_a06d9d6680e838b965666986e63c980e7}\label{namespacemom__eos_a06d9d6680e838b965666986e63c980e7}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!calculate\+\_\+density\+\_\+derivs\+\_\+scalar@{calculate\+\_\+density\+\_\+derivs\+\_\+scalar}}
\index{calculate\+\_\+density\+\_\+derivs\+\_\+scalar@{calculate\+\_\+density\+\_\+derivs\+\_\+scalar}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{calculate\+\_\+density\+\_\+derivs\+\_\+scalar()}{calculate\_density\_derivs\_scalar()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calculate\+\_\+density\+\_\+derivs\+\_\+scalar (\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,  }\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS,  }\item[{real, intent(in), optional}]{scale }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calls the appropriate subroutines to calculate density derivatives by promoting a scalar to a one-\/element array. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em t} & Potential temperature referenced to the surface \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em s} & Salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em pressure} & Pressure \mbox{[}Pa\mbox{]} or \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}\\
\hline
\mbox{\tt out}  & {\em drho\+\_\+dt} & The partial derivative of density with potential temperature \mbox{[}kg m-\/3 deg\+C-\/1\mbox{]} or \mbox{[}R deg\+C-\/1 $\sim$$>$ kg m-\/3 deg\+C-\/1\mbox{]}\\
\hline
\mbox{\tt out}  & {\em drho\+\_\+ds} & The partial derivative of density with salinity, in \mbox{[}kg m-\/3 ppt-\/1\mbox{]} or \mbox{[}R ppt-\/1 $\sim$$>$ kg m-\/3 ppt-\/1\mbox{]}\\
\hline
 & {\em eos} & Equation of state structure\\
\hline
\mbox{\tt in}  & {\em scale} & A multiplicative factor by which to scale density in combination with scaling given by US \mbox{[}various\mbox{]} \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
800   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: t\textcolor{comment}{ !< Potential temperature referenced to the surface [degC]}
801   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: s\textcolor{comment}{ !< Salinity [ppt]}
802   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: pressure\textcolor{comment}{ !< Pressure [Pa] or [R L2 T-2 ~> Pa]}
803   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(out)} :: drho\_dt\textcolor{comment}{ !< The partial derivative of density with potential}
804 \textcolor{comment}{                                         !! temperature [kg m-3 degC-1] or [R degC-1 ~> kg m-3 degC-1]}
805   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(out)} :: drho\_ds\textcolor{comment}{ !< The partial derivative of density with salinity,}
806 \textcolor{comment}{                                         !! in [kg m-3 ppt-1] or [R ppt-1 ~> kg m-3 ppt-1]}
807   \textcolor{keywordtype}{type}(eos\_type), \textcolor{keywordtype}{pointer}     :: eos\textcolor{comment}{     !< Equation of state structure}
808   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: scale\textcolor{comment}{   !< A multiplicative factor by which to scale density}
809 \textcolor{comment}{                                         !! in combination with scaling given by US [various]}
810   \textcolor{comment}{! Local variables}
811   \textcolor{keywordtype}{real} :: rho\_scale \textcolor{comment}{! A factor to convert density from kg m-3 to the desired units [R m3 kg-1 ~> 1]}
812   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
813   \textcolor{keywordtype}{integer} :: j
814 
815   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
816     \textcolor{stringliteral}{"calculate\_density\_derivs called with an unassociated EOS\_type EOS."})
817 
818   p\_scale = eos%RL2\_T2\_to\_Pa
819 
820   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
821     \textcolor{keywordflow}{case} (eos\_linear)
822       \textcolor{keyword}{call }calculate\_density\_derivs\_linear(t, s, p\_scale*pressure, drho\_dt, drho\_ds, &
823                                            eos%Rho\_T0\_S0, eos%dRho\_dT, eos%dRho\_dS)
824     \textcolor{keywordflow}{case} (eos\_wright)
825       \textcolor{keyword}{call }calculate\_density\_derivs\_wright(t, s, p\_scale*pressure, drho\_dt, drho\_ds)
826     \textcolor{keywordflow}{case} (eos\_teos10)
827       \textcolor{keyword}{call }calculate\_density\_derivs\_teos10(t, s, p\_scale*pressure, drho\_dt, drho\_ds)
828 \textcolor{keywordflow}{    case default}
829       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_density\_derivs\_scalar: EOS%form\_of\_EOS is not valid."})
830 \textcolor{keywordflow}{  end select}
831 
832   rho\_scale = eos%kg\_m3\_to\_R
833   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) rho\_scale = rho\_scale * scale
834   \textcolor{keywordflow}{if} (rho\_scale /= 1.0) \textcolor{keywordflow}{then}
835     drho\_dt = rho\_scale * drho\_dt
836     drho\_ds = rho\_scale * drho\_ds
837 \textcolor{keywordflow}{  endif}
838 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_ac3bdab784e3535d661c47d1ec8a624fd}\label{namespacemom__eos_ac3bdab784e3535d661c47d1ec8a624fd}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!calculate\+\_\+density\+\_\+scalar@{calculate\+\_\+density\+\_\+scalar}}
\index{calculate\+\_\+density\+\_\+scalar@{calculate\+\_\+density\+\_\+scalar}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{calculate\+\_\+density\+\_\+scalar()}{calculate\_density\_scalar()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calculate\+\_\+density\+\_\+scalar (\begin{DoxyParamCaption}\item[{real, intent(in)}]{T,  }\item[{real, intent(in)}]{S,  }\item[{real, intent(in)}]{pressure,  }\item[{real, intent(out)}]{rho,  }\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS,  }\item[{real, intent(in), optional}]{rho\+\_\+ref,  }\item[{real, intent(in), optional}]{scale }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calls the appropriate subroutine to calculate density of sea water for scalar inputs. If rho\+\_\+ref is present, the anomaly with respect to rho\+\_\+ref is returned. The pressure and density can be rescaled with the US. If both the US and scale arguments are present the density scaling uses the product of the two scaling factors. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em t} & Potential temperature referenced to the surface \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em s} & Salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em pressure} & Pressure \mbox{[}Pa\mbox{]} or \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}\\
\hline
\mbox{\tt out}  & {\em rho} & Density (in-\/situ if pressure is local) \mbox{[}kg m-\/3\mbox{]} or \mbox{[}R $\sim$$>$ kg m-\/3\mbox{]}\\
\hline
 & {\em eos} & Equation of state structure\\
\hline
\mbox{\tt in}  & {\em rho\+\_\+ref} & A reference density \mbox{[}kg m-\/3\mbox{]}\\
\hline
\mbox{\tt in}  & {\em scale} & A multiplicative factor by which to scale density in combination with scaling given by US \mbox{[}various\mbox{]} \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
166   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: t\textcolor{comment}{        !< Potential temperature referenced to the surface [degC]}
167   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: s\textcolor{comment}{        !< Salinity [ppt]}
168   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: pressure\textcolor{comment}{ !< Pressure [Pa] or [R L2 T-2 ~> Pa]}
169   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(out)} :: rho\textcolor{comment}{      !< Density (in-situ if pressure is local) [kg m-3] or [R ~> kg
       m-3]}
170   \textcolor{keywordtype}{type}(eos\_type), \textcolor{keywordtype}{pointer}     :: eos\textcolor{comment}{      !< Equation of state structure}
171   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: rho\_ref\textcolor{comment}{  !< A reference density [kg m-3]}
172   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: scale\textcolor{comment}{    !< A multiplicative factor by which to scale density in}
173 \textcolor{comment}{                                          !! combination with scaling given by US [various]}
174 
175   \textcolor{keywordtype}{real} :: rho\_scale \textcolor{comment}{! A factor to convert density from kg m-3 to the desired units [R m3 kg-1 ~> 1]}
176   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
177 
178   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
179     \textcolor{stringliteral}{"calculate\_density\_scalar called with an unassociated EOS\_type EOS."})
180 
181   p\_scale = eos%RL2\_T2\_to\_Pa
182 
183   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
184     \textcolor{keywordflow}{case} (eos\_linear)
185       \textcolor{keyword}{call }calculate\_density\_linear(t, s, p\_scale*pressure, rho, &
186                                     eos%Rho\_T0\_S0, eos%dRho\_dT, eos%dRho\_dS, rho\_ref)
187     \textcolor{keywordflow}{case} (eos\_unesco)
188       \textcolor{keyword}{call }calculate\_density\_unesco(t, s, p\_scale*pressure, rho, rho\_ref)
189     \textcolor{keywordflow}{case} (eos\_wright)
190       \textcolor{keyword}{call }calculate\_density\_wright(t, s, p\_scale*pressure, rho, rho\_ref)
191     \textcolor{keywordflow}{case} (eos\_teos10)
192       \textcolor{keyword}{call }calculate\_density\_teos10(t, s, p\_scale*pressure, rho, rho\_ref)
193     \textcolor{keywordflow}{case} (eos\_nemo)
194       \textcolor{keyword}{call }calculate\_density\_nemo(t, s, p\_scale*pressure, rho, rho\_ref)
195 \textcolor{keywordflow}{    case default}
196       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_density\_scalar: EOS is not valid."})
197 \textcolor{keywordflow}{  end select}
198 
199   rho\_scale = eos%kg\_m3\_to\_R
200   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) rho\_scale = rho\_scale * scale
201   rho = rho\_scale * rho
202 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_a8c0fa67a7a4911eb5fa33c5d17b997f9}\label{namespacemom__eos_a8c0fa67a7a4911eb5fa33c5d17b997f9}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!calculate\+\_\+density\+\_\+second\+\_\+derivs\+\_\+array@{calculate\+\_\+density\+\_\+second\+\_\+derivs\+\_\+array}}
\index{calculate\+\_\+density\+\_\+second\+\_\+derivs\+\_\+array@{calculate\+\_\+density\+\_\+second\+\_\+derivs\+\_\+array}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{calculate\+\_\+density\+\_\+second\+\_\+derivs\+\_\+array()}{calculate\_density\_second\_derivs\_array()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calculate\+\_\+density\+\_\+second\+\_\+derivs\+\_\+array (\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\+\_\+d\+S\+\_\+dS,  }\item[{real, dimension(\+:), intent(inout)}]{drho\+\_\+d\+S\+\_\+dT,  }\item[{real, dimension(\+:), intent(inout)}]{drho\+\_\+d\+T\+\_\+dT,  }\item[{real, dimension(\+:), intent(inout)}]{drho\+\_\+d\+S\+\_\+dP,  }\item[{real, dimension(\+:), intent(inout)}]{drho\+\_\+d\+T\+\_\+dP,  }\item[{integer, intent(in)}]{start,  }\item[{integer, intent(in)}]{npts,  }\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS,  }\item[{real, intent(in), optional}]{scale }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calls the appropriate subroutine to calculate density second derivatives for 1-\/D array inputs. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em t} & Potential temperature referenced to the surface \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em s} & Salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em pressure} & Pressure \mbox{[}Pa\mbox{]} or \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em drho\+\_\+ds\+\_\+ds} & Partial derivative of beta with respect to S \mbox{[}kg m-\/3 ppt-\/2\mbox{]} or \mbox{[}R ppt-\/2 $\sim$$>$ kg m-\/3 ppt-\/2\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em drho\+\_\+ds\+\_\+dt} & Partial derivative of beta with respect to T \mbox{[}kg m-\/3 ppt-\/1 deg\+C-\/1\mbox{]} or \mbox{[}R ppt-\/1 deg\+C-\/1 $\sim$$>$ kg m-\/3 ppt-\/1 deg\+C-\/1\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em drho\+\_\+dt\+\_\+dt} & Partial derivative of alpha with respect to T \mbox{[}kg m-\/3 deg\+C-\/2\mbox{]} or \mbox{[}R deg\+C-\/2 $\sim$$>$ kg m-\/3 deg\+C-\/2\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em drho\+\_\+ds\+\_\+dp} & Partial derivative of beta with respect to pressure \mbox{[}kg m-\/3 ppt-\/1 Pa-\/1\mbox{]} or \mbox{[}R ppt-\/1 Pa-\/1 $\sim$$>$ kg m-\/3 ppt-\/1 Pa-\/1\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em drho\+\_\+dt\+\_\+dp} & Partial derivative of alpha with respect to pressure \mbox{[}kg m-\/3 deg\+C-\/1 Pa-\/1\mbox{]} or \mbox{[}R deg\+C-\/1 Pa-\/1 $\sim$$>$ kg m-\/3 deg\+C-\/1 Pa-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em start} & Starting index within the array\\
\hline
\mbox{\tt in}  & {\em npts} & The number of values to calculate\\
\hline
 & {\em eos} & Equation of state structure\\
\hline
\mbox{\tt in}  & {\em scale} & A multiplicative factor by which to scale density in combination with scaling given by US \mbox{[}various\mbox{]} \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
844   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}  :: t\textcolor{comment}{ !< Potential temperature referenced to the surface [degC]}
845   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}  :: s\textcolor{comment}{ !< Salinity [ppt]}
846   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}  :: pressure\textcolor{comment}{   !< Pressure [Pa] or [R L2 T-2 ~> Pa]}
847   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: drho\_ds\_ds\textcolor{comment}{ !< Partial derivative of beta with respect to S}
848 \textcolor{comment}{                                                  !!  [kg m-3 ppt-2] or [R ppt-2 ~> kg m-3 ppt-2]}
849   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: drho\_ds\_dt\textcolor{comment}{ !< Partial derivative of beta with respect to T}
850 \textcolor{comment}{                                                  !! [kg m-3 ppt-1 degC-1] or [R ppt-1 degC-1 ~> kg m-3
       ppt-1 degC-1]}
851   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: drho\_dt\_dt\textcolor{comment}{ !< Partial derivative of alpha with respect to T}
852 \textcolor{comment}{                                                  !! [kg m-3 degC-2] or [R degC-2 ~> kg m-3 degC-2]}
853   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: drho\_ds\_dp\textcolor{comment}{ !< Partial derivative of beta with respect to pressure}
854 \textcolor{comment}{                                                  !! [kg m-3 ppt-1 Pa-1] or [R ppt-1 Pa-1 ~> kg m-3 ppt-1
       Pa-1]}
855   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: drho\_dt\_dp\textcolor{comment}{ !< Partial derivative of alpha with respect to pressure}
856 \textcolor{comment}{                                                  !! [kg m-3 degC-1 Pa-1] or [R degC-1 Pa-1 ~> kg m-3
       degC-1 Pa-1]}
857   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}  :: start\textcolor{comment}{ !< Starting index within the array}
858   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}  :: npts\textcolor{comment}{  !< The number of values to calculate}
859   \textcolor{keywordtype}{type}(eos\_type),     \textcolor{keywordtype}{pointer}     :: eos\textcolor{comment}{   !< Equation of state structure}
860   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{ !< A multiplicative factor by which to scale density}
861 \textcolor{comment}{                                                  !! in combination with scaling given by US [various]}
862   \textcolor{comment}{! Local variables}
863   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(pressure))} :: pres  \textcolor{comment}{! Pressure converted to [Pa]}
864   \textcolor{keywordtype}{real} :: rho\_scale \textcolor{comment}{! A factor to convert density from kg m-3 to the desired units [R m3 kg-1 ~> 1]}
865   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
866   \textcolor{keywordtype}{real} :: i\_p\_scale \textcolor{comment}{! The inverse of the factor to convert pressure to units of Pa [R L2 T-2 Pa-1 ~> 1]}
867   \textcolor{keywordtype}{integer} :: j
868 
869   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
870     \textcolor{stringliteral}{"calculate\_density\_derivs called with an unassociated EOS\_type EOS."})
871 
872   p\_scale = eos%RL2\_T2\_to\_Pa
873 
874   \textcolor{keywordflow}{if} (p\_scale == 1.0) \textcolor{keywordflow}{then}
875     \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
876       \textcolor{keywordflow}{case} (eos\_linear)
877         \textcolor{keyword}{call }calculate\_density\_second\_derivs\_linear(t, s, pressure, drho\_ds\_ds, drho\_ds\_dt, &
878                                                     drho\_dt\_dt, drho\_ds\_dp, drho\_dt\_dp, start, npts)
879       \textcolor{keywordflow}{case} (eos\_wright)
880         \textcolor{keyword}{call }calculate\_density\_second\_derivs\_wright(t, s, pressure, drho\_ds\_ds, drho\_ds\_dt, &
881                                                     drho\_dt\_dt, drho\_ds\_dp, drho\_dt\_dp, start, npts)
882       \textcolor{keywordflow}{case} (eos\_teos10)
883         \textcolor{keyword}{call }calculate\_density\_second\_derivs\_teos10(t, s, pressure, drho\_ds\_ds, drho\_ds\_dt, &
884                                                     drho\_dt\_dt, drho\_ds\_dp, drho\_dt\_dp, start, npts)
885 \textcolor{keywordflow}{      case default}
886         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_density\_derivs: EOS%form\_of\_EOS is not valid."})
887 \textcolor{keywordflow}{    end select}
888   \textcolor{keywordflow}{else}
889     \textcolor{keywordflow}{do} j=start,start+npts-1 ; pres(j) = p\_scale * pressure(j) ;\textcolor{keywordflow}{ enddo}
890     \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
891       \textcolor{keywordflow}{case} (eos\_linear)
892         \textcolor{keyword}{call }calculate\_density\_second\_derivs\_linear(t, s, pres, drho\_ds\_ds, drho\_ds\_dt, &
893                                                     drho\_dt\_dt, drho\_ds\_dp, drho\_dt\_dp, start, npts)
894       \textcolor{keywordflow}{case} (eos\_wright)
895         \textcolor{keyword}{call }calculate\_density\_second\_derivs\_wright(t, s, pres, drho\_ds\_ds, drho\_ds\_dt, &
896                                                     drho\_dt\_dt, drho\_ds\_dp, drho\_dt\_dp, start, npts)
897       \textcolor{keywordflow}{case} (eos\_teos10)
898         \textcolor{keyword}{call }calculate\_density\_second\_derivs\_teos10(t, s, pres, drho\_ds\_ds, drho\_ds\_dt, &
899                                                     drho\_dt\_dt, drho\_ds\_dp, drho\_dt\_dp, start, npts)
900 \textcolor{keywordflow}{      case default}
901         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_density\_derivs: EOS%form\_of\_EOS is not valid."})
902 \textcolor{keywordflow}{    end select}
903 \textcolor{keywordflow}{  endif}
904 
905   rho\_scale = eos%kg\_m3\_to\_R
906   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) rho\_scale = rho\_scale * scale
907   \textcolor{keywordflow}{if} (rho\_scale /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=start,start+npts-1
908     drho\_ds\_ds(j) = rho\_scale * drho\_ds\_ds(j)
909     drho\_ds\_dt(j) = rho\_scale * drho\_ds\_dt(j)
910     drho\_dt\_dt(j) = rho\_scale * drho\_dt\_dt(j)
911     drho\_ds\_dp(j) = rho\_scale * drho\_ds\_dp(j)
912     drho\_dt\_dp(j) = rho\_scale * drho\_dt\_dp(j)
913 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif}
914 
915   \textcolor{keywordflow}{if} (p\_scale /= 1.0) \textcolor{keywordflow}{then}
916     i\_p\_scale = 1.0 / p\_scale
917     \textcolor{keywordflow}{do} j=start,start+npts-1
918       drho\_ds\_dp(j) = i\_p\_scale * drho\_ds\_dp(j)
919       drho\_dt\_dp(j) = i\_p\_scale * drho\_dt\_dp(j)
920 \textcolor{keywordflow}{    enddo}
921 \textcolor{keywordflow}{  endif}
922 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_a2d7a984ed1c48d9e0ea1046de3eac886}\label{namespacemom__eos_a2d7a984ed1c48d9e0ea1046de3eac886}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!calculate\+\_\+density\+\_\+second\+\_\+derivs\+\_\+scalar@{calculate\+\_\+density\+\_\+second\+\_\+derivs\+\_\+scalar}}
\index{calculate\+\_\+density\+\_\+second\+\_\+derivs\+\_\+scalar@{calculate\+\_\+density\+\_\+second\+\_\+derivs\+\_\+scalar}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{calculate\+\_\+density\+\_\+second\+\_\+derivs\+\_\+scalar()}{calculate\_density\_second\_derivs\_scalar()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calculate\+\_\+density\+\_\+second\+\_\+derivs\+\_\+scalar (\begin{DoxyParamCaption}\item[{real, intent(in)}]{T,  }\item[{real, intent(in)}]{S,  }\item[{real, intent(in)}]{pressure,  }\item[{real, intent(out)}]{drho\+\_\+d\+S\+\_\+dS,  }\item[{real, intent(out)}]{drho\+\_\+d\+S\+\_\+dT,  }\item[{real, intent(out)}]{drho\+\_\+d\+T\+\_\+dT,  }\item[{real, intent(out)}]{drho\+\_\+d\+S\+\_\+dP,  }\item[{real, intent(out)}]{drho\+\_\+d\+T\+\_\+dP,  }\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS,  }\item[{real, intent(in), optional}]{scale }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calls the appropriate subroutine to calculate density second derivatives for scalar nputs. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em t} & Potential temperature referenced to the surface \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em s} & Salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em pressure} & Pressure \mbox{[}Pa\mbox{]} or \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}\\
\hline
\mbox{\tt out}  & {\em drho\+\_\+ds\+\_\+ds} & Partial derivative of beta with respect to S \mbox{[}kg m-\/3 ppt-\/2\mbox{]} or \mbox{[}R ppt-\/2 $\sim$$>$ kg m-\/3 ppt-\/2\mbox{]}\\
\hline
\mbox{\tt out}  & {\em drho\+\_\+ds\+\_\+dt} & Partial derivative of beta with respect to T \mbox{[}kg m-\/3 ppt-\/1 deg\+C-\/1\mbox{]} or \mbox{[}R ppt-\/1 deg\+C-\/1 $\sim$$>$ kg m-\/3 ppt-\/1 deg\+C-\/1\mbox{]}\\
\hline
\mbox{\tt out}  & {\em drho\+\_\+dt\+\_\+dt} & Partial derivative of alpha with respect to T \mbox{[}kg m-\/3 deg\+C-\/2\mbox{]} or \mbox{[}R deg\+C-\/2 $\sim$$>$ kg m-\/3 deg\+C-\/2\mbox{]}\\
\hline
\mbox{\tt out}  & {\em drho\+\_\+ds\+\_\+dp} & Partial derivative of beta with respect to pressure \mbox{[}kg m-\/3 ppt-\/1 Pa-\/1\mbox{]} or \mbox{[}R ppt-\/1 Pa-\/1 $\sim$$>$ kg m-\/3 ppt-\/1 Pa-\/1\mbox{]}\\
\hline
\mbox{\tt out}  & {\em drho\+\_\+dt\+\_\+dp} & Partial derivative of alpha with respect to pressure \mbox{[}kg m-\/3 deg\+C-\/1 Pa-\/1\mbox{]} or \mbox{[}R deg\+C-\/1 Pa-\/1 $\sim$$>$ kg m-\/3 deg\+C-\/1 Pa-\/1\mbox{]}\\
\hline
 & {\em eos} & Equation of state structure\\
\hline
\mbox{\tt in}  & {\em scale} & A multiplicative factor by which to scale density in combination with scaling given by US \mbox{[}various\mbox{]} \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
928   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: t\textcolor{comment}{ !< Potential temperature referenced to the surface [degC]}
929   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: s\textcolor{comment}{ !< Salinity [ppt]}
930   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: pressure\textcolor{comment}{   !< Pressure [Pa] or [R L2 T-2 ~> Pa]}
931   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: drho\_ds\_ds\textcolor{comment}{ !< Partial derivative of beta with respect to S}
932 \textcolor{comment}{                                  !! [kg m-3 ppt-2] or [R ppt-2 ~> kg m-3 ppt-2]}
933   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: drho\_ds\_dt\textcolor{comment}{ !< Partial derivative of beta with respect to T}
934 \textcolor{comment}{                                  !! [kg m-3 ppt-1 degC-1] or [R ppt-1 degC-1 ~> kg m-3 ppt-1 degC-1]}
935   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: drho\_dt\_dt\textcolor{comment}{ !< Partial derivative of alpha with respect to T}
936 \textcolor{comment}{                                  !! [kg m-3 degC-2] or [R degC-2 ~> kg m-3 degC-2]}
937   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: drho\_ds\_dp\textcolor{comment}{ !< Partial derivative of beta with respect to pressure}
938 \textcolor{comment}{                                  !! [kg m-3 ppt-1 Pa-1] or [R ppt-1 Pa-1 ~> kg m-3 ppt-1 Pa-1]}
939   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: drho\_dt\_dp\textcolor{comment}{ !< Partial derivative of alpha with respect to pressure}
940 \textcolor{comment}{                                  !! [kg m-3 degC-1 Pa-1] or [R degC-1 Pa-1 ~> kg m-3 degC-1 Pa-1]}
941   \textcolor{keywordtype}{type}(eos\_type), \textcolor{keywordtype}{pointer}    :: eos\textcolor{comment}{ !< Equation of state structure}
942   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{ !< A multiplicative factor by which to scale density}
943 \textcolor{comment}{                                  !! in combination with scaling given by US [various]}
944   \textcolor{comment}{! Local variables}
945   \textcolor{keywordtype}{real} :: rho\_scale \textcolor{comment}{! A factor to convert density from kg m-3 to the desired units [R m3 kg-1 ~> 1]}
946   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
947   \textcolor{keywordtype}{real} :: i\_p\_scale \textcolor{comment}{! The inverse of the factor to convert pressure to units of Pa [R L2 T-2 Pa-1 ~> 1]}
948 
949   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
950     \textcolor{stringliteral}{"calculate\_density\_derivs called with an unassociated EOS\_type EOS."})
951 
952   p\_scale = eos%RL2\_T2\_to\_Pa
953 
954   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
955     \textcolor{keywordflow}{case} (eos\_linear)
956       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_linear(t, s, p\_scale*pressure, drho\_ds\_ds, drho\_ds\_dt, &
957                                                   drho\_dt\_dt, drho\_ds\_dp, drho\_dt\_dp)
958     \textcolor{keywordflow}{case} (eos\_wright)
959       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_wright(t, s, p\_scale*pressure, drho\_ds\_ds, drho\_ds\_dt, &
960                                                   drho\_dt\_dt, drho\_ds\_dp, drho\_dt\_dp)
961     \textcolor{keywordflow}{case} (eos\_teos10)
962       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_teos10(t, s, p\_scale*pressure, drho\_ds\_ds, drho\_ds\_dt, &
963                                                   drho\_dt\_dt, drho\_ds\_dp, drho\_dt\_dp)
964 \textcolor{keywordflow}{    case default}
965       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_density\_derivs: EOS%form\_of\_EOS is not valid."})
966 \textcolor{keywordflow}{  end select}
967 
968   rho\_scale = eos%kg\_m3\_to\_R
969   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) rho\_scale = rho\_scale * scale
970   \textcolor{keywordflow}{if} (rho\_scale /= 1.0) \textcolor{keywordflow}{then}
971     drho\_ds\_ds = rho\_scale * drho\_ds\_ds
972     drho\_ds\_dt = rho\_scale * drho\_ds\_dt
973     drho\_dt\_dt = rho\_scale * drho\_dt\_dt
974     drho\_ds\_dp = rho\_scale * drho\_ds\_dp
975     drho\_dt\_dp = rho\_scale * drho\_dt\_dp
976 \textcolor{keywordflow}{  endif}
977 
978   \textcolor{keywordflow}{if} (p\_scale /= 1.0) \textcolor{keywordflow}{then}
979     i\_p\_scale = 1.0 / p\_scale
980     drho\_ds\_dp = i\_p\_scale * drho\_ds\_dp
981     drho\_dt\_dp = i\_p\_scale * drho\_dt\_dp
982 \textcolor{keywordflow}{  endif}
983 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_a43d417da1636adb2cd184f76223afded}\label{namespacemom__eos_a43d417da1636adb2cd184f76223afded}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!calculate\+\_\+spec\+\_\+vol\+\_\+array@{calculate\+\_\+spec\+\_\+vol\+\_\+array}}
\index{calculate\+\_\+spec\+\_\+vol\+\_\+array@{calculate\+\_\+spec\+\_\+vol\+\_\+array}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{calculate\+\_\+spec\+\_\+vol\+\_\+array()}{calculate\_spec\_vol\_array()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calculate\+\_\+spec\+\_\+vol\+\_\+array (\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[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS,  }\item[{real, intent(in), optional}]{spv\+\_\+ref,  }\item[{real, intent(in), optional}]{scale }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calls the appropriate subroutine to calculate the specific volume of sea water for 1-\/D array inputs. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em t} & potential temperature relative to the surface \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em s} & salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em pressure} & pressure \mbox{[}Pa\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em specvol} & in situ specific volume \mbox{[}kg m-\/3\mbox{]}\\
\hline
\mbox{\tt in}  & {\em start} & the starting point in the arrays.\\
\hline
\mbox{\tt in}  & {\em npts} & the number of values to calculate.\\
\hline
 & {\em eos} & Equation of state structure\\
\hline
\mbox{\tt in}  & {\em spv\+\_\+ref} & A reference specific volume \mbox{[}m3 kg-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em scale} & A multiplicative factor by which to scale specific volume in combination with scaling given by US \mbox{[}various\mbox{]} \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
486   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: t\textcolor{comment}{        !< potential temperature relative to the surface [degC]}
487   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: s\textcolor{comment}{        !< salinity [ppt]}
488   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< pressure [Pa]}
489   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: specvol\textcolor{comment}{  !< in situ specific volume [kg m-3]}
490   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: start\textcolor{comment}{    !< the starting point in the arrays.}
491   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: npts\textcolor{comment}{     !< the number of values to calculate.}
492   \textcolor{keywordtype}{type}(eos\_type),     \textcolor{keywordtype}{pointer}       :: eos\textcolor{comment}{      !< Equation of state structure}
493   \textcolor{keywordtype}{real},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: spv\_ref\textcolor{comment}{  !< A reference specific volume [m3 kg-1]}
494   \textcolor{keywordtype}{real},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{    !< A multiplicative factor by which to scale specific}
495 \textcolor{comment}{                                                !! volume in combination with scaling given by US [various]}
496 
497   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(specvol))}  :: rho   \textcolor{comment}{! Density [kg m-3]}
498   \textcolor{keywordtype}{integer} :: j
499 
500   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
501     \textcolor{stringliteral}{"calculate\_spec\_vol\_array called with an unassociated EOS\_type EOS."})
502 
503   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
504     \textcolor{keywordflow}{case} (eos\_linear)
505       \textcolor{keyword}{call }calculate\_spec\_vol\_linear(t, s, pressure, specvol, start, npts, &
506                eos%rho\_T0\_S0, eos%drho\_dT, eos%drho\_dS, spv\_ref)
507     \textcolor{keywordflow}{case} (eos\_unesco)
508       \textcolor{keyword}{call }calculate\_spec\_vol\_unesco(t, s, pressure, specvol, start, npts, spv\_ref)
509     \textcolor{keywordflow}{case} (eos\_wright)
510       \textcolor{keyword}{call }calculate\_spec\_vol\_wright(t, s, pressure, specvol, start, npts, spv\_ref)
511     \textcolor{keywordflow}{case} (eos\_teos10)
512       \textcolor{keyword}{call }calculate\_spec\_vol\_teos10(t, s, pressure, specvol, start, npts, spv\_ref)
513     \textcolor{keywordflow}{case} (eos\_nemo)
514       \textcolor{keyword}{call }calculate\_density\_nemo(t, s, pressure, rho, start, npts)
515       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(spv\_ref)) \textcolor{keywordflow}{then}
516         specvol(:) = 1.0 / rho(:) - spv\_ref
517       \textcolor{keywordflow}{else}
518         specvol(:) = 1.0 / rho(:)
519 \textcolor{keywordflow}{      endif}
520 \textcolor{keywordflow}{    case default}
521       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_spec\_vol\_array: EOS%form\_of\_EOS is not valid."})
522 \textcolor{keywordflow}{  end select}
523 
524   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (scale /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=start,start+npts-1
525     specvol(j) = scale * specvol(j)
526 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif} ;\textcolor{keywordflow}{ endif}
527 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_a35f9c33d1aeffbf9986349463bab3b9c}\label{namespacemom__eos_a35f9c33d1aeffbf9986349463bab3b9c}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!calculate\+\_\+spec\+\_\+vol\+\_\+derivs\+\_\+array@{calculate\+\_\+spec\+\_\+vol\+\_\+derivs\+\_\+array}}
\index{calculate\+\_\+spec\+\_\+vol\+\_\+derivs\+\_\+array@{calculate\+\_\+spec\+\_\+vol\+\_\+derivs\+\_\+array}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{calculate\+\_\+spec\+\_\+vol\+\_\+derivs\+\_\+array()}{calculate\_spec\_vol\_derivs\_array()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calculate\+\_\+spec\+\_\+vol\+\_\+derivs\+\_\+array (\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,  }\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calls the appropriate subroutine to calculate specific volume derivatives for an array. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em t} & Potential temperature referenced to the surface \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em s} & Salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em pressure} & Pressure \mbox{[}Pa\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em dsv\+\_\+dt} & The partial derivative of specific volume with potential temperature \mbox{[}m3 kg-\/1 deg\+C-\/1\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em dsv\+\_\+ds} & The partial derivative of specific volume with salinity \mbox{[}m3 kg-\/1 ppt-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em start} & Starting index within the array\\
\hline
\mbox{\tt in}  & {\em npts} & The number of values to calculate\\
\hline
 & {\em eos} & Equation of state structure \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
988   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}  :: t\textcolor{comment}{ !< Potential temperature referenced to the surface [degC]}
989   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}  :: s\textcolor{comment}{ !< Salinity [ppt]}
990   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}  :: pressure\textcolor{comment}{ !< Pressure [Pa]}
991   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: dsv\_dt\textcolor{comment}{ !< The partial derivative of specific volume with potential}
992 \textcolor{comment}{                                              !! temperature [m3 kg-1 degC-1]}
993   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: dsv\_ds\textcolor{comment}{ !< The partial derivative of specific volume with salinity}
994 \textcolor{comment}{                                              !! [m3 kg-1 ppt-1]}
995   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}  :: start\textcolor{comment}{  !< Starting index within the array}
996   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}  :: npts\textcolor{comment}{   !< The number of values to calculate}
997   \textcolor{keywordtype}{type}(eos\_type),     \textcolor{keywordtype}{pointer}     :: eos\textcolor{comment}{    !< Equation of state structure}
998 
999   \textcolor{comment}{! Local variables}
1000   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(T))} :: press   \textcolor{comment}{! Pressure converted to [Pa]}
1001   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(T))} :: rho     \textcolor{comment}{! In situ density [kg m-3]}
1002   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(T))} :: drho\_dt \textcolor{comment}{! Derivative of density with temperature [kg m-3 degC-1]}
1003   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(T))} :: drho\_ds \textcolor{comment}{! Derivative of density with salinity [kg m-3 ppt-1]}
1004   \textcolor{keywordtype}{integer} :: j
1005 
1006   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
1007     \textcolor{stringliteral}{"calculate\_spec\_vol\_derivs\_array called with an unassociated EOS\_type EOS."})
1008 
1009   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
1010     \textcolor{keywordflow}{case} (eos\_linear)
1011       \textcolor{keyword}{call }calculate\_specvol\_derivs\_linear(t, s, pressure, dsv\_dt, dsv\_ds, start, &
1012                                            npts, eos%Rho\_T0\_S0, eos%dRho\_dT, eos%dRho\_dS)
1013     \textcolor{keywordflow}{case} (eos\_unesco)
1014       \textcolor{keyword}{call }calculate\_density\_unesco(t, s, pressure, rho, start, npts)
1015       \textcolor{keyword}{call }calculate\_density\_derivs\_unesco(t, s, pressure, drho\_dt, drho\_ds, start, npts)
1016       \textcolor{keywordflow}{do} j=start,start+npts-1
1017         dsv\_dt(j) = -drho\_dt(j)/(rho(j)**2)
1018         dsv\_ds(j) = -drho\_ds(j)/(rho(j)**2)
1019 \textcolor{keywordflow}{      enddo}
1020     \textcolor{keywordflow}{case} (eos\_wright)
1021       \textcolor{keyword}{call }calculate\_specvol\_derivs\_wright(t, s, pressure, dsv\_dt, dsv\_ds, start, npts)
1022     \textcolor{keywordflow}{case} (eos\_teos10)
1023       \textcolor{keyword}{call }calculate\_specvol\_derivs\_teos10(t, s, pressure, dsv\_dt, dsv\_ds, start, npts)
1024     \textcolor{keywordflow}{case} (eos\_nemo)
1025       \textcolor{keyword}{call }calculate\_density\_nemo(t, s, pressure, rho, start, npts)
1026       \textcolor{keyword}{call }calculate\_density\_derivs\_nemo(t, s, pressure, drho\_dt, drho\_ds, start, npts)
1027       \textcolor{keywordflow}{do} j=start,start+npts-1
1028         dsv\_dt(j) = -drho\_dt(j)/(rho(j)**2)
1029         dsv\_ds(j) = -drho\_ds(j)/(rho(j)**2)
1030 \textcolor{keywordflow}{      enddo}
1031 \textcolor{keywordflow}{    case default}
1032       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_spec\_vol\_derivs\_array: EOS%form\_of\_EOS is not valid."})
1033 \textcolor{keywordflow}{  end select}
1034 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_a58b52a452d779c53e6421aaa3eac6e8b}\label{namespacemom__eos_a58b52a452d779c53e6421aaa3eac6e8b}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!calculate\+\_\+stanley\+\_\+density\+\_\+1d@{calculate\+\_\+stanley\+\_\+density\+\_\+1d}}
\index{calculate\+\_\+stanley\+\_\+density\+\_\+1d@{calculate\+\_\+stanley\+\_\+density\+\_\+1d}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{calculate\+\_\+stanley\+\_\+density\+\_\+1d()}{calculate\_stanley\_density\_1d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calculate\+\_\+stanley\+\_\+density\+\_\+1d (\begin{DoxyParamCaption}\item[{real, dimension(\+:), intent(in)}]{T,  }\item[{real, dimension(\+:), intent(in)}]{S,  }\item[{real, dimension(\+:), intent(in)}]{pressure,  }\item[{real, dimension(\+:), intent(in)}]{Tvar,  }\item[{real, dimension(\+:), intent(in)}]{T\+Scov,  }\item[{real, dimension(\+:), intent(in)}]{Svar,  }\item[{real, dimension(\+:), intent(inout)}]{rho,  }\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS,  }\item[{integer, dimension(2), intent(in), optional}]{dom,  }\item[{real, intent(in), optional}]{rho\+\_\+ref,  }\item[{real, intent(in), optional}]{scale }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calls the appropriate subroutine to calculate the density of sea water for 1-\/D array inputs including the variance of T, S and covariance of T-\/S, potentially limiting the domain of indices that are worked on. The calculation uses only the second order correction in a series as discussed in Stanley et al., 2020. If rho\+\_\+ref is present, the anomaly with respect to rho\+\_\+ref is returned. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em t} & Potential temperature referenced to the surface \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em s} & Salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em pressure} & Pressure \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}\\
\hline
\mbox{\tt in}  & {\em tvar} & Variance of potential temperature \mbox{[}deg\+C2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em tscov} & Covariance of potential temperature and salinity \mbox{[}degC ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em svar} & Variance of salinity \mbox{[}ppt2\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em rho} & Density (in-\/situ if pressure is local) \mbox{[}R $\sim$$>$ kg m-\/3\mbox{]}\\
\hline
 & {\em eos} & Equation of state structure\\
\hline
\mbox{\tt in}  & {\em dom} & The domain of indices to work on, taking into account that arrays start at 1.\\
\hline
\mbox{\tt in}  & {\em rho\+\_\+ref} & A reference density \mbox{[}kg m-\/3\mbox{]}\\
\hline
\mbox{\tt in}  & {\em scale} & A multiplicative factor by which to scale density in combination with scaling given by US \mbox{[}various\mbox{]} \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
417   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: t\textcolor{comment}{        !< Potential temperature referenced to the surface
       [degC]}
418   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: s\textcolor{comment}{        !< Salinity [ppt]}
419   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< Pressure [R L2 T-2 ~> Pa]}
420   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: tvar\textcolor{comment}{     !< Variance of potential temperature [degC2]}
421   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: tscov\textcolor{comment}{    !< Covariance of potential temperature and salinity
       [degC ppt]}
422   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: svar\textcolor{comment}{     !< Variance of salinity [ppt2]}
423   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(inout)} :: rho\textcolor{comment}{      !< Density (in-situ if pressure is local) [R ~> kg m-3]}
424   \textcolor{keywordtype}{type}(eos\_type),        \textcolor{keywordtype}{pointer}       :: eos\textcolor{comment}{      !< Equation of state structure}
425   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: dom\textcolor{comment}{   !< The domain of indices to work on, taking}
426 \textcolor{comment}{                                                       !! into account that arrays start at 1.}
427   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: rho\_ref\textcolor{comment}{ !< A reference density [kg m-3]}
428   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{ !< A multiplicative factor by which to scale density}
429 \textcolor{comment}{                                                   !! in combination with scaling given by US [various]}
430   \textcolor{comment}{! Local variables}
431   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
432   \textcolor{keywordtype}{real} :: rho\_scale \textcolor{comment}{! A factor to convert density from kg m-3 to the desired units [R m3 kg-1 ~> 1]}
433   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(rho))} :: pres  \textcolor{comment}{! Pressure converted to [Pa]}
434   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(T))} :: d2rdtt, d2rdst, d2rdss, d2rdsp, d2rdtp \textcolor{comment}{! Second derivatives of density wrt
       T,S,p}
435   \textcolor{keywordtype}{integer} :: i, is, ie, npts
436 
437   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
438     \textcolor{stringliteral}{"calculate\_density\_1d called with an unassociated EOS\_type EOS."})
439 
440   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dom)) \textcolor{keywordflow}{then}
441     is = dom(1) ; ie = dom(2) ; npts = 1 + ie - is
442   \textcolor{keywordflow}{else}
443     is = 1 ; ie = \textcolor{keyword}{size}(rho) ; npts = 1 + ie - is
444 \textcolor{keywordflow}{  endif}
445 
446   p\_scale = eos%RL2\_T2\_to\_Pa
447   \textcolor{keywordflow}{do} i=is,ie
448     pres(i) = p\_scale * pressure(i)
449 \textcolor{keywordflow}{  enddo}
450 
451   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
452     \textcolor{keywordflow}{case} (eos\_linear)
453       \textcolor{keyword}{call }calculate\_density\_linear(t, s, pres, rho, 1, npts, &
454                                     eos%Rho\_T0\_S0, eos%dRho\_dT, eos%dRho\_dS, rho\_ref)
455       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_linear(t, s, pres, d2rdss, d2rdst, &
456                                                   d2rdtt, d2rdsp, d2rdtp, 1, npts)
457     \textcolor{keywordflow}{case} (eos\_wright)
458       \textcolor{keyword}{call }calculate\_density\_wright(t, s, pres, rho, 1, npts, rho\_ref)
459       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_wright(t, s, pres, d2rdss, d2rdst, &
460                                                   d2rdtt, d2rdsp, d2rdtp, 1, npts)
461     \textcolor{keywordflow}{case} (eos\_teos10)
462       \textcolor{keyword}{call }calculate\_density\_teos10(t, s, pres, rho, 1, npts, rho\_ref)
463       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_teos10(t, s, pres, d2rdss, d2rdst, &
464                                                   d2rdtt, d2rdsp, d2rdtp, 1, npts)
465 \textcolor{keywordflow}{    case default}
466       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_stanley\_density\_scalar: EOS is not valid."})
467 \textcolor{keywordflow}{  end select}
468 
469   \textcolor{comment}{! Equation 25 of Stanley et al., 2020.}
470   \textcolor{keywordflow}{do} i=is,ie
471     rho(i) = rho(i) &
472              + ( 0.5 * d2rdtt(i) * tvar(i) + ( d2rdst(i) * tscov(i) + 0.5 * d2rdss(i) * svar(i) ) )
473 \textcolor{keywordflow}{  enddo}
474 
475   rho\_scale = eos%kg\_m3\_to\_R
476   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) rho\_scale = rho\_scale * scale
477   \textcolor{keywordflow}{if} (rho\_scale /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} i=is,ie
478     rho(i) = rho\_scale * rho(i)
479 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif}
480 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_a102df91898d116a6b4346f00dc818612}\label{namespacemom__eos_a102df91898d116a6b4346f00dc818612}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!calculate\+\_\+stanley\+\_\+density\+\_\+array@{calculate\+\_\+stanley\+\_\+density\+\_\+array}}
\index{calculate\+\_\+stanley\+\_\+density\+\_\+array@{calculate\+\_\+stanley\+\_\+density\+\_\+array}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{calculate\+\_\+stanley\+\_\+density\+\_\+array()}{calculate\_stanley\_density\_array()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calculate\+\_\+stanley\+\_\+density\+\_\+array (\begin{DoxyParamCaption}\item[{real, dimension(\+:), intent(in)}]{T,  }\item[{real, dimension(\+:), intent(in)}]{S,  }\item[{real, dimension(\+:), intent(in)}]{pressure,  }\item[{real, dimension(\+:), intent(in)}]{Tvar,  }\item[{real, dimension(\+:), intent(in)}]{T\+Scov,  }\item[{real, dimension(\+:), intent(in)}]{Svar,  }\item[{real, dimension(\+:), intent(inout)}]{rho,  }\item[{integer, intent(in)}]{start,  }\item[{integer, intent(in)}]{npts,  }\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS,  }\item[{real, intent(in), optional}]{rho\+\_\+ref,  }\item[{real, intent(in), optional}]{scale }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calls the appropriate subroutine to calculate the density of sea water for 1-\/D array inputs including the variance of T, S and covariance of T-\/S. The calculation uses only the second order correction in a series as discussed in Stanley et al., 2020. If rho\+\_\+ref is present, the anomaly with respect to rho\+\_\+ref is returned. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em t} & Potential temperature referenced to the surface \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em s} & Salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em pressure} & Pressure \mbox{[}Pa\mbox{]}\\
\hline
\mbox{\tt in}  & {\em tvar} & Variance of potential temperature referenced to the surface \mbox{[}deg\+C2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em tscov} & Covariance of potential temperature and salinity \mbox{[}degC ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em svar} & Variance of salinity \mbox{[}ppt2\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em rho} & Density (in-\/situ if pressure is local) \mbox{[}kg m-\/3\mbox{]}\\
\hline
\mbox{\tt in}  & {\em start} & Start index for computation\\
\hline
\mbox{\tt in}  & {\em npts} & Number of point to compute\\
\hline
 & {\em eos} & Equation of state structure\\
\hline
\mbox{\tt in}  & {\em rho\+\_\+ref} & A reference density \mbox{[}kg m-\/3\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em scale} & A multiplicative factor by which to scale density from kg m-\/3 to the desired units \mbox{[}R m3 kg-\/1\mbox{]} \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
306   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: t\textcolor{comment}{        !< Potential temperature referenced to the surface [degC]}
307   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: s\textcolor{comment}{        !< Salinity [ppt]}
308   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< Pressure [Pa]}
309   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: tvar\textcolor{comment}{     !< Variance of potential temperature referenced to the
       surface [degC2]}
310   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: tscov\textcolor{comment}{    !< Covariance of potential temperature and salinity [degC
       ppt]}
311   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: svar\textcolor{comment}{     !< Variance of salinity [ppt2]}
312   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: rho\textcolor{comment}{      !< Density (in-situ if pressure is local) [kg m-3]}
313   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: start\textcolor{comment}{    !< Start index for computation}
314   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: npts\textcolor{comment}{     !< Number of point to compute}
315   \textcolor{keywordtype}{type}(eos\_type),     \textcolor{keywordtype}{pointer}       :: eos\textcolor{comment}{      !< Equation of state structure}
316   \textcolor{keywordtype}{real},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: rho\_ref\textcolor{comment}{  !< A reference density [kg m-3].}
317   \textcolor{keywordtype}{real},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{    !< A multiplicative factor by which to scale density}
318 \textcolor{comment}{                                                !! from kg m-3 to the desired units [R m3 kg-1]}
319   \textcolor{comment}{! Local variables}
320   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(T))} :: d2rdtt, d2rdst, d2rdss, d2rdsp, d2rdtp \textcolor{comment}{! Second derivatives of density wrt
       T,S,p}
321   \textcolor{keywordtype}{integer} :: j
322 
323   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
324     \textcolor{stringliteral}{"calculate\_density\_array called with an unassociated EOS\_type EOS."})
325 
326   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
327     \textcolor{keywordflow}{case} (eos\_linear)
328       \textcolor{keyword}{call }calculate\_density\_linear(t, s, pressure, rho, start, npts, &
329                                     eos%Rho\_T0\_S0, eos%dRho\_dT, eos%dRho\_dS, rho\_ref)
330       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_linear(t, s, pressure, d2rdss, d2rdst, &
331                                                   d2rdtt, d2rdsp, d2rdtp, start, npts)
332     \textcolor{keywordflow}{case} (eos\_wright)
333       \textcolor{keyword}{call }calculate\_density\_wright(t, s, pressure, rho, start, npts, rho\_ref)
334       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_wright(t, s, pressure, d2rdss, d2rdst, &
335                                                   d2rdtt, d2rdsp, d2rdtp, start, npts)
336     \textcolor{keywordflow}{case} (eos\_teos10)
337       \textcolor{keyword}{call }calculate\_density\_teos10(t, s, pressure, rho, start, npts, rho\_ref)
338       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_teos10(t, s, pressure, d2rdss, d2rdst, &
339                                                   d2rdtt, d2rdsp, d2rdtp, start, npts)
340 \textcolor{keywordflow}{    case default}
341       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_stanley\_density\_array: EOS%form\_of\_EOS is not valid."})
342 \textcolor{keywordflow}{  end select}
343 
344   \textcolor{comment}{! Equation 25 of Stanley et al., 2020.}
345   \textcolor{keywordflow}{do} j=start,start+npts-1
346     rho(j) = rho(j) &
347              + ( 0.5 * d2rdtt(j) * tvar(j) + ( d2rdst(j) * tscov(j) + 0.5 * d2rdss(j) * svar(j) ) )
348 \textcolor{keywordflow}{  enddo}
349 
350   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (scale /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=start,start+npts-1
351     rho(j) = scale * rho(j)
352 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif} ;\textcolor{keywordflow}{ endif}
353 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_a66d40148737ef1a3b1ae44917c7fe0c3}\label{namespacemom__eos_a66d40148737ef1a3b1ae44917c7fe0c3}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!calculate\+\_\+stanley\+\_\+density\+\_\+scalar@{calculate\+\_\+stanley\+\_\+density\+\_\+scalar}}
\index{calculate\+\_\+stanley\+\_\+density\+\_\+scalar@{calculate\+\_\+stanley\+\_\+density\+\_\+scalar}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{calculate\+\_\+stanley\+\_\+density\+\_\+scalar()}{calculate\_stanley\_density\_scalar()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calculate\+\_\+stanley\+\_\+density\+\_\+scalar (\begin{DoxyParamCaption}\item[{real, intent(in)}]{T,  }\item[{real, intent(in)}]{S,  }\item[{real, intent(in)}]{pressure,  }\item[{real, intent(in)}]{Tvar,  }\item[{real, intent(in)}]{T\+Scov,  }\item[{real, intent(in)}]{Svar,  }\item[{real, intent(out)}]{rho,  }\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS,  }\item[{real, intent(in), optional}]{rho\+\_\+ref,  }\item[{real, intent(in), optional}]{scale }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calls the appropriate subroutine to calculate density of sea water for scalar inputs including the variance of T, S and covariance of T-\/S. The calculation uses only the second order correction in a series as discussed in Stanley et al., 2020. If rho\+\_\+ref is present, the anomaly with respect to rho\+\_\+ref is returned. The density can be rescaled using rho\+\_\+ref. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em t} & Potential temperature referenced to the surface \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em s} & Salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em tvar} & Variance of potential temperature referenced to the surface \mbox{[}deg\+C2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em tscov} & Covariance of potential temperature and salinity \mbox{[}degC ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em svar} & Variance of salinity \mbox{[}ppt2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em pressure} & Pressure \mbox{[}Pa\mbox{]}\\
\hline
\mbox{\tt out}  & {\em rho} & Density (in-\/situ if pressure is local) \mbox{[}kg m-\/3\mbox{]} or \mbox{[}R $\sim$$>$ kg m-\/3\mbox{]}\\
\hline
 & {\em eos} & Equation of state structure\\
\hline
\mbox{\tt in}  & {\em rho\+\_\+ref} & A reference density \mbox{[}kg m-\/3\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em scale} & A multiplicative factor by which to scale density from kg m-\/3 to the desired units \mbox{[}R m3 kg-\/1\mbox{]} \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
212   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: t\textcolor{comment}{        !< Potential temperature referenced to the surface [degC]}
213   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: s\textcolor{comment}{        !< Salinity [ppt]}
214   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: tvar\textcolor{comment}{     !< Variance of potential temperature referenced to the surface
       [degC2]}
215   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: tscov\textcolor{comment}{    !< Covariance of potential temperature and salinity [degC ppt]}
216   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: svar\textcolor{comment}{     !< Variance of salinity [ppt2]}
217   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: pressure\textcolor{comment}{ !< Pressure [Pa]}
218   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(out)} :: rho\textcolor{comment}{      !< Density (in-situ if pressure is local) [kg m-3] or [R ~> kg
       m-3]}
219   \textcolor{keywordtype}{type}(eos\_type), \textcolor{keywordtype}{pointer}     :: eos\textcolor{comment}{      !< Equation of state structure}
220   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: rho\_ref\textcolor{comment}{  !< A reference density [kg m-3].}
221   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: scale\textcolor{comment}{    !< A multiplicative factor by which to scale density}
222 \textcolor{comment}{                                          !! from kg m-3 to the desired units [R m3 kg-1]}
223   \textcolor{comment}{! Local variables}
224   \textcolor{keywordtype}{real} :: d2rdtt, d2rdst, d2rdss, d2rdsp, d2rdtp \textcolor{comment}{! Second derivatives of density wrt T,S,p}
225   \textcolor{keywordtype}{real} :: rho\_scale \textcolor{comment}{! A factor to convert density from kg m-3 to the desired units [R m3 kg-1 ~> 1]}
226   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
227 
228   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
229     \textcolor{stringliteral}{"calculate\_stanley\_density\_scalar called with an unassociated EOS\_type EOS."})
230 
231   p\_scale = eos%RL2\_T2\_to\_Pa
232 
233   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
234     \textcolor{keywordflow}{case} (eos\_linear)
235       \textcolor{keyword}{call }calculate\_density\_linear(t, s, p\_scale*pressure, rho, &
236                                     eos%Rho\_T0\_S0, eos%dRho\_dT, eos%dRho\_dS, rho\_ref)
237       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_linear(t, s, pressure, d2rdss, d2rdst, &
238                                                   d2rdtt, d2rdsp, d2rdtp)
239     \textcolor{keywordflow}{case} (eos\_wright)
240       \textcolor{keyword}{call }calculate\_density\_wright(t, s, p\_scale*pressure, rho, rho\_ref)
241       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_wright(t, s, pressure, d2rdss, d2rdst, &
242                                                   d2rdtt, d2rdsp, d2rdtp)
243     \textcolor{keywordflow}{case} (eos\_teos10)
244       \textcolor{keyword}{call }calculate\_density\_teos10(t, s, p\_scale*pressure, rho, rho\_ref)
245       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_teos10(t, s, pressure, d2rdss, d2rdst, &
246                                                   d2rdtt, d2rdsp, d2rdtp)
247 \textcolor{keywordflow}{    case default}
248       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_stanley\_density\_scalar: EOS is not valid."})
249 \textcolor{keywordflow}{  end select}
250 
251   \textcolor{comment}{! Equation 25 of Stanley et al., 2020.}
252   rho = rho + ( 0.5 * d2rdtt * tvar + ( d2rdst * tscov + 0.5 * d2rdss * svar ) )
253 
254   rho\_scale = eos%kg\_m3\_to\_R
255   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) rho\_scale = rho\_scale * scale
256   rho = rho\_scale * rho
257 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_ab9669ca4a2e4f3507be7efe047c18ab7}\label{namespacemom__eos_ab9669ca4a2e4f3507be7efe047c18ab7}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!calculate\+\_\+tfreeze\+\_\+array@{calculate\+\_\+tfreeze\+\_\+array}}
\index{calculate\+\_\+tfreeze\+\_\+array@{calculate\+\_\+tfreeze\+\_\+array}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{calculate\+\_\+tfreeze\+\_\+array()}{calculate\_tfreeze\_array()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calculate\+\_\+tfreeze\+\_\+array (\begin{DoxyParamCaption}\item[{real, dimension(\+:), intent(in)}]{S,  }\item[{real, dimension(\+:), intent(in)}]{pressure,  }\item[{real, dimension(\+:), intent(inout)}]{T\+\_\+fr,  }\item[{integer, intent(in)}]{start,  }\item[{integer, intent(in)}]{npts,  }\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS,  }\item[{real, intent(in), optional}]{pres\+\_\+scale }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calls the appropriate subroutine to calculate the freezing point for a 1-\/D array. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em s} & Salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em pressure} & Pressure \mbox{[}Pa\mbox{]} or \mbox{[}other\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em t\+\_\+fr} & Freezing point potential temperature referenced to the surface \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em start} & Starting index within the array\\
\hline
\mbox{\tt in}  & {\em npts} & The number of values to calculate\\
\hline
 & {\em eos} & Equation of state structure\\
\hline
\mbox{\tt in}  & {\em pres\+\_\+scale} & A multiplicative factor to convert pressure into Pa. \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
656   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: s\textcolor{comment}{        !< Salinity [ppt]}
657   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< Pressure [Pa] or [other]}
658   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: t\_fr\textcolor{comment}{     !< Freezing point potential temperature referenced}
659 \textcolor{comment}{                                                !! to the surface [degC]}
660   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: start\textcolor{comment}{    !< Starting index within the array}
661   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: npts\textcolor{comment}{     !< The number of values to calculate}
662   \textcolor{keywordtype}{type}(eos\_type),     \textcolor{keywordtype}{pointer}       :: eos\textcolor{comment}{      !< Equation of state structure}
663   \textcolor{keywordtype}{real},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: pres\_scale\textcolor{comment}{ !< A multiplicative factor to convert pressure into Pa.}
664 
665   \textcolor{comment}{! Local variables}
666   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(pressure))} :: pres  \textcolor{comment}{! Pressure converted to [Pa]}
667   \textcolor{keywordtype}{real} :: p\_scale \textcolor{comment}{! A factor to convert pressure to units of Pa.}
668   \textcolor{keywordtype}{integer} :: j
669 
670   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
671     \textcolor{stringliteral}{"calculate\_TFreeze\_scalar called with an unassociated EOS\_type EOS."})
672 
673   p\_scale = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(pres\_scale)) p\_scale = pres\_scale
674 
675   \textcolor{keywordflow}{if} (p\_scale == 1.0) \textcolor{keywordflow}{then}
676     \textcolor{keywordflow}{select case} (eos%form\_of\_TFreeze)
677       \textcolor{keywordflow}{case} (tfreeze\_linear)
678         \textcolor{keyword}{call }calculate\_tfreeze\_linear(s, pressure, t\_fr, start, npts, &
679                                       eos%TFr\_S0\_P0, eos%dTFr\_dS, eos%dTFr\_dp)
680       \textcolor{keywordflow}{case} (tfreeze\_millero)
681         \textcolor{keyword}{call }calculate\_tfreeze\_millero(s, pressure, t\_fr, start, npts)
682       \textcolor{keywordflow}{case} (tfreeze\_teos10)
683         \textcolor{keyword}{call }calculate\_tfreeze\_teos10(s, pressure, t\_fr, start, npts)
684 \textcolor{keywordflow}{      case default}
685         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_TFreeze\_scalar: form\_of\_TFreeze is not valid."})
686 \textcolor{keywordflow}{    end select}
687   \textcolor{keywordflow}{else}
688     \textcolor{keywordflow}{do} j=start,start+npts-1 ; pres(j) = p\_scale * pressure(j) ;\textcolor{keywordflow}{ enddo}
689     \textcolor{keywordflow}{select case} (eos%form\_of\_TFreeze)
690       \textcolor{keywordflow}{case} (tfreeze\_linear)
691         \textcolor{keyword}{call }calculate\_tfreeze\_linear(s, pres, t\_fr, start, npts, &
692                                       eos%TFr\_S0\_P0, eos%dTFr\_dS, eos%dTFr\_dp)
693       \textcolor{keywordflow}{case} (tfreeze\_millero)
694         \textcolor{keyword}{call }calculate\_tfreeze\_millero(s, pres, t\_fr, start, npts)
695       \textcolor{keywordflow}{case} (tfreeze\_teos10)
696         \textcolor{keyword}{call }calculate\_tfreeze\_teos10(s, pres, t\_fr, start, npts)
697 \textcolor{keywordflow}{      case default}
698         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_TFreeze\_scalar: form\_of\_TFreeze is not valid."})
699 \textcolor{keywordflow}{    end select}
700 \textcolor{keywordflow}{  endif}
701 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_ad46af8402aba49dbdd73817d33e83270}\label{namespacemom__eos_ad46af8402aba49dbdd73817d33e83270}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!calculate\+\_\+tfreeze\+\_\+scalar@{calculate\+\_\+tfreeze\+\_\+scalar}}
\index{calculate\+\_\+tfreeze\+\_\+scalar@{calculate\+\_\+tfreeze\+\_\+scalar}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{calculate\+\_\+tfreeze\+\_\+scalar()}{calculate\_tfreeze\_scalar()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calculate\+\_\+tfreeze\+\_\+scalar (\begin{DoxyParamCaption}\item[{real, intent(in)}]{S,  }\item[{real, intent(in)}]{pressure,  }\item[{real, intent(out)}]{T\+\_\+fr,  }\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS,  }\item[{real, intent(in), optional}]{pres\+\_\+scale }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calls the appropriate subroutine to calculate the freezing point for scalar inputs. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em s} & Salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em pressure} & Pressure \mbox{[}Pa\mbox{]} or \mbox{[}other\mbox{]}\\
\hline
\mbox{\tt out}  & {\em t\+\_\+fr} & Freezing point potential temperature referenced to the surface \mbox{[}degC\mbox{]}\\
\hline
 & {\em eos} & Equation of state structure\\
\hline
\mbox{\tt in}  & {\em pres\+\_\+scale} & A multiplicative factor to convert pressure into Pa \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
625   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: s\textcolor{comment}{ !< Salinity [ppt]}
626   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: pressure\textcolor{comment}{ !< Pressure [Pa] or [other]}
627   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(out)} :: t\_fr\textcolor{comment}{ !< Freezing point potential temperature referenced}
628 \textcolor{comment}{                                      !! to the surface [degC]}
629   \textcolor{keywordtype}{type}(eos\_type), \textcolor{keywordtype}{pointer}     :: eos\textcolor{comment}{ !< Equation of state structure}
630   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: pres\_scale\textcolor{comment}{ !< A multiplicative factor to convert pressure into Pa}
631 
632   \textcolor{comment}{! Local variables}
633   \textcolor{keywordtype}{real} :: p\_scale \textcolor{comment}{! A factor to convert pressure to units of Pa.}
634 
635   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
636     \textcolor{stringliteral}{"calculate\_TFreeze\_scalar called with an unassociated EOS\_type EOS."})
637 
638   p\_scale = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(pres\_scale)) p\_scale = pres\_scale
639 
640   \textcolor{keywordflow}{select case} (eos%form\_of\_TFreeze)
641     \textcolor{keywordflow}{case} (tfreeze\_linear)
642       \textcolor{keyword}{call }calculate\_tfreeze\_linear(s, p\_scale*pressure, t\_fr, eos%TFr\_S0\_P0, &
643                                     eos%dTFr\_dS, eos%dTFr\_dp)
644     \textcolor{keywordflow}{case} (tfreeze\_millero)
645       \textcolor{keyword}{call }calculate\_tfreeze\_millero(s, p\_scale*pressure, t\_fr)
646     \textcolor{keywordflow}{case} (tfreeze\_teos10)
647       \textcolor{keyword}{call }calculate\_tfreeze\_teos10(s, p\_scale*pressure, t\_fr)
648 \textcolor{keywordflow}{    case default}
649       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_TFreeze\_scalar: form\_of\_TFreeze is not valid."})
650 \textcolor{keywordflow}{  end select}
651 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_a5b1ff89023e9d7da4074c7c1a71c9a85}\label{namespacemom__eos_a5b1ff89023e9d7da4074c7c1a71c9a85}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!convert\+\_\+temp\+\_\+salt\+\_\+for\+\_\+teos10@{convert\+\_\+temp\+\_\+salt\+\_\+for\+\_\+teos10}}
\index{convert\+\_\+temp\+\_\+salt\+\_\+for\+\_\+teos10@{convert\+\_\+temp\+\_\+salt\+\_\+for\+\_\+teos10}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{convert\+\_\+temp\+\_\+salt\+\_\+for\+\_\+teos10()}{convert\_temp\_salt\_for\_teos10()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+eos\+::convert\+\_\+temp\+\_\+salt\+\_\+for\+\_\+teos10 (\begin{DoxyParamCaption}\item[{real, dimension(hi\%isd\+:hi\%ied,hi\%jsd\+:hi\%jed,kd), intent(inout)}]{T,  }\item[{real, dimension(hi\%isd\+:hi\%ied,hi\%jsd\+:hi\%jed,kd), intent(inout)}]{S,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in)}]{HI,  }\item[{integer, intent(in)}]{kd,  }\item[{real, dimension(hi\%isd\+:hi\%ied,hi\%jsd\+:hi\%jed,kd), intent(in)}]{mask\+\_\+z,  }\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS }\end{DoxyParamCaption})}



Convert T\&S to Absolute Salinity and Conservative Temperature if using T\+E\+O\+S10. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em kd} & The number of layers to work on\\
\hline
\mbox{\tt in}  & {\em hi} & The horizontal index structure\\
\hline
\mbox{\tt in,out}  & {\em t} & Potential temperature referenced to the surface \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em s} & Salinity \mbox{[}ppt\mbox{]}\\
\hline
\mbox{\tt in}  & {\em mask\+\_\+z} & 3d mask regulating which points to convert.\\
\hline
 & {\em eos} & Equation of state structure \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
1532   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}    :: kd\textcolor{comment}{  !< The number of layers to work on}
1533   \textcolor{keywordtype}{type}(hor\_index\_type),  \textcolor{keywordtype}{intent(in)}    :: hi\textcolor{comment}{       !< The horizontal index structure}
1534   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed,kd)}, &
1535                          \textcolor{keywordtype}{intent(inout)} :: t\textcolor{comment}{   !< Potential temperature referenced to the surface [degC]}
1536   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed,kd)}, &
1537                          \textcolor{keywordtype}{intent(inout)} :: s\textcolor{comment}{   !< Salinity [ppt]}
1538   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed,kd)}, &
1539                          \textcolor{keywordtype}{intent(in)}    :: mask\_z\textcolor{comment}{ !< 3d mask regulating which points to convert.}
1540   \textcolor{keywordtype}{type}(eos\_type),        \textcolor{keywordtype}{pointer}       :: eos\textcolor{comment}{ !< Equation of state structure}
1541 
1542   \textcolor{keywordtype}{integer} :: i, j, k
1543   \textcolor{keywordtype}{real} :: gsw\_sr\_from\_sp, gsw\_ct\_from\_pt, gsw\_sa\_from\_sp
1544   \textcolor{keywordtype}{real} :: p
1545 
1546   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
1547     \textcolor{stringliteral}{"convert\_temp\_salt\_to\_TEOS10 called with an unassociated EOS\_type EOS."})
1548 
1549   \textcolor{keywordflow}{if} ((eos%form\_of\_EOS /= eos\_teos10) .and. (eos%form\_of\_EOS /= eos\_nemo)) \textcolor{keywordflow}{return}
1550 
1551   \textcolor{keywordflow}{do} k=1,kd ; \textcolor{keywordflow}{do} j=hi%jsc,hi%jec ; \textcolor{keywordflow}{do} i=hi%isc,hi%iec
1552     \textcolor{keywordflow}{if} (mask\_z(i,j,k) >= 1.0) \textcolor{keywordflow}{then}
1553      s(i,j,k) = gsw\_sr\_from\_sp(s(i,j,k))
1554 \textcolor{comment}{!     Get absolute salinity from practical salinity, converting pressures from Pascal to dbar.}
1555 \textcolor{comment}{!     If this option is activated, pressure will need to be added as an argument, and it should be}
1556 \textcolor{comment}{!     moved out into module that is not shared between components, where the ocean\_grid can be used.}
1557 \textcolor{comment}{!     S(i,j,k) = gsw\_sa\_from\_sp(S(i,j,k),pres(i,j,k)*1.0e-4,G%geoLonT(i,j),G%geoLatT(i,j))}
1558      t(i,j,k) = gsw\_ct\_from\_pt(s(i,j,k), t(i,j,k))
1559 \textcolor{keywordflow}{    endif}
1560 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_a1108fb5de7a69d01746df3995f7e3f0d}\label{namespacemom__eos_a1108fb5de7a69d01746df3995f7e3f0d}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!eos\+\_\+allocate@{eos\+\_\+allocate}}
\index{eos\+\_\+allocate@{eos\+\_\+allocate}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{eos\+\_\+allocate()}{eos\_allocate()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+eos\+::eos\+\_\+allocate (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS }\end{DoxyParamCaption})}



Allocates E\+O\+S\+\_\+type. 


\begin{DoxyParams}{Parameters}
{\em eos} & Equation of state structure \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
1491   \textcolor{keywordtype}{type}(eos\_type), \textcolor{keywordtype}{pointer} :: eos\textcolor{comment}{ !< Equation of state structure}
1492 
1493   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{allocate}(eos)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_a782d326108e390902e520efc078e8296}\label{namespacemom__eos_a782d326108e390902e520efc078e8296}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!eos\+\_\+domain@{eos\+\_\+domain}}
\index{eos\+\_\+domain@{eos\+\_\+domain}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{eos\+\_\+domain()}{eos\_domain()}}
{\footnotesize\ttfamily integer function, dimension(2), public mom\+\_\+eos\+::eos\+\_\+domain (\begin{DoxyParamCaption}\item[{type(hor\+\_\+index\+\_\+type), intent(in)}]{HI,  }\item[{integer, intent(in), optional}]{halo }\end{DoxyParamCaption})}



This subroutine returns a two point integer array indicating the domain of i-\/indices to work on in E\+OS calls based on information from a hor\+\_\+index type. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em hi} & The horizontal index structure\\
\hline
\mbox{\tt in}  & {\em halo} & The halo size to work on; missing is equivalent to 0.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The index domain that the E\+OS will work on, taking into account that the arrays inside the E\+OS routines will start at 1. 
\end{DoxyReturn}


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


\begin{DoxyCode}
1163   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)}  :: hi\textcolor{comment}{    !< The horizontal index structure}
1164   \textcolor{keywordtype}{integer},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: halo\textcolor{comment}{  !< The halo size to work on; missing is equivalent to 0.}
1165   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)} :: eosdom\textcolor{comment}{   !< The index domain that the EOS will work on, taking into account}
1166 \textcolor{comment}{                                    !! that the arrays inside the EOS routines will start at 1.}
1167 
1168   \textcolor{comment}{! Local variables}
1169   \textcolor{keywordtype}{integer} :: halo\_sz
1170 
1171   halo\_sz = 0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(halo)) halo\_sz = halo
1172 
1173   eosdom(1) = hi%isc - (hi%isd-1) - halo\_sz
1174   eosdom(2) = hi%iec - (hi%isd-1) + halo\_sz
1175 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_acab6a23bef0a98f15f0a479bdd1ec63c}\label{namespacemom__eos_acab6a23bef0a98f15f0a479bdd1ec63c}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!eos\+\_\+end@{eos\+\_\+end}}
\index{eos\+\_\+end@{eos\+\_\+end}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{eos\+\_\+end()}{eos\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+eos\+::eos\+\_\+end (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS }\end{DoxyParamCaption})}



Deallocates E\+O\+S\+\_\+type. 


\begin{DoxyParams}{Parameters}
{\em eos} & Equation of state structure \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
1498   \textcolor{keywordtype}{type}(eos\_type), \textcolor{keywordtype}{pointer} :: eos\textcolor{comment}{ !< Equation of state structure}
1499 
1500   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{deallocate}(eos)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_a3ab220b9c98dac3b8f6b7c1606b811cf}\label{namespacemom__eos_a3ab220b9c98dac3b8f6b7c1606b811cf}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!eos\+\_\+init@{eos\+\_\+init}}
\index{eos\+\_\+init@{eos\+\_\+init}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{eos\+\_\+init()}{eos\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+eos\+::eos\+\_\+init (\begin{DoxyParamCaption}\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in), optional}]{US }\end{DoxyParamCaption})}



Initializes E\+O\+S\+\_\+type by allocating and reading parameters. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em param\+\_\+file} & Parameter file structure\\
\hline
 & {\em eos} & Equation of state structure\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
1349   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< Parameter file structure}
1350   \textcolor{keywordtype}{type}(eos\_type),        \textcolor{keywordtype}{pointer}    :: eos\textcolor{comment}{ !< Equation of state structure}
1351   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)} :: us\textcolor{comment}{  !< A dimensional unit scaling type}
1352   \textcolor{keywordtype}{optional} :: us
1353   \textcolor{comment}{! Local variables}
1354 \textcolor{preprocessor}{#include "version\_variable.h"}
1355 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_EOS"} \textcolor{comment}{! This module's name.}
1356   \textcolor{keywordtype}{character(len=40)}  :: tmpstr
1357 
1358   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }eos\_allocate(eos)
1359 
1360   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}
1361   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})
1362 
1363   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EQN\_OF\_STATE"}, tmpstr, &
1364                  \textcolor{stringliteral}{"EQN\_OF\_STATE determines which ocean equation of state "}//&
1365                  \textcolor{stringliteral}{"should be used.  Currently, the valid choices are "}//&
1366                  \textcolor{stringliteral}{'"LINEAR", "UNESCO", "WRIGHT", "NEMO" and "TEOS10". '}//&
1367                  \textcolor{stringliteral}{"This is only used if USE\_EOS is true."}, default=eos\_default)
1368   \textcolor{keywordflow}{select case} (uppercase(tmpstr))
1369     \textcolor{keywordflow}{case} (eos\_linear\_string)
1370       eos%form\_of\_EOS = eos\_linear
1371     \textcolor{keywordflow}{case} (eos\_unesco\_string)
1372       eos%form\_of\_EOS = eos\_unesco
1373     \textcolor{keywordflow}{case} (eos\_wright\_string)
1374       eos%form\_of\_EOS = eos\_wright
1375     \textcolor{keywordflow}{case} (eos\_teos10\_string)
1376       eos%form\_of\_EOS = eos\_teos10
1377     \textcolor{keywordflow}{case} (eos\_nemo\_string)
1378       eos%form\_of\_EOS = eos\_nemo
1379 \textcolor{keywordflow}{    case default}
1380       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"interpret\_eos\_selection: EQN\_OF\_STATE "}//&
1381                               trim(tmpstr) // \textcolor{stringliteral}{"in input file is invalid."})
1382 \textcolor{keywordflow}{  end select}
1383   \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{'interpret\_eos\_selection: equation of state set to "'} // &
1384                 trim(tmpstr)//\textcolor{stringliteral}{'"'}, 5)
1385 
1386   \textcolor{keywordflow}{if} (eos%form\_of\_EOS == eos\_linear) \textcolor{keywordflow}{then}
1387     eos%Compressible = .false.
1388     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RHO\_T0\_S0"}, eos%Rho\_T0\_S0, &
1389                  \textcolor{stringliteral}{"When EQN\_OF\_STATE="}//trim(eos\_linear\_string)//\textcolor{stringliteral}{", "}//&
1390                  \textcolor{stringliteral}{"this is the density at T=0, S=0."}, units=\textcolor{stringliteral}{"kg m-3"}, &
1391                  default=1000.0)
1392     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DRHO\_DT"}, eos%dRho\_dT, &
1393                  \textcolor{stringliteral}{"When EQN\_OF\_STATE="}//trim(eos\_linear\_string)//\textcolor{stringliteral}{", "}//&
1394                  \textcolor{stringliteral}{"this is the partial derivative of density with "}//&
1395                  \textcolor{stringliteral}{"temperature."}, units=\textcolor{stringliteral}{"kg m-3 K-1"}, default=-0.2)
1396     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DRHO\_DS"}, eos%dRho\_dS, &
1397                  \textcolor{stringliteral}{"When EQN\_OF\_STATE="}//trim(eos\_linear\_string)//\textcolor{stringliteral}{", "}//&
1398                  \textcolor{stringliteral}{"this is the partial derivative of density with "}//&
1399                  \textcolor{stringliteral}{"salinity."}, units=\textcolor{stringliteral}{"kg m-3 PSU-1"}, default=0.8)
1400 \textcolor{keywordflow}{  endif}
1401 
1402   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EOS\_QUADRATURE"}, eos%EOS\_quadrature, &
1403                  \textcolor{stringliteral}{"If true, always use the generic (quadrature) code "}//&
1404                  \textcolor{stringliteral}{"code for the integrals of density."}, default=.false.)
1405 
1406   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TFREEZE\_FORM"}, tmpstr, &
1407                  \textcolor{stringliteral}{"TFREEZE\_FORM determines which expression should be "}//&
1408                  \textcolor{stringliteral}{"used for the freezing point.  Currently, the valid "}//&
1409                  \textcolor{stringliteral}{'choices are "LINEAR", "MILLERO\_78", "TEOS10"'}, &
1410                  default=tfreeze\_default)
1411   \textcolor{keywordflow}{select case} (uppercase(tmpstr))
1412     \textcolor{keywordflow}{case} (tfreeze\_linear\_string)
1413       eos%form\_of\_TFreeze = tfreeze\_linear
1414     \textcolor{keywordflow}{case} (tfreeze\_millero\_string)
1415       eos%form\_of\_TFreeze = tfreeze\_millero
1416     \textcolor{keywordflow}{case} (tfreeze\_teos10\_string)
1417       eos%form\_of\_TFreeze = tfreeze\_teos10
1418 \textcolor{keywordflow}{    case default}
1419       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"interpret\_eos\_selection:  TFREEZE\_FORM "}//&
1420                               trim(tmpstr) // \textcolor{stringliteral}{"in input file is invalid."})
1421 \textcolor{keywordflow}{  end select}
1422 
1423   \textcolor{keywordflow}{if} (eos%form\_of\_TFreeze == tfreeze\_linear) \textcolor{keywordflow}{then}
1424     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TFREEZE\_S0\_P0"},eos%TFr\_S0\_P0, &
1425                  \textcolor{stringliteral}{"When TFREEZE\_FORM="}//trim(tfreeze\_linear\_string)//\textcolor{stringliteral}{", "}//&
1426                  \textcolor{stringliteral}{"this is the freezing potential temperature at "}//&
1427                  \textcolor{stringliteral}{"S=0, P=0."}, units=\textcolor{stringliteral}{"deg C"}, default=0.0)
1428     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DTFREEZE\_DS"},eos%dTFr\_dS, &
1429                  \textcolor{stringliteral}{"When TFREEZE\_FORM="}//trim(tfreeze\_linear\_string)//\textcolor{stringliteral}{", "}//&
1430                  \textcolor{stringliteral}{"this is the derivative of the freezing potential "}//&
1431                  \textcolor{stringliteral}{"temperature with salinity."}, &
1432                  units=\textcolor{stringliteral}{"deg C PSU-1"}, default=-0.054)
1433     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DTFREEZE\_DP"},eos%dTFr\_dP, &
1434                  \textcolor{stringliteral}{"When TFREEZE\_FORM="}//trim(tfreeze\_linear\_string)//\textcolor{stringliteral}{", "}//&
1435                  \textcolor{stringliteral}{"this is the derivative of the freezing potential "}//&
1436                  \textcolor{stringliteral}{"temperature with pressure."}, &
1437                  units=\textcolor{stringliteral}{"deg C Pa-1"}, default=0.0)
1438 \textcolor{keywordflow}{  endif}
1439 
1440   \textcolor{keywordflow}{if} ((eos%form\_of\_EOS == eos\_teos10 .OR. eos%form\_of\_EOS == eos\_nemo) .AND. &
1441       eos%form\_of\_TFreeze /= tfreeze\_teos10) \textcolor{keywordflow}{then}
1442       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"interpret\_eos\_selection:  EOS\_TEOS10 or EOS\_NEMO \(\backslash\)n"} //&
1443       \textcolor{stringliteral}{"should only be used along with TFREEZE\_FORM = TFREEZE\_TEOS10 ."})
1444 \textcolor{keywordflow}{  endif}
1445 
1446   \textcolor{comment}{! Unit conversions}
1447   eos%m\_to\_Z = 1. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) eos%m\_to\_Z = us%m\_to\_Z
1448   eos%kg\_m3\_to\_R = 1. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) eos%kg\_m3\_to\_R = us%kg\_m3\_to\_R
1449   eos%R\_to\_kg\_m3 = 1. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) eos%R\_to\_kg\_m3 = us%R\_to\_kg\_m3
1450   eos%RL2\_T2\_to\_Pa = 1. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) eos%RL2\_T2\_to\_Pa = us%RL2\_T2\_to\_Pa
1451   eos%L\_T\_to\_m\_s = 1. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) eos%L\_T\_to\_m\_s = us%L\_T\_to\_m\_s
1452 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_a949f5bb0744c827bf11cca01316ceed4}\label{namespacemom__eos_a949f5bb0744c827bf11cca01316ceed4}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!eos\+\_\+manual\+\_\+init@{eos\+\_\+manual\+\_\+init}}
\index{eos\+\_\+manual\+\_\+init@{eos\+\_\+manual\+\_\+init}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{eos\+\_\+manual\+\_\+init()}{eos\_manual\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+eos\+::eos\+\_\+manual\+\_\+init (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS,  }\item[{integer, intent(in), optional}]{form\+\_\+of\+\_\+\+E\+OS,  }\item[{integer, intent(in), optional}]{form\+\_\+of\+\_\+\+T\+Freeze,  }\item[{logical, intent(in), optional}]{E\+O\+S\+\_\+quadrature,  }\item[{logical, intent(in), optional}]{Compressible,  }\item[{real, intent(in), optional}]{Rho\+\_\+\+T0\+\_\+\+S0,  }\item[{real, intent(in), optional}]{drho\+\_\+dT,  }\item[{real, intent(in), optional}]{d\+Rho\+\_\+dS,  }\item[{real, intent(in), optional}]{T\+Fr\+\_\+\+S0\+\_\+\+P0,  }\item[{real, intent(in), optional}]{d\+T\+Fr\+\_\+dS,  }\item[{real, intent(in), optional}]{d\+T\+Fr\+\_\+dp }\end{DoxyParamCaption})}



Manually initialized an E\+OS type (intended for unit testing of routines which need a specific E\+OS) 


\begin{DoxyParams}[1]{Parameters}
 & {\em eos} & Equation of state structure\\
\hline
\mbox{\tt in}  & {\em form\+\_\+of\+\_\+eos} & A coded integer indicating the equation of state to use.\\
\hline
\mbox{\tt in}  & {\em form\+\_\+of\+\_\+tfreeze} & A coded integer indicating the expression for the potential temperature of the freezing point.\\
\hline
\mbox{\tt in}  & {\em eos\+\_\+quadrature} & If true, always use the generic (quadrature) code for the integrals of density.\\
\hline
\mbox{\tt in}  & {\em compressible} & If true, in situ density is a function of pressure.\\
\hline
\mbox{\tt in}  & {\em rho\+\_\+t0\+\_\+s0} & Density at T=0 degC and S=0 ppt \mbox{[}kg m-\/3\mbox{]}\\
\hline
\mbox{\tt in}  & {\em drho\+\_\+dt} & Partial derivative of density with temperature in \mbox{[}kg m-\/3 deg\+C-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em drho\+\_\+ds} & Partial derivative of density with salinity in \mbox{[}kg m-\/3 ppt-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em tfr\+\_\+s0\+\_\+p0} & The freezing potential temperature at S=0, P=0 \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt in}  & {\em dtfr\+\_\+ds} & The derivative of freezing point with salinity in \mbox{[}degC ppt-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em dtfr\+\_\+dp} & The derivative of freezing point with pressure in \mbox{[}degC Pa-\/1\mbox{]} \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
1458   \textcolor{keywordtype}{type}(eos\_type),    \textcolor{keywordtype}{pointer}    :: eos\textcolor{comment}{ !< Equation of state structure}
1459   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: form\_of\_eos\textcolor{comment}{ !< A coded integer indicating the equation of state to use.}
1460   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: form\_of\_tfreeze\textcolor{comment}{ !< A coded integer indicating the expression for}
1461 \textcolor{comment}{                                       !! the potential temperature of the freezing point.}
1462   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: eos\_quadrature\textcolor{comment}{ !< If true, always use the generic (quadrature)}
1463 \textcolor{comment}{                                       !! code for the integrals of density.}
1464   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: compressible\textcolor{comment}{  !< If true, in situ density is a function of pressure.}
1465   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: rho\_t0\_s0\textcolor{comment}{ !< Density at T=0 degC and S=0 ppt [kg m-3]}
1466   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: drho\_dt\textcolor{comment}{   !< Partial derivative of density with temperature}
1467 \textcolor{comment}{                                             !! in [kg m-3 degC-1]}
1468   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: drho\_ds\textcolor{comment}{   !< Partial derivative of density with salinity}
1469 \textcolor{comment}{                                             !! in [kg m-3 ppt-1]}
1470   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: tfr\_s0\_p0\textcolor{comment}{ !< The freezing potential temperature at S=0, P=0 [degC]}
1471   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: dtfr\_ds\textcolor{comment}{   !< The derivative of freezing point with salinity}
1472 \textcolor{comment}{                                             !! in [degC ppt-1]}
1473   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: dtfr\_dp\textcolor{comment}{   !< The derivative of freezing point with pressure}
1474 \textcolor{comment}{                                             !! in [degC Pa-1]}
1475 
1476   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(form\_of\_eos    ))  eos%form\_of\_EOS     = form\_of\_eos
1477   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(form\_of\_tfreeze))  eos%form\_of\_TFreeze = form\_of\_tfreeze
1478   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(eos\_quadrature ))  eos%EOS\_quadrature  = eos\_quadrature
1479   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(compressible   ))  eos%Compressible    = compressible
1480   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(rho\_t0\_s0      ))  eos%Rho\_T0\_S0       = rho\_t0\_s0
1481   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(drho\_dt        ))  eos%drho\_dT         = drho\_dt
1482   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(drho\_ds        ))  eos%dRho\_dS         = drho\_ds
1483   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(tfr\_s0\_p0      ))  eos%TFr\_S0\_P0       = tfr\_s0\_p0
1484   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dtfr\_ds        ))  eos%dTFr\_dS         = dtfr\_ds
1485   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dtfr\_dp        ))  eos%dTFr\_dp         = dtfr\_dp
1486 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_aad531f2540628368c33198bb31d51201}\label{namespacemom__eos_aad531f2540628368c33198bb31d51201}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!eos\+\_\+quadrature@{eos\+\_\+quadrature}}
\index{eos\+\_\+quadrature@{eos\+\_\+quadrature}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{eos\+\_\+quadrature()}{eos\_quadrature()}}
{\footnotesize\ttfamily logical function, public mom\+\_\+eos\+::eos\+\_\+quadrature (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS }\end{DoxyParamCaption})}



Return value of E\+O\+S\+\_\+quadrature. 


\begin{DoxyParams}{Parameters}
{\em eos} & Equation of state structure \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
1565   \textcolor{keywordtype}{type}(eos\_type),    \textcolor{keywordtype}{pointer}     :: eos\textcolor{comment}{ !< Equation of state structure}
1566 
1567   eos\_quadrature  = eos%EOS\_quadrature
1568 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_ae608600501a98f8f317d8f27a054327e}\label{namespacemom__eos_ae608600501a98f8f317d8f27a054327e}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!eos\+\_\+use\+\_\+linear@{eos\+\_\+use\+\_\+linear}}
\index{eos\+\_\+use\+\_\+linear@{eos\+\_\+use\+\_\+linear}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{eos\+\_\+use\+\_\+linear()}{eos\_use\_linear()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+eos\+::eos\+\_\+use\+\_\+linear (\begin{DoxyParamCaption}\item[{real, intent(in)}]{Rho\+\_\+\+T0\+\_\+\+S0,  }\item[{real, intent(in)}]{d\+Rho\+\_\+dT,  }\item[{real, intent(in)}]{d\+Rho\+\_\+dS,  }\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS,  }\item[{logical, intent(in), optional}]{use\+\_\+quadrature }\end{DoxyParamCaption})}



Set equation of state structure (E\+OS) to linear with given coefficients. 

\begin{DoxyNote}{Note}
This routine is primarily for testing and allows a local copy of the E\+O\+S\+\_\+type (E\+OS argument) to be set to use the linear equation of state independent from the rest of the model.
\end{DoxyNote}

\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em rho\+\_\+t0\+\_\+s0} & Density at T=0 degC and S=0 ppt \mbox{[}kg m-\/3\mbox{]}\\
\hline
\mbox{\tt in}  & {\em drho\+\_\+dt} & Partial derivative of density with temperature \mbox{[}kg m-\/3 deg\+C-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em drho\+\_\+ds} & Partial derivative of density with salinity \mbox{[}kg m-\/3 ppt-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em use\+\_\+quadrature} & If true, always use the generic (quadrature) code for the integrals of density.\\
\hline
 & {\em eos} & Equation of state structure \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
1509   \textcolor{keywordtype}{real},              \textcolor{keywordtype}{intent(in)} :: rho\_t0\_s0\textcolor{comment}{ !< Density at T=0 degC and S=0 ppt [kg m-3]}
1510   \textcolor{keywordtype}{real},              \textcolor{keywordtype}{intent(in)} :: drho\_dt\textcolor{comment}{   !< Partial derivative of density with temperature [kg m-3
       degC-1]}
1511   \textcolor{keywordtype}{real},              \textcolor{keywordtype}{intent(in)} :: drho\_ds\textcolor{comment}{   !< Partial derivative of density with salinity [kg m-3 ppt-1]}
1512   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: use\_quadrature\textcolor{comment}{ !< If true, always use the generic (quadrature)}
1513 \textcolor{comment}{                                             !! code for the integrals of density.}
1514   \textcolor{keywordtype}{type}(eos\_type),    \textcolor{keywordtype}{pointer}    :: eos\textcolor{comment}{       !< Equation of state structure}
1515 
1516   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
1517     \textcolor{stringliteral}{"MOM\_EOS.F90: EOS\_use\_linear() called with an unassociated EOS\_type EOS."})
1518 
1519   eos%form\_of\_EOS = eos\_linear
1520   eos%Compressible = .false.
1521   eos%Rho\_T0\_S0 = rho\_t0\_s0
1522   eos%dRho\_dT = drho\_dt
1523   eos%dRho\_dS = drho\_ds
1524   eos%EOS\_quadrature = .false.
1525   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(use\_quadrature)) eos%EOS\_quadrature = use\_quadrature
1526 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_a5e15d4f5b758ab149421c33145b0444c}\label{namespacemom__eos_a5e15d4f5b758ab149421c33145b0444c}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!extract\+\_\+member\+\_\+eos@{extract\+\_\+member\+\_\+eos}}
\index{extract\+\_\+member\+\_\+eos@{extract\+\_\+member\+\_\+eos}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{extract\+\_\+member\+\_\+eos()}{extract\_member\_eos()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+eos\+::extract\+\_\+member\+\_\+eos (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS,  }\item[{integer, intent(out), optional}]{form\+\_\+of\+\_\+\+E\+OS,  }\item[{integer, intent(out), optional}]{form\+\_\+of\+\_\+\+T\+Freeze,  }\item[{logical, intent(out), optional}]{E\+O\+S\+\_\+quadrature,  }\item[{logical, intent(out), optional}]{Compressible,  }\item[{real, intent(out), optional}]{Rho\+\_\+\+T0\+\_\+\+S0,  }\item[{real, intent(out), optional}]{drho\+\_\+dT,  }\item[{real, intent(out), optional}]{d\+Rho\+\_\+dS,  }\item[{real, intent(out), optional}]{T\+Fr\+\_\+\+S0\+\_\+\+P0,  }\item[{real, intent(out), optional}]{d\+T\+Fr\+\_\+dS,  }\item[{real, intent(out), optional}]{d\+T\+Fr\+\_\+dp }\end{DoxyParamCaption})}



Extractor routine for the E\+OS type if the members need to be accessed outside this module. 


\begin{DoxyParams}[1]{Parameters}
 & {\em eos} & Equation of state structure\\
\hline
\mbox{\tt out}  & {\em form\+\_\+of\+\_\+eos} & A coded integer indicating the equation of state to use.\\
\hline
\mbox{\tt out}  & {\em form\+\_\+of\+\_\+tfreeze} & A coded integer indicating the expression for the potential temperature of the freezing point.\\
\hline
\mbox{\tt out}  & {\em eos\+\_\+quadrature} & If true, always use the generic (quadrature) code for the integrals of density.\\
\hline
\mbox{\tt out}  & {\em compressible} & If true, in situ density is a function of pressure.\\
\hline
\mbox{\tt out}  & {\em rho\+\_\+t0\+\_\+s0} & Density at T=0 degC and S=0 ppt \mbox{[}kg m-\/3\mbox{]}\\
\hline
\mbox{\tt out}  & {\em drho\+\_\+dt} & Partial derivative of density with temperature in \mbox{[}kg m-\/3 deg\+C-\/1\mbox{]}\\
\hline
\mbox{\tt out}  & {\em drho\+\_\+ds} & Partial derivative of density with salinity in \mbox{[}kg m-\/3 ppt-\/1\mbox{]}\\
\hline
\mbox{\tt out}  & {\em tfr\+\_\+s0\+\_\+p0} & The freezing potential temperature at S=0, P=0 \mbox{[}degC\mbox{]}\\
\hline
\mbox{\tt out}  & {\em dtfr\+\_\+ds} & The derivative of freezing point with salinity \mbox{[}degC P\+S\+U-\/1\mbox{]}\\
\hline
\mbox{\tt out}  & {\em dtfr\+\_\+dp} & The derivative of freezing point with pressure \mbox{[}degC Pa-\/1\mbox{]} \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
1574   \textcolor{keywordtype}{type}(eos\_type),    \textcolor{keywordtype}{pointer}     :: eos\textcolor{comment}{ !< Equation of state structure}
1575   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: form\_of\_eos\textcolor{comment}{ !< A coded integer indicating the equation of state to use.}
1576   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: form\_of\_tfreeze\textcolor{comment}{ !< A coded integer indicating the expression for}
1577 \textcolor{comment}{                                       !! the potential temperature of the freezing point.}
1578   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: eos\_quadrature\textcolor{comment}{ !< If true, always use the generic (quadrature)}
1579 \textcolor{comment}{                                       !! code for the integrals of density.}
1580   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: compressible\textcolor{comment}{ !< If true, in situ density is a function of pressure.}
1581   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: rho\_t0\_s0\textcolor{comment}{ !< Density at T=0 degC and S=0 ppt [kg m-3]}
1582   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: drho\_dt\textcolor{comment}{   !< Partial derivative of density with temperature}
1583 \textcolor{comment}{                                              !! in [kg m-3 degC-1]}
1584   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: drho\_ds\textcolor{comment}{   !< Partial derivative of density with salinity}
1585 \textcolor{comment}{                                              !! in [kg m-3 ppt-1]}
1586   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: tfr\_s0\_p0\textcolor{comment}{ !< The freezing potential temperature at S=0, P=0 [degC]}
1587   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: dtfr\_ds\textcolor{comment}{   !< The derivative of freezing point with salinity}
1588 \textcolor{comment}{                                              !! [degC PSU-1]}
1589   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: dtfr\_dp\textcolor{comment}{   !< The derivative of freezing point with pressure}
1590 \textcolor{comment}{                                              !! [degC Pa-1]}
1591 
1592   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(form\_of\_eos    ))  form\_of\_eos     = eos%form\_of\_EOS
1593   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(form\_of\_tfreeze))  form\_of\_tfreeze = eos%form\_of\_TFreeze
1594   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(eos\_quadrature ))  eos\_quadrature  = eos%EOS\_quadrature
1595   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(compressible   ))  compressible    = eos%Compressible
1596   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(rho\_t0\_s0      ))  rho\_t0\_s0       = eos%Rho\_T0\_S0
1597   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(drho\_dt        ))  drho\_dt         = eos%drho\_dT
1598   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(drho\_ds        ))  drho\_ds         = eos%dRho\_dS
1599   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(tfr\_s0\_p0      ))  tfr\_s0\_p0       = eos%TFr\_S0\_P0
1600   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dtfr\_ds        ))  dtfr\_ds         = eos%dTFr\_dS
1601   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dtfr\_dp        ))  dtfr\_dp         = eos%dTFr\_dp
1602 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__eos_aee169aee0e4cbed420782d772282bb69}\label{namespacemom__eos_aee169aee0e4cbed420782d772282bb69}} 
\index{mom\+\_\+eos@{mom\+\_\+eos}!query\+\_\+compressible@{query\+\_\+compressible}}
\index{query\+\_\+compressible@{query\+\_\+compressible}!mom\+\_\+eos@{mom\+\_\+eos}}
\subsubsection{\texorpdfstring{query\+\_\+compressible()}{query\_compressible()}}
{\footnotesize\ttfamily logical function, public mom\+\_\+eos\+::query\+\_\+compressible (\begin{DoxyParamCaption}\item[{type(\hyperlink{structmom__eos_1_1eos__type}{eos\+\_\+type}), pointer}]{E\+OS }\end{DoxyParamCaption})}



Returns true if the equation of state is compressible (i.\+e. has pressure dependence) 


\begin{DoxyParams}{Parameters}
{\em eos} & Equation of state structure \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
1339   \textcolor{keywordtype}{type}(eos\_type), \textcolor{keywordtype}{pointer} :: eos\textcolor{comment}{ !< Equation of state structure}
1340 
1341   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
1342     \textcolor{stringliteral}{"query\_compressible called with an unassociated EOS\_type EOS."})
1343 
1344   query\_compressible = eos%compressible
\end{DoxyCode}
