\hypertarget{namespacelock__exchange__initialization}{}\doxysection{lock\+\_\+exchange\+\_\+initialization Module Reference}
\label{namespacelock__exchange__initialization}\index{lock\_exchange\_initialization@{lock\_exchange\_initialization}}


\doxysubsection{Detailed Description}
Initialization of the \char`\"{}lock exchange\char`\"{} experiment. lock\+\_\+exchange = A 2-\/d density driven hydraulic exchange flow. \doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacelock__exchange__initialization_a031749f6391fa3a8e517889e96ad6115}{lock\+\_\+exchange\+\_\+initialize\+\_\+thickness}} (h, G, GV, US, param\+\_\+file, just\+\_\+read\+\_\+params)
\begin{DoxyCompactList}\small\item\em This subroutine initializes layer thicknesses for the lock\+\_\+exchange experiment. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacelock__exchange__initialization_a031749f6391fa3a8e517889e96ad6115}\label{namespacelock__exchange__initialization_a031749f6391fa3a8e517889e96ad6115}} 
\index{lock\_exchange\_initialization@{lock\_exchange\_initialization}!lock\_exchange\_initialize\_thickness@{lock\_exchange\_initialize\_thickness}}
\index{lock\_exchange\_initialize\_thickness@{lock\_exchange\_initialize\_thickness}!lock\_exchange\_initialization@{lock\_exchange\_initialization}}
\doxysubsubsection{\texorpdfstring{lock\_exchange\_initialize\_thickness()}{lock\_exchange\_initialize\_thickness()}}
{\footnotesize\ttfamily subroutine, public lock\+\_\+exchange\+\_\+initialization\+::lock\+\_\+exchange\+\_\+initialize\+\_\+thickness (\begin{DoxyParamCaption}\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(out)}]{h,  }\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(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{logical, intent(in), optional}]{just\+\_\+read\+\_\+params }\end{DoxyParamCaption})}



This subroutine initializes layer thicknesses for the lock\+\_\+exchange experiment. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ out}}  & {\em h} & The thickness that is being initialized \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure indicating the open file to parse for model parameter values. \\
\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 26 of file lock\+\_\+exchange\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{27   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{           !< The ocean's grid structure.}}
\DoxyCodeLine{28   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{          !< The ocean's vertical grid structure.}}
\DoxyCodeLine{29   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{          !< A dimensional unit scaling type}}
\DoxyCodeLine{30 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{31                            \textcolor{keywordtype}{intent(out)} :: h\textcolor{comment}{           !< The thickness that is being initialized [H \string~> m or kg m-\/2].}}
\DoxyCodeLine{32   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{  !< A structure indicating the open file}}
\DoxyCodeLine{33 \textcolor{comment}{                                                      !! to parse for model parameter values.}}
\DoxyCodeLine{34   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: just\_read\_params\textcolor{comment}{ !< If present and true, this call will}}
\DoxyCodeLine{35 \textcolor{comment}{                                                      !! only read parameters without changing h.}}
\DoxyCodeLine{36 }
\DoxyCodeLine{37 \textcolor{keywordtype}{  real} :: e0(SZK\_(GV))     \textcolor{comment}{! The resting interface heights [Z \string~> m], usually}}
\DoxyCodeLine{38                            \textcolor{comment}{! negative because it is positive upward.}}
\DoxyCodeLine{39 \textcolor{keywordtype}{  real} :: e\_pert(SZK\_(GV)) \textcolor{comment}{! Interface height perturbations, positive upward [Z \string~> m].}}
\DoxyCodeLine{40 \textcolor{keywordtype}{  real} :: eta1D(SZK\_(GV)+1)\textcolor{comment}{! Interface height relative to the sea surface}}
\DoxyCodeLine{41                            \textcolor{comment}{! positive upward [Z \string~> m].}}
\DoxyCodeLine{42 \textcolor{keywordtype}{  real} :: front\_displacement \textcolor{comment}{! Vertical displacement acrodd front}}
\DoxyCodeLine{43 \textcolor{keywordtype}{  real} :: thermocline\_thickness \textcolor{comment}{! Thickness of stratified region}}
\DoxyCodeLine{44   \textcolor{keywordtype}{logical} :: just\_read    \textcolor{comment}{! If true, just read parameters but set nothing.}}
\DoxyCodeLine{45 \textcolor{comment}{! This include declares and sets the variable "version".}}
\DoxyCodeLine{46 \textcolor{preprocessor}{\#include "version\_variable.h"}}
\DoxyCodeLine{47 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"lock\_exchange\_initialize\_thickness"} \textcolor{comment}{! This subroutine's name.}}
\DoxyCodeLine{48   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz}
\DoxyCodeLine{49 }
\DoxyCodeLine{50   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{51 }
\DoxyCodeLine{52   just\_read = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(just\_read\_params)) just\_read = just\_read\_params}
\DoxyCodeLine{53 }
\DoxyCodeLine{54   \textcolor{keywordflow}{if} (.not.just\_read) \&}
\DoxyCodeLine{55     \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"  lock\_exchange\_initialization.F90, lock\_exchange\_initialize\_thickness: setting thickness"}, 5)}
\DoxyCodeLine{56 }
\DoxyCodeLine{57   \textcolor{keywordflow}{if} (.not.just\_read) \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})}
\DoxyCodeLine{58   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FRONT\_DISPLACEMENT"}, front\_displacement, \&}
\DoxyCodeLine{59                  \textcolor{stringliteral}{"The vertical displacement of interfaces across the front. "}//\&}
\DoxyCodeLine{60                  \textcolor{stringliteral}{"A value larger in magnitude that MAX\_DEPTH is truncated,"}, \&}
\DoxyCodeLine{61                  units=\textcolor{stringliteral}{"m"}, fail\_if\_missing=.not.just\_read, do\_not\_log=just\_read, scale=us\%m\_to\_Z)}
\DoxyCodeLine{62   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"THERMOCLINE\_THICKNESS"}, thermocline\_thickness, \&}
\DoxyCodeLine{63                  \textcolor{stringliteral}{"The thickness of the thermocline in the lock exchange "}//\&}
\DoxyCodeLine{64                  \textcolor{stringliteral}{"experiment.  A value of zero creates a two layer system "}//\&}
\DoxyCodeLine{65                  \textcolor{stringliteral}{"with vanished layers in between the two inflated layers."}, \&}
\DoxyCodeLine{66                  default=0., units=\textcolor{stringliteral}{"m"}, do\_not\_log=just\_read, scale=us\%m\_to\_Z)}
\DoxyCodeLine{67 }
\DoxyCodeLine{68   \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! All run-\/time parameters have been read, so return.}}
\DoxyCodeLine{69 }
\DoxyCodeLine{70   \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{71     \textcolor{keywordflow}{do} k=2,nz}
\DoxyCodeLine{72       eta1d(k) = -\/0.5 * g\%max\_depth \& \textcolor{comment}{! Middle of column}}
\DoxyCodeLine{73               -\/ thermocline\_thickness * ( (real(k-\/1))/real(nz) -\/0.5 ) \textcolor{comment}{! Stratification}}
\DoxyCodeLine{74       \textcolor{keywordflow}{if} (g\%geoLonT(i,j)-\/g\%west\_lon < 0.5 * g\%len\_lon) \textcolor{keywordflow}{then}}
\DoxyCodeLine{75         eta1d(k) = eta1d(k) + 0.5 * front\_displacement}
\DoxyCodeLine{76       \textcolor{keywordflow}{elseif} (g\%geoLonT(i,j)-\/g\%west\_lon > 0.5 * g\%len\_lon) \textcolor{keywordflow}{then}}
\DoxyCodeLine{77         eta1d(k) = eta1d(k) -\/ 0.5 * front\_displacement}
\DoxyCodeLine{78 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{79 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{80     eta1d(nz+1) = -\/g\%max\_depth \textcolor{comment}{! Force bottom interface to bottom}}
\DoxyCodeLine{81     \textcolor{keywordflow}{do} k=nz,2,-\/1 \textcolor{comment}{! Make sure interfaces increase upwards}}
\DoxyCodeLine{82       eta1d(k) = max( eta1d(k), eta1d(k+1) + gv\%Angstrom\_Z )}
\DoxyCodeLine{83 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{84     eta1d(1) = 0. \textcolor{comment}{! Force bottom interface to bottom}}
\DoxyCodeLine{85     \textcolor{keywordflow}{do} k=2,nz \textcolor{comment}{! Make sure interfaces decrease downwards}}
\DoxyCodeLine{86       eta1d(k) = min( eta1d(k), eta1d(k-\/1) -\/ gv\%Angstrom\_Z )}
\DoxyCodeLine{87 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{88     \textcolor{keywordflow}{do} k=nz,1,-\/1}
\DoxyCodeLine{89       h(i,j,k) = gv\%Z\_to\_H * (eta1d(k) -\/ eta1d(k+1))}
\DoxyCodeLine{90 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{91 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{92 }

\end{DoxyCode}
