\hypertarget{namespacedense__water__initialization}{}\doxysection{dense\+\_\+water\+\_\+initialization Module Reference}
\label{namespacedense__water__initialization}\index{dense\_water\_initialization@{dense\_water\_initialization}}


\doxysubsection{Detailed Description}
Initialization routines for the dense water formation and overflow experiment. 

This experiment consists of a shelf accumulating dense water, which spills over an upward slope and a sill, before flowing down a slope into an open ocean region. It\textquotesingle{}s intended as a test of one of the motivating situations for the adaptive coordinate.

The nondimensional widths of the 5 regions are controlled by the {\ttfamily D\+E\+N\+S\+E\+\_\+\+W\+A\+T\+E\+R\+\_\+\+D\+O\+M\+A\+I\+N\+\_\+\+P\+A\+R\+A\+MS}, and the heights of the sill and shelf as a fraction of the total domain depth are controlled by {\ttfamily D\+E\+N\+S\+E\+\_\+\+W\+A\+T\+E\+R\+\_\+\+S\+I\+L\+L\+\_\+\+H\+E\+I\+G\+HT} and {\ttfamily D\+E\+N\+S\+E\+\_\+\+W\+A\+T\+E\+R\+\_\+\+S\+H\+E\+L\+F\+\_\+\+H\+E\+I\+G\+HT}.

The density in the domain is governed by a linear equation of state, and is set up with a mixed layer of non-\/dimensional depth {\ttfamily D\+E\+N\+S\+E\+\_\+\+W\+A\+T\+E\+R\+\_\+\+M\+LD} below which there is a linear stratification from {\ttfamily S\+\_\+\+R\+EF}, increasing by {\ttfamily S\+\_\+\+R\+A\+N\+GE} to the bottom.

To force the experiment, there are sponges on the inflow and outflow of the domain. The inflow sponge has a salinity anomaly of {\ttfamily D\+E\+N\+S\+E\+\_\+\+W\+A\+T\+E\+R\+\_\+\+E\+A\+S\+T\+\_\+\+S\+P\+O\+N\+G\+E\+\_\+\+S\+A\+LT} through the entire depth. The outflow sponge simply restores to the initial condition. Both sponges have controllable widths and restoring timescales. \doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacedense__water__initialization_ae2a5062c406c66b1917f2ad564d4a5e6}{dense\+\_\+water\+\_\+initialize\+\_\+topography}} (D, G, param\+\_\+file, max\+\_\+depth)
\begin{DoxyCompactList}\small\item\em Initialize the topography field for the dense water experiment. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacedense__water__initialization_a0e1384953bfbb302a7b93dd7abb6cb7b}{dense\+\_\+water\+\_\+initialize\+\_\+ts}} (G, GV, param\+\_\+file, eqn\+\_\+of\+\_\+state, T, S, h, just\+\_\+read\+\_\+params)
\begin{DoxyCompactList}\small\item\em Initialize the temperature and salinity for the dense water experiment. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacedense__water__initialization_aa663ab693084a07cf066806d6b529c14}{dense\+\_\+water\+\_\+initialize\+\_\+sponges}} (G, GV, US, tv, param\+\_\+file, use\+\_\+\+A\+LE, C\+Sp, A\+C\+Sp)
\begin{DoxyCompactList}\small\item\em Initialize the restoring sponges for the dense water experiment. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacedense__water__initialization_a8996fccad16389cd1b688f83ebf3a630}\label{namespacedense__water__initialization_a8996fccad16389cd1b688f83ebf3a630}} 
character(len=40) \mbox{\hyperlink{namespacedense__water__initialization_a8996fccad16389cd1b688f83ebf3a630}{mdl}} = \char`\"{}dense\+\_\+water\+\_\+initialization\char`\"{}
\begin{DoxyCompactList}\small\item\em Module name. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacedense__water__initialization_a2411cd7a7a8c202a345e66ae25a6f5a0}\label{namespacedense__water__initialization_a2411cd7a7a8c202a345e66ae25a6f5a0}} 
real, parameter \mbox{\hyperlink{namespacedense__water__initialization_a2411cd7a7a8c202a345e66ae25a6f5a0}{default\+\_\+sill}} = 0.\+2
\begin{DoxyCompactList}\small\item\em Default depth of the sill \mbox{[}nondim\mbox{]}. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacedense__water__initialization_aa43e2347923c52d91a9ca2fc07b49949}\label{namespacedense__water__initialization_aa43e2347923c52d91a9ca2fc07b49949}} 
real, parameter \mbox{\hyperlink{namespacedense__water__initialization_aa43e2347923c52d91a9ca2fc07b49949}{default\+\_\+shelf}} = 0.\+4
\begin{DoxyCompactList}\small\item\em Default depth of the shelf \mbox{[}nondim\mbox{]}. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacedense__water__initialization_a8dde2a4823fdb9aa5e4911dcb965176f}\label{namespacedense__water__initialization_a8dde2a4823fdb9aa5e4911dcb965176f}} 
real, parameter \mbox{\hyperlink{namespacedense__water__initialization_a8dde2a4823fdb9aa5e4911dcb965176f}{default\+\_\+mld}} = 0.\+25
\begin{DoxyCompactList}\small\item\em Default depth of the mixed layer \mbox{[}nondim\mbox{]}. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacedense__water__initialization_aa663ab693084a07cf066806d6b529c14}\label{namespacedense__water__initialization_aa663ab693084a07cf066806d6b529c14}} 
\index{dense\_water\_initialization@{dense\_water\_initialization}!dense\_water\_initialize\_sponges@{dense\_water\_initialize\_sponges}}
\index{dense\_water\_initialize\_sponges@{dense\_water\_initialize\_sponges}!dense\_water\_initialization@{dense\_water\_initialization}}
\doxysubsubsection{\texorpdfstring{dense\_water\_initialize\_sponges()}{dense\_water\_initialize\_sponges()}}
{\footnotesize\ttfamily subroutine, public dense\+\_\+water\+\_\+initialization\+::dense\+\_\+water\+\_\+initialize\+\_\+sponges (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{logical, intent(in)}]{use\+\_\+\+A\+LE,  }\item[{type(sponge\+\_\+cs), pointer}]{C\+Sp,  }\item[{type(ale\+\_\+sponge\+\_\+cs), pointer}]{A\+C\+Sp }\end{DoxyParamCaption})}



Initialize the restoring sponges for the dense water experiment. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & Horizontal grid control structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Vertical grid control structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & Thermodynamic variables \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & Parameter file structure \\
\hline
\mbox{\texttt{ in}}  & {\em use\+\_\+ale} & A\+LE flag \\
\hline
 & {\em csp} & Layered sponge control structure pointer \\
\hline
 & {\em acsp} & A\+LE sponge control structure pointer \\
\hline
\end{DoxyParams}


Definition at line 156 of file dense\+\_\+water\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{156   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{ !< Horizontal grid control structure}}
\DoxyCodeLine{157   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{ !< Vertical grid control structure}}
\DoxyCodeLine{158   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{ !< A dimensional unit scaling type}}
\DoxyCodeLine{159   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(in)} :: tv\textcolor{comment}{ !< Thermodynamic variables}}
\DoxyCodeLine{160   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< Parameter file structure}}
\DoxyCodeLine{161   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)} :: use\_ALE\textcolor{comment}{ !< ALE flag}}
\DoxyCodeLine{162   \textcolor{keywordtype}{type}(sponge\_CS),         \textcolor{keywordtype}{pointer}    :: CSp\textcolor{comment}{ !< Layered sponge control structure pointer}}
\DoxyCodeLine{163   \textcolor{keywordtype}{type}(ALE\_sponge\_CS),     \textcolor{keywordtype}{pointer}    :: ACSp\textcolor{comment}{ !< ALE sponge control structure pointer}}
\DoxyCodeLine{164   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{165 \textcolor{keywordtype}{  real} :: west\_sponge\_time\_scale, east\_sponge\_time\_scale \textcolor{comment}{! Sponge timescales [T \string~> s]}}
\DoxyCodeLine{166 \textcolor{keywordtype}{  real} :: west\_sponge\_width, east\_sponge\_width}
\DoxyCodeLine{167 }
\DoxyCodeLine{168 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))} :: Idamp \textcolor{comment}{! inverse damping timescale [T-\/1 \string~> s-\/1]}}
\DoxyCodeLine{169 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))} :: h  \textcolor{comment}{! sponge thicknesses [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{170 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))} :: T  \textcolor{comment}{! sponge temperature [degC]}}
\DoxyCodeLine{171 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))} :: S  \textcolor{comment}{! sponge salinity [ppt]}}
\DoxyCodeLine{172 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV)+1)} :: e0, eta1D \textcolor{comment}{! interface positions for ALE sponge [Z \string~> m]}}
\DoxyCodeLine{173 }
\DoxyCodeLine{174   \textcolor{keywordtype}{integer} :: i, j, k, nz}
\DoxyCodeLine{175 \textcolor{keywordtype}{  real} :: x, zi, zmid, dist}
\DoxyCodeLine{176 \textcolor{keywordtype}{  real} :: mld, S\_ref, S\_range, S\_dense, T\_ref, sill\_height}
\DoxyCodeLine{177 }
\DoxyCodeLine{178   nz = gv\%ke}
\DoxyCodeLine{179 }
\DoxyCodeLine{180   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DENSE\_WATER\_WEST\_SPONGE\_TIME\_SCALE"}, west\_sponge\_time\_scale, \&}
\DoxyCodeLine{181        \textcolor{stringliteral}{"The time scale on the west (outflow) of the domain for restoring. If zero, the sponge is disabled."}, \&}
\DoxyCodeLine{182        units=\textcolor{stringliteral}{"s"}, default=0., scale=us\%s\_to\_T)}
\DoxyCodeLine{183   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DENSE\_WATER\_WEST\_SPONGE\_WIDTH"}, west\_sponge\_width, \&}
\DoxyCodeLine{184        \textcolor{stringliteral}{"The fraction of the domain in which the western (outflow) sponge is active."}, \&}
\DoxyCodeLine{185        units=\textcolor{stringliteral}{"nondim"}, default=0.1)}
\DoxyCodeLine{186   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DENSE\_WATER\_EAST\_SPONGE\_TIME\_SCALE"}, east\_sponge\_time\_scale, \&}
\DoxyCodeLine{187        \textcolor{stringliteral}{"The time scale on the east (outflow) of the domain for restoring. If zero, the sponge is disabled."}, \&}
\DoxyCodeLine{188        units=\textcolor{stringliteral}{"s"}, default=0., scale=us\%s\_to\_T)}
\DoxyCodeLine{189   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DENSE\_WATER\_EAST\_SPONGE\_WIDTH"}, east\_sponge\_width, \&}
\DoxyCodeLine{190        \textcolor{stringliteral}{"The fraction of the domain in which the eastern (outflow) sponge is active."}, \&}
\DoxyCodeLine{191        units=\textcolor{stringliteral}{"nondim"}, default=0.1)}
\DoxyCodeLine{192 }
\DoxyCodeLine{193   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DENSE\_WATER\_EAST\_SPONGE\_SALT"}, s\_dense, \&}
\DoxyCodeLine{194        \textcolor{stringliteral}{"Salt anomaly of the dense water being formed in the overflow region."}, \&}
\DoxyCodeLine{195        units=\textcolor{stringliteral}{"1e-\/3"}, default=4.0)}
\DoxyCodeLine{196 }
\DoxyCodeLine{197   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DENSE\_WATER\_MLD"}, mld, default=default\_mld, do\_not\_log=.true.)}
\DoxyCodeLine{198   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DENSE\_WATER\_SILL\_HEIGHT"}, sill\_height, default=default\_sill, do\_not\_log=.true.)}
\DoxyCodeLine{199 }
\DoxyCodeLine{200   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"S\_REF"}, s\_ref, default=35.0, do\_not\_log=.true.)}
\DoxyCodeLine{201   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"S\_RANGE"}, s\_range, do\_not\_log=.true.)}
\DoxyCodeLine{202   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"T\_REF"}, t\_ref, do\_not\_log=.true.)}
\DoxyCodeLine{203 }
\DoxyCodeLine{204   \textcolor{comment}{! no active sponges}}
\DoxyCodeLine{205   \textcolor{keywordflow}{if} (west\_sponge\_time\_scale <= 0. .and. east\_sponge\_time\_scale <= 0.) \textcolor{keywordflow}{return}}
\DoxyCodeLine{206 }
\DoxyCodeLine{207   \textcolor{comment}{! everywhere is initially unsponged}}
\DoxyCodeLine{208   idamp(:,:) = 0.0}
\DoxyCodeLine{209 }
\DoxyCodeLine{210   \textcolor{keywordflow}{do} j = g\%jsc, g\%jec}
\DoxyCodeLine{211     \textcolor{keywordflow}{do} i = g\%isc,g\%iec}
\DoxyCodeLine{212       \textcolor{keywordflow}{if} (g\%mask2dT(i,j) > 0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{213         \textcolor{comment}{! nondimensional x position}}
\DoxyCodeLine{214         x = (g\%geoLonT(i,j) -\/ g\%west\_lon) / g\%len\_lon}
\DoxyCodeLine{215 }
\DoxyCodeLine{216         \textcolor{keywordflow}{if} (west\_sponge\_time\_scale > 0. .and. x < west\_sponge\_width) \textcolor{keywordflow}{then}}
\DoxyCodeLine{217           dist = 1. -\/ x / west\_sponge\_width}
\DoxyCodeLine{218           \textcolor{comment}{! scale restoring by depth into sponge}}
\DoxyCodeLine{219           idamp(i,j) = 1. / west\_sponge\_time\_scale * max(0., min(1., dist))}
\DoxyCodeLine{220         \textcolor{keywordflow}{elseif} (east\_sponge\_time\_scale > 0. .and. x > (1. -\/ east\_sponge\_width)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{221           dist = 1. -\/ (1. -\/ x) / east\_sponge\_width}
\DoxyCodeLine{222           idamp(i,j) = 1. / east\_sponge\_time\_scale * max(0., min(1., dist))}
\DoxyCodeLine{223 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{224 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{225 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{226 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{227 }
\DoxyCodeLine{228   \textcolor{keywordflow}{if} (use\_ale) \textcolor{keywordflow}{then}}
\DoxyCodeLine{229     \textcolor{comment}{! construct a uniform grid for the sponge}}
\DoxyCodeLine{230     \textcolor{keywordflow}{do} k = 1,nz}
\DoxyCodeLine{231       e0(k) = -\/g\%max\_depth * (real(k -\/ 1) / real(nz))}
\DoxyCodeLine{232 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{233     e0(nz+1) = -\/g\%max\_depth}
\DoxyCodeLine{234 }
\DoxyCodeLine{235     \textcolor{keywordflow}{do} j = g\%jsc,g\%jec}
\DoxyCodeLine{236       \textcolor{keywordflow}{do} i = g\%isc,g\%iec}
\DoxyCodeLine{237         eta1d(nz+1) = -\/g\%bathyT(i,j)}
\DoxyCodeLine{238         \textcolor{keywordflow}{do} k = nz,1,-\/1}
\DoxyCodeLine{239           eta1d(k) = e0(k)}
\DoxyCodeLine{240 }
\DoxyCodeLine{241           \textcolor{keywordflow}{if} (eta1d(k) < (eta1d(k+1) + gv\%Angstrom\_Z)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{242             \textcolor{comment}{! is this layer vanished?}}
\DoxyCodeLine{243             eta1d(k) = eta1d(k+1) + gv\%Angstrom\_Z}
\DoxyCodeLine{244             h(i,j,k) = gv\%Angstrom\_H}
\DoxyCodeLine{245           \textcolor{keywordflow}{else}}
\DoxyCodeLine{246             h(i,j,k) = gv\%Z\_to\_H * (eta1d(k) -\/ eta1d(k+1))}
\DoxyCodeLine{247 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{248 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{249 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{250 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{251 }
\DoxyCodeLine{252     \textcolor{keyword}{call }initialize\_ale\_sponge(idamp, g, param\_file, acsp, h, nz)}
\DoxyCodeLine{253 }
\DoxyCodeLine{254     \textcolor{comment}{! construct temperature and salinity for the sponge}}
\DoxyCodeLine{255     \textcolor{comment}{! start with initial condition}}
\DoxyCodeLine{256     t(:,:,:) = t\_ref}
\DoxyCodeLine{257     s(:,:,:) = s\_ref}
\DoxyCodeLine{258 }
\DoxyCodeLine{259     \textcolor{keywordflow}{do} j = g\%jsc,g\%jec}
\DoxyCodeLine{260       \textcolor{keywordflow}{do} i = g\%isc,g\%iec}
\DoxyCodeLine{261         zi = 0.}
\DoxyCodeLine{262         x = (g\%geoLonT(i,j) -\/ g\%west\_lon) / g\%len\_lon}
\DoxyCodeLine{263         \textcolor{keywordflow}{do} k = 1,nz}
\DoxyCodeLine{264           \textcolor{comment}{! nondimensional middle of layer}}
\DoxyCodeLine{265           zmid = zi + 0.5 * h(i,j,k) / (gv\%Z\_to\_H * g\%max\_depth)}
\DoxyCodeLine{266 }
\DoxyCodeLine{267           \textcolor{keywordflow}{if} (x > (1. -\/ east\_sponge\_width)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{268             \textcolor{comment}{!if (zmid >= 0.9 * sill\_height) \&}}
\DoxyCodeLine{269                  s(i,j,k) = s\_ref + s\_dense}
\DoxyCodeLine{270           \textcolor{keywordflow}{else}}
\DoxyCodeLine{271             \textcolor{comment}{! linear between bottom of mixed layer and bottom}}
\DoxyCodeLine{272             \textcolor{keywordflow}{if} (zmid >= mld) \&}
\DoxyCodeLine{273                  s(i,j,k) = s\_ref + s\_range * (zmid -\/ mld) / (1.0 -\/ mld)}
\DoxyCodeLine{274 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{275 }
\DoxyCodeLine{276           zi = zi + h(i,j,k) / (gv\%Z\_to\_H * g\%max\_depth)}
\DoxyCodeLine{277 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{278 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{279 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{280 }
\DoxyCodeLine{281     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv\%T)) \textcolor{keyword}{call }set\_up\_ale\_sponge\_field(t, g, tv\%T, acsp)}
\DoxyCodeLine{282     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv\%S)) \textcolor{keyword}{call }set\_up\_ale\_sponge\_field(s, g, tv\%S, acsp)}
\DoxyCodeLine{283   \textcolor{keywordflow}{else}}
\DoxyCodeLine{284     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"dense\_water\_initialize\_sponges: trying to use non ALE sponge"})}
\DoxyCodeLine{285 \textcolor{keywordflow}{  endif}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacedense__water__initialization_ae2a5062c406c66b1917f2ad564d4a5e6}\label{namespacedense__water__initialization_ae2a5062c406c66b1917f2ad564d4a5e6}} 
\index{dense\_water\_initialization@{dense\_water\_initialization}!dense\_water\_initialize\_topography@{dense\_water\_initialize\_topography}}
\index{dense\_water\_initialize\_topography@{dense\_water\_initialize\_topography}!dense\_water\_initialization@{dense\_water\_initialization}}
\doxysubsubsection{\texorpdfstring{dense\_water\_initialize\_topography()}{dense\_water\_initialize\_topography()}}
{\footnotesize\ttfamily subroutine, public dense\+\_\+water\+\_\+initialization\+::dense\+\_\+water\+\_\+initialize\+\_\+topography (\begin{DoxyParamCaption}\item[{real, dimension(g\%isd\+:g\%ied,g\%jsd\+:g\%jed), intent(out)}]{D,  }\item[{type(dyn\+\_\+horgrid\+\_\+type), intent(in)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{real, intent(in)}]{max\+\_\+depth }\end{DoxyParamCaption})}



Initialize the topography field for the dense water experiment. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The dynamic horizontal grid type \\
\hline
\mbox{\texttt{ out}}  & {\em d} & Ocean bottom depth in the units of depth\+\_\+max \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & Parameter file structure \\
\hline
\mbox{\texttt{ in}}  & {\em max\+\_\+depth} & Maximum ocean depth in arbitrary units \\
\hline
\end{DoxyParams}


Definition at line 36 of file dense\+\_\+water\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{36   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),  \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{ !< The dynamic horizontal grid type}}
\DoxyCodeLine{37 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(G\%isd:G\%ied,G\%jsd:G\%jed)}, \&}
\DoxyCodeLine{38                            \textcolor{keywordtype}{intent(out)} :: D\textcolor{comment}{ !< Ocean bottom depth in the units of depth\_max}}
\DoxyCodeLine{39   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{ !< Parameter file structure}}
\DoxyCodeLine{40 \textcolor{keywordtype}{  real},                    \textcolor{keywordtype}{intent(in)}  :: max\_depth\textcolor{comment}{ !< Maximum ocean depth in arbitrary units}}
\DoxyCodeLine{41 }
\DoxyCodeLine{42   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{43 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(5)} :: domain\_params \textcolor{comment}{! nondimensional widths of all domain sections}}
\DoxyCodeLine{44 \textcolor{keywordtype}{  real} :: sill\_frac, shelf\_frac}
\DoxyCodeLine{45   \textcolor{keywordtype}{integer} :: i, j}
\DoxyCodeLine{46 \textcolor{keywordtype}{  real} :: x}
\DoxyCodeLine{47 }
\DoxyCodeLine{48   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DENSE\_WATER\_DOMAIN\_PARAMS"}, domain\_params, \&}
\DoxyCodeLine{49        \textcolor{stringliteral}{"Fractional widths of all the domain sections for the dense water experiment.\(\backslash\)n"}//\&}
\DoxyCodeLine{50        \textcolor{stringliteral}{"As a 5-\/element vector:\(\backslash\)n"}//\&}
\DoxyCodeLine{51        \textcolor{stringliteral}{"  -\/ open ocean, the section at maximum depth\(\backslash\)n"}//\&}
\DoxyCodeLine{52        \textcolor{stringliteral}{"  -\/ downslope, the downward overflow slope\(\backslash\)n"}//\&}
\DoxyCodeLine{53        \textcolor{stringliteral}{"  -\/ sill separating downslope from upslope\(\backslash\)n"}//\&}
\DoxyCodeLine{54        \textcolor{stringliteral}{"  -\/ upslope, the upward slope accumulating dense water\(\backslash\)n"}//\&}
\DoxyCodeLine{55        \textcolor{stringliteral}{"  -\/ the shelf in the dense formation region."}, \&}
\DoxyCodeLine{56        units=\textcolor{stringliteral}{"nondim"}, fail\_if\_missing=.true.)}
\DoxyCodeLine{57   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DENSE\_WATER\_SILL\_DEPTH"}, sill\_frac, \&}
\DoxyCodeLine{58        \textcolor{stringliteral}{"Depth of the sill separating downslope from upslope, as fraction of basin depth."}, \&}
\DoxyCodeLine{59        units=\textcolor{stringliteral}{"nondim"}, default=default\_sill)}
\DoxyCodeLine{60   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DENSE\_WATER\_SHELF\_DEPTH"}, shelf\_frac, \&}
\DoxyCodeLine{61        \textcolor{stringliteral}{"Depth of the shelf region accumulating dense water for overflow, as fraction of basin depth."}, \&}
\DoxyCodeLine{62        units=\textcolor{stringliteral}{"nondim"}, default=default\_shelf)}
\DoxyCodeLine{63 }
\DoxyCodeLine{64   \textcolor{keywordflow}{do} i = 2, 5}
\DoxyCodeLine{65     \textcolor{comment}{! turn widths into positions}}
\DoxyCodeLine{66     domain\_params(i) = domain\_params(i-\/1) + domain\_params(i)}
\DoxyCodeLine{67 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{68 }
\DoxyCodeLine{69   \textcolor{keywordflow}{do} j = g\%jsc,g\%jec}
\DoxyCodeLine{70     \textcolor{keywordflow}{do} i = g\%isc,g\%iec}
\DoxyCodeLine{71       \textcolor{comment}{! compute normalised zonal coordinate}}
\DoxyCodeLine{72       x = (g\%geoLonT(i,j) -\/ g\%west\_lon) / g\%len\_lon}
\DoxyCodeLine{73 }
\DoxyCodeLine{74       \textcolor{keywordflow}{if} (x <= domain\_params(1)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{75         \textcolor{comment}{! open ocean region}}
\DoxyCodeLine{76         d(i,j) = max\_depth}
\DoxyCodeLine{77       \textcolor{keywordflow}{elseif} (x <= domain\_params(2)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{78         \textcolor{comment}{! downslope region, linear}}
\DoxyCodeLine{79         d(i,j) = max\_depth -\/ (1.0 -\/ sill\_frac) * max\_depth * \&}
\DoxyCodeLine{80              (x -\/ domain\_params(1)) / (domain\_params(2) -\/ domain\_params(1))}
\DoxyCodeLine{81       \textcolor{keywordflow}{elseif} (x <= domain\_params(3)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{82         \textcolor{comment}{! sill region}}
\DoxyCodeLine{83         d(i,j) = sill\_frac * max\_depth}
\DoxyCodeLine{84       \textcolor{keywordflow}{elseif} (x <= domain\_params(4)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{85         \textcolor{comment}{! upslope region}}
\DoxyCodeLine{86         d(i,j) = sill\_frac * max\_depth + (shelf\_frac -\/ sill\_frac) * max\_depth * \&}
\DoxyCodeLine{87              (x -\/ domain\_params(3)) / (domain\_params(4) -\/ domain\_params(3))}
\DoxyCodeLine{88       \textcolor{keywordflow}{else}}
\DoxyCodeLine{89         \textcolor{comment}{! shelf region}}
\DoxyCodeLine{90         d(i,j) = shelf\_frac * max\_depth}
\DoxyCodeLine{91 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{92 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{93 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{94 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacedense__water__initialization_a0e1384953bfbb302a7b93dd7abb6cb7b}\label{namespacedense__water__initialization_a0e1384953bfbb302a7b93dd7abb6cb7b}} 
\index{dense\_water\_initialization@{dense\_water\_initialization}!dense\_water\_initialize\_ts@{dense\_water\_initialize\_ts}}
\index{dense\_water\_initialize\_ts@{dense\_water\_initialize\_ts}!dense\_water\_initialization@{dense\_water\_initialization}}
\doxysubsubsection{\texorpdfstring{dense\_water\_initialize\_ts()}{dense\_water\_initialize\_ts()}}
{\footnotesize\ttfamily subroutine, public dense\+\_\+water\+\_\+initialization\+::dense\+\_\+water\+\_\+initialize\+\_\+ts (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(eos\+\_\+type), pointer}]{eqn\+\_\+of\+\_\+state,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(out)}]{T,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(out)}]{S,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(in)}]{h,  }\item[{logical, intent(in), optional}]{just\+\_\+read\+\_\+params }\end{DoxyParamCaption})}



Initialize the temperature and salinity for the dense water experiment. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & Horizontal grid control structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Vertical grid control structure \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & Parameter file structure \\
\hline
 & {\em eqn\+\_\+of\+\_\+state} & E\+OS structure \\
\hline
\mbox{\texttt{ out}}  & {\em t} & Output temperature \mbox{[}degC\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em s} & Output salinity \mbox{[}ppt\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em just\+\_\+read\+\_\+params} & If present and true, this call will only read parameters without changing h. \\
\hline
\end{DoxyParams}


Definition at line 99 of file dense\+\_\+water\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{99   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{ !< Horizontal grid control structure}}
\DoxyCodeLine{100   \textcolor{keywordtype}{type}(verticalGrid\_type),                   \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{ !< Vertical grid control structure}}
\DoxyCodeLine{101   \textcolor{keywordtype}{type}(param\_file\_type),                     \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{ !< Parameter file structure}}
\DoxyCodeLine{102   \textcolor{keywordtype}{type}(EOS\_type),                            \textcolor{keywordtype}{pointer}     :: eqn\_of\_state\textcolor{comment}{ !< EOS structure}}
\DoxyCodeLine{103 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(out)} :: T\textcolor{comment}{ !< Output temperature [degC]}}
\DoxyCodeLine{104 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(out)} :: S\textcolor{comment}{ !< Output salinity [ppt]}}
\DoxyCodeLine{105 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}  :: h\textcolor{comment}{ !< Layer thicknesses [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{106   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: just\_read\_params\textcolor{comment}{ !< If present and true, this call will}}
\DoxyCodeLine{107 \textcolor{comment}{                                                      !! only read parameters without changing h.}}
\DoxyCodeLine{108   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{109 \textcolor{keywordtype}{  real} :: mld, S\_ref, S\_range, T\_ref}
\DoxyCodeLine{110 \textcolor{keywordtype}{  real} :: zi, zmid}
\DoxyCodeLine{111   \textcolor{keywordtype}{logical} :: just\_read    \textcolor{comment}{! If true, just read parameters but set nothing.}}
\DoxyCodeLine{112   \textcolor{keywordtype}{integer} :: i, j, k, nz}
\DoxyCodeLine{113 }
\DoxyCodeLine{114   nz = gv\%ke}
\DoxyCodeLine{115 }
\DoxyCodeLine{116   just\_read = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(just\_read\_params)) just\_read = just\_read\_params}
\DoxyCodeLine{117 }
\DoxyCodeLine{118   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DENSE\_WATER\_MLD"}, mld, \&}
\DoxyCodeLine{119        \textcolor{stringliteral}{"Depth of unstratified mixed layer as a fraction of the water column."}, \&}
\DoxyCodeLine{120        units=\textcolor{stringliteral}{"nondim"}, default=default\_mld, do\_not\_log=just\_read)}
\DoxyCodeLine{121   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"S\_REF"}, s\_ref, \textcolor{stringliteral}{'Reference salinity'}, \&}
\DoxyCodeLine{122                  default=35.0, units=\textcolor{stringliteral}{'1e-\/3'}, do\_not\_log=just\_read)}
\DoxyCodeLine{123   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"T\_REF"}, t\_ref, \textcolor{stringliteral}{'Reference temperature'}, units=\textcolor{stringliteral}{'degC'}, \&}
\DoxyCodeLine{124                 fail\_if\_missing=.not.just\_read, do\_not\_log=just\_read)}
\DoxyCodeLine{125   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"S\_RANGE"}, s\_range, \textcolor{stringliteral}{'Initial salinity range'}, \&}
\DoxyCodeLine{126                 units=\textcolor{stringliteral}{'1e-\/3'}, default=2.0, do\_not\_log=just\_read)}
\DoxyCodeLine{127 }
\DoxyCodeLine{128   \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! All run-\/time parameters have been read, so return.}}
\DoxyCodeLine{129 }
\DoxyCodeLine{130   \textcolor{comment}{! uniform temperature everywhere}}
\DoxyCodeLine{131   t(:,:,:) = t\_ref}
\DoxyCodeLine{132 }
\DoxyCodeLine{133   \textcolor{keywordflow}{do} j = g\%jsc,g\%jec}
\DoxyCodeLine{134     \textcolor{keywordflow}{do} i = g\%isc,g\%iec}
\DoxyCodeLine{135       zi = 0.}
\DoxyCodeLine{136       \textcolor{keywordflow}{do} k = 1,nz}
\DoxyCodeLine{137         \textcolor{comment}{! nondimensional middle of layer}}
\DoxyCodeLine{138         zmid = zi + 0.5 * h(i,j,k) / (gv\%Z\_to\_H * g\%max\_depth)}
\DoxyCodeLine{139 }
\DoxyCodeLine{140         \textcolor{keywordflow}{if} (zmid < mld) \textcolor{keywordflow}{then}}
\DoxyCodeLine{141           \textcolor{comment}{! use reference salinity in the mixed layer}}
\DoxyCodeLine{142           s(i,j,k) = s\_ref}
\DoxyCodeLine{143         \textcolor{keywordflow}{else}}
\DoxyCodeLine{144           \textcolor{comment}{! linear between bottom of mixed layer and bottom}}
\DoxyCodeLine{145           s(i,j,k) = s\_ref + s\_range * (zmid -\/ mld) / (1.0 -\/ mld)}
\DoxyCodeLine{146 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{147 }
\DoxyCodeLine{148         zi = zi + h(i,j,k) / (gv\%Z\_to\_H * g\%max\_depth)}
\DoxyCodeLine{149 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{150 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{151 \textcolor{keywordflow}{  enddo}}

\end{DoxyCode}
