\hypertarget{namespacebenchmark__initialization}{}\section{benchmark\+\_\+initialization Module Reference}
\label{namespacebenchmark__initialization}\index{benchmark\+\_\+initialization@{benchmark\+\_\+initialization}}


\subsection{Detailed Description}
Initialization for the \char`\"{}bench mark\char`\"{} configuration. \subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \hyperlink{namespacebenchmark__initialization_aa9f5b306237bd4938a117fe871a93ed7}{benchmark\+\_\+initialize\+\_\+topography} (D, G, param\+\_\+file, max\+\_\+depth, US)
\begin{DoxyCompactList}\small\item\em This subroutine sets up the benchmark test case topography. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacebenchmark__initialization_a47e8f35398b09d4d89245097b0eecb6f}{benchmark\+\_\+initialize\+\_\+thickness} (h, G, GV, US, param\+\_\+file, eqn\+\_\+of\+\_\+state, P\+\_\+\+Ref, just\+\_\+read\+\_\+params)
\begin{DoxyCompactList}\small\item\em Initializes layer thicknesses for the benchmark test case, by finding the depths of interfaces in a specified latitude-\/dependent temperature profile with an exponentially decaying thermocline on top of a linear stratification. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespacebenchmark__initialization_a87453c99eb3531147878d61b774c91a8}{benchmark\+\_\+init\+\_\+temperature\+\_\+salinity} (T, S, G, GV, US, param\+\_\+file, eqn\+\_\+of\+\_\+state, P\+\_\+\+Ref, just\+\_\+read\+\_\+params)
\begin{DoxyCompactList}\small\item\em Initializes layer temperatures and salinities for benchmark. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacebenchmark__initialization_a87453c99eb3531147878d61b774c91a8}\label{namespacebenchmark__initialization_a87453c99eb3531147878d61b774c91a8}} 
\index{benchmark\+\_\+initialization@{benchmark\+\_\+initialization}!benchmark\+\_\+init\+\_\+temperature\+\_\+salinity@{benchmark\+\_\+init\+\_\+temperature\+\_\+salinity}}
\index{benchmark\+\_\+init\+\_\+temperature\+\_\+salinity@{benchmark\+\_\+init\+\_\+temperature\+\_\+salinity}!benchmark\+\_\+initialization@{benchmark\+\_\+initialization}}
\subsubsection{\texorpdfstring{benchmark\+\_\+init\+\_\+temperature\+\_\+salinity()}{benchmark\_init\_temperature\_salinity()}}
{\footnotesize\ttfamily subroutine, public benchmark\+\_\+initialization\+::benchmark\+\_\+init\+\_\+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[{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[{type(eos\+\_\+type), pointer}]{eqn\+\_\+of\+\_\+state,  }\item[{real, intent(in)}]{P\+\_\+\+Ref,  }\item[{logical, intent(in), optional}]{just\+\_\+read\+\_\+params }\end{DoxyParamCaption})}



Initializes layer temperatures and salinities for benchmark. 


\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 potential temperature that is being initialized.\\
\hline
\mbox{\tt out}  & {\em s} & The salinity that is being initialized.\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\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 structure\\
\hline
\mbox{\tt in}  & {\em p\+\_\+ref} & The coordinate-\/density reference pressure \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}.\\
\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 217 of file benchmark\+\_\+initialization.\+F90.


\begin{DoxyCode}
217   \textcolor{keywordtype}{type}(ocean\_grid\_type),               \textcolor{keywordtype}{intent(in)}  :: g\textcolor{comment}{            !< The ocean's grid structure.}
218   \textcolor{keywordtype}{type}(verticalgrid\_type),             \textcolor{keywordtype}{intent(in)}  :: gv\textcolor{comment}{           !< The ocean's vertical grid structure.}
219   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(out)} :: t\textcolor{comment}{       !< The potential temperature}
220 \textcolor{comment}{                                                                   !! that is being initialized.}
221   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(out)} :: s\textcolor{comment}{       !< The salinity that is being}
222 \textcolor{comment}{                                                                   !! initialized.}
223   \textcolor{keywordtype}{type}(unit\_scale\_type),                     \textcolor{keywordtype}{intent(in)}  :: us\textcolor{comment}{     !< A dimensional unit scaling type}
224   \textcolor{keywordtype}{type}(param\_file\_type),               \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{   !< A structure indicating the}
225 \textcolor{comment}{                                                                   !! open file to parse for}
226 \textcolor{comment}{                                                                   !! model parameter values.}
227   \textcolor{keywordtype}{type}(eos\_type),                      \textcolor{keywordtype}{pointer}     :: eqn\_of\_state\textcolor{comment}{ !< Equation of state structure}
228   \textcolor{keywordtype}{real},                                \textcolor{keywordtype}{intent(in)}  :: p\_ref\textcolor{comment}{        !< The coordinate-density}
229 \textcolor{comment}{                                                                   !! reference pressure [R L2 T-2 ~> Pa].}
230   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: just\_read\_params\textcolor{comment}{ !< If present and true, this call will}
231 \textcolor{comment}{                                                      !! only read parameters without changing h.}
232   \textcolor{comment}{! Local variables}
233   \textcolor{keywordtype}{real} :: t0(szk\_(g)), s0(szk\_(g))
234   \textcolor{keywordtype}{real} :: pres(szk\_(g))      \textcolor{comment}{! Reference pressure [R L2 T-2 ~> Pa].}
235   \textcolor{keywordtype}{real} :: drho\_dt(szk\_(g))   \textcolor{comment}{! Derivative of density with temperature [R degC-1 ~> kg m-3 degC-1].}
236   \textcolor{keywordtype}{real} :: drho\_ds(szk\_(g))   \textcolor{comment}{! Derivative of density with salinity [R ppt-1 ~> kg m-3 ppt-1].}
237   \textcolor{keywordtype}{real} :: rho\_guess(szk\_(g)) \textcolor{comment}{! Potential density at T0 & S0 [R ~> kg m-3].}
238   \textcolor{keywordtype}{real} :: pi        \textcolor{comment}{! 3.1415926... calculated as 4*atan(1)}
239   \textcolor{keywordtype}{real} :: sst       \textcolor{comment}{!  The initial sea surface temperature [degC].}
240   \textcolor{keywordtype}{real} :: lat
241   \textcolor{keywordtype}{logical} :: just\_read    \textcolor{comment}{! If true, just read parameters but set nothing.}
242   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"benchmark\_init\_temperature\_salinity"} \textcolor{comment}{! This subroutine's name.}
243   \textcolor{keywordtype}{integer} :: i, j, k, k1, is, ie, js, je, nz, itt
244 
245   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
246 
247   just\_read = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(just\_read\_params)) just\_read = just\_read\_params
248 
249   \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! All run-time parameters have been read, so return.}
250 
251   k1 = gv%nk\_rho\_varies + 1
252 
253   \textcolor{keywordflow}{do} k=1,nz
254     pres(k) = p\_ref ; s0(k) = 35.0
255 \textcolor{keywordflow}{  enddo}
256 
257   t0(k1) = 29.0
258   \textcolor{keyword}{call }calculate\_density(t0(k1), s0(k1), pres(k1), rho\_guess(k1), eqn\_of\_state)
259   \textcolor{keyword}{call }calculate\_density\_derivs(t0, s0, pres, drho\_dt, drho\_ds, eqn\_of\_state, (/k1,k1/) )
260 
261 \textcolor{comment}{! A first guess of the layers' temperatures.                         !}
262   \textcolor{keywordflow}{do} k=1,nz
263     t0(k) = t0(k1) + (gv%Rlay(k) - rho\_guess(k1)) / drho\_dt(k1)
264 \textcolor{keywordflow}{  enddo}
265 
266 \textcolor{comment}{! Refine the guesses for each layer.                                 !}
267   \textcolor{keywordflow}{do} itt = 1,6
268     \textcolor{keyword}{call }calculate\_density(t0, s0, pres, rho\_guess, eqn\_of\_state)
269     \textcolor{keyword}{call }calculate\_density\_derivs(t0, s0, pres, drho\_dt, drho\_ds, eqn\_of\_state)
270     \textcolor{keywordflow}{do} k=1,nz
271       t0(k) = t0(k) + (gv%Rlay(k) - rho\_guess(k)) / drho\_dt(k)
272 \textcolor{keywordflow}{    enddo}
273 \textcolor{keywordflow}{  enddo}
274 
275   \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=is,ie ; \textcolor{keywordflow}{do} j=js,je
276     t(i,j,k) = t0(k)
277     s(i,j,k) = s0(k)
278 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
279   pi = 4.0*atan(1.0)
280   \textcolor{keywordflow}{do} i=is,ie ; \textcolor{keywordflow}{do} j=js,je
281     sst = 0.5*(t0(k1)+t0(nz)) - 0.9*0.5*(t0(k1)-t0(nz)) * &
282                                cos(pi*(g%geoLatT(i,j)-g%south\_lat)/(g%len\_lat))
283     \textcolor{keywordflow}{do} k=1,k1-1
284       t(i,j,k) = sst
285 \textcolor{keywordflow}{    enddo}
286 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
287 
\end{DoxyCode}
\mbox{\Hypertarget{namespacebenchmark__initialization_a47e8f35398b09d4d89245097b0eecb6f}\label{namespacebenchmark__initialization_a47e8f35398b09d4d89245097b0eecb6f}} 
\index{benchmark\+\_\+initialization@{benchmark\+\_\+initialization}!benchmark\+\_\+initialize\+\_\+thickness@{benchmark\+\_\+initialize\+\_\+thickness}}
\index{benchmark\+\_\+initialize\+\_\+thickness@{benchmark\+\_\+initialize\+\_\+thickness}!benchmark\+\_\+initialization@{benchmark\+\_\+initialization}}
\subsubsection{\texorpdfstring{benchmark\+\_\+initialize\+\_\+thickness()}{benchmark\_initialize\_thickness()}}
{\footnotesize\ttfamily subroutine, public benchmark\+\_\+initialization\+::benchmark\+\_\+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[{type(eos\+\_\+type), pointer}]{eqn\+\_\+of\+\_\+state,  }\item[{real, intent(in)}]{P\+\_\+\+Ref,  }\item[{logical, intent(in), optional}]{just\+\_\+read\+\_\+params }\end{DoxyParamCaption})}



Initializes layer thicknesses for the benchmark test case, by finding the depths of interfaces in a specified latitude-\/dependent temperature profile with an exponentially decaying thermocline on top of a linear stratification. 


\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
 & {\em eqn\+\_\+of\+\_\+state} & Equation of state structure\\
\hline
\mbox{\tt in}  & {\em p\+\_\+ref} & The coordinate-\/density reference pressure \mbox{[}R L2 T-\/2 $\sim$$>$ Pa\mbox{]}.\\
\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 87 of file benchmark\+\_\+initialization.\+F90.


\begin{DoxyCode}
87   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}  :: g\textcolor{comment}{           !< The ocean's grid structure.}
88   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}  :: gv\textcolor{comment}{          !< The ocean's vertical grid structure.}
89   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}  :: us\textcolor{comment}{ !< A dimensional unit scaling type}
90   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
91                            \textcolor{keywordtype}{intent(out)} :: h\textcolor{comment}{           !< The thickness that is being initialized [H ~> m or
       kg m-2].}
92   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{  !< A structure indicating the open file}
93 \textcolor{comment}{                                                      !! to parse for model parameter values.}
94   \textcolor{keywordtype}{type}(eos\_type),          \textcolor{keywordtype}{pointer}     :: eqn\_of\_state\textcolor{comment}{ !< Equation of state structure}
95   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{intent(in)}  :: p\_ref\textcolor{comment}{       !< The coordinate-density}
96 \textcolor{comment}{                                                      !! reference pressure [R L2 T-2 ~> Pa].}
97   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: just\_read\_params\textcolor{comment}{ !< If present and true, this call will}
98 \textcolor{comment}{                                                      !! only read parameters without changing h.}
99   \textcolor{comment}{! Local variables}
100   \textcolor{keywordtype}{real} :: e0(szk\_(gv)+1)     \textcolor{comment}{! The resting interface heights, in depth units [Z ~> m],}
101                              \textcolor{comment}{! usually negative because it is positive upward.}
102   \textcolor{keywordtype}{real} :: e\_pert(szk\_(gv)+1) \textcolor{comment}{! Interface height perturbations, positive upward,}
103                              \textcolor{comment}{! in depth units [Z ~> m].}
104   \textcolor{keywordtype}{real} :: eta1d(szk\_(gv)+1)  \textcolor{comment}{! Interface height relative to the sea surface}
105                              \textcolor{comment}{! positive upward, in depth units [Z ~> m].}
106   \textcolor{keywordtype}{real} :: sst       \textcolor{comment}{!  The initial sea surface temperature [degC].}
107   \textcolor{keywordtype}{real} :: t\_int     \textcolor{comment}{!  The initial temperature of an interface [degC].}
108   \textcolor{keywordtype}{real} :: ml\_depth  \textcolor{comment}{!  The specified initial mixed layer depth, in depth units [Z ~> m].}
109   \textcolor{keywordtype}{real} :: thermocline\_scale \textcolor{comment}{! The e-folding scale of the thermocline, in depth units [Z ~> m].}
110   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: &
111     t0, s0, &       \textcolor{comment}{! Profiles of temperature [degC] and salinity [ppt]}
112     rho\_guess, &    \textcolor{comment}{! Potential density at T0 & S0 [R ~> kg m-3].}
113     drho\_dt, &      \textcolor{comment}{! Derivative of density with temperature [R degC-1 ~> kg m-3 degC-1].}
114     drho\_ds         \textcolor{comment}{! Derivative of density with salinity [R ppt-1 ~> kg m-3 ppt-1].}
115   \textcolor{keywordtype}{real} :: pres(szk\_(gv))  \textcolor{comment}{! Reference pressure [R L2 T-2 ~> Pa].}
116   \textcolor{keywordtype}{real} :: a\_exp     \textcolor{comment}{! The fraction of the overall stratification that is exponential.}
117   \textcolor{keywordtype}{real} :: i\_ts, i\_md \textcolor{comment}{! Inverse lengthscales [Z-1 ~> m-1].}
118   \textcolor{keywordtype}{real} :: t\_frac    \textcolor{comment}{! A ratio of the interface temperature to the range}
119                     \textcolor{comment}{! between SST and the bottom temperature.}
120   \textcolor{keywordtype}{real} :: err, derr\_dz  \textcolor{comment}{! The error between the profile's temperature and the}
121                     \textcolor{comment}{! interface temperature for a given z and its derivative.}
122   \textcolor{keywordtype}{real} :: pi, z
123   \textcolor{keywordtype}{logical} :: just\_read
124   \textcolor{comment}{! This include declares and sets the variable "version".}
125 \textcolor{preprocessor}{# include "version\_variable.h"}
126 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"benchmark\_initialize\_thickness"} \textcolor{comment}{! This subroutine's name.}
127   \textcolor{keywordtype}{integer} :: i, j, k, k1, is, ie, js, je, nz, itt
128 
129   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
130 
131   just\_read = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(just\_read\_params)) just\_read = just\_read\_params
132   \textcolor{keywordflow}{if} (.not.just\_read) \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})
133   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"BENCHMARK\_ML\_DEPTH\_IC"}, ml\_depth, &
134                  \textcolor{stringliteral}{"Initial mixed layer depth in the benchmark test case."}, &
135                  units=\textcolor{stringliteral}{'m'}, default=50.0, scale=us%m\_to\_Z, do\_not\_log=just\_read)
136   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"BENCHMARK\_THERMOCLINE\_SCALE"}, thermocline\_scale, &
137                  \textcolor{stringliteral}{"Initial thermocline depth scale in the benchmark test case."}, &
138                  default=500.0, units=\textcolor{stringliteral}{"m"}, scale=us%m\_to\_Z, do\_not\_log=just\_read)
139 
140   \textcolor{keywordflow}{if} (just\_read) \textcolor{keywordflow}{return} \textcolor{comment}{! This subroutine has no run-time parameters.}
141 
142   \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"  benchmark\_initialization.F90, benchmark\_initialize\_thickness: setting thickness"}, 5)
143 
144   k1 = gv%nk\_rho\_varies + 1
145 
146   a\_exp = 0.9
147 
148 \textcolor{comment}{! This block calculates T0(k) for the purpose of diagnosing where the}
149 \textcolor{comment}{! interfaces will be found.}
150   \textcolor{keywordflow}{do} k=1,nz
151     pres(k) = p\_ref ; s0(k) = 35.0
152 \textcolor{keywordflow}{  enddo}
153   t0(k1) = 29.0
154   \textcolor{keyword}{call }calculate\_density(t0(k1), s0(k1), pres(k1), rho\_guess(k1), eqn\_of\_state)
155   \textcolor{keyword}{call }calculate\_density\_derivs(t0(k1), s0(k1), pres(k1), drho\_dt(k1), drho\_ds(k1), eqn\_of\_state)
156 
157 \textcolor{comment}{! A first guess of the layers' temperatures.}
158   \textcolor{keywordflow}{do} k=1,nz
159     t0(k) = t0(k1) + (gv%Rlay(k) - rho\_guess(k1)) / drho\_dt(k1)
160 \textcolor{keywordflow}{  enddo}
161 
162 \textcolor{comment}{! Refine the guesses for each layer.}
163   \textcolor{keywordflow}{do} itt=1,6
164     \textcolor{keyword}{call }calculate\_density(t0, s0, pres, rho\_guess, eqn\_of\_state)
165     \textcolor{keyword}{call }calculate\_density\_derivs(t0, s0, pres, drho\_dt, drho\_ds, eqn\_of\_state)
166     \textcolor{keywordflow}{do} k=1,nz
167       t0(k) = t0(k) + (gv%Rlay(k) - rho\_guess(k)) / drho\_dt(k)
168 \textcolor{keywordflow}{    enddo}
169 \textcolor{keywordflow}{  enddo}
170 
171   pi = 4.0*atan(1.0)
172   i\_ts = 1.0 / thermocline\_scale
173   i\_md = 1.0 / g%max\_depth
174   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
175     sst = 0.5*(t0(k1)+t0(nz)) - 0.9*0.5*(t0(k1)-t0(nz)) * &
176                                cos(pi*(g%geoLatT(i,j)-g%south\_lat)/(g%len\_lat))
177 
178     \textcolor{keywordflow}{do} k=1,nz ; e\_pert(k) = 0.0 ;\textcolor{keywordflow}{ enddo}
179 
180     \textcolor{comment}{!   This sets the initial thickness (in [H ~> m or kg m-2]) of the layers.  The thicknesses}
181     \textcolor{comment}{! are set to insure that: 1. each layer is at least  Gv%Angstrom\_m thick, and}
182     \textcolor{comment}{! 2. the interfaces are where they should be based on the resting depths and interface}
183     \textcolor{comment}{! height perturbations, as long at this doesn't interfere with 1.}
184     eta1d(nz+1) = -g%bathyT(i,j)
185 
186     \textcolor{keywordflow}{do} k=nz,2,-1
187       t\_int = 0.5*(t0(k) + t0(k-1))
188       t\_frac = (t\_int - t0(nz)) / (sst - t0(nz))
189       \textcolor{comment}{! Find the z such that T\_frac = a exp(z/thermocline\_scale) + (1-a) (z+D)/D}
190       z = 0.0
191       \textcolor{keywordflow}{do} itt=1,6
192         err = a\_exp * exp(z*i\_ts) + (1.0 - a\_exp) * (z*i\_md + 1.0) - t\_frac
193         derr\_dz = a\_exp * i\_ts * exp(z*i\_ts) + (1.0 - a\_exp) * i\_md
194         z = z - err / derr\_dz
195 \textcolor{keywordflow}{      enddo}
196       e0(k) = z
197 \textcolor{comment}{!       e0(K) = -ML\_depth + thermocline\_scale * log((T\_int - T0(nz)) / (SST - T0(nz)))}
198 
199       eta1d(k) = e0(k) + e\_pert(k)
200 
201       \textcolor{keywordflow}{if} (eta1d(k) > -ml\_depth) eta1d(k) = -ml\_depth
202 
203       \textcolor{keywordflow}{if} (eta1d(k) < eta1d(k+1) + gv%Angstrom\_Z) &
204         eta1d(k) = eta1d(k+1) + gv%Angstrom\_Z
205 
206       h(i,j,k) = max(gv%Z\_to\_H * (eta1d(k) - eta1d(k+1)), gv%Angstrom\_H)
207 \textcolor{keywordflow}{    enddo}
208     h(i,j,1) = max(gv%Z\_to\_H * (0.0 - eta1d(2)), gv%Angstrom\_H)
209 
210 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
211 
\end{DoxyCode}
\mbox{\Hypertarget{namespacebenchmark__initialization_aa9f5b306237bd4938a117fe871a93ed7}\label{namespacebenchmark__initialization_aa9f5b306237bd4938a117fe871a93ed7}} 
\index{benchmark\+\_\+initialization@{benchmark\+\_\+initialization}!benchmark\+\_\+initialize\+\_\+topography@{benchmark\+\_\+initialize\+\_\+topography}}
\index{benchmark\+\_\+initialize\+\_\+topography@{benchmark\+\_\+initialize\+\_\+topography}!benchmark\+\_\+initialization@{benchmark\+\_\+initialization}}
\subsubsection{\texorpdfstring{benchmark\+\_\+initialize\+\_\+topography()}{benchmark\_initialize\_topography()}}
{\footnotesize\ttfamily subroutine, public benchmark\+\_\+initialization\+::benchmark\+\_\+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,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in), optional}]{US }\end{DoxyParamCaption})}



This subroutine sets up the benchmark test case topography. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The dynamic horizontal grid type\\
\hline
\mbox{\tt out}  & {\em d} & Ocean bottom depth in m or \mbox{[}Z $\sim$$>$ m\mbox{]} if US is present\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & Parameter file structure\\
\hline
\mbox{\tt in}  & {\em max\+\_\+depth} & Maximum model depth in the units of D\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type \\
\hline
\end{DoxyParams}


Definition at line 35 of file benchmark\+\_\+initialization.\+F90.


\begin{DoxyCode}
35   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),          \textcolor{keywordtype}{intent(in)}  :: g\textcolor{comment}{ !< The dynamic horizontal grid type}
36   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%isd:G%ied,G%jsd:G%jed)}, &
37                                    \textcolor{keywordtype}{intent(out)} :: d\textcolor{comment}{ !< Ocean bottom depth in m or [Z ~> m] if US is present}
38   \textcolor{keywordtype}{type}(param\_file\_type),           \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{ !< Parameter file structure}
39   \textcolor{keywordtype}{real},                            \textcolor{keywordtype}{intent(in)}  :: max\_depth\textcolor{comment}{ !< Maximum model depth in the units of D}
40   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: us\textcolor{comment}{ !< A dimensional unit scaling type}
41 
42   \textcolor{comment}{! Local variables}
43   \textcolor{keywordtype}{real} :: min\_depth            \textcolor{comment}{! The minimum and maximum depths [Z ~> m].}
44   \textcolor{keywordtype}{real} :: pi                   \textcolor{comment}{! 3.1415926... calculated as 4*atan(1)}
45   \textcolor{keywordtype}{real} :: d0                   \textcolor{comment}{! A constant to make the maximum     !}
46                                \textcolor{comment}{! basin depth MAXIMUM\_DEPTH.         !}
47   \textcolor{keywordtype}{real} :: m\_to\_z  \textcolor{comment}{! A dimensional rescaling factor.}
48   \textcolor{keywordtype}{real} :: x, y
49   \textcolor{comment}{! This include declares and sets the variable "version".}
50 \textcolor{preprocessor}{# include "version\_variable.h"}
51 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"benchmark\_initialize\_topography"} \textcolor{comment}{! This subroutine's name.}
52   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed
53   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
54   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
55 
56   \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"  benchmark\_initialization.F90, benchmark\_initialize\_topography: setting topography"}, 5)
57 
58   m\_to\_z = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) m\_to\_z = us%m\_to\_Z
59 
60   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})
61   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MINIMUM\_DEPTH"}, min\_depth, &
62                  \textcolor{stringliteral}{"The minimum depth of the ocean."}, units=\textcolor{stringliteral}{"m"}, default=0.0, scale=m\_to\_z)
63 
64   pi = 4.0*atan(1.0)
65   d0 = max\_depth / 0.5
66 
67 \textcolor{comment}{!  Calculate the depth of the bottom.}
68   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
69     x = (g%geoLonT(i,j)-g%west\_lon) / g%len\_lon
70     y = (g%geoLatT(i,j)-g%south\_lat) / g%len\_lat
71 \textcolor{comment}{!  This sets topography that has a reentrant channel to the south.}
72     d(i,j) = -d0 * ( y*(1.0 + 0.6*cos(4.0*pi*x)) &
73                    + 0.75*exp(-6.0*y) &
74                    + 0.05*cos(10.0*pi*x) - 0.7 )
75     \textcolor{keywordflow}{if} (d(i,j) > max\_depth) d(i,j) = max\_depth
76     \textcolor{keywordflow}{if} (d(i,j) < min\_depth) d(i,j) = 0.
77 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
78 
\end{DoxyCode}
