\hypertarget{interfacemom__eos_1_1calculate__density}{}\section{mom\+\_\+eos\+:\+:calculate\+\_\+density Interface Reference}
\label{interfacemom__eos_1_1calculate__density}\index{mom\+\_\+eos\+::calculate\+\_\+density@{mom\+\_\+eos\+::calculate\+\_\+density}}


\subsection{Detailed Description}
Calculates density of sea water from T, S and P. 

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

\subsection*{Private functions}
\begin{DoxyCompactItemize}
\item 
subroutine \hyperlink{interfacemom__eos_1_1calculate__density_a784e74a411a4ab45fde914754f27894e}{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{interfacemom__eos_1_1calculate__density_a9c2bb282a0662cf90074096d64f15377}{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{interfacemom__eos_1_1calculate__density_aa113783c30ac2dbeef25e428929abe54}{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{interfacemom__eos_1_1calculate__density_abf1cef7a943f4ae996c954c45bab9ea1}{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{interfacemom__eos_1_1calculate__density_ab702d0b5d50a77451bfcea5a8f3c58f3}{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{interfacemom__eos_1_1calculate__density_a49e5008e5bc77c498a869f1c9eda1f43}{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}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Calculates density of sea water from T, S and P. 

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



\subsection{Functions and subroutines}
\mbox{\Hypertarget{interfacemom__eos_1_1calculate__density_aa113783c30ac2dbeef25e428929abe54}\label{interfacemom__eos_1_1calculate__density_aa113783c30ac2dbeef25e428929abe54}} 
\index{mom\+\_\+eos\+::calculate\+\_\+density@{mom\+\_\+eos\+::calculate\+\_\+density}!calculate\+\_\+density\+\_\+1d@{calculate\+\_\+density\+\_\+1d}}
\index{calculate\+\_\+density\+\_\+1d@{calculate\+\_\+density\+\_\+1d}!mom\+\_\+eos\+::calculate\+\_\+density@{mom\+\_\+eos\+::calculate\+\_\+density}}
\subsubsection{\texorpdfstring{calculate\+\_\+density\+\_\+1d()}{calculate\_density\_1d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calculate\+\_\+density\+::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{interfacemom__eos_1_1calculate__density_a9c2bb282a0662cf90074096d64f15377}\label{interfacemom__eos_1_1calculate__density_a9c2bb282a0662cf90074096d64f15377}} 
\index{mom\+\_\+eos\+::calculate\+\_\+density@{mom\+\_\+eos\+::calculate\+\_\+density}!calculate\+\_\+density\+\_\+array@{calculate\+\_\+density\+\_\+array}}
\index{calculate\+\_\+density\+\_\+array@{calculate\+\_\+density\+\_\+array}!mom\+\_\+eos\+::calculate\+\_\+density@{mom\+\_\+eos\+::calculate\+\_\+density}}
\subsubsection{\texorpdfstring{calculate\+\_\+density\+\_\+array()}{calculate\_density\_array()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calculate\+\_\+density\+::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{interfacemom__eos_1_1calculate__density_a784e74a411a4ab45fde914754f27894e}\label{interfacemom__eos_1_1calculate__density_a784e74a411a4ab45fde914754f27894e}} 
\index{mom\+\_\+eos\+::calculate\+\_\+density@{mom\+\_\+eos\+::calculate\+\_\+density}!calculate\+\_\+density\+\_\+scalar@{calculate\+\_\+density\+\_\+scalar}}
\index{calculate\+\_\+density\+\_\+scalar@{calculate\+\_\+density\+\_\+scalar}!mom\+\_\+eos\+::calculate\+\_\+density@{mom\+\_\+eos\+::calculate\+\_\+density}}
\subsubsection{\texorpdfstring{calculate\+\_\+density\+\_\+scalar()}{calculate\_density\_scalar()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calculate\+\_\+density\+::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{interfacemom__eos_1_1calculate__density_a49e5008e5bc77c498a869f1c9eda1f43}\label{interfacemom__eos_1_1calculate__density_a49e5008e5bc77c498a869f1c9eda1f43}} 
\index{mom\+\_\+eos\+::calculate\+\_\+density@{mom\+\_\+eos\+::calculate\+\_\+density}!calculate\+\_\+stanley\+\_\+density\+\_\+1d@{calculate\+\_\+stanley\+\_\+density\+\_\+1d}}
\index{calculate\+\_\+stanley\+\_\+density\+\_\+1d@{calculate\+\_\+stanley\+\_\+density\+\_\+1d}!mom\+\_\+eos\+::calculate\+\_\+density@{mom\+\_\+eos\+::calculate\+\_\+density}}
\subsubsection{\texorpdfstring{calculate\+\_\+stanley\+\_\+density\+\_\+1d()}{calculate\_stanley\_density\_1d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calculate\+\_\+density\+::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{interfacemom__eos_1_1calculate__density_ab702d0b5d50a77451bfcea5a8f3c58f3}\label{interfacemom__eos_1_1calculate__density_ab702d0b5d50a77451bfcea5a8f3c58f3}} 
\index{mom\+\_\+eos\+::calculate\+\_\+density@{mom\+\_\+eos\+::calculate\+\_\+density}!calculate\+\_\+stanley\+\_\+density\+\_\+array@{calculate\+\_\+stanley\+\_\+density\+\_\+array}}
\index{calculate\+\_\+stanley\+\_\+density\+\_\+array@{calculate\+\_\+stanley\+\_\+density\+\_\+array}!mom\+\_\+eos\+::calculate\+\_\+density@{mom\+\_\+eos\+::calculate\+\_\+density}}
\subsubsection{\texorpdfstring{calculate\+\_\+stanley\+\_\+density\+\_\+array()}{calculate\_stanley\_density\_array()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calculate\+\_\+density\+::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{interfacemom__eos_1_1calculate__density_abf1cef7a943f4ae996c954c45bab9ea1}\label{interfacemom__eos_1_1calculate__density_abf1cef7a943f4ae996c954c45bab9ea1}} 
\index{mom\+\_\+eos\+::calculate\+\_\+density@{mom\+\_\+eos\+::calculate\+\_\+density}!calculate\+\_\+stanley\+\_\+density\+\_\+scalar@{calculate\+\_\+stanley\+\_\+density\+\_\+scalar}}
\index{calculate\+\_\+stanley\+\_\+density\+\_\+scalar@{calculate\+\_\+stanley\+\_\+density\+\_\+scalar}!mom\+\_\+eos\+::calculate\+\_\+density@{mom\+\_\+eos\+::calculate\+\_\+density}}
\subsubsection{\texorpdfstring{calculate\+\_\+stanley\+\_\+density\+\_\+scalar()}{calculate\_stanley\_density\_scalar()}}
{\footnotesize\ttfamily subroutine mom\+\_\+eos\+::calculate\+\_\+density\+::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}


The documentation for this interface was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
/home/cermak/src/\+M\+O\+M6.\+devrob/src/equation\+\_\+of\+\_\+state/M\+O\+M\+\_\+\+E\+O\+S.\+F90\end{DoxyCompactItemize}
