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


\subsection{Detailed Description}
Configures the model for the geostrophic adjustment test case. \subsection*{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}
\subsection*{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}


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


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