\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}}


Calculates density of sea water from T, S and P.  


\subsection*{Private Member 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 \hyperlink{MOM__EOS_8F90_source_l00068}{68} of file \hyperlink{MOM__EOS_8F90_source}{M\+O\+M\+\_\+\+E\+O\+S.\+F90}.



\subsection{Member Function/\+Subroutine Documentation}
\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 \hyperlink{MOM__EOS_8F90_source_l00360}{360} of file \hyperlink{MOM__EOS_8F90_source}{M\+O\+M\+\_\+\+E\+O\+S.\+F90}.


\begin{DoxyCode}
00360   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: t\textcolor{comment}{        !< Potential temperature referenced to the surface
       [degC]}
00361   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: s\textcolor{comment}{        !< Salinity [ppt]}
00362   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< Pressure [R L2 T-2 ~> Pa]}
00363   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(inout)} :: rho\textcolor{comment}{      !< Density (in-situ if pressure is local) [R ~> kg m-3]}
00364   \textcolor{keywordtype}{type}(eos\_type),        \textcolor{keywordtype}{pointer}       :: eos\textcolor{comment}{      !< Equation of state structure}
00365   \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}
00366 \textcolor{comment}{                                                       !! into account that arrays start at 1.}
00367   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: rho\_ref\textcolor{comment}{ !< A reference density [kg m-3]}
00368   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{ !< A multiplicative factor by which to scale density}
00369 \textcolor{comment}{                                                   !! in combination with scaling given by US [various]}
00370   \textcolor{comment}{! Local variables}
00371   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
00372   \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]}
00373   \textcolor{keywordtype}{real} :: rho\_unscale \textcolor{comment}{! A factor to convert density from R to kg m-3 [kg m-3 R-1 ~> 1]}
00374   \textcolor{keywordtype}{real} :: rho\_reference \textcolor{comment}{! rho\_ref converted to [kg m-3]}
00375   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(rho))} :: pres  \textcolor{comment}{! Pressure converted to [Pa]}
00376   \textcolor{keywordtype}{integer} :: i, is, ie, npts
00377 
00378   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
00379     \textcolor{stringliteral}{"calculate\_density\_1d called with an unassociated EOS\_type EOS."})
00380 
00381   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dom)) \textcolor{keywordflow}{then}
00382     is = dom(1) ; ie = dom(2) ; npts = 1 + ie - is
00383   \textcolor{keywordflow}{else}
00384     is = 1 ; ie = \textcolor{keyword}{size}(rho) ; npts = 1 + ie - is
00385 \textcolor{keywordflow}{  endif}
00386 
00387   p\_scale = eos%RL2\_T2\_to\_Pa
00388   rho\_unscale = eos%R\_to\_kg\_m3
00389 
00390   \textcolor{keywordflow}{if} ((p\_scale == 1.0) .and. (rho\_unscale == 1.0)) \textcolor{keywordflow}{then}
00391     \textcolor{keyword}{call }calculate\_density\_array(t, s, pressure, rho, is, npts, eos, rho\_ref=rho\_ref)
00392   \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.}
00393     \textcolor{keywordflow}{do} i=is,ie ; pres(i) = p\_scale * pressure(i) ;\textcolor{keywordflow}{ enddo}
00394     rho\_reference = rho\_unscale*rho\_ref
00395     \textcolor{keyword}{call }calculate\_density\_array(t, s, pres, rho, is, npts, eos, rho\_ref=rho\_reference)
00396   \textcolor{keywordflow}{else}  \textcolor{comment}{! There is rescaling of variables, but rho\_ref is not present. Passing a 0 value of rho\_ref}
00397         \textcolor{comment}{! changes answers at roundoff for some equations of state, like Wright and UNESCO.}
00398     \textcolor{keywordflow}{do} i=is,ie ; pres(i) = p\_scale * pressure(i) ;\textcolor{keywordflow}{ enddo}
00399     \textcolor{keyword}{call }calculate\_density\_array(t, s, pres, rho, is, npts, eos)
00400 \textcolor{keywordflow}{  endif}
00401 
00402   rho\_scale = eos%kg\_m3\_to\_R
00403   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) rho\_scale = rho\_scale * scale
00404   \textcolor{keywordflow}{if} (rho\_scale /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} i=is,ie
00405     rho(i) = rho\_scale * rho(i)
00406 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif}
00407 
\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 \hyperlink{MOM__EOS_8F90_source_l00263}{263} of file \hyperlink{MOM__EOS_8F90_source}{M\+O\+M\+\_\+\+E\+O\+S.\+F90}.


\begin{DoxyCode}
00263   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: t\textcolor{comment}{        !< Potential temperature referenced to the surface [degC]}
00264   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: s\textcolor{comment}{        !< Salinity [ppt]}
00265   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< Pressure [Pa] or [R L2 T-2 ~> Pa]}
00266   \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]}
00267   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: start\textcolor{comment}{    !< Start index for computation}
00268   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: npts\textcolor{comment}{     !< Number of point to compute}
00269   \textcolor{keywordtype}{type}(eos\_type),     \textcolor{keywordtype}{pointer}       :: eos\textcolor{comment}{      !< Equation of state structure}
00270   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: rho\_ref\textcolor{comment}{  !< A reference density [kg m-3]}
00271   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{    !< A multiplicative factor by which to scale
       density}
00272 \textcolor{comment}{                                                !! in combination with scaling given by US [various]}
00273   \textcolor{keywordtype}{integer} :: j
00274 
00275   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
00276     \textcolor{stringliteral}{"calculate\_density\_array called with an unassociated EOS\_type EOS."})
00277 
00278   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
00279     \textcolor{keywordflow}{case} (eos\_linear)
00280       \textcolor{keyword}{call }calculate\_density\_linear(t, s, pressure, rho, start, npts, &
00281                                     eos%Rho\_T0\_S0, eos%dRho\_dT, eos%dRho\_dS, rho\_ref)
00282     \textcolor{keywordflow}{case} (eos\_unesco)
00283       \textcolor{keyword}{call }calculate\_density\_unesco(t, s, pressure, rho, start, npts, rho\_ref)
00284     \textcolor{keywordflow}{case} (eos\_wright)
00285       \textcolor{keyword}{call }calculate\_density\_wright(t, s, pressure, rho, start, npts, rho\_ref)
00286     \textcolor{keywordflow}{case} (eos\_teos10)
00287       \textcolor{keyword}{call }calculate\_density\_teos10(t, s, pressure, rho, start, npts, rho\_ref)
00288     \textcolor{keywordflow}{case} (eos\_nemo)
00289     \textcolor{keyword}{call }calculate\_density\_nemo(t, s, pressure, rho, start, npts, rho\_ref)
00290 \textcolor{keywordflow}{    case default}
00291       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_density\_array: EOS%form\_of\_EOS is not valid."})
00292 \textcolor{keywordflow}{  end select}
00293 
00294   \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
00295     rho(j) = scale * rho(j)
00296 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif} ;\textcolor{keywordflow}{ endif}
00297 
\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 \hyperlink{MOM__EOS_8F90_source_l00166}{166} of file \hyperlink{MOM__EOS_8F90_source}{M\+O\+M\+\_\+\+E\+O\+S.\+F90}.


\begin{DoxyCode}
00166   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: t\textcolor{comment}{        !< Potential temperature referenced to the surface [degC]}
00167   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: s\textcolor{comment}{        !< Salinity [ppt]}
00168   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: pressure\textcolor{comment}{ !< Pressure [Pa] or [R L2 T-2 ~> Pa]}
00169   \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]}
00170   \textcolor{keywordtype}{type}(eos\_type), \textcolor{keywordtype}{pointer}     :: eos\textcolor{comment}{      !< Equation of state structure}
00171   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: rho\_ref\textcolor{comment}{  !< A reference density [kg m-3]}
00172   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: scale\textcolor{comment}{    !< A multiplicative factor by which to scale density in}
00173 \textcolor{comment}{                                          !! combination with scaling given by US [various]}
00174 
00175   \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]}
00176   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
00177 
00178   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
00179     \textcolor{stringliteral}{"calculate\_density\_scalar called with an unassociated EOS\_type EOS."})
00180 
00181   p\_scale = eos%RL2\_T2\_to\_Pa
00182 
00183   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
00184     \textcolor{keywordflow}{case} (eos\_linear)
00185       \textcolor{keyword}{call }calculate\_density\_linear(t, s, p\_scale*pressure, rho, &
00186                                     eos%Rho\_T0\_S0, eos%dRho\_dT, eos%dRho\_dS, rho\_ref)
00187     \textcolor{keywordflow}{case} (eos\_unesco)
00188       \textcolor{keyword}{call }calculate\_density\_unesco(t, s, p\_scale*pressure, rho, rho\_ref)
00189     \textcolor{keywordflow}{case} (eos\_wright)
00190       \textcolor{keyword}{call }calculate\_density\_wright(t, s, p\_scale*pressure, rho, rho\_ref)
00191     \textcolor{keywordflow}{case} (eos\_teos10)
00192       \textcolor{keyword}{call }calculate\_density\_teos10(t, s, p\_scale*pressure, rho, rho\_ref)
00193     \textcolor{keywordflow}{case} (eos\_nemo)
00194       \textcolor{keyword}{call }calculate\_density\_nemo(t, s, p\_scale*pressure, rho, rho\_ref)
00195 \textcolor{keywordflow}{    case default}
00196       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_density\_scalar: EOS is not valid."})
00197 \textcolor{keywordflow}{  end select}
00198 
00199   rho\_scale = eos%kg\_m3\_to\_R
00200   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) rho\_scale = rho\_scale * scale
00201   rho = rho\_scale * rho
00202 
\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 \hyperlink{MOM__EOS_8F90_source_l00417}{417} of file \hyperlink{MOM__EOS_8F90_source}{M\+O\+M\+\_\+\+E\+O\+S.\+F90}.


\begin{DoxyCode}
00417   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: t\textcolor{comment}{        !< Potential temperature referenced to the surface
       [degC]}
00418   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: s\textcolor{comment}{        !< Salinity [ppt]}
00419   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< Pressure [R L2 T-2 ~> Pa]}
00420   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: tvar\textcolor{comment}{     !< Variance of potential temperature [degC2]}
00421   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: tscov\textcolor{comment}{    !< Covariance of potential temperature and salinity
       [degC ppt]}
00422   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: svar\textcolor{comment}{     !< Variance of salinity [ppt2]}
00423   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(inout)} :: rho\textcolor{comment}{      !< Density (in-situ if pressure is local) [R ~> kg m-3]}
00424   \textcolor{keywordtype}{type}(eos\_type),        \textcolor{keywordtype}{pointer}       :: eos\textcolor{comment}{      !< Equation of state structure}
00425   \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}
00426 \textcolor{comment}{                                                       !! into account that arrays start at 1.}
00427   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: rho\_ref\textcolor{comment}{ !< A reference density [kg m-3]}
00428   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{ !< A multiplicative factor by which to scale density}
00429 \textcolor{comment}{                                                   !! in combination with scaling given by US [various]}
00430   \textcolor{comment}{! Local variables}
00431   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
00432   \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]}
00433   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(rho))} :: pres  \textcolor{comment}{! Pressure converted to [Pa]}
00434   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(T))} :: d2rdtt, d2rdst, d2rdss, d2rdsp, d2rdtp \textcolor{comment}{! Second derivatives of density wrt
       T,S,p}
00435   \textcolor{keywordtype}{integer} :: i, is, ie, npts
00436 
00437   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
00438     \textcolor{stringliteral}{"calculate\_density\_1d called with an unassociated EOS\_type EOS."})
00439 
00440   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dom)) \textcolor{keywordflow}{then}
00441     is = dom(1) ; ie = dom(2) ; npts = 1 + ie - is
00442   \textcolor{keywordflow}{else}
00443     is = 1 ; ie = \textcolor{keyword}{size}(rho) ; npts = 1 + ie - is
00444 \textcolor{keywordflow}{  endif}
00445 
00446   p\_scale = eos%RL2\_T2\_to\_Pa
00447   \textcolor{keywordflow}{do} i=is,ie
00448     pres(i) = p\_scale * pressure(i)
00449 \textcolor{keywordflow}{  enddo}
00450 
00451   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
00452     \textcolor{keywordflow}{case} (eos\_linear)
00453       \textcolor{keyword}{call }calculate\_density\_linear(t, s, pres, rho, 1, npts, &
00454                                     eos%Rho\_T0\_S0, eos%dRho\_dT, eos%dRho\_dS, rho\_ref)
00455       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_linear(t, s, pres, d2rdss, d2rdst, &
00456                                                   d2rdtt, d2rdsp, d2rdtp, 1, npts)
00457     \textcolor{keywordflow}{case} (eos\_wright)
00458       \textcolor{keyword}{call }calculate\_density\_wright(t, s, pres, rho, 1, npts, rho\_ref)
00459       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_wright(t, s, pres, d2rdss, d2rdst, &
00460                                                   d2rdtt, d2rdsp, d2rdtp, 1, npts)
00461     \textcolor{keywordflow}{case} (eos\_teos10)
00462       \textcolor{keyword}{call }calculate\_density\_teos10(t, s, pres, rho, 1, npts, rho\_ref)
00463       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_teos10(t, s, pres, d2rdss, d2rdst, &
00464                                                   d2rdtt, d2rdsp, d2rdtp, 1, npts)
00465 \textcolor{keywordflow}{    case default}
00466       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_stanley\_density\_scalar: EOS is not valid."})
00467 \textcolor{keywordflow}{  end select}
00468 
00469   \textcolor{comment}{! Equation 25 of Stanley et al., 2020.}
00470   \textcolor{keywordflow}{do} i=is,ie
00471     rho(i) = rho(i) &
00472              + ( 0.5 * d2rdtt(i) * tvar(i) + ( d2rdst(i) * tscov(i) + 0.5 * d2rdss(i) * svar(i) ) )
00473 \textcolor{keywordflow}{  enddo}
00474 
00475   rho\_scale = eos%kg\_m3\_to\_R
00476   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) rho\_scale = rho\_scale * scale
00477   \textcolor{keywordflow}{if} (rho\_scale /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} i=is,ie
00478     rho(i) = rho\_scale * rho(i)
00479 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif}
00480 
\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 \hyperlink{MOM__EOS_8F90_source_l00306}{306} of file \hyperlink{MOM__EOS_8F90_source}{M\+O\+M\+\_\+\+E\+O\+S.\+F90}.


\begin{DoxyCode}
00306   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: t\textcolor{comment}{        !< Potential temperature referenced to the surface [degC]}
00307   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: s\textcolor{comment}{        !< Salinity [ppt]}
00308   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< Pressure [Pa]}
00309   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: tvar\textcolor{comment}{     !< Variance of potential temperature referenced to the
       surface [degC2]}
00310   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: tscov\textcolor{comment}{    !< Covariance of potential temperature and salinity [degC
       ppt]}
00311   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: svar\textcolor{comment}{     !< Variance of salinity [ppt2]}
00312   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: rho\textcolor{comment}{      !< Density (in-situ if pressure is local) [kg m-3]}
00313   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: start\textcolor{comment}{    !< Start index for computation}
00314   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: npts\textcolor{comment}{     !< Number of point to compute}
00315   \textcolor{keywordtype}{type}(eos\_type),     \textcolor{keywordtype}{pointer}       :: eos\textcolor{comment}{      !< Equation of state structure}
00316   \textcolor{keywordtype}{real},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: rho\_ref\textcolor{comment}{  !< A reference density [kg m-3].}
00317   \textcolor{keywordtype}{real},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{    !< A multiplicative factor by which to scale density}
00318 \textcolor{comment}{                                                !! from kg m-3 to the desired units [R m3 kg-1]}
00319   \textcolor{comment}{! Local variables}
00320   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(T))} :: d2rdtt, d2rdst, d2rdss, d2rdsp, d2rdtp \textcolor{comment}{! Second derivatives of density wrt
       T,S,p}
00321   \textcolor{keywordtype}{integer} :: j
00322 
00323   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
00324     \textcolor{stringliteral}{"calculate\_density\_array called with an unassociated EOS\_type EOS."})
00325 
00326   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
00327     \textcolor{keywordflow}{case} (eos\_linear)
00328       \textcolor{keyword}{call }calculate\_density\_linear(t, s, pressure, rho, start, npts, &
00329                                     eos%Rho\_T0\_S0, eos%dRho\_dT, eos%dRho\_dS, rho\_ref)
00330       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_linear(t, s, pressure, d2rdss, d2rdst, &
00331                                                   d2rdtt, d2rdsp, d2rdtp, start, npts)
00332     \textcolor{keywordflow}{case} (eos\_wright)
00333       \textcolor{keyword}{call }calculate\_density\_wright(t, s, pressure, rho, start, npts, rho\_ref)
00334       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_wright(t, s, pressure, d2rdss, d2rdst, &
00335                                                   d2rdtt, d2rdsp, d2rdtp, start, npts)
00336     \textcolor{keywordflow}{case} (eos\_teos10)
00337       \textcolor{keyword}{call }calculate\_density\_teos10(t, s, pressure, rho, start, npts, rho\_ref)
00338       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_teos10(t, s, pressure, d2rdss, d2rdst, &
00339                                                   d2rdtt, d2rdsp, d2rdtp, start, npts)
00340 \textcolor{keywordflow}{    case default}
00341       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_stanley\_density\_array: EOS%form\_of\_EOS is not valid."})
00342 \textcolor{keywordflow}{  end select}
00343 
00344   \textcolor{comment}{! Equation 25 of Stanley et al., 2020.}
00345   \textcolor{keywordflow}{do} j=start,start+npts-1
00346     rho(j) = rho(j) &
00347              + ( 0.5 * d2rdtt(j) * tvar(j) + ( d2rdst(j) * tscov(j) + 0.5 * d2rdss(j) * svar(j) ) )
00348 \textcolor{keywordflow}{  enddo}
00349 
00350   \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
00351     rho(j) = scale * rho(j)
00352 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif} ;\textcolor{keywordflow}{ endif}
00353 
\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 \hyperlink{MOM__EOS_8F90_source_l00212}{212} of file \hyperlink{MOM__EOS_8F90_source}{M\+O\+M\+\_\+\+E\+O\+S.\+F90}.


\begin{DoxyCode}
00212   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: t\textcolor{comment}{        !< Potential temperature referenced to the surface [degC]}
00213   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: s\textcolor{comment}{        !< Salinity [ppt]}
00214   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: tvar\textcolor{comment}{     !< Variance of potential temperature referenced to the surface
       [degC2]}
00215   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: tscov\textcolor{comment}{    !< Covariance of potential temperature and salinity [degC ppt]}
00216   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: svar\textcolor{comment}{     !< Variance of salinity [ppt2]}
00217   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: pressure\textcolor{comment}{ !< Pressure [Pa]}
00218   \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]}
00219   \textcolor{keywordtype}{type}(eos\_type), \textcolor{keywordtype}{pointer}     :: eos\textcolor{comment}{      !< Equation of state structure}
00220   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: rho\_ref\textcolor{comment}{  !< A reference density [kg m-3].}
00221   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: scale\textcolor{comment}{    !< A multiplicative factor by which to scale density}
00222 \textcolor{comment}{                                          !! from kg m-3 to the desired units [R m3 kg-1]}
00223   \textcolor{comment}{! Local variables}
00224   \textcolor{keywordtype}{real} :: d2rdtt, d2rdst, d2rdss, d2rdsp, d2rdtp \textcolor{comment}{! Second derivatives of density wrt T,S,p}
00225   \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]}
00226   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
00227 
00228   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
00229     \textcolor{stringliteral}{"calculate\_stanley\_density\_scalar called with an unassociated EOS\_type EOS."})
00230 
00231   p\_scale = eos%RL2\_T2\_to\_Pa
00232 
00233   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
00234     \textcolor{keywordflow}{case} (eos\_linear)
00235       \textcolor{keyword}{call }calculate\_density\_linear(t, s, p\_scale*pressure, rho, &
00236                                     eos%Rho\_T0\_S0, eos%dRho\_dT, eos%dRho\_dS, rho\_ref)
00237       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_linear(t, s, pressure, d2rdss, d2rdst, &
00238                                                   d2rdtt, d2rdsp, d2rdtp)
00239     \textcolor{keywordflow}{case} (eos\_wright)
00240       \textcolor{keyword}{call }calculate\_density\_wright(t, s, p\_scale*pressure, rho, rho\_ref)
00241       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_wright(t, s, pressure, d2rdss, d2rdst, &
00242                                                   d2rdtt, d2rdsp, d2rdtp)
00243     \textcolor{keywordflow}{case} (eos\_teos10)
00244       \textcolor{keyword}{call }calculate\_density\_teos10(t, s, p\_scale*pressure, rho, rho\_ref)
00245       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_teos10(t, s, pressure, d2rdss, d2rdst, &
00246                                                   d2rdtt, d2rdsp, d2rdtp)
00247 \textcolor{keywordflow}{    case default}
00248       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_stanley\_density\_scalar: EOS is not valid."})
00249 \textcolor{keywordflow}{  end select}
00250 
00251   \textcolor{comment}{! Equation 25 of Stanley et al., 2020.}
00252   rho = rho + ( 0.5 * d2rdtt * tvar + ( d2rdst * tscov + 0.5 * d2rdss * svar ) )
00253 
00254   rho\_scale = eos%kg\_m3\_to\_R
00255   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) rho\_scale = rho\_scale * scale
00256   rho = rho\_scale * rho
00257 
\end{DoxyCode}


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