\hypertarget{namespaceadjustment__initialization}{}\doxysection{adjustment\+\_\+initialization Module Reference}
\label{namespaceadjustment__initialization}\index{adjustment\_initialization@{adjustment\_initialization}}


\doxysubsection{Detailed Description}
Configures the model for the geostrophic adjustment test case. \doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespaceadjustment__initialization_a2110f0a8ae700fae8c42a547d2f39b4f}{adjustment\+\_\+initialize\+\_\+thickness}} (h, G, GV, US, param\+\_\+file, just\+\_\+read\+\_\+params)
\begin{DoxyCompactList}\small\item\em Initializes the layer thicknesses in the adjustment test case. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceadjustment__initialization_ae0c61c50817df8ce7297d2b6904a5b10}{adjustment\+\_\+initialize\+\_\+temperature\+\_\+salinity}} (T, S, h, G, GV, param\+\_\+file, eqn\+\_\+of\+\_\+state, just\+\_\+read\+\_\+params)
\begin{DoxyCompactList}\small\item\em Initialization of temperature and salinity in the adjustment test case. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespaceadjustment__initialization_a0b6083bd092822290a58a5fd042f0b60}\label{namespaceadjustment__initialization_a0b6083bd092822290a58a5fd042f0b60}} 
character(len=40) \mbox{\hyperlink{namespaceadjustment__initialization_a0b6083bd092822290a58a5fd042f0b60}{mdl}} = \char`\"{}adjustment\+\_\+initialization\char`\"{}
\begin{DoxyCompactList}\small\item\em This module\textquotesingle{}s name. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespaceadjustment__initialization_ae0c61c50817df8ce7297d2b6904a5b10}\label{namespaceadjustment__initialization_ae0c61c50817df8ce7297d2b6904a5b10}} 
\index{adjustment\_initialization@{adjustment\_initialization}!adjustment\_initialize\_temperature\_salinity@{adjustment\_initialize\_temperature\_salinity}}
\index{adjustment\_initialize\_temperature\_salinity@{adjustment\_initialize\_temperature\_salinity}!adjustment\_initialization@{adjustment\_initialization}}
\doxysubsubsection{\texorpdfstring{adjustment\_initialize\_temperature\_salinity()}{adjustment\_initialize\_temperature\_salinity()}}
{\footnotesize\ttfamily subroutine, public adjustment\+\_\+initialization\+::adjustment\+\_\+initialize\+\_\+temperature\+\_\+salinity (\begin{DoxyParamCaption}\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g), szk\+\_\+(g)), intent(out)}]{T,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g), szk\+\_\+(g)), intent(out)}]{S,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g), szk\+\_\+(g)), intent(in)}]{h,  }\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[{logical, intent(in), optional}]{just\+\_\+read\+\_\+params }\end{DoxyParamCaption})}



Initialization of temperature and salinity in the adjustment test case. 


\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{ out}}  & {\em t} & The temperature that is being initialized. \\
\hline
\mbox{\texttt{ out}}  & {\em s} & The salinity that is being initialized. \\
\hline
\mbox{\texttt{ in}}  & {\em h} & The model thicknesses \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
 & {\em eqn\+\_\+of\+\_\+state} & Equation of state. \\
\hline
\mbox{\texttt{ in}}  & {\em just\+\_\+read\+\_\+params} & If present and true, this call will only read parameters without changing T \& S. \\
\hline
\end{DoxyParams}


Definition at line 198 of file adjustment\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{198   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{           !< The ocean's grid structure.}}
\DoxyCodeLine{199   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{          !< The ocean's vertical grid structure.}}
\DoxyCodeLine{200 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G), SZK\_(G))}, \textcolor{keywordtype}{intent(out)} :: T\textcolor{comment}{ !< The temperature that is being initialized.}}
\DoxyCodeLine{201 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G), SZK\_(G))}, \textcolor{keywordtype}{intent(out)} :: S\textcolor{comment}{ !< The salinity that is being initialized.}}
\DoxyCodeLine{202 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G), SZK\_(G))}, \textcolor{keywordtype}{intent(in)}  :: h\textcolor{comment}{ !< The model thicknesses [H ~> m or kg m-\/2].}}
\DoxyCodeLine{203   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{   !< A structure indicating the open file to}}
\DoxyCodeLine{204 \textcolor{comment}{                                                      !! parse for model parameter values.}}
\DoxyCodeLine{205   \textcolor{keywordtype}{type}(EOS\_type),                 \textcolor{keywordtype}{pointer}     :: eqn\_of\_state\textcolor{comment}{ !< Equation of state.}}
\DoxyCodeLine{206   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: just\_read\_params\textcolor{comment}{ !< If present and true, this call will}}
\DoxyCodeLine{207 \textcolor{comment}{                                                      !! only read parameters without changing T \& S.}}
\DoxyCodeLine{208 }
\DoxyCodeLine{209   \textcolor{keywordtype}{integer}   :: i, j, k, is, ie, js, je, nz}
\DoxyCodeLine{210 \textcolor{keywordtype}{  real}      :: x, y, yy}
\DoxyCodeLine{211   \textcolor{keywordtype}{integer}   :: index\_bay\_z}
\DoxyCodeLine{212 \textcolor{keywordtype}{  real}      :: S\_ref, T\_ref         \textcolor{comment}{! Reference salinity and temerature within}}
\DoxyCodeLine{213                                     \textcolor{comment}{! surface layer}}
\DoxyCodeLine{214 \textcolor{keywordtype}{  real}      :: S\_range, T\_range     \textcolor{comment}{! Range of salinities and temperatures over the}}
\DoxyCodeLine{215                                     \textcolor{comment}{! vertical}}
\DoxyCodeLine{216 \textcolor{keywordtype}{  real}      :: xi0, xi1, dSdz, delta\_S, delta\_S\_strat}
\DoxyCodeLine{217 \textcolor{keywordtype}{  real}      :: adjustment\_width, adjustment\_deltaS}
\DoxyCodeLine{218 \textcolor{keywordtype}{  real}       :: front\_wave\_amp, front\_wave\_length, front\_wave\_asym}
\DoxyCodeLine{219 \textcolor{keywordtype}{  real}      :: eta1d(SZK\_(G)+1)}
\DoxyCodeLine{220   \textcolor{keywordtype}{logical} :: just\_read    \textcolor{comment}{! If true, just read parameters but set nothing.}}
\DoxyCodeLine{221   \textcolor{keywordtype}{character(len=20)} :: verticalCoordinate}
\DoxyCodeLine{222 }
\DoxyCodeLine{223   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{224 }
\DoxyCodeLine{225   just\_read = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(just\_read\_params)) just\_read = just\_read\_params}
\DoxyCodeLine{226 }
\DoxyCodeLine{227   \textcolor{comment}{! Parameters used by main model initialization}}
\DoxyCodeLine{228   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"S\_REF"}, s\_ref, \textcolor{stringliteral}{'Reference salinity'}, \&}
\DoxyCodeLine{229                  default=35.0, units=\textcolor{stringliteral}{'1e-\/3'}, do\_not\_log=just\_read)}
\DoxyCodeLine{230   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"T\_REF"},t\_ref,\textcolor{stringliteral}{'Reference temperature'}, units=\textcolor{stringliteral}{'C'}, \&}
\DoxyCodeLine{231                  fail\_if\_missing=.not.just\_read, do\_not\_log=just\_read)}
\DoxyCodeLine{232   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"S\_RANGE"},s\_range,\textcolor{stringliteral}{'Initial salinity range'}, units=\textcolor{stringliteral}{'1e-\/3'}, \&}
\DoxyCodeLine{233                  default=2.0, do\_not\_log=just\_read)}
\DoxyCodeLine{234   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"T\_RANGE"},t\_range,\textcolor{stringliteral}{'Initial temperature range'}, units=\textcolor{stringliteral}{'C'}, \&}
\DoxyCodeLine{235                  default=0.0, do\_not\_log=just\_read)}
\DoxyCodeLine{236   \textcolor{comment}{! Parameters specific to this experiment configuration BUT logged in previous s/r}}
\DoxyCodeLine{237   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"REGRIDDING\_COORDINATE\_MODE"},verticalcoordinate, \&}
\DoxyCodeLine{238                  default=default\_coordinate\_mode, do\_not\_log=just\_read)}
\DoxyCodeLine{239   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"ADJUSTMENT\_WIDTH"}, adjustment\_width, \&}
\DoxyCodeLine{240                  fail\_if\_missing=.not.just\_read, do\_not\_log=.true.)}
\DoxyCodeLine{241   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"ADJUSTMENT\_DELTAS"}, adjustment\_deltas, \&}
\DoxyCodeLine{242                  fail\_if\_missing=.not.just\_read, do\_not\_log=.true.)}
\DoxyCodeLine{243   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"DELTA\_S\_STRAT"}, delta\_s\_strat, \&}
\DoxyCodeLine{244                  fail\_if\_missing=.not.just\_read, do\_not\_log=.true.)}
\DoxyCodeLine{245   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"FRONT\_WAVE\_AMP"}, front\_wave\_amp, default=0., \&}
\DoxyCodeLine{246                  do\_not\_log=.true.)}
\DoxyCodeLine{247   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"FRONT\_WAVE\_LENGTH"},front\_wave\_length, \&}
\DoxyCodeLine{248                  default=0., do\_not\_log=.true.)}
\DoxyCodeLine{249   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"FRONT\_WAVE\_ASYM"}, front\_wave\_asym, default=0., \&}
\DoxyCodeLine{250                  do\_not\_log=.true.)}
\DoxyCodeLine{251 }
\DoxyCodeLine{252   \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! All run-\/time parameters have been read, so return.}}
\DoxyCodeLine{253 }
\DoxyCodeLine{254   t(:,:,:) = 0.0}
\DoxyCodeLine{255   s(:,:,:) = 0.0}
\DoxyCodeLine{256 }
\DoxyCodeLine{257   \textcolor{comment}{! Linear salinity profile}}
\DoxyCodeLine{258   \textcolor{keywordflow}{select case} ( coordinatemode(verticalcoordinate) )}
\DoxyCodeLine{259 }
\DoxyCodeLine{260     \textcolor{keywordflow}{case} ( regridding\_zstar, regridding\_sigma )}
\DoxyCodeLine{261       dsdz = -\/delta\_s\_strat / g\%max\_depth}
\DoxyCodeLine{262       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{263         eta1d(nz+1) = -\/g\%bathyT(i,j)}
\DoxyCodeLine{264         \textcolor{keywordflow}{do} k=nz,1,-\/1}
\DoxyCodeLine{265           eta1d(k) = eta1d(k+1) + h(i,j,k)*gv\%H\_to\_Z}
\DoxyCodeLine{266 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{267         \textcolor{keywordflow}{if} (front\_wave\_length /= 0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{268           y = ( 0.125 + g\%geoLatT(i,j) / front\_wave\_length ) * ( 4. * acos(0.) )}
\DoxyCodeLine{269           yy = 2. * ( g\%geoLatT(i,j) -\/ 0.5 * g\%len\_lat ) / front\_wave\_length}
\DoxyCodeLine{270           yy = min(1.0, yy); yy = max(-\/1.0, yy)}
\DoxyCodeLine{271           yy = yy * 2. * acos( 0. )}
\DoxyCodeLine{272           y = front\_wave\_amp*sin(y) + front\_wave\_asym*sin(yy)}
\DoxyCodeLine{273         \textcolor{keywordflow}{else}}
\DoxyCodeLine{274           y = 0.}
\DoxyCodeLine{275 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{276         x = ( ( g\%geoLonT(i,j) -\/ 0.5 * g\%len\_lon ) + y ) / adjustment\_width}
\DoxyCodeLine{277         x = min(1.0, x); x = max(-\/1.0, x)}
\DoxyCodeLine{278         x = x * acos( 0. )}
\DoxyCodeLine{279         delta\_s = adjustment\_deltas * 0.5 * (1. -\/ sin( x ) )}
\DoxyCodeLine{280         \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{281           s(i,j,k) = s\_ref + delta\_s + 0.5 * ( eta1d(k)+eta1d(k+1) ) * dsdz}
\DoxyCodeLine{282           x = abs(s(i,j,k) -\/ 0.5*real(nz-\/1)/real(nz)*s\_range)/s\_range*real(2*nz)}
\DoxyCodeLine{283           x = 1. -\/ min(1., x)}
\DoxyCodeLine{284           t(i,j,k) = x}
\DoxyCodeLine{285 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{286    \textcolor{comment}{!    x = GV\%H\_to\_Z*sum(T(i,j,:)*h(i,j,:))}}
\DoxyCodeLine{287    \textcolor{comment}{!    T(i,j,:) = (T(i,j,:) / x) * (G\%max\_depth*1.5/real(nz))}}
\DoxyCodeLine{288 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{289 }
\DoxyCodeLine{290     \textcolor{keywordflow}{case} ( regridding\_layer, regridding\_rho )}
\DoxyCodeLine{291       \textcolor{keywordflow}{do} k = 1,nz}
\DoxyCodeLine{292         s(:,:,k) = s\_ref + s\_range * ( (real(k)-\/0.5) / real( nz ) )}
\DoxyCodeLine{293    \textcolor{comment}{!    x = abs(S(1,1,k) -\/ 0.5*real(nz-\/1)/real(nz)*S\_range)/S\_range*real(2*nz)}}
\DoxyCodeLine{294    \textcolor{comment}{!    x = 1.-\/min(1., x)}}
\DoxyCodeLine{295    \textcolor{comment}{!    T(:,:,k) = x}}
\DoxyCodeLine{296 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{297 }
\DoxyCodeLine{298 \textcolor{keywordflow}{    case default}}
\DoxyCodeLine{299       \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"adjustment\_initialize\_temperature\_salinity: "}// \&}
\DoxyCodeLine{300       \textcolor{stringliteral}{"Unrecognized i.c. setup -\/ set ADJUSTMENT\_IC"})}
\DoxyCodeLine{301 }
\DoxyCodeLine{302 \textcolor{keywordflow}{  end select}}
\DoxyCodeLine{303 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceadjustment__initialization_a2110f0a8ae700fae8c42a547d2f39b4f}\label{namespaceadjustment__initialization_a2110f0a8ae700fae8c42a547d2f39b4f}} 
\index{adjustment\_initialization@{adjustment\_initialization}!adjustment\_initialize\_thickness@{adjustment\_initialize\_thickness}}
\index{adjustment\_initialize\_thickness@{adjustment\_initialize\_thickness}!adjustment\_initialization@{adjustment\_initialization}}
\doxysubsubsection{\texorpdfstring{adjustment\_initialize\_thickness()}{adjustment\_initialize\_thickness()}}
{\footnotesize\ttfamily subroutine, public adjustment\+\_\+initialization\+::adjustment\+\_\+initialize\+\_\+thickness (\begin{DoxyParamCaption}\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), 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})}



Initializes the layer thicknesses in the adjustment test case. 


\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 36 of file adjustment\+\_\+initialization.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{36   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{           !< The ocean's grid structure.}}
\DoxyCodeLine{37   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{          !< The ocean's vertical grid structure.}}
\DoxyCodeLine{38   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{          !< A dimensional unit scaling type}}
\DoxyCodeLine{39 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{40                            \textcolor{keywordtype}{intent(out)} :: h\textcolor{comment}{           !< The thickness that is being initialized [H ~> m or kg m-\/2].}}
\DoxyCodeLine{41   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{  !< A structure indicating the open file}}
\DoxyCodeLine{42 \textcolor{comment}{                                                      !! to parse for model parameter values.}}
\DoxyCodeLine{43   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: just\_read\_params\textcolor{comment}{ !< If present and true, this call will}}
\DoxyCodeLine{44 \textcolor{comment}{                                                      !! only read parameters without changing h.}}
\DoxyCodeLine{45   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{46 \textcolor{keywordtype}{  real} :: e0(SZK\_(G)+1)   \textcolor{comment}{! The resting interface heights, in depth units [Z ~> m], usually}}
\DoxyCodeLine{47                           \textcolor{comment}{! negative because it is positive upward.}}
\DoxyCodeLine{48 \textcolor{keywordtype}{  real} :: eta1D(SZK\_(G)+1)\textcolor{comment}{! Interface height relative to the sea surface}}
\DoxyCodeLine{49                           \textcolor{comment}{! positive upward, in depth units [Z ~> m].}}
\DoxyCodeLine{50 \textcolor{keywordtype}{  real}    :: dRho\_dS      \textcolor{comment}{! The partial derivative of density with salinity [R ppt-\/1 ~> kg m-\/3 ppt-\/1].}}
\DoxyCodeLine{51                           \textcolor{comment}{! In this subroutine it is hard coded at 1.0 kg m-\/3 ppt-\/1.}}
\DoxyCodeLine{52 \textcolor{keywordtype}{  real}    :: x, y, yy}
\DoxyCodeLine{53 \textcolor{keywordtype}{  real}    :: delta\_S\_strat, dSdz, delta\_S, S\_ref}
\DoxyCodeLine{54 \textcolor{keywordtype}{  real}    :: min\_thickness, adjustment\_width, adjustment\_delta}
\DoxyCodeLine{55 \textcolor{keywordtype}{  real}    :: adjustment\_deltaS}
\DoxyCodeLine{56 \textcolor{keywordtype}{  real}    :: front\_wave\_amp, front\_wave\_length, front\_wave\_asym}
\DoxyCodeLine{57 \textcolor{keywordtype}{  real}    :: target\_values(SZK\_(G)+1)  \textcolor{comment}{! Target densities or density anomalies [R ~> kg m-\/3]}}
\DoxyCodeLine{58   \textcolor{keywordtype}{logical} :: just\_read    \textcolor{comment}{! If true, just read parameters but set nothing.}}
\DoxyCodeLine{59   \textcolor{keywordtype}{character(len=20)} :: verticalCoordinate}
\DoxyCodeLine{60 \textcolor{comment}{! This include declares and sets the variable "version".}}
\DoxyCodeLine{61 \textcolor{preprocessor}{\#include "version\_variable.h"}}
\DoxyCodeLine{62 \textcolor{preprocessor}{}  \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz}
\DoxyCodeLine{63 }
\DoxyCodeLine{64   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{65 }
\DoxyCodeLine{66   just\_read = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(just\_read\_params)) just\_read = just\_read\_params}
\DoxyCodeLine{67 }
\DoxyCodeLine{68   \textcolor{keywordflow}{if} (.not.just\_read) \&}
\DoxyCodeLine{69     \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"initialize\_thickness\_uniform: setting thickness"})}
\DoxyCodeLine{70 }
\DoxyCodeLine{71   \textcolor{comment}{! Parameters used by main model initialization}}
\DoxyCodeLine{72   \textcolor{keywordflow}{if} (.not.just\_read) \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})}
\DoxyCodeLine{73   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"S\_REF"}, s\_ref, \textcolor{stringliteral}{'Reference salinity'}, \&}
\DoxyCodeLine{74                  default=35.0, units=\textcolor{stringliteral}{'1e-\/3'}, do\_not\_log=just\_read)}
\DoxyCodeLine{75   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"MIN\_THICKNESS"},min\_thickness,\textcolor{stringliteral}{'Minimum layer thickness'}, \&}
\DoxyCodeLine{76                  default=1.0e-\/3, units=\textcolor{stringliteral}{'m'}, scale=us\%m\_to\_Z, do\_not\_log=just\_read)}
\DoxyCodeLine{77 }
\DoxyCodeLine{78   \textcolor{comment}{! Parameters specific to this experiment configuration}}
\DoxyCodeLine{79   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"REGRIDDING\_COORDINATE\_MODE"},verticalcoordinate, \&}
\DoxyCodeLine{80                  default=default\_coordinate\_mode, do\_not\_log=just\_read)}
\DoxyCodeLine{81   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"ADJUSTMENT\_WIDTH"},adjustment\_width,     \&}
\DoxyCodeLine{82                  \textcolor{stringliteral}{"Width of frontal zone"},                                \&}
\DoxyCodeLine{83                  units=\textcolor{stringliteral}{"same as x,y"}, fail\_if\_missing=.not.just\_read, do\_not\_log=just\_read)}
\DoxyCodeLine{84   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"DELTA\_S\_STRAT"},delta\_s\_strat,           \&}
\DoxyCodeLine{85                  \textcolor{stringliteral}{"Top-\/to-\/bottom salinity difference of stratification"},  \&}
\DoxyCodeLine{86                  units=\textcolor{stringliteral}{"1e-\/3"}, fail\_if\_missing=.not.just\_read, do\_not\_log=just\_read)}
\DoxyCodeLine{87   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"ADJUSTMENT\_DELTAS"},adjustment\_deltas,   \&}
\DoxyCodeLine{88                  \textcolor{stringliteral}{"Salinity difference across front"},                     \&}
\DoxyCodeLine{89                  units=\textcolor{stringliteral}{"1e-\/3"}, fail\_if\_missing=.not.just\_read, do\_not\_log=just\_read)}
\DoxyCodeLine{90   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"FRONT\_WAVE\_AMP"},front\_wave\_amp,         \&}
\DoxyCodeLine{91                  \textcolor{stringliteral}{"Amplitude of trans-\/frontal wave perturbation"},         \&}
\DoxyCodeLine{92                  units=\textcolor{stringliteral}{"same as x,y"}, default=0., do\_not\_log=just\_read)}
\DoxyCodeLine{93   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"FRONT\_WAVE\_LENGTH"},front\_wave\_length,   \&}
\DoxyCodeLine{94                  \textcolor{stringliteral}{"Wave-\/length of trans-\/frontal wave perturbation"},       \&}
\DoxyCodeLine{95                  units=\textcolor{stringliteral}{"same as x,y"}, default=0., do\_not\_log=just\_read)}
\DoxyCodeLine{96   \textcolor{keyword}{call }get\_param(param\_file, mdl,\textcolor{stringliteral}{"FRONT\_WAVE\_ASYM"},front\_wave\_asym,       \&}
\DoxyCodeLine{97                  \textcolor{stringliteral}{"Amplitude of frontal asymmetric perturbation"},         \&}
\DoxyCodeLine{98                  units=\textcolor{stringliteral}{"same as x,y"}, default=0., do\_not\_log=just\_read)}
\DoxyCodeLine{99 }
\DoxyCodeLine{100   \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! All run-\/time parameters have been read, so return.}}
\DoxyCodeLine{101 }
\DoxyCodeLine{102   \textcolor{comment}{! WARNING: this routine specifies the interface heights so that the last layer}}
\DoxyCodeLine{103   \textcolor{comment}{!          is vanished, even at maximum depth. In order to have a uniform}}
\DoxyCodeLine{104   \textcolor{comment}{!          layer distribution, use this line of code within the loop:}}
\DoxyCodeLine{105   \textcolor{comment}{!          e0(k) = -\/G\%max\_depth * real(k-\/1) / real(nz)}}
\DoxyCodeLine{106   \textcolor{comment}{!          To obtain a thickness distribution where the last layer is}}
\DoxyCodeLine{107   \textcolor{comment}{!          vanished and the other thicknesses uniformly distributed, use:}}
\DoxyCodeLine{108   \textcolor{comment}{!          e0(k) = -\/G\%max\_depth * real(k-\/1) / real(nz-\/1)}}
\DoxyCodeLine{109 }
\DoxyCodeLine{110   dsdz = -\/delta\_s\_strat / g\%max\_depth}
\DoxyCodeLine{111 }
\DoxyCodeLine{112   \textcolor{keywordflow}{select case} ( coordinatemode(verticalcoordinate) )}
\DoxyCodeLine{113 }
\DoxyCodeLine{114     \textcolor{keywordflow}{case} ( regridding\_layer, regridding\_rho )}
\DoxyCodeLine{115       drho\_ds = 1.0 * us\%kg\_m3\_to\_R}
\DoxyCodeLine{116       \textcolor{keywordflow}{if} (delta\_s\_strat /= 0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{117         \textcolor{comment}{! This was previously coded ambiguously.}}
\DoxyCodeLine{118         adjustment\_delta = (adjustment\_deltas / delta\_s\_strat) * g\%max\_depth}
\DoxyCodeLine{119         \textcolor{keywordflow}{do} k=1,nz+1}
\DoxyCodeLine{120           e0(k) = adjustment\_delta -\/ (g\%max\_depth + 2*adjustment\_delta) * (real(k-\/1) / real(nz))}
\DoxyCodeLine{121 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{122       \textcolor{keywordflow}{else}}
\DoxyCodeLine{123         adjustment\_delta = 2.*g\%max\_depth}
\DoxyCodeLine{124         \textcolor{keywordflow}{do} k=1,nz+1}
\DoxyCodeLine{125           e0(k) = -\/g\%max\_depth * (real(k-\/1) / real(nz))}
\DoxyCodeLine{126 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{127 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{128       \textcolor{keywordflow}{if} (nz > 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{129         target\_values(1)    = ( gv\%Rlay(1) + 0.5*(gv\%Rlay(1)-\/gv\%Rlay(2)) )}
\DoxyCodeLine{130         target\_values(nz+1) = ( gv\%Rlay(nz) + 0.5*(gv\%Rlay(nz)-\/gv\%Rlay(nz-\/1)) )}
\DoxyCodeLine{131       \textcolor{keywordflow}{else} \textcolor{comment}{! This might not be needed, but it avoids segmentation faults if nz=1.}}
\DoxyCodeLine{132         target\_values(1)    = 0.0}
\DoxyCodeLine{133         target\_values(nz+1) = 2.0 * gv\%Rlay(1)}
\DoxyCodeLine{134 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{135       \textcolor{keywordflow}{do} k = 2,nz}
\DoxyCodeLine{136         target\_values(k) = target\_values(k-\/1) + ( gv\%Rlay(nz) -\/ gv\%Rlay(1) ) / (nz-\/1)}
\DoxyCodeLine{137 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{138       target\_values(:) = target\_values(:) -\/ 1000.*us\%kg\_m3\_to\_R}
\DoxyCodeLine{139       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{140         \textcolor{keywordflow}{if} (front\_wave\_length /= 0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{141           y = ( 0.125 + g\%geoLatT(i,j) / front\_wave\_length ) * ( 4. * acos(0.) )}
\DoxyCodeLine{142           yy = 2. * ( g\%geoLatT(i,j) -\/ 0.5 * g\%len\_lat ) / adjustment\_width}
\DoxyCodeLine{143           yy = min(1.0, yy); yy = max(-\/1.0, yy)}
\DoxyCodeLine{144           yy = yy * 2. * acos( 0. )}
\DoxyCodeLine{145           y = front\_wave\_amp*sin(y) + front\_wave\_asym*sin(yy)}
\DoxyCodeLine{146         \textcolor{keywordflow}{else}}
\DoxyCodeLine{147           y = 0.}
\DoxyCodeLine{148 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{149         x = ( ( g\%geoLonT(i,j) -\/ 0.5 * g\%len\_lon ) + y ) / adjustment\_width}
\DoxyCodeLine{150         x = min(1.0, x); x = max(-\/1.0, x)}
\DoxyCodeLine{151         x = x * acos( 0. )}
\DoxyCodeLine{152         delta\_s = adjustment\_deltas * 0.5 * (1. -\/ sin( x ) )}
\DoxyCodeLine{153         \textcolor{keywordflow}{do} k=2,nz}
\DoxyCodeLine{154           \textcolor{keywordflow}{if} (drho\_ds*dsdz /= 0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{155             eta1d(k) = ( target\_values(k) -\/ drho\_ds*( s\_ref + delta\_s ) ) / (drho\_ds*dsdz)}
\DoxyCodeLine{156           \textcolor{keywordflow}{else}}
\DoxyCodeLine{157             eta1d(k) = e0(k) -\/ (0.5*adjustment\_delta) * sin( x )}
\DoxyCodeLine{158 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{159           eta1d(k) = max( eta1d(k), -\/g\%max\_depth )}
\DoxyCodeLine{160           eta1d(k) = min( eta1d(k), 0. )}
\DoxyCodeLine{161 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{162         eta1d(1) = 0.; eta1d(nz+1) = -\/g\%max\_depth}
\DoxyCodeLine{163         \textcolor{keywordflow}{do} k=nz,1,-\/1}
\DoxyCodeLine{164           \textcolor{keywordflow}{if} (eta1d(k) > 0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{165             eta1d(k) = max( eta1d(k+1) + min\_thickness, 0. )}
\DoxyCodeLine{166             h(i,j,k) = gv\%Z\_to\_H * max( eta1d(k) -\/ eta1d(k+1), min\_thickness )}
\DoxyCodeLine{167           \textcolor{keywordflow}{elseif} (eta1d(k) <= (eta1d(k+1) + min\_thickness)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{168             eta1d(k) = eta1d(k+1) + min\_thickness}
\DoxyCodeLine{169             h(i,j,k) = gv\%Z\_to\_H * min\_thickness}
\DoxyCodeLine{170           \textcolor{keywordflow}{else}}
\DoxyCodeLine{171             h(i,j,k) = gv\%Z\_to\_H * (eta1d(k) -\/ eta1d(k+1))}
\DoxyCodeLine{172 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{173 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{174 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{175 }
\DoxyCodeLine{176     \textcolor{keywordflow}{case} ( regridding\_zstar, regridding\_sigma )}
\DoxyCodeLine{177       \textcolor{keywordflow}{do} k=1,nz+1}
\DoxyCodeLine{178         eta1d(k) = -\/g\%max\_depth * (real(k-\/1) / real(nz))}
\DoxyCodeLine{179         eta1d(k) = max(min(eta1d(k), 0.), -\/g\%max\_depth)}
\DoxyCodeLine{180 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{181       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{182         \textcolor{keywordflow}{do} k=nz,1,-\/1}
\DoxyCodeLine{183           h(i,j,k) = gv\%Z\_to\_H * (eta1d(k) -\/ eta1d(k+1))}
\DoxyCodeLine{184 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{185 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{186 }
\DoxyCodeLine{187 \textcolor{keywordflow}{    case default}}
\DoxyCodeLine{188       \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"adjustment\_initialize\_thickness: "}// \&}
\DoxyCodeLine{189                      \textcolor{stringliteral}{"Unrecognized i.c. setup -\/ set ADJUSTMENT\_IC"})}
\DoxyCodeLine{190 }
\DoxyCodeLine{191 \textcolor{keywordflow}{  end select}}
\DoxyCodeLine{192 }

\end{DoxyCode}
