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


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


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


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


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

\end{DoxyCode}
