\hypertarget{namespacelock__exchange__initialization}{}\section{lock\+\_\+exchange\+\_\+initialization Module Reference}
\label{namespacelock__exchange__initialization}\index{lock\+\_\+exchange\+\_\+initialization@{lock\+\_\+exchange\+\_\+initialization}}


\subsection{Detailed Description}
Initialization of the \char`\"{}lock exchange\char`\"{} experiment. lock\+\_\+exchange = A 2-\/d density driven hydraulic exchange flow. \subsection*{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}


\subsection{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}}
\subsubsection{\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{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure.\\
\hline
\mbox{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure.\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt out}  & {\em h} & The thickness that is being initialized \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & A structure indicating the open file to parse for model parameter values.\\
\hline
\mbox{\tt in}  & {\em just\+\_\+read\+\_\+params} & If present and true, this call will only read parameters without changing h. \\
\hline
\end{DoxyParams}


Definition at line 27 of file lock\+\_\+exchange\+\_\+initialization.\+F90.


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