\hypertarget{namespacemom__energetic__pbl}{}\doxysection{mom\+\_\+energetic\+\_\+pbl Module Reference}
\label{namespacemom__energetic__pbl}\index{mom\_energetic\_pbl@{mom\_energetic\_pbl}}


\doxysubsection{Detailed Description}
Energetically consistent planetary boundary layer parameterization. \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmom__energetic__pbl_1_1energetic__pbl__cs}{energetic\+\_\+pbl\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em This control structure holds parameters for the \mbox{\hyperlink{namespaceMOM__energetic__PBL}{M\+O\+M\+\_\+energetic\+\_\+\+P\+BL}} module. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__energetic__pbl_1_1epbl__column__diags}{epbl\+\_\+column\+\_\+diags}}
\begin{DoxyCompactList}\small\item\em A type for conveniently passing around e\+P\+BL diagnostics for a column. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__energetic__pbl_a39d18925dcbd4477d63188edeae399f0}{energetic\+\_\+pbl}} (h\+\_\+3d, u\+\_\+3d, v\+\_\+3d, tv, fluxes, dt, Kd\+\_\+int, G, GV, US, CS, d\+S\+V\+\_\+dT, d\+S\+V\+\_\+dS, T\+K\+E\+\_\+forced, buoy\+\_\+flux, dt\+\_\+diag, last\+\_\+call, d\+T\+\_\+expected, d\+S\+\_\+expected, Waves)
\begin{DoxyCompactList}\small\item\em This subroutine determines the diffusivities from the integrated energetics mixed layer model. It assumes that heating, cooling and freshwater fluxes have already been applied. All calculations are done implicitly, and there is no stability limit on the time step. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__energetic__pbl_a01291f3e97cfdcf58866a1e9b0bcfc26}{epbl\+\_\+column}} (h, u, v, T0, S0, d\+S\+V\+\_\+dT, d\+S\+V\+\_\+dS, T\+K\+E\+\_\+forcing, B\+\_\+flux, absf, u\+\_\+star, u\+\_\+star\+\_\+mean, dt, M\+L\+D\+\_\+io, Kd, mixvel, mixlen, GV, US, CS, e\+CD, dt\+\_\+diag, Waves, G, i, j)
\begin{DoxyCompactList}\small\item\em This subroutine determines the diffusivities from the integrated energetics mixed layer model for a single column of water. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__energetic__pbl_a786e4381a925e3c84d0e99be09295627}{find\+\_\+pe\+\_\+chg}} (Kddt\+\_\+h0, d\+Kddt\+\_\+h, hp\+\_\+a, hp\+\_\+b, Th\+\_\+a, Sh\+\_\+a, Th\+\_\+b, Sh\+\_\+b, d\+T\+\_\+to\+\_\+d\+P\+E\+\_\+a, d\+S\+\_\+to\+\_\+d\+P\+E\+\_\+a, d\+T\+\_\+to\+\_\+d\+P\+E\+\_\+b, d\+S\+\_\+to\+\_\+d\+P\+E\+\_\+b, pres\+\_\+Z, d\+T\+\_\+to\+\_\+d\+Col\+Ht\+\_\+a, d\+S\+\_\+to\+\_\+d\+Col\+Ht\+\_\+a, d\+T\+\_\+to\+\_\+d\+Col\+Ht\+\_\+b, d\+S\+\_\+to\+\_\+d\+Col\+Ht\+\_\+b, P\+E\+\_\+chg, d\+P\+Ec\+\_\+d\+Kd, d\+P\+E\+\_\+max, d\+P\+Ec\+\_\+d\+Kd\+\_\+0, P\+E\+\_\+\+Col\+Ht\+\_\+cor)
\begin{DoxyCompactList}\small\item\em This subroutine calculates the change in potential energy and or derivatives for several changes in an interfaces\textquotesingle{}s diapycnal diffusivity times a timestep. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__energetic__pbl_a3eb660658d0677c55c6187dcf4a180b5}{find\+\_\+pe\+\_\+chg\+\_\+orig}} (Kddt\+\_\+h, h\+\_\+k, b\+\_\+den\+\_\+1, d\+Te\+\_\+term, d\+Se\+\_\+term, d\+T\+\_\+km1\+\_\+t2, d\+S\+\_\+km1\+\_\+t2, d\+T\+\_\+to\+\_\+d\+P\+E\+\_\+k, d\+S\+\_\+to\+\_\+d\+P\+E\+\_\+k, d\+T\+\_\+to\+\_\+d\+P\+Ea, d\+S\+\_\+to\+\_\+d\+P\+Ea, pres\+\_\+Z, d\+T\+\_\+to\+\_\+d\+Col\+Ht\+\_\+k, d\+S\+\_\+to\+\_\+d\+Col\+Ht\+\_\+k, d\+T\+\_\+to\+\_\+d\+Col\+Hta, d\+S\+\_\+to\+\_\+d\+Col\+Hta, P\+E\+\_\+chg, d\+P\+Ec\+\_\+d\+Kd, d\+P\+E\+\_\+max, d\+P\+Ec\+\_\+d\+Kd\+\_\+0)
\begin{DoxyCompactList}\small\item\em This subroutine calculates the change in potential energy and or derivatives for several changes in an interfaces\textquotesingle{}s diapycnal diffusivity times a timestep using the original form used in the first version of e\+P\+BL. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__energetic__pbl_a7686c6a30a476068859f7a2a30e652df}{find\+\_\+mstar}} (CS, US, Buoyancy\+\_\+\+Flux, U\+Star, U\+Star\+\_\+\+Mean, B\+LD, Abs\+\_\+\+Coriolis, M\+Star, Langmuir\+\_\+\+Number, M\+Star\+\_\+\+LT, Convect\+\_\+\+Langmuir\+\_\+\+Number)
\begin{DoxyCompactList}\small\item\em This subroutine finds the Mstar value for e\+P\+BL. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__energetic__pbl_ac7fd166f015884862a3798882ad1c977}{mstar\+\_\+langmuir}} (CS, US, Abs\+\_\+\+Coriolis, Buoyancy\+\_\+\+Flux, U\+Star, B\+LD, Langmuir\+\_\+\+Number, Mstar, M\+Star\+\_\+\+LT, Convect\+\_\+\+Langmuir\+\_\+\+Number)
\begin{DoxyCompactList}\small\item\em This subroutine modifies the Mstar value if the Langmuir number is present. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__energetic__pbl_af3a7ca5357ed9a1383c9556b117116dc}{energetic\+\_\+pbl\+\_\+get\+\_\+mld}} (CS, M\+LD, G, US, m\+\_\+to\+\_\+\+M\+L\+D\+\_\+units)
\begin{DoxyCompactList}\small\item\em Copies the e\+P\+BL active mixed layer depth into M\+LD, in units of \mbox{[}Z $\sim$$>$ m\mbox{]} unless other units are specified. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__energetic__pbl_ad9fa0dc4ba4e126ec686b44a5829c2e8}{energetic\+\_\+pbl\+\_\+init}} (Time, G, GV, US, param\+\_\+file, diag, CS)
\begin{DoxyCompactList}\small\item\em This subroutine initializes the energetic\+\_\+\+P\+BL module. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__energetic__pbl_a64860c8b0110ba516795a288acdefd1f}{energetic\+\_\+pbl\+\_\+end}} (CS)
\begin{DoxyCompactList}\small\item\em Clean up and deallocate memory associated with the energetic\+\_\+\+P\+BL module. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacemom__energetic__pbl_ac8feb21d88c79d5b112c512a19c810a6}\label{namespacemom__energetic__pbl_ac8feb21d88c79d5b112c512a19c810a6}} 
logical \mbox{\hyperlink{namespacemom__energetic__pbl_ac8feb21d88c79d5b112c512a19c810a6}{report\+\_\+avg\+\_\+its}} = .false.
\begin{DoxyCompactList}\small\item\em Report the average number of e\+P\+BL iterations for debugging. \end{DoxyCompactList}\end{DoxyCompactItemize}
\textbf{ }\par
\begin{DoxyCompactItemize}
\item 
integer, parameter \mbox{\hyperlink{namespacemom__energetic__pbl_a62611ee2449d47b4ac347ecc5815c927}{use\+\_\+fixed\+\_\+mstar}} = 0
\begin{DoxyCompactList}\small\item\em Enumeration values for mstar\+\_\+\+Scheme. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__energetic__pbl_a2f6f5a6f3b88370f8956a16805ff8d93}\label{namespacemom__energetic__pbl_a2f6f5a6f3b88370f8956a16805ff8d93}} 
integer, parameter \mbox{\hyperlink{namespacemom__energetic__pbl_a2f6f5a6f3b88370f8956a16805ff8d93}{mstar\+\_\+from\+\_\+ekman}} = 2
\begin{DoxyCompactList}\small\item\em The value of mstar\+\_\+scheme to base mstar on the ratio of the Ekman layer depth to the Obukhov depth. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__energetic__pbl_a5504d7a4935753ac24c43f35a729052e}\label{namespacemom__energetic__pbl_a5504d7a4935753ac24c43f35a729052e}} 
integer, parameter \mbox{\hyperlink{namespacemom__energetic__pbl_a5504d7a4935753ac24c43f35a729052e}{mstar\+\_\+from\+\_\+rh18}} = 3
\begin{DoxyCompactList}\small\item\em The value of mstar\+\_\+scheme to base mstar of of R\+H18. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__energetic__pbl_a408fc314121efffe70ff08b56b920343}\label{namespacemom__energetic__pbl_a408fc314121efffe70ff08b56b920343}} 
integer, parameter \mbox{\hyperlink{namespacemom__energetic__pbl_a408fc314121efffe70ff08b56b920343}{no\+\_\+langmuir}} = 0
\begin{DoxyCompactList}\small\item\em The value of L\+T\+\_\+\+E\+N\+H\+A\+N\+C\+E\+\_\+\+F\+O\+RM not use Langmuir turbolence. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__energetic__pbl_af8dec1f8eeb76a7638d11acc279f9bbd}\label{namespacemom__energetic__pbl_af8dec1f8eeb76a7638d11acc279f9bbd}} 
integer, parameter \mbox{\hyperlink{namespacemom__energetic__pbl_af8dec1f8eeb76a7638d11acc279f9bbd}{langmuir\+\_\+rescale}} = 2
\begin{DoxyCompactList}\small\item\em The value of L\+T\+\_\+\+E\+N\+H\+A\+N\+C\+E\+\_\+\+F\+O\+RM to use a multiplicative rescaling of mstar to account for Langmuir turbulence. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__energetic__pbl_a502b7fb02ebdec866caed1508a103c1d}\label{namespacemom__energetic__pbl_a502b7fb02ebdec866caed1508a103c1d}} 
integer, parameter \mbox{\hyperlink{namespacemom__energetic__pbl_a502b7fb02ebdec866caed1508a103c1d}{langmuir\+\_\+add}} = 3
\begin{DoxyCompactList}\small\item\em The value of L\+T\+\_\+\+E\+N\+H\+A\+N\+C\+E\+\_\+\+F\+O\+RM to add a contribution to mstar from Langmuir turblence to other contributions. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__energetic__pbl_a148db2e43fc3bb4cc1f266ec7391a7dd}\label{namespacemom__energetic__pbl_a148db2e43fc3bb4cc1f266ec7391a7dd}} 
integer, parameter \mbox{\hyperlink{namespacemom__energetic__pbl_a148db2e43fc3bb4cc1f266ec7391a7dd}{wt\+\_\+from\+\_\+croot\+\_\+tke}} = 0
\begin{DoxyCompactList}\small\item\em Use a constant times the cube root of remaining T\+KE to calculate the turbulent velocity. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__energetic__pbl_a0dc2252a2315d8d99000f9b003b24b00}\label{namespacemom__energetic__pbl_a0dc2252a2315d8d99000f9b003b24b00}} 
integer, parameter \mbox{\hyperlink{namespacemom__energetic__pbl_a0dc2252a2315d8d99000f9b003b24b00}{wt\+\_\+from\+\_\+rh18}} = 1
\begin{DoxyCompactList}\small\item\em Use a scheme based on a combination of w$\ast$ and v$\ast$ as documented in Reichl \& Hallberg (2018) to calculate the turbulent velocity. \end{DoxyCompactList}\item 
character $\ast$(20), parameter \mbox{\hyperlink{namespacemom__energetic__pbl_a1242b6400e7d01529a3d19b85e0d5b5b}{constant\+\_\+string}} = \char`\"{}C\+O\+N\+S\+T\+A\+NT\char`\"{}
\begin{DoxyCompactList}\small\item\em Enumeration values for mstar\+\_\+\+Scheme. \end{DoxyCompactList}\item 
character $\ast$(20), parameter \mbox{\hyperlink{namespacemom__energetic__pbl_a193184bbe6bba5bfcb7b077d620cbfe7}{om4\+\_\+string}} = \char`\"{}O\+M4\char`\"{}
\begin{DoxyCompactList}\small\item\em Enumeration values for mstar\+\_\+\+Scheme. \end{DoxyCompactList}\item 
character $\ast$(20), parameter \mbox{\hyperlink{namespacemom__energetic__pbl_a6fc8bff404f05376f1f3b4c90cb169a0}{rh18\+\_\+string}} = \char`\"{}R\+E\+I\+C\+H\+L\+\_\+\+H18\char`\"{}
\begin{DoxyCompactList}\small\item\em Enumeration values for mstar\+\_\+\+Scheme. \end{DoxyCompactList}\item 
character $\ast$(20), parameter \mbox{\hyperlink{namespacemom__energetic__pbl_a6617f3587ab57c34581cd76bd80b9249}{root\+\_\+tke\+\_\+string}} = \char`\"{}C\+U\+B\+E\+\_\+\+R\+O\+O\+T\+\_\+\+T\+KE\char`\"{}
\begin{DoxyCompactList}\small\item\em Enumeration values for mstar\+\_\+\+Scheme. \end{DoxyCompactList}\item 
character $\ast$(20), parameter \mbox{\hyperlink{namespacemom__energetic__pbl_a4299f4ef5bbeabb5d0ca7e6016546ac4}{none\+\_\+string}} = \char`\"{}N\+O\+NE\char`\"{}
\begin{DoxyCompactList}\small\item\em Enumeration values for mstar\+\_\+\+Scheme. \end{DoxyCompactList}\item 
character $\ast$(20), parameter \mbox{\hyperlink{namespacemom__energetic__pbl_a6e1dc5a516a3ea979f425084c1291139}{rescaled\+\_\+string}} = \char`\"{}R\+E\+S\+C\+A\+LE\char`\"{}
\begin{DoxyCompactList}\small\item\em Enumeration values for mstar\+\_\+\+Scheme. \end{DoxyCompactList}\item 
character $\ast$(20), parameter \mbox{\hyperlink{namespacemom__energetic__pbl_a54d8529555fee1f2ada7a7107f3c266c}{additive\+\_\+string}} = \char`\"{}A\+D\+D\+I\+T\+I\+VE\char`\"{}
\begin{DoxyCompactList}\small\item\em Enumeration values for mstar\+\_\+\+Scheme. \end{DoxyCompactList}\end{DoxyCompactItemize}



\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__energetic__pbl_a39d18925dcbd4477d63188edeae399f0}\label{namespacemom__energetic__pbl_a39d18925dcbd4477d63188edeae399f0}} 
\index{mom\_energetic\_pbl@{mom\_energetic\_pbl}!energetic\_pbl@{energetic\_pbl}}
\index{energetic\_pbl@{energetic\_pbl}!mom\_energetic\_pbl@{mom\_energetic\_pbl}}
\doxysubsubsection{\texorpdfstring{energetic\_pbl()}{energetic\_pbl()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+energetic\+\_\+pbl\+::energetic\+\_\+pbl (\begin{DoxyParamCaption}\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(inout)}]{h\+\_\+3d,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(in)}]{u\+\_\+3d,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(in)}]{v\+\_\+3d,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(inout)}]{tv,  }\item[{type(forcing), intent(inout)}]{fluxes,  }\item[{real, intent(in)}]{dt,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke+1), intent(out)}]{Kd\+\_\+int,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__energetic__pbl_1_1energetic__pbl__cs}{energetic\+\_\+pbl\+\_\+cs}}), pointer}]{CS,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(in)}]{d\+S\+V\+\_\+dT,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(in)}]{d\+S\+V\+\_\+dS,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(in)}]{T\+K\+E\+\_\+forced,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed), intent(in)}]{buoy\+\_\+flux,  }\item[{real, intent(in), optional}]{dt\+\_\+diag,  }\item[{logical, intent(in), optional}]{last\+\_\+call,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(out), optional}]{d\+T\+\_\+expected,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(out), optional}]{d\+S\+\_\+expected,  }\item[{type(wave\+\_\+parameters\+\_\+cs), optional, pointer}]{Waves }\end{DoxyParamCaption})}



This subroutine determines the diffusivities from the integrated energetics mixed layer model. It assumes that heating, cooling and freshwater fluxes have already been applied. All calculations are done implicitly, and there is no stability limit on the time step. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\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{ in,out}}  & {\em h\+\_\+3d} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+3d} & Zonal velocities interpolated to h points \\
\hline
\mbox{\texttt{ in}}  & {\em v\+\_\+3d} & Zonal velocities interpolated to h points \\
\hline
\mbox{\texttt{ in}}  & {\em dsv\+\_\+dt} & The partial derivative of in-\/situ specific \\
\hline
\mbox{\texttt{ in}}  & {\em dsv\+\_\+ds} & The partial derivative of in-\/situ specific \\
\hline
\mbox{\texttt{ in}}  & {\em tke\+\_\+forced} & The forcing requirements to homogenize the \\
\hline
\mbox{\texttt{ in,out}}  & {\em tv} & A structure containing pointers to any available thermodynamic fields. Absent fields have N\+U\+LL ptrs. \\
\hline
\mbox{\texttt{ in,out}}  & {\em fluxes} & A structure containing pointers to any possible forcing fields. Unused fields have N\+U\+LL ptrs. \\
\hline
\mbox{\texttt{ in}}  & {\em dt} & Time increment \mbox{[}T $\sim$$>$ s\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em kd\+\_\+int} & The diagnosed diffusivities at interfaces \\
\hline
 & {\em cs} & The control structure returned by a previous call to mixedlayer\+\_\+init. \\
\hline
\mbox{\texttt{ in}}  & {\em buoy\+\_\+flux} & The surface buoyancy flux \mbox{[}Z2 T-\/3 $\sim$$>$ m2 s-\/3\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em dt\+\_\+diag} & The diagnostic time step, which may be less than dt if there are two calls to mixedlayer \mbox{[}T $\sim$$>$ s\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em last\+\_\+call} & If true, this is the last call to mixedlayer in the current time step, so diagnostics will be written. The default is .true. \\
\hline
\mbox{\texttt{ out}}  & {\em dt\+\_\+expected} & The values of temperature change that \\
\hline
\mbox{\texttt{ out}}  & {\em ds\+\_\+expected} & The values of salinity change that \\
\hline
 & {\em waves} & Wave CS \\
\hline
\end{DoxyParams}


Definition at line 251 of file M\+O\+M\+\_\+energetic\+\_\+\+P\+B\+L.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{251   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{      !< The ocean's grid structure.}}
\DoxyCodeLine{252   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{     !< The ocean's vertical grid structure.}}
\DoxyCodeLine{253   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{     !< A dimensional unit scaling type}}
\DoxyCodeLine{254 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{255                            \textcolor{keywordtype}{intent(inout)} :: h\_3d\textcolor{comment}{   !< Layer thicknesses [H ~> m or kg m-\/2].}}
\DoxyCodeLine{256 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{257                            \textcolor{keywordtype}{intent(in)}    :: u\_3d\textcolor{comment}{   !< Zonal velocities interpolated to h points}}
\DoxyCodeLine{258 \textcolor{comment}{                                                   !! [L T-\/1 ~> m s-\/1].}}
\DoxyCodeLine{259 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{260                            \textcolor{keywordtype}{intent(in)}    :: v\_3d\textcolor{comment}{   !< Zonal velocities interpolated to h points}}
\DoxyCodeLine{261 \textcolor{comment}{                                                   !! [L T-\/1 ~> m s-\/1].}}
\DoxyCodeLine{262 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{263                            \textcolor{keywordtype}{intent(in)}    :: dSV\_dT\textcolor{comment}{ !< The partial derivative of in-\/situ specific}}
\DoxyCodeLine{264 \textcolor{comment}{                                                   !! volume with potential temperature}}
\DoxyCodeLine{265 \textcolor{comment}{                                                   !! [R-\/1 degC-\/1 ~> m3 kg-\/1 degC-\/1].}}
\DoxyCodeLine{266 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{267                            \textcolor{keywordtype}{intent(in)}    :: dSV\_dS\textcolor{comment}{ !< The partial derivative of in-\/situ specific}}
\DoxyCodeLine{268 \textcolor{comment}{                                                   !! volume with salinity [R-\/1 ppt-\/1 ~> m3 kg-\/1 ppt-\/1].}}
\DoxyCodeLine{269 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{270                            \textcolor{keywordtype}{intent(in)}    :: TKE\_forced\textcolor{comment}{ !< The forcing requirements to homogenize the}}
\DoxyCodeLine{271 \textcolor{comment}{                                                   !! forcing that has been applied to each layer}}
\DoxyCodeLine{272 \textcolor{comment}{                                                   !! [R Z3 T-\/2 ~> J m-\/2].}}
\DoxyCodeLine{273   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{     !< A structure containing pointers to any}}
\DoxyCodeLine{274 \textcolor{comment}{                                                   !! available thermodynamic fields. Absent fields}}
\DoxyCodeLine{275 \textcolor{comment}{                                                   !! have NULL ptrs.}}
\DoxyCodeLine{276   \textcolor{keywordtype}{type}(forcing),           \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< A structure containing pointers to any}}
\DoxyCodeLine{277 \textcolor{comment}{                                                   !! possible forcing fields. Unused fields have}}
\DoxyCodeLine{278 \textcolor{comment}{                                                   !! NULL ptrs.}}
\DoxyCodeLine{279 \textcolor{keywordtype}{  real},                    \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{     !< Time increment [T ~> s].}}
\DoxyCodeLine{280 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)}, \&}
\DoxyCodeLine{281                            \textcolor{keywordtype}{intent(out)}   :: Kd\_int\textcolor{comment}{ !< The diagnosed diffusivities at interfaces}}
\DoxyCodeLine{282 \textcolor{comment}{                                                   !! [Z2 s-\/1 ~> m2 s-\/1].}}
\DoxyCodeLine{283   \textcolor{keywordtype}{type}(energetic\_PBL\_CS),  \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{     !< The control structure returned by a previous}}
\DoxyCodeLine{284 \textcolor{comment}{                                                   !! call to mixedlayer\_init.}}
\DoxyCodeLine{285 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \&}
\DoxyCodeLine{286                            \textcolor{keywordtype}{intent(in)}    :: buoy\_flux\textcolor{comment}{ !< The surface buoyancy flux [Z2 T-\/3 ~> m2 s-\/3].}}
\DoxyCodeLine{287 \textcolor{keywordtype}{  real},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dt\_diag\textcolor{comment}{   !< The diagnostic time step, which may be less}}
\DoxyCodeLine{288 \textcolor{comment}{                                                   !! than dt if there are two calls to mixedlayer [T ~> s].}}
\DoxyCodeLine{289   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: last\_call\textcolor{comment}{ !< If true, this is the last call to}}
\DoxyCodeLine{290 \textcolor{comment}{                                                   !! mixedlayer in the current time step, so}}
\DoxyCodeLine{291 \textcolor{comment}{                                                   !! diagnostics will be written. The default}}
\DoxyCodeLine{292 \textcolor{comment}{                                                   !! is .true.}}
\DoxyCodeLine{293 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{294                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)}   :: dT\_expected\textcolor{comment}{ !< The values of temperature change that}}
\DoxyCodeLine{295 \textcolor{comment}{                                                   !! should be expected when the returned}}
\DoxyCodeLine{296 \textcolor{comment}{                                                   !! diffusivities are applied [degC].}}
\DoxyCodeLine{297 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{298                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)}   :: dS\_expected\textcolor{comment}{ !< The values of salinity change that}}
\DoxyCodeLine{299 \textcolor{comment}{                                                   !! should be expected when the returned}}
\DoxyCodeLine{300 \textcolor{comment}{                                                   !! diffusivities are applied [ppt].}}
\DoxyCodeLine{301   \textcolor{keywordtype}{type}(wave\_parameters\_CS), \&}
\DoxyCodeLine{302                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}       :: Waves\textcolor{comment}{  !< Wave CS}}
\DoxyCodeLine{303 }
\DoxyCodeLine{304 \textcolor{comment}{!    This subroutine determines the diffusivities from the integrated energetics}}
\DoxyCodeLine{305 \textcolor{comment}{!  mixed layer model.  It assumes that heating, cooling and freshwater fluxes}}
\DoxyCodeLine{306 \textcolor{comment}{!  have already been applied.  All calculations are done implicitly, and there}}
\DoxyCodeLine{307 \textcolor{comment}{!  is no stability limit on the time step.}}
\DoxyCodeLine{308 \textcolor{comment}{!}}
\DoxyCodeLine{309 \textcolor{comment}{!    For each interior interface, first discard the TKE to account for mixing}}
\DoxyCodeLine{310 \textcolor{comment}{! of shortwave radiation through the next denser cell.  Next drive mixing based}}
\DoxyCodeLine{311 \textcolor{comment}{! on the local? values of ustar + wstar, subject to available energy.  This}}
\DoxyCodeLine{312 \textcolor{comment}{! step sets the value of Kd(K).  Any remaining energy is then subject to decay}}
\DoxyCodeLine{313 \textcolor{comment}{! before being handed off to the next interface.  mech\_TKE and conv\_PErel are treated}}
\DoxyCodeLine{314 \textcolor{comment}{! separately for the purposes of decay, but are used proportionately to drive}}
\DoxyCodeLine{315 \textcolor{comment}{! mixing.}}
\DoxyCodeLine{316 \textcolor{comment}{!}}
\DoxyCodeLine{317 \textcolor{comment}{!   The key parameters for the mixed layer are found in the control structure.}}
\DoxyCodeLine{318 \textcolor{comment}{!   To use the classic constant mstar mixied layers choose MSTAR\_SCHEME=CONSTANT.}}
\DoxyCodeLine{319 \textcolor{comment}{! The key parameters then include mstar, nstar, TKE\_decay, and conv\_decay.}}
\DoxyCodeLine{320 \textcolor{comment}{! For the Oberhuber (1993) mixed layer,the values of these are:}}
\DoxyCodeLine{321 \textcolor{comment}{!      mstar = 1.25,  nstar = 1, TKE\_decay = 2.5, conv\_decay = 0.5}}
\DoxyCodeLine{322 \textcolor{comment}{! TKE\_decay is 1/kappa in eq. 28 of Oberhuber (1993), while conv\_decay is 1/mu.}}
\DoxyCodeLine{323 \textcolor{comment}{! For a traditional Kraus-\/Turner mixed layer, the values are:}}
\DoxyCodeLine{324 \textcolor{comment}{!      mstar = 1.25, nstar = 0.4, TKE\_decay = 0.0, conv\_decay = 0.0}}
\DoxyCodeLine{325 }
\DoxyCodeLine{326   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{327 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZK\_(GV))} :: \&}
\DoxyCodeLine{328     h\_2d, \&         \textcolor{comment}{! A 2-\/d slice of the layer thickness [H ~> m or kg m-\/2].}}
\DoxyCodeLine{329     T\_2d, \&         \textcolor{comment}{! A 2-\/d slice of the layer temperatures [degC].}}
\DoxyCodeLine{330     S\_2d, \&         \textcolor{comment}{! A 2-\/d slice of the layer salinities [ppt].}}
\DoxyCodeLine{331     TKE\_forced\_2d, \& \textcolor{comment}{! A 2-\/d slice of TKE\_forced [R Z3 T-\/2 ~> J m-\/2].}}
\DoxyCodeLine{332     dSV\_dT\_2d, \&    \textcolor{comment}{! A 2-\/d slice of dSV\_dT [R-\/1 degC-\/1 ~> m3 kg-\/1 degC-\/1].}}
\DoxyCodeLine{333     dSV\_dS\_2d, \&    \textcolor{comment}{! A 2-\/d slice of dSV\_dS [R-\/1 ppt-\/1 ~> m3 kg-\/1 ppt-\/1].}}
\DoxyCodeLine{334     u\_2d, \&         \textcolor{comment}{! A 2-\/d slice of the zonal velocity [L T-\/1 ~> m s-\/1].}}
\DoxyCodeLine{335     v\_2d            \textcolor{comment}{! A 2-\/d slice of the meridional velocity [L T-\/1 ~> m s-\/1].}}
\DoxyCodeLine{336 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZK\_(GV)+1)} :: \&}
\DoxyCodeLine{337     Kd\_2d           \textcolor{comment}{! A 2-\/d version of the diapycnal diffusivity [Z2 T-\/1 ~> m2 s-\/1].}}
\DoxyCodeLine{338 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: \&}
\DoxyCodeLine{339     h, \&            \textcolor{comment}{! The layer thickness [H ~> m or kg m-\/2].}}
\DoxyCodeLine{340     T0, \&           \textcolor{comment}{! The initial layer temperatures [degC].}}
\DoxyCodeLine{341     S0, \&           \textcolor{comment}{! The initial layer salinities [ppt].}}
\DoxyCodeLine{342     dSV\_dT\_1d, \&    \textcolor{comment}{! The partial derivatives of specific volume with temperature [R-\/1 degC-\/1 ~> m3 kg-\/1 degC-\/1].}}
\DoxyCodeLine{343     dSV\_dS\_1d, \&    \textcolor{comment}{! The partial derivatives of specific volume with salinity [R-\/1 ppt-\/1 ~> m3 kg-\/1 ppt-\/1].}}
\DoxyCodeLine{344     TKE\_forcing, \&  \textcolor{comment}{! Forcing of the TKE in the layer coming from TKE\_forced [R Z3 T-\/2 ~> J m-\/2].}}
\DoxyCodeLine{345     u, \&            \textcolor{comment}{! The zonal velocity [L T-\/1 ~> m s-\/1].}}
\DoxyCodeLine{346     v               \textcolor{comment}{! The meridional velocity [L T-\/1 ~> m s-\/1].}}
\DoxyCodeLine{347 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV)+1)} :: \&}
\DoxyCodeLine{348     Kd, \&           \textcolor{comment}{! The diapycnal diffusivity [Z2 T-\/1 ~> m2 s-\/1].}}
\DoxyCodeLine{349     mixvel, \&       \textcolor{comment}{! A turbulent mixing veloxity [Z T-\/1 ~> m s-\/1].}}
\DoxyCodeLine{350     mixlen          \textcolor{comment}{! A turbulent mixing length [Z ~> m].}}
\DoxyCodeLine{351 \textcolor{keywordtype}{  real} :: h\_neglect \textcolor{comment}{! A thickness that is so small it is usually lost}}
\DoxyCodeLine{352                     \textcolor{comment}{! in roundoff and can be neglected [H ~> m or kg m-\/2].}}
\DoxyCodeLine{353 }
\DoxyCodeLine{354 \textcolor{keywordtype}{  real} :: absf      \textcolor{comment}{! The absolute value of f [T-\/1 ~> s-\/1].}}
\DoxyCodeLine{355 \textcolor{keywordtype}{  real} :: U\_star    \textcolor{comment}{! The surface friction velocity [Z T-\/1 ~> m s-\/1].}}
\DoxyCodeLine{356 \textcolor{keywordtype}{  real} :: U\_Star\_Mean \textcolor{comment}{! The surface friction without gustiness [Z T-\/1 ~> m s-\/1].}}
\DoxyCodeLine{357 \textcolor{keywordtype}{  real} :: B\_Flux    \textcolor{comment}{! The surface buoyancy flux [Z2 T-\/3 ~> m2 s-\/3]}}
\DoxyCodeLine{358 \textcolor{keywordtype}{  real} :: MLD\_io    \textcolor{comment}{! The mixed layer depth found by ePBL\_column [Z ~> m].}}
\DoxyCodeLine{359 }
\DoxyCodeLine{360 \textcolor{comment}{! The following are only used for diagnostics.}}
\DoxyCodeLine{361 \textcolor{keywordtype}{  real} :: dt\_\_diag  \textcolor{comment}{! A copy of dt\_diag (if present) or dt [T ~> s].}}
\DoxyCodeLine{362   \textcolor{keywordtype}{logical} :: write\_diags  \textcolor{comment}{! If true, write out diagnostics with this step.}}
\DoxyCodeLine{363   \textcolor{keywordtype}{logical} :: reset\_diags  \textcolor{comment}{! If true, zero out the accumulated diagnostics.}}
\DoxyCodeLine{364 }
\DoxyCodeLine{365   \textcolor{keywordtype}{logical} :: debug=.false.  \textcolor{comment}{! Change this hard-\/coded value for debugging.}}
\DoxyCodeLine{366   \textcolor{keywordtype}{type}(ePBL\_column\_diags) :: eCD \textcolor{comment}{! A container for passing around diagnostics.}}
\DoxyCodeLine{367 }
\DoxyCodeLine{368   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz}
\DoxyCodeLine{369 }
\DoxyCodeLine{370   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = gv\%ke}
\DoxyCodeLine{371 }
\DoxyCodeLine{372   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(cs)) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"energetic\_PBL: "}//\&}
\DoxyCodeLine{373          \textcolor{stringliteral}{"Module must be initialized before it is used."})}
\DoxyCodeLine{374 }
\DoxyCodeLine{375   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(tv\%eqn\_of\_state)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{376       \textcolor{stringliteral}{"energetic\_PBL: Temperature, salinity and an equation of state "}//\&}
\DoxyCodeLine{377       \textcolor{stringliteral}{"must now be used."})}
\DoxyCodeLine{378   \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(fluxes\%ustar)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{379       \textcolor{stringliteral}{"energetic\_PBL: No surface TKE fluxes (ustar) defined in mixedlayer!"})}
\DoxyCodeLine{380   debug = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt\_expected) .or. \textcolor{keyword}{present}(ds\_expected)) debug = .true.}
\DoxyCodeLine{381 }
\DoxyCodeLine{382   \textcolor{keywordflow}{if} (debug) \textcolor{keyword}{allocate}(ecd\%dT\_expect(nz), ecd\%dS\_expect(nz))}
\DoxyCodeLine{383 }
\DoxyCodeLine{384   h\_neglect = gv\%H\_subroundoff}
\DoxyCodeLine{385 }
\DoxyCodeLine{386   dt\_\_diag = dt ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt\_diag)) dt\_\_diag = dt\_diag}
\DoxyCodeLine{387   write\_diags = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(last\_call)) write\_diags = last\_call}
\DoxyCodeLine{388 }
\DoxyCodeLine{389 }
\DoxyCodeLine{390   \textcolor{comment}{! Determine whether to zero out diagnostics before accumulation.}}
\DoxyCodeLine{391   reset\_diags = .true.}
\DoxyCodeLine{392   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt\_diag) .and. write\_diags .and. (dt\_\_diag > dt)) \&}
\DoxyCodeLine{393     reset\_diags = .false.  \textcolor{comment}{! This is the second call to mixedlayer.}}
\DoxyCodeLine{394 }
\DoxyCodeLine{395   \textcolor{keywordflow}{if} (reset\_diags) \textcolor{keywordflow}{then}}
\DoxyCodeLine{396     \textcolor{keywordflow}{if} (cs\%TKE\_diagnostics) \textcolor{keywordflow}{then}}
\DoxyCodeLine{397 \textcolor{comment}{!!OMP parallel do default(none) shared(is,ie,js,je,CS)}}
\DoxyCodeLine{398       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{399         cs\%diag\_TKE\_wind(i,j) = 0.0 ; cs\%diag\_TKE\_MKE(i,j) = 0.0}
\DoxyCodeLine{400         cs\%diag\_TKE\_conv(i,j) = 0.0 ; cs\%diag\_TKE\_forcing(i,j) = 0.0}
\DoxyCodeLine{401         cs\%diag\_TKE\_mixing(i,j) = 0.0 ; cs\%diag\_TKE\_mech\_decay(i,j) = 0.0}
\DoxyCodeLine{402         cs\%diag\_TKE\_conv\_decay(i,j) = 0.0 \textcolor{comment}{!; CS\%diag\_TKE\_unbalanced(i,j) = 0.0}}
\DoxyCodeLine{403 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{404 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{405 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{406   \textcolor{comment}{! if (CS\%id\_Mixing\_Length>0) CS\%Mixing\_Length(:,:,:) = 0.0}}
\DoxyCodeLine{407   \textcolor{comment}{! if (CS\%id\_Velocity\_Scale>0) CS\%Velocity\_Scale(:,:,:) = 0.0}}
\DoxyCodeLine{408 }
\DoxyCodeLine{409 \textcolor{comment}{!!OMP parallel do default(private) shared(js,je,nz,is,ie,h\_3d,u\_3d,v\_3d,tv,dt, \&}}
\DoxyCodeLine{410 \textcolor{comment}{!!OMP                                  CS,G,GV,US,fluxes,debug, \&}}
\DoxyCodeLine{411 \textcolor{comment}{!!OMP                                  TKE\_forced,dSV\_dT,dSV\_dS,Kd\_int)}}
\DoxyCodeLine{412   \textcolor{keywordflow}{do} j=js,je}
\DoxyCodeLine{413     \textcolor{comment}{! Copy the thicknesses and other fields to 2-\/d arrays.}}
\DoxyCodeLine{414     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{415       h\_2d(i,k) = h\_3d(i,j,k) ; u\_2d(i,k) = u\_3d(i,j,k) ; v\_2d(i,k) = v\_3d(i,j,k)}
\DoxyCodeLine{416       t\_2d(i,k) = tv\%T(i,j,k) ; s\_2d(i,k) = tv\%S(i,j,k)}
\DoxyCodeLine{417       tke\_forced\_2d(i,k) = tke\_forced(i,j,k)}
\DoxyCodeLine{418       dsv\_dt\_2d(i,k) = dsv\_dt(i,j,k) ; dsv\_ds\_2d(i,k) = dsv\_ds(i,j,k)}
\DoxyCodeLine{419 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{420 }
\DoxyCodeLine{421     \textcolor{comment}{!   Determine the initial mech\_TKE and conv\_PErel, including the energy required}}
\DoxyCodeLine{422     \textcolor{comment}{! to mix surface heating through the topmost cell, the energy released by mixing}}
\DoxyCodeLine{423     \textcolor{comment}{! surface cooling \& brine rejection down through the topmost cell, and}}
\DoxyCodeLine{424     \textcolor{comment}{! homogenizing the shortwave heating within that cell.  This sets the energy}}
\DoxyCodeLine{425     \textcolor{comment}{! and ustar and wstar available to drive mixing at the first interior}}
\DoxyCodeLine{426     \textcolor{comment}{! interface.}}
\DoxyCodeLine{427     \textcolor{keywordflow}{do} i=is,ie ; \textcolor{keywordflow}{if} (g\%mask2dT(i,j) > 0.5) \textcolor{keywordflow}{then}}
\DoxyCodeLine{428 }
\DoxyCodeLine{429       \textcolor{comment}{! Copy the thicknesses and other fields to 1-\/d arrays.}}
\DoxyCodeLine{430       \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{431         h(k) = h\_2d(i,k) + gv\%H\_subroundoff ; u(k) = u\_2d(i,k) ; v(k) = v\_2d(i,k)}
\DoxyCodeLine{432         t0(k) = t\_2d(i,k) ; s0(k) = s\_2d(i,k) ; tke\_forcing(k) =  tke\_forced\_2d(i,k)}
\DoxyCodeLine{433         dsv\_dt\_1d(k) = dsv\_dt\_2d(i,k) ; dsv\_ds\_1d(k) = dsv\_ds\_2d(i,k)}
\DoxyCodeLine{434 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{435       \textcolor{keywordflow}{do} k=1,nz+1 ; kd(k) = 0.0 ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{436 }
\DoxyCodeLine{437       \textcolor{comment}{! Make local copies of surface forcing and process them.}}
\DoxyCodeLine{438       u\_star = fluxes\%ustar(i,j)}
\DoxyCodeLine{439       u\_star\_mean = fluxes\%ustar\_gustless(i,j)}
\DoxyCodeLine{440       b\_flux = buoy\_flux(i,j)}
\DoxyCodeLine{441       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes\%ustar\_shelf) .and. \textcolor{keyword}{associated}(fluxes\%frac\_shelf\_h)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{442         \textcolor{keywordflow}{if} (fluxes\%frac\_shelf\_h(i,j) > 0.0) \&}
\DoxyCodeLine{443           u\_star = (1.0 -\/ fluxes\%frac\_shelf\_h(i,j)) * u\_star + \&}
\DoxyCodeLine{444                    fluxes\%frac\_shelf\_h(i,j) * fluxes\%ustar\_shelf(i,j)}
\DoxyCodeLine{445 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{446       \textcolor{keywordflow}{if} (u\_star < cs\%ustar\_min) u\_star = cs\%ustar\_min}
\DoxyCodeLine{447       \textcolor{keywordflow}{if} (cs\%omega\_frac >= 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{448         absf = 2.0*cs\%omega}
\DoxyCodeLine{449       \textcolor{keywordflow}{else}}
\DoxyCodeLine{450         absf = 0.25*((abs(g\%CoriolisBu(i,j)) + abs(g\%CoriolisBu(i-\/1,j-\/1))) + \&}
\DoxyCodeLine{451                      (abs(g\%CoriolisBu(i,j-\/1)) + abs(g\%CoriolisBu(i-\/1,j))))}
\DoxyCodeLine{452         \textcolor{keywordflow}{if} (cs\%omega\_frac > 0.0) \&}
\DoxyCodeLine{453           absf = sqrt(cs\%omega\_frac*4.0*cs\%omega**2 + (1.0-\/cs\%omega\_frac)*absf**2)}
\DoxyCodeLine{454 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{455 }
\DoxyCodeLine{456       \textcolor{comment}{! Perhaps provide a first guess for MLD based on a stored previous value.}}
\DoxyCodeLine{457       mld\_io = -\/1.0}
\DoxyCodeLine{458       \textcolor{keywordflow}{if} (cs\%MLD\_iteration\_guess .and. (cs\%ML\_Depth(i,j) > 0.0))  mld\_io = cs\%ML\_Depth(i,j)}
\DoxyCodeLine{459 }
\DoxyCodeLine{460       \textcolor{keyword}{call }epbl\_column(h, u, v, t0, s0, dsv\_dt\_1d, dsv\_ds\_1d, tke\_forcing, b\_flux, absf, \&}
\DoxyCodeLine{461                        u\_star, u\_star\_mean, dt, mld\_io, kd, mixvel, mixlen, gv, \&}
\DoxyCodeLine{462                        us, cs, ecd, dt\_diag=dt\_diag, waves=waves, g=g, i=i, j=j)}
\DoxyCodeLine{463 }
\DoxyCodeLine{464 }
\DoxyCodeLine{465       \textcolor{comment}{! Copy the diffusivities to a 2-\/d array.}}
\DoxyCodeLine{466       \textcolor{keywordflow}{do} k=1,nz+1}
\DoxyCodeLine{467         kd\_2d(i,k) = kd(k)}
\DoxyCodeLine{468 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{469       cs\%ML\_depth(i,j) = mld\_io}
\DoxyCodeLine{470 }
\DoxyCodeLine{471       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt\_expected)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{472         \textcolor{keywordflow}{do} k=1,nz ; dt\_expected(i,j,k) = ecd\%dT\_expect(k) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{473 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{474       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(ds\_expected)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{475         \textcolor{keywordflow}{do} k=1,nz ; ds\_expected(i,j,k) = ecd\%dS\_expect(k) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{476 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{477 }
\DoxyCodeLine{478       \textcolor{keywordflow}{if} (cs\%TKE\_diagnostics) \textcolor{keywordflow}{then}}
\DoxyCodeLine{479         cs\%diag\_TKE\_MKE(i,j) = cs\%diag\_TKE\_MKE(i,j) + ecd\%dTKE\_MKE}
\DoxyCodeLine{480         cs\%diag\_TKE\_conv(i,j) = cs\%diag\_TKE\_conv(i,j) + ecd\%dTKE\_conv}
\DoxyCodeLine{481         cs\%diag\_TKE\_forcing(i,j) = cs\%diag\_TKE\_forcing(i,j) + ecd\%dTKE\_forcing}
\DoxyCodeLine{482         cs\%diag\_TKE\_wind(i,j) = cs\%diag\_TKE\_wind(i,j) + ecd\%dTKE\_wind}
\DoxyCodeLine{483         cs\%diag\_TKE\_mixing(i,j) = cs\%diag\_TKE\_mixing(i,j) + ecd\%dTKE\_mixing}
\DoxyCodeLine{484         cs\%diag\_TKE\_mech\_decay(i,j) = cs\%diag\_TKE\_mech\_decay(i,j) + ecd\%dTKE\_mech\_decay}
\DoxyCodeLine{485         cs\%diag\_TKE\_conv\_decay(i,j) = cs\%diag\_TKE\_conv\_decay(i,j) + ecd\%dTKE\_conv\_decay}
\DoxyCodeLine{486        \textcolor{comment}{! CS\%diag\_TKE\_unbalanced(i,j) = CS\%diag\_TKE\_unbalanced(i,j) + eCD\%dTKE\_unbalanced}}
\DoxyCodeLine{487 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{488       \textcolor{comment}{! Write to 3-\/D for outputing Mixing length and velocity scale.}}
\DoxyCodeLine{489       \textcolor{keywordflow}{if} (cs\%id\_Mixing\_Length>0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{490         cs\%Mixing\_Length(i,j,k) = mixlen(k)}
\DoxyCodeLine{491 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{492       \textcolor{keywordflow}{if} (cs\%id\_Velocity\_Scale>0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{493         cs\%Velocity\_Scale(i,j,k) = mixvel(k)}
\DoxyCodeLine{494 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{495       \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs\%mstar\_mix)) cs\%mstar\_mix(i,j) = ecd\%mstar}
\DoxyCodeLine{496       \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs\%mstar\_lt)) cs\%mstar\_lt(i,j) = ecd\%mstar\_LT}
\DoxyCodeLine{497       \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs\%La)) cs\%La(i,j) = ecd\%LA}
\DoxyCodeLine{498       \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs\%La\_mod)) cs\%La\_mod(i,j) = ecd\%LAmod}
\DoxyCodeLine{499     \textcolor{keywordflow}{else} \textcolor{comment}{! End of the ocean-\/point part of the i-\/loop}}
\DoxyCodeLine{500       \textcolor{comment}{! For masked points, Kd\_int must still be set (to 0) because it has intent out.}}
\DoxyCodeLine{501       \textcolor{keywordflow}{do} k=1,nz+1 ; kd\_2d(i,k) = 0. ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{502       cs\%ML\_depth(i,j) = 0.0}
\DoxyCodeLine{503 }
\DoxyCodeLine{504       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt\_expected)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{505         \textcolor{keywordflow}{do} k=1,nz ; dt\_expected(i,j,k) = 0.0 ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{506 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{507       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(ds\_expected)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{508         \textcolor{keywordflow}{do} k=1,nz ; ds\_expected(i,j,k) = 0.0 ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{509 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{510 \textcolor{keywordflow}{    endif} ;\textcolor{keywordflow}{ enddo} \textcolor{comment}{! Close of i-\/loop -\/ Note unusual loop order!}}
\DoxyCodeLine{511 }
\DoxyCodeLine{512     \textcolor{keywordflow}{do} k=1,nz+1 ; \textcolor{keywordflow}{do} i=is,ie ; kd\_int(i,j,k) = kd\_2d(i,k) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{513 }
\DoxyCodeLine{514 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! j-\/loop}}
\DoxyCodeLine{515 }
\DoxyCodeLine{516   \textcolor{keywordflow}{if} (write\_diags) \textcolor{keywordflow}{then}}
\DoxyCodeLine{517     \textcolor{keywordflow}{if} (cs\%id\_ML\_depth > 0) \textcolor{keyword}{call }post\_data(cs\%id\_ML\_depth, cs\%ML\_depth, cs\%diag)}
\DoxyCodeLine{518     \textcolor{keywordflow}{if} (cs\%id\_hML\_depth > 0) \textcolor{keyword}{call }post\_data(cs\%id\_hML\_depth, cs\%ML\_depth, cs\%diag)}
\DoxyCodeLine{519     \textcolor{keywordflow}{if} (cs\%id\_TKE\_wind > 0) \textcolor{keyword}{call }post\_data(cs\%id\_TKE\_wind, cs\%diag\_TKE\_wind, cs\%diag)}
\DoxyCodeLine{520     \textcolor{keywordflow}{if} (cs\%id\_TKE\_MKE > 0)  \textcolor{keyword}{call }post\_data(cs\%id\_TKE\_MKE, cs\%diag\_TKE\_MKE, cs\%diag)}
\DoxyCodeLine{521     \textcolor{keywordflow}{if} (cs\%id\_TKE\_conv > 0) \textcolor{keyword}{call }post\_data(cs\%id\_TKE\_conv, cs\%diag\_TKE\_conv, cs\%diag)}
\DoxyCodeLine{522     \textcolor{keywordflow}{if} (cs\%id\_TKE\_forcing > 0) \textcolor{keyword}{call }post\_data(cs\%id\_TKE\_forcing, cs\%diag\_TKE\_forcing, cs\%diag)}
\DoxyCodeLine{523     \textcolor{keywordflow}{if} (cs\%id\_TKE\_mixing > 0) \textcolor{keyword}{call }post\_data(cs\%id\_TKE\_mixing, cs\%diag\_TKE\_mixing, cs\%diag)}
\DoxyCodeLine{524     \textcolor{keywordflow}{if} (cs\%id\_TKE\_mech\_decay > 0) \&}
\DoxyCodeLine{525       \textcolor{keyword}{call }post\_data(cs\%id\_TKE\_mech\_decay, cs\%diag\_TKE\_mech\_decay, cs\%diag)}
\DoxyCodeLine{526     \textcolor{keywordflow}{if} (cs\%id\_TKE\_conv\_decay > 0) \&}
\DoxyCodeLine{527       \textcolor{keyword}{call }post\_data(cs\%id\_TKE\_conv\_decay, cs\%diag\_TKE\_conv\_decay, cs\%diag)}
\DoxyCodeLine{528     \textcolor{keywordflow}{if} (cs\%id\_Mixing\_Length > 0) \textcolor{keyword}{call }post\_data(cs\%id\_Mixing\_Length, cs\%Mixing\_Length, cs\%diag)}
\DoxyCodeLine{529     \textcolor{keywordflow}{if} (cs\%id\_Velocity\_Scale >0) \textcolor{keyword}{call }post\_data(cs\%id\_Velocity\_Scale, cs\%Velocity\_Scale, cs\%diag)}
\DoxyCodeLine{530     \textcolor{keywordflow}{if} (cs\%id\_MSTAR\_MIX > 0)     \textcolor{keyword}{call }post\_data(cs\%id\_MSTAR\_MIX, cs\%MSTAR\_MIX, cs\%diag)}
\DoxyCodeLine{531     \textcolor{keywordflow}{if} (cs\%id\_LA > 0)       \textcolor{keyword}{call }post\_data(cs\%id\_LA, cs\%LA, cs\%diag)}
\DoxyCodeLine{532     \textcolor{keywordflow}{if} (cs\%id\_LA\_MOD > 0)   \textcolor{keyword}{call }post\_data(cs\%id\_LA\_MOD, cs\%LA\_MOD, cs\%diag)}
\DoxyCodeLine{533     \textcolor{keywordflow}{if} (cs\%id\_MSTAR\_LT > 0) \textcolor{keyword}{call }post\_data(cs\%id\_MSTAR\_LT, cs\%MSTAR\_LT, cs\%diag)}
\DoxyCodeLine{534 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{535 }
\DoxyCodeLine{536   \textcolor{keywordflow}{if} (debug) \textcolor{keyword}{deallocate}(ecd\%dT\_expect, ecd\%dS\_expect)}
\DoxyCodeLine{537 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__energetic__pbl_a64860c8b0110ba516795a288acdefd1f}\label{namespacemom__energetic__pbl_a64860c8b0110ba516795a288acdefd1f}} 
\index{mom\_energetic\_pbl@{mom\_energetic\_pbl}!energetic\_pbl\_end@{energetic\_pbl\_end}}
\index{energetic\_pbl\_end@{energetic\_pbl\_end}!mom\_energetic\_pbl@{mom\_energetic\_pbl}}
\doxysubsubsection{\texorpdfstring{energetic\_pbl\_end()}{energetic\_pbl\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+energetic\+\_\+pbl\+::energetic\+\_\+pbl\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__energetic__pbl_1_1energetic__pbl__cs}{energetic\+\_\+pbl\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Clean up and deallocate memory associated with the energetic\+\_\+\+P\+BL module. 


\begin{DoxyParams}{Parameters}
{\em cs} & Energetic\+\_\+\+P\+BL control structure that will be deallocated in this subroutine. \\
\hline
\end{DoxyParams}


Definition at line 2422 of file M\+O\+M\+\_\+energetic\+\_\+\+P\+B\+L.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{2422   \textcolor{keywordtype}{type}(energetic\_PBL\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< Energetic\_PBL control structure that}}
\DoxyCodeLine{2423 \textcolor{comment}{                                        !! will be deallocated in this subroutine.}}
\DoxyCodeLine{2424 }
\DoxyCodeLine{2425   \textcolor{keywordtype}{character(len=256)} :: mesg}
\DoxyCodeLine{2426 \textcolor{keywordtype}{  real} :: avg\_its}
\DoxyCodeLine{2427 }
\DoxyCodeLine{2428   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{2429 }
\DoxyCodeLine{2430   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs\%ML\_depth))            \textcolor{keyword}{deallocate}(cs\%ML\_depth)}
\DoxyCodeLine{2431   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs\%LA))                  \textcolor{keyword}{deallocate}(cs\%LA)}
\DoxyCodeLine{2432   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs\%LA\_MOD))              \textcolor{keyword}{deallocate}(cs\%LA\_MOD)}
\DoxyCodeLine{2433   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs\%MSTAR\_MIX))           \textcolor{keyword}{deallocate}(cs\%MSTAR\_MIX)}
\DoxyCodeLine{2434   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs\%MSTAR\_LT))            \textcolor{keyword}{deallocate}(cs\%MSTAR\_LT)}
\DoxyCodeLine{2435   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs\%diag\_TKE\_wind))       \textcolor{keyword}{deallocate}(cs\%diag\_TKE\_wind)}
\DoxyCodeLine{2436   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs\%diag\_TKE\_MKE))        \textcolor{keyword}{deallocate}(cs\%diag\_TKE\_MKE)}
\DoxyCodeLine{2437   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs\%diag\_TKE\_conv))       \textcolor{keyword}{deallocate}(cs\%diag\_TKE\_conv)}
\DoxyCodeLine{2438   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs\%diag\_TKE\_forcing))    \textcolor{keyword}{deallocate}(cs\%diag\_TKE\_forcing)}
\DoxyCodeLine{2439   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs\%diag\_TKE\_mixing))     \textcolor{keyword}{deallocate}(cs\%diag\_TKE\_mixing)}
\DoxyCodeLine{2440   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs\%diag\_TKE\_mech\_decay)) \textcolor{keyword}{deallocate}(cs\%diag\_TKE\_mech\_decay)}
\DoxyCodeLine{2441   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs\%diag\_TKE\_conv\_decay)) \textcolor{keyword}{deallocate}(cs\%diag\_TKE\_conv\_decay)}
\DoxyCodeLine{2442   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs\%Mixing\_Length))       \textcolor{keyword}{deallocate}(cs\%Mixing\_Length)}
\DoxyCodeLine{2443   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs\%Velocity\_Scale))      \textcolor{keyword}{deallocate}(cs\%Velocity\_Scale)}
\DoxyCodeLine{2444 }
\DoxyCodeLine{2445   \textcolor{keywordflow}{if} (report\_avg\_its) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2446     \textcolor{keyword}{call }efp\_sum\_across\_pes(cs\%sum\_its, 2)}
\DoxyCodeLine{2447 }
\DoxyCodeLine{2448     avg\_its = efp\_to\_real(cs\%sum\_its(1)) / efp\_to\_real(cs\%sum\_its(2))}
\DoxyCodeLine{2449     \textcolor{keyword}{write} (mesg,*) \textcolor{stringliteral}{"Average ePBL iterations = "}, avg\_its}
\DoxyCodeLine{2450     \textcolor{keyword}{call }mom\_mesg(mesg)}
\DoxyCodeLine{2451 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2452 }
\DoxyCodeLine{2453   \textcolor{keyword}{deallocate}(cs)}
\DoxyCodeLine{2454 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__energetic__pbl_af3a7ca5357ed9a1383c9556b117116dc}\label{namespacemom__energetic__pbl_af3a7ca5357ed9a1383c9556b117116dc}} 
\index{mom\_energetic\_pbl@{mom\_energetic\_pbl}!energetic\_pbl\_get\_mld@{energetic\_pbl\_get\_mld}}
\index{energetic\_pbl\_get\_mld@{energetic\_pbl\_get\_mld}!mom\_energetic\_pbl@{mom\_energetic\_pbl}}
\doxysubsubsection{\texorpdfstring{energetic\_pbl\_get\_mld()}{energetic\_pbl\_get\_mld()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+energetic\+\_\+pbl\+::energetic\+\_\+pbl\+\_\+get\+\_\+mld (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__energetic__pbl_1_1energetic__pbl__cs}{energetic\+\_\+pbl\+\_\+cs}}), pointer}]{CS,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed), intent(out)}]{M\+LD,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, intent(in), optional}]{m\+\_\+to\+\_\+\+M\+L\+D\+\_\+units }\end{DoxyParamCaption})}



Copies the e\+P\+BL active mixed layer depth into M\+LD, in units of \mbox{[}Z $\sim$$>$ m\mbox{]} unless other units are specified. 


\begin{DoxyParams}[1]{Parameters}
 & {\em cs} & Control structure for e\+P\+BL \\
\hline
\mbox{\texttt{ in}}  & {\em g} & Grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ out}}  & {\em mld} & Depth of e\+P\+BL active mixing layer \mbox{[}Z $\sim$$>$ m\mbox{]} or other units \\
\hline
\mbox{\texttt{ in}}  & {\em m\+\_\+to\+\_\+mld\+\_\+units} & A conversion factor from meters to the desired units for M\+LD \\
\hline
\end{DoxyParams}


Definition at line 1952 of file M\+O\+M\+\_\+energetic\+\_\+\+P\+B\+L.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1952   \textcolor{keywordtype}{type}(energetic\_PBL\_CS),           \textcolor{keywordtype}{pointer}     :: CS\textcolor{comment}{  !< Control structure for ePBL}}
\DoxyCodeLine{1953   \textcolor{keywordtype}{type}(ocean\_grid\_type),            \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{   !< Grid structure}}
\DoxyCodeLine{1954   \textcolor{keywordtype}{type}(unit\_scale\_type),            \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{  !< A dimensional unit scaling type}}
\DoxyCodeLine{1955 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \textcolor{keywordtype}{intent(out)} :: MLD\textcolor{comment}{ !< Depth of ePBL active mixing layer [Z ~> m] or other units}}
\DoxyCodeLine{1956 \textcolor{keywordtype}{  real},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: m\_to\_MLD\_units\textcolor{comment}{ !< A conversion factor from meters}}
\DoxyCodeLine{1957 \textcolor{comment}{                                                       !! to the desired units for MLD}}
\DoxyCodeLine{1958   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1959 \textcolor{keywordtype}{  real} :: scale  \textcolor{comment}{! A dimensional rescaling factor}}
\DoxyCodeLine{1960   \textcolor{keywordtype}{integer} :: i,j}
\DoxyCodeLine{1961 }
\DoxyCodeLine{1962   scale = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(m\_to\_mld\_units)) scale = us\%Z\_to\_m * m\_to\_mld\_units}
\DoxyCodeLine{1963 }
\DoxyCodeLine{1964   \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{1965     mld(i,j) = scale*cs\%ML\_Depth(i,j)}
\DoxyCodeLine{1966 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1967 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__energetic__pbl_ad9fa0dc4ba4e126ec686b44a5829c2e8}\label{namespacemom__energetic__pbl_ad9fa0dc4ba4e126ec686b44a5829c2e8}} 
\index{mom\_energetic\_pbl@{mom\_energetic\_pbl}!energetic\_pbl\_init@{energetic\_pbl\_init}}
\index{energetic\_pbl\_init@{energetic\_pbl\_init}!mom\_energetic\_pbl@{mom\_energetic\_pbl}}
\doxysubsubsection{\texorpdfstring{energetic\_pbl\_init()}{energetic\_pbl\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+energetic\+\_\+pbl\+::energetic\+\_\+pbl\+\_\+init (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in), target}]{Time,  }\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(diag\+\_\+ctrl), intent(inout), target}]{diag,  }\item[{type(\mbox{\hyperlink{structmom__energetic__pbl_1_1energetic__pbl__cs}{energetic\+\_\+pbl\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



This subroutine initializes the energetic\+\_\+\+P\+BL module. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em time} & The current model time \\
\hline
\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{ in}}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters \\
\hline
\mbox{\texttt{ in,out}}  & {\em diag} & A structure that is used to regulate diagnostic output \\
\hline
 & {\em cs} & A pointer that is set to point to the control structure for this module \\
\hline
\end{DoxyParams}


Definition at line 1973 of file M\+O\+M\+\_\+energetic\+\_\+\+P\+B\+L.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1973   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< The current model time}}
\DoxyCodeLine{1974   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{1975   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{1976   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{1977   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse for run-\/time parameters}}
\DoxyCodeLine{1978   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{ !< A structure that is used to regulate diagnostic output}}
\DoxyCodeLine{1979   \textcolor{keywordtype}{type}(energetic\_PBL\_CS),  \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< A pointer that is set to point to the control}}
\DoxyCodeLine{1980 \textcolor{comment}{                                                 !! structure for this module}}
\DoxyCodeLine{1981   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1982   \textcolor{comment}{! This include declares and sets the variable "version".}}
\DoxyCodeLine{1983 \textcolor{preprocessor}{\# include "version\_variable.h"}}
\DoxyCodeLine{1984 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_energetic\_PBL"}  \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{1985   \textcolor{keywordtype}{character(len=20)}  :: tmpstr}
\DoxyCodeLine{1986 \textcolor{keywordtype}{  real} :: omega\_frac\_dflt}
\DoxyCodeLine{1987   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed}
\DoxyCodeLine{1988   \textcolor{keywordtype}{integer} :: mstar\_mode, LT\_enhance, wT\_mode}
\DoxyCodeLine{1989   \textcolor{keywordtype}{logical} :: default\_2018\_answers}
\DoxyCodeLine{1990   \textcolor{keywordtype}{logical} :: use\_temperature, use\_omega}
\DoxyCodeLine{1991   \textcolor{keywordtype}{logical} :: use\_la\_windsea}
\DoxyCodeLine{1992   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{1993 }
\DoxyCodeLine{1994   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1995     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"mixedlayer\_init called with an associated"}//\&}
\DoxyCodeLine{1996                             \textcolor{stringliteral}{"associated control structure."})}
\DoxyCodeLine{1997     \textcolor{keywordflow}{return}}
\DoxyCodeLine{1998   \textcolor{keywordflow}{else} ; \textcolor{keyword}{allocate}(cs) ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{1999 }
\DoxyCodeLine{2000   cs\%diag => diag}
\DoxyCodeLine{2001   cs\%Time => time}
\DoxyCodeLine{2002 }
\DoxyCodeLine{2003 \textcolor{comment}{! Set default, read and log parameters}}
\DoxyCodeLine{2004   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})}
\DoxyCodeLine{2005 }
\DoxyCodeLine{2006 }
\DoxyCodeLine{2007 \textcolor{comment}{!/1. General ePBL settings}}
\DoxyCodeLine{2008   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"OMEGA"}, cs\%omega, \&}
\DoxyCodeLine{2009                  \textcolor{stringliteral}{"The rotation rate of the earth."}, units=\textcolor{stringliteral}{"s-\/1"}, \&}
\DoxyCodeLine{2010                  default=7.2921e-\/5, scale=us\%T\_to\_S)}
\DoxyCodeLine{2011   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ML\_USE\_OMEGA"}, use\_omega, \&}
\DoxyCodeLine{2012                  \textcolor{stringliteral}{"If true, use the absolute rotation rate instead of the "}//\&}
\DoxyCodeLine{2013                  \textcolor{stringliteral}{"vertical component of rotation when setting the decay "}//\&}
\DoxyCodeLine{2014                  \textcolor{stringliteral}{"scale for turbulence."}, default=.false., do\_not\_log=.true.)}
\DoxyCodeLine{2015   omega\_frac\_dflt = 0.0}
\DoxyCodeLine{2016   \textcolor{keywordflow}{if} (use\_omega) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2017     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"ML\_USE\_OMEGA is depricated; use ML\_OMEGA\_FRAC=1.0 instead."})}
\DoxyCodeLine{2018     omega\_frac\_dflt = 1.0}
\DoxyCodeLine{2019 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2020   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ML\_OMEGA\_FRAC"}, cs\%omega\_frac, \&}
\DoxyCodeLine{2021                  \textcolor{stringliteral}{"When setting the decay scale for turbulence, use this "}//\&}
\DoxyCodeLine{2022                  \textcolor{stringliteral}{"fraction of the absolute rotation rate blended with the "}//\&}
\DoxyCodeLine{2023                  \textcolor{stringliteral}{"local value of f, as sqrt((1-\/of)*f\string^2 + of*4*omega\string^2)."}, \&}
\DoxyCodeLine{2024                  units=\textcolor{stringliteral}{"nondim"}, default=omega\_frac\_dflt)}
\DoxyCodeLine{2025   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EKMAN\_SCALE\_COEF"}, cs\%Ekman\_scale\_coef, \&}
\DoxyCodeLine{2026                  \textcolor{stringliteral}{"A nondimensional scaling factor controlling the inhibition "}//\&}
\DoxyCodeLine{2027                  \textcolor{stringliteral}{"of the diffusive length scale by rotation. Making this larger "}//\&}
\DoxyCodeLine{2028                  \textcolor{stringliteral}{"decreases the PBL diffusivity."}, units=\textcolor{stringliteral}{"nondim"}, default=1.0)}
\DoxyCodeLine{2029   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEFAULT\_2018\_ANSWERS"}, default\_2018\_answers, \&}
\DoxyCodeLine{2030                  \textcolor{stringliteral}{"This sets the default value for the various \_2018\_ANSWERS parameters."}, \&}
\DoxyCodeLine{2031                  default=.false.)}
\DoxyCodeLine{2032   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_2018\_ANSWERS"}, cs\%answers\_2018, \&}
\DoxyCodeLine{2033                  \textcolor{stringliteral}{"If true, use the order of arithmetic and expressions that recover the "}//\&}
\DoxyCodeLine{2034                  \textcolor{stringliteral}{"answers from the end of 2018.  Otherwise, use updated and more robust "}//\&}
\DoxyCodeLine{2035                  \textcolor{stringliteral}{"forms of the same expressions."}, default=default\_2018\_answers)}
\DoxyCodeLine{2036 }
\DoxyCodeLine{2037 }
\DoxyCodeLine{2038   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_ORIGINAL\_PE\_CALC"}, cs\%orig\_PE\_calc, \&}
\DoxyCodeLine{2039                  \textcolor{stringliteral}{"If true, the ePBL code uses the original form of the "}//\&}
\DoxyCodeLine{2040                  \textcolor{stringliteral}{"potential energy change code.  Otherwise, the newer "}//\&}
\DoxyCodeLine{2041                  \textcolor{stringliteral}{"version that can work with successive increments to the "}//\&}
\DoxyCodeLine{2042                  \textcolor{stringliteral}{"diffusivity in upward or downward passes is used."}, default=.true.)}
\DoxyCodeLine{2043 }
\DoxyCodeLine{2044   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MKE\_TO\_TKE\_EFFIC"}, cs\%MKE\_to\_TKE\_effic, \&}
\DoxyCodeLine{2045                  \textcolor{stringliteral}{"The efficiency with which mean kinetic energy released "}//\&}
\DoxyCodeLine{2046                  \textcolor{stringliteral}{"by mechanically forced entrainment of the mixed layer "}//\&}
\DoxyCodeLine{2047                  \textcolor{stringliteral}{"is converted to turbulent kinetic energy."}, units=\textcolor{stringliteral}{"nondim"}, \&}
\DoxyCodeLine{2048                  default=0.0)}
\DoxyCodeLine{2049   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TKE\_DECAY"}, cs\%TKE\_decay, \&}
\DoxyCodeLine{2050                  \textcolor{stringliteral}{"TKE\_DECAY relates the vertical rate of decay of the "}//\&}
\DoxyCodeLine{2051                  \textcolor{stringliteral}{"TKE available for mechanical entrainment to the natural "}//\&}
\DoxyCodeLine{2052                  \textcolor{stringliteral}{"Ekman depth."}, units=\textcolor{stringliteral}{"nondim"}, default=2.5)}
\DoxyCodeLine{2053 }
\DoxyCodeLine{2054 }
\DoxyCodeLine{2055 \textcolor{comment}{!/2. Options related to setting MSTAR}}
\DoxyCodeLine{2056   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_MSTAR\_SCHEME"}, tmpstr, \&}
\DoxyCodeLine{2057                  \textcolor{stringliteral}{"EPBL\_MSTAR\_SCHEME selects the method for setting mstar.  Valid values are: \(\backslash\)n"}//\&}
\DoxyCodeLine{2058                  \textcolor{stringliteral}{"\(\backslash\)t CONSTANT   -\/ Use a fixed mstar given by MSTAR \(\backslash\)n"}//\&}
\DoxyCodeLine{2059                  \textcolor{stringliteral}{"\(\backslash\)t OM4        -\/ Use L\_Ekman/L\_Obukhov in the sabilizing limit, as in OM4 \(\backslash\)n"}//\&}
\DoxyCodeLine{2060                  \textcolor{stringliteral}{"\(\backslash\)t REICHL\_H18 -\/ Use the scheme documented in Reichl \& Hallberg, 2018."}, \&}
\DoxyCodeLine{2061                  default=constant\_string, do\_not\_log=.true.)}
\DoxyCodeLine{2062   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MSTAR\_MODE"}, mstar\_mode, default=-\/1)}
\DoxyCodeLine{2063   \textcolor{keywordflow}{if} (mstar\_mode == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2064     tmpstr = constant\_string}
\DoxyCodeLine{2065     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"Use EPBL\_MSTAR\_SCHEME = CONSTANT instead of the archaic MSTAR\_MODE = 0."})}
\DoxyCodeLine{2066   \textcolor{keywordflow}{elseif} (mstar\_mode == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2067     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"You are using a legacy mstar mode in ePBL that has been phased out. "}//\&}
\DoxyCodeLine{2068                           \textcolor{stringliteral}{"If you need to use this setting please report this error.  Also use "}//\&}
\DoxyCodeLine{2069                           \textcolor{stringliteral}{"EPBL\_MSTAR\_SCHEME to specify the scheme for mstar."})}
\DoxyCodeLine{2070   \textcolor{keywordflow}{elseif} (mstar\_mode == 2) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2071     tmpstr = om4\_string}
\DoxyCodeLine{2072     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"Use EPBL\_MSTAR\_SCHEME = OM4 instead of the archaic MSTAR\_MODE = 2."})}
\DoxyCodeLine{2073   \textcolor{keywordflow}{elseif} (mstar\_mode == 3) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2074     tmpstr = rh18\_string}
\DoxyCodeLine{2075     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"Use EPBL\_MSTAR\_SCHEME = REICHL\_H18 instead of the archaic MSTAR\_MODE = 3."})}
\DoxyCodeLine{2076   \textcolor{keywordflow}{elseif} (mstar\_mode > 3) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2077     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"An unrecognized value of the obsolete parameter MSTAR\_MODE was specified."})}
\DoxyCodeLine{2078 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2079   \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_MSTAR\_SCHEME"}, tmpstr, \&}
\DoxyCodeLine{2080                  \textcolor{stringliteral}{"EPBL\_MSTAR\_SCHEME selects the method for setting mstar.  Valid values are: \(\backslash\)n"}//\&}
\DoxyCodeLine{2081                  \textcolor{stringliteral}{"\(\backslash\)t CONSTANT   -\/ Use a fixed mstar given by MSTAR \(\backslash\)n"}//\&}
\DoxyCodeLine{2082                  \textcolor{stringliteral}{"\(\backslash\)t OM4        -\/ Use L\_Ekman/L\_Obukhov in the sabilizing limit, as in OM4 \(\backslash\)n"}//\&}
\DoxyCodeLine{2083                  \textcolor{stringliteral}{"\(\backslash\)t REICHL\_H18 -\/ Use the scheme documented in Reichl \& Hallberg, 2018."}, \&}
\DoxyCodeLine{2084                  default=constant\_string)}
\DoxyCodeLine{2085   tmpstr = uppercase(tmpstr)}
\DoxyCodeLine{2086   \textcolor{keywordflow}{select case} (tmpstr)}
\DoxyCodeLine{2087     \textcolor{keywordflow}{case} (constant\_string)}
\DoxyCodeLine{2088       cs\%mstar\_Scheme = use\_fixed\_mstar}
\DoxyCodeLine{2089     \textcolor{keywordflow}{case} (om4\_string)}
\DoxyCodeLine{2090       cs\%mstar\_Scheme = mstar\_from\_ekman}
\DoxyCodeLine{2091     \textcolor{keywordflow}{case} (rh18\_string)}
\DoxyCodeLine{2092       cs\%mstar\_Scheme = mstar\_from\_rh18}
\DoxyCodeLine{2093 \textcolor{keywordflow}{    case default}}
\DoxyCodeLine{2094       \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{'energetic\_PBL\_init: EPBL\_MSTAR\_SCHEME ="'}//trim(tmpstr)//\textcolor{stringliteral}{'"'}, 0)}
\DoxyCodeLine{2095       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"energetic\_PBL\_init: Unrecognized setting "}// \&}
\DoxyCodeLine{2096             \textcolor{stringliteral}{"EPBL\_MSTAR\_SCHEME = "}//trim(tmpstr)//\textcolor{stringliteral}{" found in input file."})}
\DoxyCodeLine{2097 \textcolor{keywordflow}{  end select}}
\DoxyCodeLine{2098 }
\DoxyCodeLine{2099   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MSTAR"}, cs\%fixed\_mstar, \&}
\DoxyCodeLine{2100                  \textcolor{stringliteral}{"The ratio of the friction velocity cubed to the TKE input to the "}//\&}
\DoxyCodeLine{2101                  \textcolor{stringliteral}{"mixed layer.  This option is used if EPBL\_MSTAR\_SCHEME = CONSTANT."}, \&}
\DoxyCodeLine{2102                  units=\textcolor{stringliteral}{"nondim"}, default=1.2, do\_not\_log=(cs\%mstar\_scheme/=use\_fixed\_mstar))}
\DoxyCodeLine{2103   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MSTAR\_CAP"}, cs\%mstar\_cap, \&}
\DoxyCodeLine{2104                  \textcolor{stringliteral}{"If this value is positive, it sets the maximum value of mstar "}//\&}
\DoxyCodeLine{2105                  \textcolor{stringliteral}{"allowed in ePBL.  (This is not used if EPBL\_MSTAR\_SCHEME = CONSTANT)."}, \&}
\DoxyCodeLine{2106                  units=\textcolor{stringliteral}{"nondim"}, default=-\/1.0, do\_not\_log=(cs\%mstar\_scheme==use\_fixed\_mstar))}
\DoxyCodeLine{2107   \textcolor{comment}{! mstar\_scheme==MStar\_from\_Ekman options}}
\DoxyCodeLine{2108   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MSTAR2\_COEF1"}, cs\%MSTAR\_COEF, \&}
\DoxyCodeLine{2109                  \textcolor{stringliteral}{"Coefficient in computing mstar when rotation and stabilizing "}//\&}
\DoxyCodeLine{2110                  \textcolor{stringliteral}{"effects are both important (used if EPBL\_MSTAR\_SCHEME = OM4)."}, \&}
\DoxyCodeLine{2111                  units=\textcolor{stringliteral}{"nondim"}, default=0.3, do\_not\_log=(cs\%mstar\_scheme/=mstar\_from\_ekman))}
\DoxyCodeLine{2112   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MSTAR2\_COEF2"}, cs\%C\_EK, \&}
\DoxyCodeLine{2113                  \textcolor{stringliteral}{"Coefficient in computing mstar when only rotation limits "}// \&}
\DoxyCodeLine{2114                  \textcolor{stringliteral}{"the total mixing (used if EPBL\_MSTAR\_SCHEME = OM4)"}, \&}
\DoxyCodeLine{2115                  units=\textcolor{stringliteral}{"nondim"}, default=0.085, do\_not\_log=(cs\%mstar\_scheme/=mstar\_from\_ekman))}
\DoxyCodeLine{2116   \textcolor{comment}{! mstar\_scheme==MStar\_from\_RH18 options}}
\DoxyCodeLine{2117   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RH18\_MSTAR\_CN1"}, cs\%RH18\_mstar\_cn1,\&}
\DoxyCodeLine{2118                  \textcolor{stringliteral}{"MSTAR\_N coefficient 1 (outter-\/most coefficient for fit). "}//\&}
\DoxyCodeLine{2119                  \textcolor{stringliteral}{"The value of 0.275 is given in RH18.  Increasing this "}//\&}
\DoxyCodeLine{2120                  \textcolor{stringliteral}{"coefficient increases MSTAR for all values of Hf/ust, but more "}//\&}
\DoxyCodeLine{2121                  \textcolor{stringliteral}{"effectively at low values (weakly developed OSBLs)."}, \&}
\DoxyCodeLine{2122                  units=\textcolor{stringliteral}{"nondim"}, default=0.275, do\_not\_log=(cs\%mstar\_scheme/=mstar\_from\_rh18))}
\DoxyCodeLine{2123   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RH18\_MSTAR\_CN2"}, cs\%RH18\_mstar\_cn2,\&}
\DoxyCodeLine{2124                  \textcolor{stringliteral}{"MSTAR\_N coefficient 2 (coefficient outside of exponential decay). "}//\&}
\DoxyCodeLine{2125                  \textcolor{stringliteral}{"The value of 8.0 is given in RH18.  Increasing this coefficient "}//\&}
\DoxyCodeLine{2126                  \textcolor{stringliteral}{"increases MSTAR for all values of HF/ust, with a much more even "}//\&}
\DoxyCodeLine{2127                  \textcolor{stringliteral}{"effect across a wide range of Hf/ust than CN1."}, \&}
\DoxyCodeLine{2128                  units=\textcolor{stringliteral}{"nondim"}, default=8.0, do\_not\_log=(cs\%mstar\_scheme/=mstar\_from\_rh18))}
\DoxyCodeLine{2129   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RH18\_MSTAR\_CN3"}, cs\%RH18\_mstar\_CN3,\&}
\DoxyCodeLine{2130                  \textcolor{stringliteral}{"MSTAR\_N coefficient 3 (exponential decay coefficient). "}//\&}
\DoxyCodeLine{2131                  \textcolor{stringliteral}{"The value of -\/5.0 is given in RH18.  Increasing this increases how "}//\&}
\DoxyCodeLine{2132                  \textcolor{stringliteral}{"quickly the value of MSTAR decreases as Hf/ust increases."}, \&}
\DoxyCodeLine{2133                   units=\textcolor{stringliteral}{"nondim"}, default=-\/5.0, do\_not\_log=(cs\%mstar\_scheme/=mstar\_from\_rh18))}
\DoxyCodeLine{2134   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RH18\_MSTAR\_CS1"}, cs\%RH18\_mstar\_cs1,\&}
\DoxyCodeLine{2135                  \textcolor{stringliteral}{"MSTAR\_S coefficient for RH18 in stabilizing limit. "}//\&}
\DoxyCodeLine{2136                  \textcolor{stringliteral}{"The value of 0.2 is given in RH18 and increasing it increases "}//\&}
\DoxyCodeLine{2137                  \textcolor{stringliteral}{"MSTAR in the presence of a stabilizing surface buoyancy flux."}, \&}
\DoxyCodeLine{2138                  units=\textcolor{stringliteral}{"nondim"}, default=0.2, do\_not\_log=(cs\%mstar\_scheme/=mstar\_from\_rh18))}
\DoxyCodeLine{2139   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RH18\_MSTAR\_CS2"}, cs\%RH18\_mstar\_cs2,\&}
\DoxyCodeLine{2140                  \textcolor{stringliteral}{"MSTAR\_S exponent for RH18 in stabilizing limit. "}//\&}
\DoxyCodeLine{2141                  \textcolor{stringliteral}{"The value of 0.4 is given in RH18 and increasing it increases MSTAR "}//\&}
\DoxyCodeLine{2142                  \textcolor{stringliteral}{"exponentially in the presence of a stabilizing surface buoyancy flux."}, \&}
\DoxyCodeLine{2143                  units=\textcolor{stringliteral}{"nondim"}, default=0.4, do\_not\_log=(cs\%mstar\_scheme/=mstar\_from\_rh18))}
\DoxyCodeLine{2144 }
\DoxyCodeLine{2145 }
\DoxyCodeLine{2146 \textcolor{comment}{!/ Convective turbulence related options}}
\DoxyCodeLine{2147   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"NSTAR"}, cs\%nstar, \&}
\DoxyCodeLine{2148                  \textcolor{stringliteral}{"The portion of the buoyant potential energy imparted by "}//\&}
\DoxyCodeLine{2149                  \textcolor{stringliteral}{"surface fluxes that is available to drive entrainment "}//\&}
\DoxyCodeLine{2150                  \textcolor{stringliteral}{"at the base of mixed layer when that energy is positive."}, \&}
\DoxyCodeLine{2151                  units=\textcolor{stringliteral}{"nondim"}, default=0.2)}
\DoxyCodeLine{2152   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MSTAR\_CONV\_ADJ"}, cs\%mstar\_convect\_coef, \&}
\DoxyCodeLine{2153                  \textcolor{stringliteral}{"Coefficient used for reducing mstar during convection "}//\&}
\DoxyCodeLine{2154                  \textcolor{stringliteral}{"due to reduction of stable density gradient."}, \&}
\DoxyCodeLine{2155                  units=\textcolor{stringliteral}{"nondim"}, default=0.0)}
\DoxyCodeLine{2156 }
\DoxyCodeLine{2157 \textcolor{comment}{!/ Mixing Length Options}}
\DoxyCodeLine{2158   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"USE\_MLD\_ITERATION"}, cs\%Use\_MLD\_iteration, \&}
\DoxyCodeLine{2159                  \textcolor{stringliteral}{"A logical that specifies whether or not to use the "}//\&}
\DoxyCodeLine{2160                  \textcolor{stringliteral}{"distance to the bottom of the actively turbulent boundary "}//\&}
\DoxyCodeLine{2161                  \textcolor{stringliteral}{"layer to help set the EPBL length scale."}, default=.true.)}
\DoxyCodeLine{2162   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_TRANSITION\_SCALE"}, cs\%transLay\_scale, \&}
\DoxyCodeLine{2163                  \textcolor{stringliteral}{"A scale for the mixing length in the transition layer "}//\&}
\DoxyCodeLine{2164                  \textcolor{stringliteral}{"at the edge of the boundary layer as a fraction of the "}//\&}
\DoxyCodeLine{2165                  \textcolor{stringliteral}{"boundary layer thickness."}, units=\textcolor{stringliteral}{"nondim"}, default=0.1)}
\DoxyCodeLine{2166   \textcolor{keywordflow}{if} ( cs\%Use\_MLD\_iteration .and. abs(cs\%transLay\_scale-\/0.5) >= 0.5) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2167     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"If flag USE\_MLD\_ITERATION is true, then "}//\&}
\DoxyCodeLine{2168                  \textcolor{stringliteral}{"EPBL\_TRANSITION should be greater than 0 and less than 1."})}
\DoxyCodeLine{2169 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2170 }
\DoxyCodeLine{2171   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MLD\_ITERATION\_GUESS"}, cs\%MLD\_ITERATION\_GUESS, \&}
\DoxyCodeLine{2172                  \textcolor{stringliteral}{"If true, use the previous timestep MLD as a first guess in the MLD iteration, "}//\&}
\DoxyCodeLine{2173                  \textcolor{stringliteral}{"otherwise use half the ocean depth as the first guess of the boundary layer "}//\&}
\DoxyCodeLine{2174                  \textcolor{stringliteral}{"depth.  The default is false to facilitate reproducibility."}, \&}
\DoxyCodeLine{2175                  default=.false., do\_not\_log=.not.cs\%Use\_MLD\_iteration)}
\DoxyCodeLine{2176   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_MLD\_TOLERANCE"}, cs\%MLD\_tol, \&}
\DoxyCodeLine{2177                  \textcolor{stringliteral}{"The tolerance for the iteratively determined mixed "}//\&}
\DoxyCodeLine{2178                  \textcolor{stringliteral}{"layer depth.  This is only used with USE\_MLD\_ITERATION."}, \&}
\DoxyCodeLine{2179                  units=\textcolor{stringliteral}{"meter"}, default=1.0, scale=us\%m\_to\_Z, do\_not\_log=.not.cs\%Use\_MLD\_iteration)}
\DoxyCodeLine{2180   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_MLD\_BISECTION"}, cs\%MLD\_bisection, \&}
\DoxyCodeLine{2181                  \textcolor{stringliteral}{"If true, use bisection with the iterative determination of the self-\/consistent "}//\&}
\DoxyCodeLine{2182                  \textcolor{stringliteral}{"mixed layer depth.  Otherwise use the false position after a maximum and minimum "}//\&}
\DoxyCodeLine{2183                  \textcolor{stringliteral}{"bound have been evaluated and the returned value or bisection before this."}, \&}
\DoxyCodeLine{2184                  default=.true., do\_not\_log=.not.cs\%Use\_MLD\_iteration) \textcolor{comment}{!\#\#\# The default should become false.}}
\DoxyCodeLine{2185   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_MLD\_MAX\_ITS"}, cs\%max\_MLD\_its, \&}
\DoxyCodeLine{2186                  \textcolor{stringliteral}{"The maximum number of iterations that can be used to find a self-\/consistent "}//\&}
\DoxyCodeLine{2187                  \textcolor{stringliteral}{"mixed layer depth.  If EPBL\_MLD\_BISECTION is true, the maximum number "}//\&}
\DoxyCodeLine{2188                  \textcolor{stringliteral}{"iteractions needed is set by Depth/2\string^MAX\_ITS < EPBL\_MLD\_TOLERANCE."}, \&}
\DoxyCodeLine{2189                  default=20, do\_not\_log=.not.cs\%Use\_MLD\_iteration)}
\DoxyCodeLine{2190   \textcolor{keywordflow}{if} (.not.cs\%Use\_MLD\_iteration) cs\%Max\_MLD\_Its = 1}
\DoxyCodeLine{2191   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_MIN\_MIX\_LEN"}, cs\%min\_mix\_len, \&}
\DoxyCodeLine{2192                  \textcolor{stringliteral}{"The minimum mixing length scale that will be used "}//\&}
\DoxyCodeLine{2193                  \textcolor{stringliteral}{"by ePBL.  The default (0) does not set a minimum."}, \&}
\DoxyCodeLine{2194                  units=\textcolor{stringliteral}{"meter"}, default=0.0, scale=us\%m\_to\_Z)}
\DoxyCodeLine{2195 }
\DoxyCodeLine{2196   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MIX\_LEN\_EXPONENT"}, cs\%MixLenExponent, \&}
\DoxyCodeLine{2197                  \textcolor{stringliteral}{"The exponent applied to the ratio of the distance to the MLD "}//\&}
\DoxyCodeLine{2198                  \textcolor{stringliteral}{"and the MLD depth which determines the shape of the mixing length. "}//\&}
\DoxyCodeLine{2199                  \textcolor{stringliteral}{"This is only used if USE\_MLD\_ITERATION is True."}, \&}
\DoxyCodeLine{2200                  units=\textcolor{stringliteral}{"nondim"}, default=2.0)}
\DoxyCodeLine{2201 }
\DoxyCodeLine{2202 \textcolor{comment}{!/ Turbulent velocity scale in mixing coefficient}}
\DoxyCodeLine{2203   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_VEL\_SCALE\_SCHEME"}, tmpstr, \&}
\DoxyCodeLine{2204                  \textcolor{stringliteral}{"Selects the method for translating TKE into turbulent velocities. "}//\&}
\DoxyCodeLine{2205                  \textcolor{stringliteral}{"Valid values are: \(\backslash\)n"}//\&}
\DoxyCodeLine{2206                  \textcolor{stringliteral}{"\(\backslash\)t CUBE\_ROOT\_TKE  -\/ A constant times the cube root of remaining TKE. \(\backslash\)n"}//\&}
\DoxyCodeLine{2207                  \textcolor{stringliteral}{"\(\backslash\)t REICHL\_H18 -\/ Use the scheme based on a combination of w* and v* as \(\backslash\)n"}//\&}
\DoxyCodeLine{2208                  \textcolor{stringliteral}{"\(\backslash\)t              documented in Reichl \& Hallberg, 2018."}, \&}
\DoxyCodeLine{2209                  default=root\_tke\_string, do\_not\_log=.true.)}
\DoxyCodeLine{2210   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_VEL\_SCALE\_MODE"}, wt\_mode, default=-\/1)}
\DoxyCodeLine{2211   \textcolor{keywordflow}{if} (wt\_mode == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2212     tmpstr = root\_tke\_string}
\DoxyCodeLine{2213     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"Use EPBL\_VEL\_SCALE\_SCHEME = CUBE\_ROOT\_TKE instead of the archaic EPBL\_VEL\_SCALE\_MODE = 0."})}
\DoxyCodeLine{2214   \textcolor{keywordflow}{elseif} (wt\_mode == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2215     tmpstr = rh18\_string}
\DoxyCodeLine{2216     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"Use EPBL\_VEL\_SCALE\_SCHEME = REICHL\_H18 instead of the archaic EPBL\_VEL\_SCALE\_MODE = 1."})}
\DoxyCodeLine{2217   \textcolor{keywordflow}{elseif} (wt\_mode >= 2) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2218     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"An unrecognized value of the obsolete parameter EPBL\_VEL\_SCALE\_MODE was specified."})}
\DoxyCodeLine{2219 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2220   \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_VEL\_SCALE\_SCHEME"}, tmpstr, \&}
\DoxyCodeLine{2221                  \textcolor{stringliteral}{"Selects the method for translating TKE into turbulent velocities. "}//\&}
\DoxyCodeLine{2222                  \textcolor{stringliteral}{"Valid values are: \(\backslash\)n"}//\&}
\DoxyCodeLine{2223                  \textcolor{stringliteral}{"\(\backslash\)t CUBE\_ROOT\_TKE  -\/ A constant times the cube root of remaining TKE. \(\backslash\)n"}//\&}
\DoxyCodeLine{2224                  \textcolor{stringliteral}{"\(\backslash\)t REICHL\_H18 -\/ Use the scheme based on a combination of w* and v* as \(\backslash\)n"}//\&}
\DoxyCodeLine{2225                  \textcolor{stringliteral}{"\(\backslash\)t              documented in Reichl \& Hallberg, 2018."}, \&}
\DoxyCodeLine{2226                  default=root\_tke\_string)}
\DoxyCodeLine{2227   tmpstr = uppercase(tmpstr)}
\DoxyCodeLine{2228   \textcolor{keywordflow}{select case} (tmpstr)}
\DoxyCodeLine{2229     \textcolor{keywordflow}{case} (root\_tke\_string)}
\DoxyCodeLine{2230       cs\%wT\_scheme = wt\_from\_croot\_tke}
\DoxyCodeLine{2231     \textcolor{keywordflow}{case} (rh18\_string)}
\DoxyCodeLine{2232       cs\%wT\_scheme = wt\_from\_rh18}
\DoxyCodeLine{2233 \textcolor{keywordflow}{    case default}}
\DoxyCodeLine{2234       \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{'energetic\_PBL\_init: EPBL\_VEL\_SCALE\_SCHEME ="'}//trim(tmpstr)//\textcolor{stringliteral}{'"'}, 0)}
\DoxyCodeLine{2235       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"energetic\_PBL\_init: Unrecognized setting "}// \&}
\DoxyCodeLine{2236             \textcolor{stringliteral}{"EPBL\_VEL\_SCALE\_SCHEME = "}//trim(tmpstr)//\textcolor{stringliteral}{" found in input file."})}
\DoxyCodeLine{2237 \textcolor{keywordflow}{  end select}}
\DoxyCodeLine{2238 }
\DoxyCodeLine{2239   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"WSTAR\_USTAR\_COEF"}, cs\%wstar\_ustar\_coef, \&}
\DoxyCodeLine{2240                  \textcolor{stringliteral}{"A ratio relating the efficiency with which convectively "}//\&}
\DoxyCodeLine{2241                  \textcolor{stringliteral}{"released energy is converted to a turbulent velocity, "}//\&}
\DoxyCodeLine{2242                  \textcolor{stringliteral}{"relative to mechanically forced TKE. Making this larger "}//\&}
\DoxyCodeLine{2243                  \textcolor{stringliteral}{"increases the BL diffusivity"}, units=\textcolor{stringliteral}{"nondim"}, default=1.0)}
\DoxyCodeLine{2244   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_VEL\_SCALE\_FACTOR"}, cs\%vstar\_scale\_fac, \&}
\DoxyCodeLine{2245                  \textcolor{stringliteral}{"An overall nondimensional scaling factor for wT. "}//\&}
\DoxyCodeLine{2246                  \textcolor{stringliteral}{"Making this larger increases the PBL diffusivity."}, \&}
\DoxyCodeLine{2247                  units=\textcolor{stringliteral}{"nondim"}, default=1.0)}
\DoxyCodeLine{2248   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"VSTAR\_SURF\_FAC"}, cs\%vstar\_surf\_fac,\&}
\DoxyCodeLine{2249                  \textcolor{stringliteral}{"The proportionality times ustar to set vstar at the surface."}, \&}
\DoxyCodeLine{2250                  units=\textcolor{stringliteral}{"nondim"}, default=1.2)}
\DoxyCodeLine{2251 }
\DoxyCodeLine{2252   \textcolor{comment}{!/ Options related to Langmuir turbulence}}
\DoxyCodeLine{2253   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"USE\_LA\_LI2016"}, use\_la\_windsea, \&}
\DoxyCodeLine{2254        \textcolor{stringliteral}{"A logical to use the Li et al. 2016 (submitted) formula to "}//\&}
\DoxyCodeLine{2255        \textcolor{stringliteral}{"determine the Langmuir number."}, units=\textcolor{stringliteral}{"nondim"}, default=.false.)}
\DoxyCodeLine{2256   \textcolor{comment}{! Note this can be activated in other ways, but this preserves the old method.}}
\DoxyCodeLine{2257   \textcolor{keywordflow}{if} (use\_la\_windsea) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2258     cs\%USE\_LT = .true.}
\DoxyCodeLine{2259   \textcolor{keywordflow}{else}}
\DoxyCodeLine{2260     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_LT"}, cs\%USE\_LT, \&}
\DoxyCodeLine{2261                  \textcolor{stringliteral}{"A logical to use a LT parameterization."}, \&}
\DoxyCodeLine{2262                  units=\textcolor{stringliteral}{"nondim"}, default=.false.)}
\DoxyCodeLine{2263 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2264   \textcolor{keywordflow}{if} (cs\%USE\_LT) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2265     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_LANGMUIR\_SCHEME"}, tmpstr, \&}
\DoxyCodeLine{2266                  \textcolor{stringliteral}{"EPBL\_LANGMUIR\_SCHEME selects the method for including Langmuir turbulence. "}//\&}
\DoxyCodeLine{2267                  \textcolor{stringliteral}{"Valid values are: \(\backslash\)n"}//\&}
\DoxyCodeLine{2268                  \textcolor{stringliteral}{"\(\backslash\)t NONE     -\/ Do not do any extra mixing due to Langmuir turbulence \(\backslash\)n"}//\&}
\DoxyCodeLine{2269                  \textcolor{stringliteral}{"\(\backslash\)t RESCALE  -\/ Use a multiplicative rescaling of mstar to account for Langmuir turbulence \(\backslash\)n"}//\&}
\DoxyCodeLine{2270                  \textcolor{stringliteral}{"\(\backslash\)t ADDITIVE -\/ Add a Langmuir turblence contribution to mstar to other contributions"}, \&}
\DoxyCodeLine{2271                  default=none\_string, do\_not\_log=.true.)}
\DoxyCodeLine{2272     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LT\_ENHANCE"}, lt\_enhance, default=-\/1)}
\DoxyCodeLine{2273     \textcolor{keywordflow}{if} (lt\_enhance == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2274       tmpstr = none\_string}
\DoxyCodeLine{2275       \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"Use EPBL\_LANGMUIR\_SCHEME = NONE instead of the archaic LT\_ENHANCE = 0."})}
\DoxyCodeLine{2276     \textcolor{keywordflow}{elseif} (lt\_enhance == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2277       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"You are using a legacy LT\_ENHANCE mode in ePBL that has been phased out. "}//\&}
\DoxyCodeLine{2278                             \textcolor{stringliteral}{"If you need to use this setting please report this error.  Also use "}//\&}
\DoxyCodeLine{2279                             \textcolor{stringliteral}{"EPBL\_LANGMUIR\_SCHEME to specify the scheme for mstar."})}
\DoxyCodeLine{2280     \textcolor{keywordflow}{elseif} (lt\_enhance == 2) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2281       tmpstr = rescaled\_string}
\DoxyCodeLine{2282       \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"Use EPBL\_LANGMUIR\_SCHEME = RESCALE instead of the archaic LT\_ENHANCE = 2."})}
\DoxyCodeLine{2283     \textcolor{keywordflow}{elseif} (lt\_enhance == 3) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2284       tmpstr = additive\_string}
\DoxyCodeLine{2285       \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"Use EPBL\_LANGMUIR\_SCHEME = ADDITIVE instead of the archaic LT\_ENHANCE = 3."})}
\DoxyCodeLine{2286     \textcolor{keywordflow}{elseif} (lt\_enhance > 3) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2287       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"An unrecognized value of the obsolete parameter LT\_ENHANCE was specified."})}
\DoxyCodeLine{2288 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{2289     \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_LANGMUIR\_SCHEME"}, tmpstr, \&}
\DoxyCodeLine{2290                  \textcolor{stringliteral}{"EPBL\_LANGMUIR\_SCHEME selects the method for including Langmuir turbulence. "}//\&}
\DoxyCodeLine{2291                  \textcolor{stringliteral}{"Valid values are: \(\backslash\)n"}//\&}
\DoxyCodeLine{2292                  \textcolor{stringliteral}{"\(\backslash\)t NONE     -\/ Do not do any extra mixing due to Langmuir turbulence \(\backslash\)n"}//\&}
\DoxyCodeLine{2293                  \textcolor{stringliteral}{"\(\backslash\)t RESCALE  -\/ Use a multiplicative rescaling of mstar to account for Langmuir turbulence \(\backslash\)n"}//\&}
\DoxyCodeLine{2294                  \textcolor{stringliteral}{"\(\backslash\)t ADDITIVE -\/ Add a Langmuir turblence contribution to mstar to other contributions"}, \&}
\DoxyCodeLine{2295                  default=none\_string)}
\DoxyCodeLine{2296     tmpstr = uppercase(tmpstr)}
\DoxyCodeLine{2297     \textcolor{keywordflow}{select case} (tmpstr)}
\DoxyCodeLine{2298       \textcolor{keywordflow}{case} (none\_string)}
\DoxyCodeLine{2299         cs\%LT\_enhance\_form = no\_langmuir}
\DoxyCodeLine{2300       \textcolor{keywordflow}{case} (rescaled\_string)}
\DoxyCodeLine{2301         cs\%LT\_enhance\_form = langmuir\_rescale}
\DoxyCodeLine{2302       \textcolor{keywordflow}{case} (additive\_string)}
\DoxyCodeLine{2303         cs\%LT\_enhance\_form = langmuir\_add}
\DoxyCodeLine{2304 \textcolor{keywordflow}{      case default}}
\DoxyCodeLine{2305         \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{'energetic\_PBL\_init: EPBL\_LANGMUIR\_SCHEME ="'}//trim(tmpstr)//\textcolor{stringliteral}{'"'}, 0)}
\DoxyCodeLine{2306         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"energetic\_PBL\_init: Unrecognized setting "}// \&}
\DoxyCodeLine{2307               \textcolor{stringliteral}{"EPBL\_LANGMUIR\_SCHEME = "}//trim(tmpstr)//\textcolor{stringliteral}{" found in input file."})}
\DoxyCodeLine{2308 \textcolor{keywordflow}{    end select}}
\DoxyCodeLine{2309 }
\DoxyCodeLine{2310     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LT\_ENHANCE\_COEF"}, cs\%LT\_ENHANCE\_COEF, \&}
\DoxyCodeLine{2311                  \textcolor{stringliteral}{"Coefficient for Langmuir enhancement of mstar"}, \&}
\DoxyCodeLine{2312                  units=\textcolor{stringliteral}{"nondim"}, default=0.447, do\_not\_log=(cs\%LT\_enhance\_form==no\_langmuir))}
\DoxyCodeLine{2313     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LT\_ENHANCE\_EXP"}, cs\%LT\_ENHANCE\_EXP, \&}
\DoxyCodeLine{2314                  \textcolor{stringliteral}{"Exponent for Langmuir enhancementt of mstar"}, \&}
\DoxyCodeLine{2315                  units=\textcolor{stringliteral}{"nondim"}, default=-\/1.33,  do\_not\_log=(cs\%LT\_enhance\_form==no\_langmuir))}
\DoxyCodeLine{2316     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LT\_MOD\_LAC1"}, cs\%LaC\_MLDoEK, \&}
\DoxyCodeLine{2317                  \textcolor{stringliteral}{"Coefficient for modification of Langmuir number due to "}//\&}
\DoxyCodeLine{2318                  \textcolor{stringliteral}{"MLD approaching Ekman depth."}, \&}
\DoxyCodeLine{2319                  units=\textcolor{stringliteral}{"nondim"}, default=-\/0.87,  do\_not\_log=(cs\%LT\_enhance\_form==no\_langmuir))}
\DoxyCodeLine{2320     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LT\_MOD\_LAC2"}, cs\%LaC\_MLDoOB\_stab, \&}
\DoxyCodeLine{2321                  \textcolor{stringliteral}{"Coefficient for modification of Langmuir number due to "}//\&}
\DoxyCodeLine{2322                  \textcolor{stringliteral}{"MLD approaching stable Obukhov depth."}, \&}
\DoxyCodeLine{2323                  units=\textcolor{stringliteral}{"nondim"}, default=0.0,  do\_not\_log=(cs\%LT\_enhance\_form==no\_langmuir))}
\DoxyCodeLine{2324     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LT\_MOD\_LAC3"}, cs\%LaC\_MLDoOB\_un, \&}
\DoxyCodeLine{2325                  \textcolor{stringliteral}{"Coefficient for modification of Langmuir number due to "}//\&}
\DoxyCodeLine{2326                  \textcolor{stringliteral}{"MLD approaching unstable Obukhov depth."}, \&}
\DoxyCodeLine{2327                  units=\textcolor{stringliteral}{"nondim"}, default=0.0,  do\_not\_log=(cs\%LT\_enhance\_form==no\_langmuir))}
\DoxyCodeLine{2328     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LT\_MOD\_LAC4"}, cs\%Lac\_EKoOB\_stab, \&}
\DoxyCodeLine{2329                  \textcolor{stringliteral}{"Coefficient for modification of Langmuir number due to "}//\&}
\DoxyCodeLine{2330                  \textcolor{stringliteral}{"ratio of Ekman to stable Obukhov depth."}, \&}
\DoxyCodeLine{2331                  units=\textcolor{stringliteral}{"nondim"}, default=0.95,  do\_not\_log=(cs\%LT\_enhance\_form==no\_langmuir))}
\DoxyCodeLine{2332     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LT\_MOD\_LAC5"}, cs\%Lac\_EKoOB\_un, \&}
\DoxyCodeLine{2333                  \textcolor{stringliteral}{"Coefficient for modification of Langmuir number due to "}//\&}
\DoxyCodeLine{2334                  \textcolor{stringliteral}{"ratio of Ekman to unstable Obukhov depth."}, \&}
\DoxyCodeLine{2335                  units=\textcolor{stringliteral}{"nondim"}, default=0.95,  do\_not\_log=(cs\%LT\_enhance\_form==no\_langmuir))}
\DoxyCodeLine{2336 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2337 }
\DoxyCodeLine{2338 }
\DoxyCodeLine{2339 \textcolor{comment}{!/ Logging parameters}}
\DoxyCodeLine{2340   \textcolor{comment}{! This gives a minimum decay scale that is typically much less than Angstrom.}}
\DoxyCodeLine{2341   cs\%ustar\_min = 2e-\/4*cs\%omega*(gv\%Angstrom\_Z + gv\%H\_to\_Z*gv\%H\_subroundoff)}
\DoxyCodeLine{2342   \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"!EPBL\_USTAR\_MIN"}, cs\%ustar\_min*us\%Z\_to\_m*us\%s\_to\_T, \&}
\DoxyCodeLine{2343                  \textcolor{stringliteral}{"The (tiny) minimum friction velocity used within the "}//\&}
\DoxyCodeLine{2344                  \textcolor{stringliteral}{"ePBL code, derived from OMEGA and ANGSTROM."}, units=\textcolor{stringliteral}{"m s-\/1"}, \&}
\DoxyCodeLine{2345                  like\_default=.true.)}
\DoxyCodeLine{2346 }
\DoxyCodeLine{2347 }
\DoxyCodeLine{2348 \textcolor{comment}{!/ Checking output flags}}
\DoxyCodeLine{2349   cs\%id\_ML\_depth = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ePBL\_h\_ML'}, diag\%axesT1, \&}
\DoxyCodeLine{2350       time, \textcolor{stringliteral}{'Surface boundary layer depth'}, \textcolor{stringliteral}{'m'}, conversion=us\%Z\_to\_m, \&}
\DoxyCodeLine{2351       cmor\_long\_name=\textcolor{stringliteral}{'Ocean Mixed Layer Thickness Defined by Mixing Scheme'})}
\DoxyCodeLine{2352   \textcolor{comment}{! This is an alias for the same variable as ePBL\_h\_ML}}
\DoxyCodeLine{2353   cs\%id\_hML\_depth = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'h\_ML'}, diag\%axesT1, \&}
\DoxyCodeLine{2354       time, \textcolor{stringliteral}{'Surface mixed layer depth based on active turbulence'}, \textcolor{stringliteral}{'m'}, conversion=us\%Z\_to\_m)}
\DoxyCodeLine{2355   cs\%id\_TKE\_wind = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ePBL\_TKE\_wind'}, diag\%axesT1, \&}
\DoxyCodeLine{2356       time, \textcolor{stringliteral}{'Wind-\/stirring source of mixed layer TKE'}, \textcolor{stringliteral}{'W m-\/2'}, conversion=us\%RZ3\_T3\_to\_W\_m2)}
\DoxyCodeLine{2357   cs\%id\_TKE\_MKE = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ePBL\_TKE\_MKE'}, diag\%axesT1, \&}
\DoxyCodeLine{2358       time, \textcolor{stringliteral}{'Mean kinetic energy source of mixed layer TKE'}, \textcolor{stringliteral}{'W m-\/2'}, conversion=us\%RZ3\_T3\_to\_W\_m2)}
\DoxyCodeLine{2359   cs\%id\_TKE\_conv = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ePBL\_TKE\_conv'}, diag\%axesT1, \&}
\DoxyCodeLine{2360       time, \textcolor{stringliteral}{'Convective source of mixed layer TKE'}, \textcolor{stringliteral}{'W m-\/2'}, conversion=us\%RZ3\_T3\_to\_W\_m2)}
\DoxyCodeLine{2361   cs\%id\_TKE\_forcing = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ePBL\_TKE\_forcing'}, diag\%axesT1, \&}
\DoxyCodeLine{2362       time, \textcolor{stringliteral}{'TKE consumed by mixing surface forcing or penetrative shortwave radation '}//\&}
\DoxyCodeLine{2363             \textcolor{stringliteral}{'through model layers'}, \textcolor{stringliteral}{'W m-\/2'}, conversion=us\%RZ3\_T3\_to\_W\_m2)}
\DoxyCodeLine{2364   cs\%id\_TKE\_mixing = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ePBL\_TKE\_mixing'}, diag\%axesT1, \&}
\DoxyCodeLine{2365       time, \textcolor{stringliteral}{'TKE consumed by mixing that deepens the mixed layer'}, \textcolor{stringliteral}{'W m-\/2'}, conversion=us\%RZ3\_T3\_to\_W\_m2)}
\DoxyCodeLine{2366   cs\%id\_TKE\_mech\_decay = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ePBL\_TKE\_mech\_decay'}, diag\%axesT1, \&}
\DoxyCodeLine{2367       time, \textcolor{stringliteral}{'Mechanical energy decay sink of mixed layer TKE'}, \textcolor{stringliteral}{'W m-\/2'}, conversion=us\%RZ3\_T3\_to\_W\_m2)}
\DoxyCodeLine{2368   cs\%id\_TKE\_conv\_decay = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ePBL\_TKE\_conv\_decay'}, diag\%axesT1, \&}
\DoxyCodeLine{2369       time, \textcolor{stringliteral}{'Convective energy decay sink of mixed layer TKE'}, \textcolor{stringliteral}{'W m-\/2'}, conversion=us\%RZ3\_T3\_to\_W\_m2)}
\DoxyCodeLine{2370   cs\%id\_Mixing\_Length = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'Mixing\_Length'}, diag\%axesTi, \&}
\DoxyCodeLine{2371       time, \textcolor{stringliteral}{'Mixing Length that is used'}, \textcolor{stringliteral}{'m'}, conversion=us\%Z\_to\_m)}
\DoxyCodeLine{2372   cs\%id\_Velocity\_Scale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'Velocity\_Scale'}, diag\%axesTi, \&}
\DoxyCodeLine{2373       time, \textcolor{stringliteral}{'Velocity Scale that is used.'}, \textcolor{stringliteral}{'m s-\/1'}, conversion=us\%Z\_to\_m*us\%s\_to\_T)}
\DoxyCodeLine{2374   cs\%id\_MSTAR\_mix = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'MSTAR'}, diag\%axesT1, \&}
\DoxyCodeLine{2375       time, \textcolor{stringliteral}{'Total mstar that is used.'}, \textcolor{stringliteral}{'nondim'})}
\DoxyCodeLine{2376 }
\DoxyCodeLine{2377   \textcolor{keywordflow}{if} (cs\%use\_LT) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2378     cs\%id\_LA = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'LA'}, diag\%axesT1, \&}
\DoxyCodeLine{2379         time, \textcolor{stringliteral}{'Langmuir number.'}, \textcolor{stringliteral}{'nondim'})}
\DoxyCodeLine{2380     cs\%id\_LA\_mod = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'LA\_MOD'}, diag\%axesT1, \&}
\DoxyCodeLine{2381         time, \textcolor{stringliteral}{'Modified Langmuir number.'}, \textcolor{stringliteral}{'nondim'})}
\DoxyCodeLine{2382     cs\%id\_MSTAR\_LT = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'MSTAR\_LT'}, diag\%axesT1, \&}
\DoxyCodeLine{2383         time, \textcolor{stringliteral}{'Increase in mstar due to Langmuir Turbulence.'}, \textcolor{stringliteral}{'nondim'})}
\DoxyCodeLine{2384 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2385 }
\DoxyCodeLine{2386   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ENABLE\_THERMODYNAMICS"}, use\_temperature, \&}
\DoxyCodeLine{2387                  \textcolor{stringliteral}{"If true, temperature and salinity are used as state "}//\&}
\DoxyCodeLine{2388                  \textcolor{stringliteral}{"variables."}, default=.true.)}
\DoxyCodeLine{2389 }
\DoxyCodeLine{2390   \textcolor{keywordflow}{if} (report\_avg\_its) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2391     cs\%sum\_its(1) = real\_to\_efp(0.0) ; cs\%sum\_its(2) = real\_to\_efp(0.0)}
\DoxyCodeLine{2392 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2393 }
\DoxyCodeLine{2394   \textcolor{keywordflow}{if} (max(cs\%id\_TKE\_wind, cs\%id\_TKE\_MKE, cs\%id\_TKE\_conv, \&}
\DoxyCodeLine{2395           cs\%id\_TKE\_mixing, cs\%id\_TKE\_mech\_decay, cs\%id\_TKE\_forcing, \&}
\DoxyCodeLine{2396           cs\%id\_TKE\_conv\_decay) > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2397     \textcolor{keyword}{call }safe\_alloc\_alloc(cs\%diag\_TKE\_wind, isd, ied, jsd, jed)}
\DoxyCodeLine{2398     \textcolor{keyword}{call }safe\_alloc\_alloc(cs\%diag\_TKE\_MKE, isd, ied, jsd, jed)}
\DoxyCodeLine{2399     \textcolor{keyword}{call }safe\_alloc\_alloc(cs\%diag\_TKE\_conv, isd, ied, jsd, jed)}
\DoxyCodeLine{2400     \textcolor{keyword}{call }safe\_alloc\_alloc(cs\%diag\_TKE\_forcing, isd, ied, jsd, jed)}
\DoxyCodeLine{2401     \textcolor{keyword}{call }safe\_alloc\_alloc(cs\%diag\_TKE\_mixing, isd, ied, jsd, jed)}
\DoxyCodeLine{2402     \textcolor{keyword}{call }safe\_alloc\_alloc(cs\%diag\_TKE\_mech\_decay, isd, ied, jsd, jed)}
\DoxyCodeLine{2403     \textcolor{keyword}{call }safe\_alloc\_alloc(cs\%diag\_TKE\_conv\_decay, isd, ied, jsd, jed)}
\DoxyCodeLine{2404 }
\DoxyCodeLine{2405     cs\%TKE\_diagnostics = .true.}
\DoxyCodeLine{2406 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2407   \textcolor{keywordflow}{if} (cs\%id\_Velocity\_Scale>0) \textcolor{keyword}{call }safe\_alloc\_alloc(cs\%Velocity\_Scale, isd, ied, jsd, jed, gv\%ke+1)}
\DoxyCodeLine{2408   \textcolor{keywordflow}{if} (cs\%id\_Mixing\_Length>0) \textcolor{keyword}{call }safe\_alloc\_alloc(cs\%Mixing\_Length, isd, ied, jsd, jed, gv\%ke+1)}
\DoxyCodeLine{2409 }
\DoxyCodeLine{2410   \textcolor{keyword}{call }safe\_alloc\_alloc(cs\%ML\_depth, isd, ied, jsd, jed)}
\DoxyCodeLine{2411   \textcolor{keywordflow}{if} (max(cs\%id\_mstar\_mix, cs\%id\_LA, cs\%id\_LA\_mod, cs\%id\_MSTAR\_LT ) >0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2412     \textcolor{keyword}{call }safe\_alloc\_alloc(cs\%Mstar\_mix, isd, ied, jsd, jed)}
\DoxyCodeLine{2413     \textcolor{keyword}{call }safe\_alloc\_alloc(cs\%LA, isd, ied, jsd, jed)}
\DoxyCodeLine{2414     \textcolor{keyword}{call }safe\_alloc\_alloc(cs\%LA\_MOD, isd, ied, jsd, jed)}
\DoxyCodeLine{2415     \textcolor{keyword}{call }safe\_alloc\_alloc(cs\%MSTAR\_LT, isd, ied, jsd, jed)}
\DoxyCodeLine{2416 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2417 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__energetic__pbl_a01291f3e97cfdcf58866a1e9b0bcfc26}\label{namespacemom__energetic__pbl_a01291f3e97cfdcf58866a1e9b0bcfc26}} 
\index{mom\_energetic\_pbl@{mom\_energetic\_pbl}!epbl\_column@{epbl\_column}}
\index{epbl\_column@{epbl\_column}!mom\_energetic\_pbl@{mom\_energetic\_pbl}}
\doxysubsubsection{\texorpdfstring{epbl\_column()}{epbl\_column()}}
{\footnotesize\ttfamily subroutine mom\+\_\+energetic\+\_\+pbl\+::epbl\+\_\+column (\begin{DoxyParamCaption}\item[{real, dimension(szk\+\_\+(gv)), intent(in)}]{h,  }\item[{real, dimension(szk\+\_\+(gv)), intent(in)}]{u,  }\item[{real, dimension(szk\+\_\+(gv)), intent(in)}]{v,  }\item[{real, dimension(szk\+\_\+(gv)), intent(in)}]{T0,  }\item[{real, dimension(szk\+\_\+(gv)), intent(in)}]{S0,  }\item[{real, dimension(szk\+\_\+(gv)), intent(in)}]{d\+S\+V\+\_\+dT,  }\item[{real, dimension(szk\+\_\+(gv)), intent(in)}]{d\+S\+V\+\_\+dS,  }\item[{real, dimension(szk\+\_\+(gv)), intent(in)}]{T\+K\+E\+\_\+forcing,  }\item[{real, intent(in)}]{B\+\_\+flux,  }\item[{real, intent(in)}]{absf,  }\item[{real, intent(in)}]{u\+\_\+star,  }\item[{real, intent(in)}]{u\+\_\+star\+\_\+mean,  }\item[{real, intent(in)}]{dt,  }\item[{real, intent(inout)}]{M\+L\+D\+\_\+io,  }\item[{real, dimension(szk\+\_\+(gv)+1), intent(out)}]{Kd,  }\item[{real, dimension(szk\+\_\+(gv)+1), intent(out)}]{mixvel,  }\item[{real, dimension(szk\+\_\+(gv)+1), intent(out)}]{mixlen,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__energetic__pbl_1_1energetic__pbl__cs}{energetic\+\_\+pbl\+\_\+cs}}), pointer}]{CS,  }\item[{type(\mbox{\hyperlink{structmom__energetic__pbl_1_1epbl__column__diags}{epbl\+\_\+column\+\_\+diags}}), intent(inout)}]{e\+CD,  }\item[{real, intent(in), optional}]{dt\+\_\+diag,  }\item[{type(wave\+\_\+parameters\+\_\+cs), optional, pointer}]{Waves,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout), optional}]{G,  }\item[{integer, intent(in), optional}]{i,  }\item[{integer, intent(in), optional}]{j }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine determines the diffusivities from the integrated energetics mixed layer model for a single column of water. 


\begin{DoxyParams}[1]{Parameters}
\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{ in}}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em u} & Zonal velocities interpolated to h points \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em v} & Zonal velocities interpolated to h points \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em t0} & The initial layer temperatures \mbox{[}degC\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em s0} & The initial layer salinities \mbox{[}ppt\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em dsv\+\_\+dt} & The partial derivative of in-\/situ specific volume with potential temperature \mbox{[}R-\/1 deg\+C-\/1 $\sim$$>$ m3 kg-\/1 deg\+C-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em dsv\+\_\+ds} & The partial derivative of in-\/situ specific volume with salinity \mbox{[}R-\/1 ppt-\/1 $\sim$$>$ m3 kg-\/1 ppt-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em tke\+\_\+forcing} & The forcing requirements to homogenize the forcing that has been applied to each layer \mbox{[}R Z3 T-\/2 $\sim$$>$ J m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em b\+\_\+flux} & The surface buoyancy flux \mbox{[}Z2 T-\/3 $\sim$$>$ m2 s-\/3\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em absf} & The absolute value of the Coriolis parameter \mbox{[}T-\/1 $\sim$$>$ s-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+star} & The surface friction velocity \mbox{[}Z T-\/1 $\sim$$>$ m s-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+star\+\_\+mean} & The surface friction velocity without any contribution from unresolved gustiness \mbox{[}Z T-\/1 $\sim$$>$ m s-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in,out}}  & {\em mld\+\_\+io} & A first guess at the mixed layer depth on input, and the calculated mixed layer depth on output \mbox{[}Z $\sim$$>$ m\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em dt} & Time increment \mbox{[}T $\sim$$>$ s\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em kd} & The diagnosed diffusivities at interfaces \\
\hline
\mbox{\texttt{ out}}  & {\em mixvel} & The mixing velocity scale used in Kd \\
\hline
\mbox{\texttt{ out}}  & {\em mixlen} & The mixing length scale used in Kd \mbox{[}Z $\sim$$>$ m\mbox{]}. \\
\hline
 & {\em cs} & The control structure returned by a previous call to mixedlayer\+\_\+init. \\
\hline
\mbox{\texttt{ in,out}}  & {\em ecd} & A container for passing around diagnostics. \\
\hline
\mbox{\texttt{ in}}  & {\em dt\+\_\+diag} & The diagnostic time step, which may be less than dt if there are two calls to mixedlayer \mbox{[}T $\sim$$>$ s\mbox{]}. \\
\hline
 & {\em waves} & Wave CS for Langmuir turbulence \\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & The ocean\textquotesingle{}s grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em i} & The i-\/index to work on (used for Waves) \\
\hline
\mbox{\texttt{ in}}  & {\em j} & The i-\/index to work on (used for Waves) \\
\hline
\end{DoxyParams}


Definition at line 547 of file M\+O\+M\+\_\+energetic\+\_\+\+P\+B\+L.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{547   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{     !< The ocean's vertical grid structure.}}
\DoxyCodeLine{548   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{     !< A dimensional unit scaling type}}
\DoxyCodeLine{549 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}  :: h\textcolor{comment}{      !< Layer thicknesses [H ~> m or kg m-\/2].}}
\DoxyCodeLine{550 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}  :: u\textcolor{comment}{      !< Zonal velocities interpolated to h points}}
\DoxyCodeLine{551 \textcolor{comment}{                                                   !! [L T-\/1 ~> m s-\/1].}}
\DoxyCodeLine{552 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}  :: v\textcolor{comment}{      !< Zonal velocities interpolated to h points}}
\DoxyCodeLine{553 \textcolor{comment}{                                                   !! [L T-\/1 ~> m s-\/1].}}
\DoxyCodeLine{554 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}  :: T0\textcolor{comment}{     !< The initial layer temperatures [degC].}}
\DoxyCodeLine{555 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}  :: S0\textcolor{comment}{     !< The initial layer salinities [ppt].}}
\DoxyCodeLine{556 }
\DoxyCodeLine{557 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}  :: dSV\_dT\textcolor{comment}{ !< The partial derivative of in-\/situ specific}}
\DoxyCodeLine{558 \textcolor{comment}{                                                   !! volume with potential temperature}}
\DoxyCodeLine{559 \textcolor{comment}{                                                   !! [R-\/1 degC-\/1 ~> m3 kg-\/1 degC-\/1].}}
\DoxyCodeLine{560 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}  :: dSV\_dS\textcolor{comment}{ !< The partial derivative of in-\/situ specific}}
\DoxyCodeLine{561 \textcolor{comment}{                                                   !! volume with salinity [R-\/1 ppt-\/1 ~> m3 kg-\/1 ppt-\/1].}}
\DoxyCodeLine{562 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}  :: TKE\_forcing\textcolor{comment}{ !< The forcing requirements to homogenize the}}
\DoxyCodeLine{563 \textcolor{comment}{                                                   !! forcing that has been applied to each layer}}
\DoxyCodeLine{564 \textcolor{comment}{                                                   !! [R Z3 T-\/2 ~> J m-\/2].}}
\DoxyCodeLine{565 \textcolor{keywordtype}{  real},                    \textcolor{keywordtype}{intent(in)}    :: B\_flux\textcolor{comment}{ !< The surface buoyancy flux [Z2 T-\/3 ~> m2 s-\/3]}}
\DoxyCodeLine{566 \textcolor{keywordtype}{  real},                    \textcolor{keywordtype}{intent(in)}    :: absf\textcolor{comment}{   !< The absolute value of the Coriolis parameter [T-\/1 ~> s-\/1].}}
\DoxyCodeLine{567 \textcolor{keywordtype}{  real},                    \textcolor{keywordtype}{intent(in)}    :: u\_star\textcolor{comment}{ !< The surface friction velocity [Z T-\/1 ~> m s-\/1].}}
\DoxyCodeLine{568 \textcolor{keywordtype}{  real},                    \textcolor{keywordtype}{intent(in)}    :: u\_star\_mean\textcolor{comment}{ !< The surface friction velocity without any}}
\DoxyCodeLine{569 \textcolor{comment}{                                                   !! contribution from unresolved gustiness  [Z T-\/1 ~> m s-\/1].}}
\DoxyCodeLine{570 \textcolor{keywordtype}{  real},                    \textcolor{keywordtype}{intent(inout)} :: MLD\_io\textcolor{comment}{ !< A first guess at the mixed layer depth on input, and}}
\DoxyCodeLine{571 \textcolor{comment}{                                                   !! the calculated mixed layer depth on output [Z ~> m].}}
\DoxyCodeLine{572 \textcolor{keywordtype}{  real},                    \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{     !< Time increment [T ~> s].}}
\DoxyCodeLine{573 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV)+1)}, \&}
\DoxyCodeLine{574                            \textcolor{keywordtype}{intent(out)}   :: Kd\textcolor{comment}{     !< The diagnosed diffusivities at interfaces}}
\DoxyCodeLine{575 \textcolor{comment}{                                                   !! [Z2 T-\/1 ~> m2 s-\/1].}}
\DoxyCodeLine{576 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV)+1)}, \&}
\DoxyCodeLine{577                            \textcolor{keywordtype}{intent(out)}   :: mixvel\textcolor{comment}{ !< The mixing velocity scale used in Kd}}
\DoxyCodeLine{578 \textcolor{comment}{                                                   !! [Z T-\/1 ~> m s-\/1].}}
\DoxyCodeLine{579 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV)+1)}, \&}
\DoxyCodeLine{580                            \textcolor{keywordtype}{intent(out)}   :: mixlen\textcolor{comment}{ !< The mixing length scale used in Kd [Z ~> m].}}
\DoxyCodeLine{581   \textcolor{keywordtype}{type}(energetic\_PBL\_CS),  \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{     !< The control structure returned by a previous}}
\DoxyCodeLine{582 \textcolor{comment}{                                                   !! call to mixedlayer\_init.}}
\DoxyCodeLine{583   \textcolor{keywordtype}{type}(ePBL\_column\_diags), \textcolor{keywordtype}{intent(inout)} :: eCD\textcolor{comment}{    !< A container for passing around diagnostics.}}
\DoxyCodeLine{584 \textcolor{keywordtype}{  real},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dt\_diag\textcolor{comment}{   !< The diagnostic time step, which may be less}}
\DoxyCodeLine{585 \textcolor{comment}{                                                   !! than dt if there are two calls to mixedlayer [T ~> s].}}
\DoxyCodeLine{586   \textcolor{keywordtype}{type}(wave\_parameters\_CS), \&}
\DoxyCodeLine{587                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}       :: Waves\textcolor{comment}{  !< Wave CS for Langmuir turbulence}}
\DoxyCodeLine{588   \textcolor{keywordtype}{type}(ocean\_grid\_type), \&}
\DoxyCodeLine{589                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{      !< The ocean's grid structure.}}
\DoxyCodeLine{590   \textcolor{keywordtype}{integer},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: i\textcolor{comment}{      !< The i-\/index to work on (used for Waves)}}
\DoxyCodeLine{591   \textcolor{keywordtype}{integer},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: j\textcolor{comment}{      !< The i-\/index to work on (used for Waves)}}
\DoxyCodeLine{592 }
\DoxyCodeLine{593 \textcolor{comment}{!    This subroutine determines the diffusivities in a single column from the integrated energetics}}
\DoxyCodeLine{594 \textcolor{comment}{!  planetary boundary layer (ePBL) model.  It assumes that heating, cooling and freshwater fluxes}}
\DoxyCodeLine{595 \textcolor{comment}{!  have already been applied.  All calculations are done implicitly, and there}}
\DoxyCodeLine{596 \textcolor{comment}{!  is no stability limit on the time step.}}
\DoxyCodeLine{597 \textcolor{comment}{!}}
\DoxyCodeLine{598 \textcolor{comment}{!    For each interior interface, first discard the TKE to account for mixing}}
\DoxyCodeLine{599 \textcolor{comment}{! of shortwave radiation through the next denser cell.  Next drive mixing based}}
\DoxyCodeLine{600 \textcolor{comment}{! on the local? values of ustar + wstar, subject to available energy.  This}}
\DoxyCodeLine{601 \textcolor{comment}{! step sets the value of Kd(K).  Any remaining energy is then subject to decay}}
\DoxyCodeLine{602 \textcolor{comment}{! before being handed off to the next interface.  mech\_TKE and conv\_PErel are treated}}
\DoxyCodeLine{603 \textcolor{comment}{! separately for the purposes of decay, but are used proportionately to drive}}
\DoxyCodeLine{604 \textcolor{comment}{! mixing.}}
\DoxyCodeLine{605 }
\DoxyCodeLine{606   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{607 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV)+1)} :: \&}
\DoxyCodeLine{608     pres\_Z, \&       \textcolor{comment}{! Interface pressures with a rescaling factor to convert interface height}}
\DoxyCodeLine{609                     \textcolor{comment}{! movements into changes in column potential energy [R Z2 T-\/2 ~> kg m-\/1 s-\/2].}}
\DoxyCodeLine{610     hb\_hs           \textcolor{comment}{! The distance from the bottom over the thickness of the}}
\DoxyCodeLine{611                     \textcolor{comment}{! water column [nondim].}}
\DoxyCodeLine{612 \textcolor{keywordtype}{  real} :: mech\_TKE  \textcolor{comment}{!   The mechanically generated turbulent kinetic energy}}
\DoxyCodeLine{613                     \textcolor{comment}{! available for mixing over a time step [R Z3 T-\/2 ~> J m-\/2].}}
\DoxyCodeLine{614 \textcolor{keywordtype}{  real} :: conv\_PErel \textcolor{comment}{! The potential energy that has been convectively released}}
\DoxyCodeLine{615                     \textcolor{comment}{! during this timestep [R Z3 T-\/2 ~> J m-\/2]. A portion nstar\_FC}}
\DoxyCodeLine{616                     \textcolor{comment}{! of conv\_PErel is available to drive mixing.}}
\DoxyCodeLine{617 \textcolor{keywordtype}{  real} :: htot      \textcolor{comment}{!   The total depth of the layers above an interface [H ~> m or kg m-\/2].}}
\DoxyCodeLine{618 \textcolor{keywordtype}{  real} :: uhtot     \textcolor{comment}{!   The depth integrated zonal and meridional velocities in the}}
\DoxyCodeLine{619 \textcolor{keywordtype}{  real} :: vhtot     \textcolor{comment}{! layers above [H L T-\/1 ~> m2 s-\/1 or kg m-\/1 s-\/1].}}
\DoxyCodeLine{620 \textcolor{keywordtype}{  real} :: Idecay\_len\_TKE  \textcolor{comment}{! The inverse of a turbulence decay length scale [H-\/1 ~> m-\/1 or m2 kg-\/1].}}
\DoxyCodeLine{621 \textcolor{keywordtype}{  real} :: h\_sum     \textcolor{comment}{! The total thickness of the water column [H ~> m or kg m-\/2].}}
\DoxyCodeLine{622 }
\DoxyCodeLine{623 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: \&}
\DoxyCodeLine{624     dT\_to\_dColHt, \& \textcolor{comment}{! Partial derivative of the total column height with the temperature changes}}
\DoxyCodeLine{625                     \textcolor{comment}{! within a layer [Z degC-\/1 ~> m degC-\/1].}}
\DoxyCodeLine{626     ds\_to\_dcolht, \& \textcolor{comment}{! Partial derivative of the total column height with the salinity changes}}
\DoxyCodeLine{627                     \textcolor{comment}{! within a layer  [Z ppt-\/1 ~> m ppt-\/1].}}
\DoxyCodeLine{628     dt\_to\_dpe, \&    \textcolor{comment}{! Partial derivatives of column potential energy with the temperature}}
\DoxyCodeLine{629                     \textcolor{comment}{! changes within a layer, in [R Z3 T-\/2 degC-\/1 ~> J m-\/2 degC-\/1].}}
\DoxyCodeLine{630     ds\_to\_dpe, \&    \textcolor{comment}{! Partial derivatives of column potential energy with the salinity changes}}
\DoxyCodeLine{631                     \textcolor{comment}{! within a layer, in [R Z3 T-\/2 ppt-\/1 ~> J m-\/2 ppt-\/1].}}
\DoxyCodeLine{632     dt\_to\_dcolht\_a, \& \textcolor{comment}{! Partial derivative of the total column height with the temperature changes}}
\DoxyCodeLine{633                     \textcolor{comment}{! within a layer, including the implicit effects  of mixing with layers higher}}
\DoxyCodeLine{634                     \textcolor{comment}{! in the water column [Z degC-\/1 ~> m degC-\/1].}}
\DoxyCodeLine{635     ds\_to\_dcolht\_a, \& \textcolor{comment}{! Partial derivative of the total column height with the salinity changes}}
\DoxyCodeLine{636                     \textcolor{comment}{! within a layer, including the implicit effects  of mixing with layers higher}}
\DoxyCodeLine{637                     \textcolor{comment}{! in the water column [Z ppt-\/1 ~> m ppt-\/1].}}
\DoxyCodeLine{638     dt\_to\_dpe\_a, \&  \textcolor{comment}{! Partial derivatives of column potential energy with the temperature changes}}
\DoxyCodeLine{639                     \textcolor{comment}{! within a layer, including the implicit effects of mixing with layers higher}}
\DoxyCodeLine{640                     \textcolor{comment}{! in the water column [R Z3 T-\/2 degC-\/1 ~> J m-\/2 degC-\/1].}}
\DoxyCodeLine{641     ds\_to\_dpe\_a, \&  \textcolor{comment}{! Partial derivative of column potential energy with the salinity changes}}
\DoxyCodeLine{642                     \textcolor{comment}{! within a layer, including the implicit effects of mixing with layers higher}}
\DoxyCodeLine{643                     \textcolor{comment}{! in the water column [R Z3 T-\/2 ppt-\/1 ~> J m-\/2 ppt-\/1].}}
\DoxyCodeLine{644     c1, \&           \textcolor{comment}{! c1 is used by the tridiagonal solver [nondim].}}
\DoxyCodeLine{645     te, \&           \textcolor{comment}{! Estimated final values of T in the column [degC].}}
\DoxyCodeLine{646     se, \&           \textcolor{comment}{! Estimated final values of S in the column [ppt].}}
\DoxyCodeLine{647     dte, \&          \textcolor{comment}{! Running (1-\/way) estimates of temperature change [degC].}}
\DoxyCodeLine{648     dse, \&          \textcolor{comment}{! Running (1-\/way) estimates of salinity change [ppt].}}
\DoxyCodeLine{649     th\_a, \&         \textcolor{comment}{! An effective temperature times a thickness in the layer above, including implicit}}
\DoxyCodeLine{650                     \textcolor{comment}{! mixing effects with other yet higher layers [degC H ~> degC m or degC kg m-\/2].}}
\DoxyCodeLine{651     sh\_a, \&         \textcolor{comment}{! An effective salinity times a thickness in the layer above, including implicit}}
\DoxyCodeLine{652                     \textcolor{comment}{! mixing effects with other yet higher layers [ppt H ~> ppt m or ppt kg m-\/2].}}
\DoxyCodeLine{653     th\_b, \&         \textcolor{comment}{! An effective temperature times a thickness in the layer below, including implicit}}
\DoxyCodeLine{654                     \textcolor{comment}{! mixing effects with other yet lower layers [degC H ~> degC m or degC kg m-\/2].}}
\DoxyCodeLine{655     sh\_b            \textcolor{comment}{! An effective salinity times a thickness in the layer below, including implicit}}
\DoxyCodeLine{656                     \textcolor{comment}{! mixing effects with other yet lower layers [ppt H ~> ppt m or ppt kg m-\/2].}}
\DoxyCodeLine{657 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV)+1)} :: \&}
\DoxyCodeLine{658     MixLen\_shape, \& \textcolor{comment}{! A nondimensional shape factor for the mixing length that}}
\DoxyCodeLine{659                     \textcolor{comment}{! gives it an appropriate assymptotic value at the bottom of}}
\DoxyCodeLine{660                     \textcolor{comment}{! the boundary layer.}}
\DoxyCodeLine{661     kddt\_h          \textcolor{comment}{! The diapycnal diffusivity times a timestep divided by the}}
\DoxyCodeLine{662                     \textcolor{comment}{! average thicknesses around a layer [H ~> m or kg m-\/2].}}
\DoxyCodeLine{663 \textcolor{keywordtype}{  real} :: b1        \textcolor{comment}{! b1 is inverse of the pivot used by the tridiagonal solver [H-\/1 ~> m-\/1 or m2 kg-\/1].}}
\DoxyCodeLine{664 \textcolor{keywordtype}{  real} :: hp\_a      \textcolor{comment}{! An effective pivot thickness of the layer including the effects}}
\DoxyCodeLine{665                     \textcolor{comment}{! of coupling with layers above [H ~> m or kg m-\/2].  This is the first term}}
\DoxyCodeLine{666                     \textcolor{comment}{! in the denominator of b1 in a downward-\/oriented tridiagonal solver.}}
\DoxyCodeLine{667 \textcolor{keywordtype}{  real} :: h\_neglect \textcolor{comment}{! A thickness that is so small it is usually lost}}
\DoxyCodeLine{668                     \textcolor{comment}{! in roundoff and can be neglected [H ~> m or kg m-\/2].}}
\DoxyCodeLine{669 \textcolor{keywordtype}{  real} :: dMass     \textcolor{comment}{! The mass per unit area within a layer [Z R ~> kg m-\/2].}}
\DoxyCodeLine{670 \textcolor{keywordtype}{  real} :: dPres     \textcolor{comment}{! The hydrostatic pressure change across a layer [R Z2 T-\/2 ~> Pa = J m-\/3].}}
\DoxyCodeLine{671 \textcolor{keywordtype}{  real} :: dMKE\_max  \textcolor{comment}{! The maximum amount of mean kinetic energy that could be}}
\DoxyCodeLine{672                     \textcolor{comment}{! converted to turbulent kinetic energy if the velocity in}}
\DoxyCodeLine{673                     \textcolor{comment}{! the layer below an interface were homogenized with all of}}
\DoxyCodeLine{674                     \textcolor{comment}{! the water above the interface [R Z3 T-\/2 ~> J m-\/2].}}
\DoxyCodeLine{675 \textcolor{keywordtype}{  real} :: MKE2\_Hharm \textcolor{comment}{! Twice the inverse of the harmonic mean of the thickness}}
\DoxyCodeLine{676                     \textcolor{comment}{! of a layer and the thickness of the water above, used in}}
\DoxyCodeLine{677                     \textcolor{comment}{! the MKE conversion equation [H-\/1 ~> m-\/1 or m2 kg-\/1].}}
\DoxyCodeLine{678 }
\DoxyCodeLine{679 \textcolor{keywordtype}{  real} :: dt\_h      \textcolor{comment}{! The timestep divided by the averages of the thicknesses around}}
\DoxyCodeLine{680                     \textcolor{comment}{! a layer, times a thickness conversion factor [H T m-\/2 ~> s m-\/1 or kg s m-\/4].}}
\DoxyCodeLine{681 \textcolor{keywordtype}{  real} :: h\_bot     \textcolor{comment}{! The distance from the bottom [H ~> m or kg m-\/2].}}
\DoxyCodeLine{682 \textcolor{keywordtype}{  real} :: h\_rsum    \textcolor{comment}{! The running sum of h from the top [Z ~> m].}}
\DoxyCodeLine{683 \textcolor{keywordtype}{  real} :: I\_hs      \textcolor{comment}{! The inverse of h\_sum [H-\/1 ~> m-\/1 or m2 kg-\/1].}}
\DoxyCodeLine{684 \textcolor{keywordtype}{  real} :: I\_MLD     \textcolor{comment}{! The inverse of the current value of MLD [Z-\/1 ~> m-\/1].}}
\DoxyCodeLine{685 \textcolor{keywordtype}{  real} :: h\_tt      \textcolor{comment}{! The distance from the surface or up to the next interface}}
\DoxyCodeLine{686                     \textcolor{comment}{! that did not exhibit turbulent mixing from this scheme plus}}
\DoxyCodeLine{687                     \textcolor{comment}{! a surface mixing roughness length given by h\_tt\_min [H ~> m or kg m-\/2].}}
\DoxyCodeLine{688 \textcolor{keywordtype}{  real} :: h\_tt\_min  \textcolor{comment}{! A surface roughness length [H ~> m or kg m-\/2].}}
\DoxyCodeLine{689 }
\DoxyCodeLine{690 \textcolor{keywordtype}{  real} :: C1\_3      \textcolor{comment}{! = 1/3.}}
\DoxyCodeLine{691 \textcolor{keywordtype}{  real} :: I\_dtrho   \textcolor{comment}{! 1.0 / (dt * Rho0) times conversion factors in [m3 Z-\/3 R-\/1 T2 s-\/3 ~> m3 kg-\/1 s-\/1].}}
\DoxyCodeLine{692                     \textcolor{comment}{! This is used convert TKE back into ustar\string^3.}}
\DoxyCodeLine{693 \textcolor{keywordtype}{  real} :: vstar     \textcolor{comment}{! An in-\/situ turbulent velocity [Z T-\/1 ~> m s-\/1].}}
\DoxyCodeLine{694 \textcolor{keywordtype}{  real} :: mstar\_total \textcolor{comment}{! The value of mstar used in ePBL [nondim]}}
\DoxyCodeLine{695 \textcolor{keywordtype}{  real} :: mstar\_LT  \textcolor{comment}{! An addition to mstar due to Langmuir turbulence [nondim] (output for diagnostic)}}
\DoxyCodeLine{696 \textcolor{keywordtype}{  real} :: MLD\_output \textcolor{comment}{! The mixed layer depth output from this routine [Z ~> m].}}
\DoxyCodeLine{697 \textcolor{keywordtype}{  real} :: LA        \textcolor{comment}{! The value of the Langmuir number [nondim]}}
\DoxyCodeLine{698 \textcolor{keywordtype}{  real} :: LAmod     \textcolor{comment}{! The modified Langmuir number by convection [nondim]}}
\DoxyCodeLine{699 \textcolor{keywordtype}{  real} :: hbs\_here  \textcolor{comment}{! The local minimum of hb\_hs and MixLen\_shape, times a}}
\DoxyCodeLine{700                     \textcolor{comment}{! conversion factor from H to Z [Z H-\/1 ~> 1 or m3 kg-\/1].}}
\DoxyCodeLine{701 \textcolor{keywordtype}{  real} :: nstar\_FC  \textcolor{comment}{! The fraction of conv\_PErel that can be converted to mixing [nondim].}}
\DoxyCodeLine{702 \textcolor{keywordtype}{  real} :: TKE\_reduc \textcolor{comment}{! The fraction by which TKE and other energy fields are}}
\DoxyCodeLine{703                     \textcolor{comment}{! reduced to support mixing [nondim]. between 0 and 1.}}
\DoxyCodeLine{704 \textcolor{keywordtype}{  real} :: tot\_TKE   \textcolor{comment}{! The total TKE available to support mixing at interface K [R Z3 T-\/2 ~> J m-\/2].}}
\DoxyCodeLine{705 \textcolor{keywordtype}{  real} :: TKE\_here  \textcolor{comment}{! The total TKE at this point in the algorithm [R Z3 T-\/2 ~> J m-\/2].}}
\DoxyCodeLine{706 \textcolor{keywordtype}{  real} :: dT\_km1\_t2 \textcolor{comment}{! A diffusivity-\/independent term related to the temperature}}
\DoxyCodeLine{707                     \textcolor{comment}{! change in the layer above the interface [degC].}}
\DoxyCodeLine{708 \textcolor{keywordtype}{  real} :: dS\_km1\_t2 \textcolor{comment}{! A diffusivity-\/independent term related to the salinity}}
\DoxyCodeLine{709                     \textcolor{comment}{! change in the layer above the interface [ppt].}}
\DoxyCodeLine{710 \textcolor{keywordtype}{  real} :: dTe\_term  \textcolor{comment}{! A diffusivity-\/independent term related to the temperature}}
\DoxyCodeLine{711                     \textcolor{comment}{! change in the layer below the interface [degC H ~> degC m or degC kg m-\/2].}}
\DoxyCodeLine{712 \textcolor{keywordtype}{  real} :: dSe\_term  \textcolor{comment}{! A diffusivity-\/independent term related to the salinity}}
\DoxyCodeLine{713                     \textcolor{comment}{! change in the layer above the interface [ppt H ~> ppt m or ppt kg m-\/2].}}
\DoxyCodeLine{714 \textcolor{keywordtype}{  real} :: dTe\_t2    \textcolor{comment}{! A part of dTe\_term [degC H ~> degC m or degC kg m-\/2].}}
\DoxyCodeLine{715 \textcolor{keywordtype}{  real} :: dSe\_t2    \textcolor{comment}{! A part of dSe\_term [ppt H ~> ppt m or ppt kg m-\/2].}}
\DoxyCodeLine{716 \textcolor{keywordtype}{  real} :: dPE\_conv  \textcolor{comment}{! The convective change in column potential energy [R Z3 T-\/2 ~> J m-\/2].}}
\DoxyCodeLine{717 \textcolor{keywordtype}{  real} :: MKE\_src   \textcolor{comment}{! The mean kinetic energy source of TKE due to Kddt\_h(K) [R Z3 T-\/2 ~> J m-\/2].}}
\DoxyCodeLine{718 \textcolor{keywordtype}{  real} :: dMKE\_src\_dK  \textcolor{comment}{! The partial derivative of MKE\_src with Kddt\_h(K) [R Z3 T-\/2 H-\/1 ~> J m-\/3 or J kg-\/1].}}
\DoxyCodeLine{719 \textcolor{keywordtype}{  real} :: Kd\_guess0    \textcolor{comment}{! A first guess of the diapycnal diffusivity [Z2 T-\/1 ~> m2 s-\/1].}}
\DoxyCodeLine{720 \textcolor{keywordtype}{  real} :: PE\_chg\_g0    \textcolor{comment}{! The potential energy change when Kd is Kd\_guess0 [R Z3 T-\/2 ~> J m-\/2]}}
\DoxyCodeLine{721 \textcolor{keywordtype}{  real} :: Kddt\_h\_g0    \textcolor{comment}{! The first guess diapycnal diffusivity times a timestep divided}}
\DoxyCodeLine{722                        \textcolor{comment}{! by the average thicknesses around a layer [H ~> m or kg m-\/2].}}
\DoxyCodeLine{723 \textcolor{keywordtype}{  real} :: PE\_chg\_max   \textcolor{comment}{! The maximum PE change for very large values of Kddt\_h(K) [R Z3 T-\/2 ~> J m-\/2].}}
\DoxyCodeLine{724 \textcolor{keywordtype}{  real} :: dPEc\_dKd\_Kd0 \textcolor{comment}{! The partial derivative of PE change with Kddt\_h(K)}}
\DoxyCodeLine{725                        \textcolor{comment}{! for very small values of Kddt\_h(K) [R Z3 T-\/2 H-\/1 ~> J m-\/3 or J kg-\/1].}}
\DoxyCodeLine{726 \textcolor{keywordtype}{  real} :: PE\_chg    \textcolor{comment}{! The change in potential energy due to mixing at an}}
\DoxyCodeLine{727                     \textcolor{comment}{! interface [R Z3 T-\/2 ~> J m-\/2], positive for the column increasing}}
\DoxyCodeLine{728                     \textcolor{comment}{! in potential energy (i.e., consuming TKE).}}
\DoxyCodeLine{729 \textcolor{keywordtype}{  real} :: TKE\_left  \textcolor{comment}{! The amount of turbulent kinetic energy left for the most}}
\DoxyCodeLine{730                     \textcolor{comment}{! recent guess at Kddt\_h(K) [R Z3 T-\/2 ~> J m-\/2].}}
\DoxyCodeLine{731 \textcolor{keywordtype}{  real} :: dPEc\_dKd  \textcolor{comment}{! The partial derivative of PE\_chg with Kddt\_h(K) [R Z3 T-\/2 H-\/1 ~> J m-\/3 or J kg-\/1].}}
\DoxyCodeLine{732 \textcolor{keywordtype}{  real} :: TKE\_left\_min, TKE\_left\_max \textcolor{comment}{! Maximum and minimum values of TKE\_left [R Z3 T-\/2 ~> J m-\/2].}}
\DoxyCodeLine{733 \textcolor{keywordtype}{  real} :: Kddt\_h\_max, Kddt\_h\_min \textcolor{comment}{! Maximum and minimum values of Kddt\_h(K) [H ~> m or kg m-\/2].}}
\DoxyCodeLine{734 \textcolor{keywordtype}{  real} :: Kddt\_h\_guess \textcolor{comment}{! A guess at the value of Kddt\_h(K) [H ~> m or kg m-\/2].}}
\DoxyCodeLine{735 \textcolor{keywordtype}{  real} :: Kddt\_h\_next  \textcolor{comment}{! The next guess at the value of Kddt\_h(K) [H ~> m or kg m-\/2].}}
\DoxyCodeLine{736 \textcolor{keywordtype}{  real} :: dKddt\_h      \textcolor{comment}{! The change between guesses at Kddt\_h(K) [H ~> m or kg m-\/2].}}
\DoxyCodeLine{737 \textcolor{keywordtype}{  real} :: dKddt\_h\_Newt \textcolor{comment}{! The change between guesses at Kddt\_h(K) with Newton's method [H ~> m or kg m-\/2].}}
\DoxyCodeLine{738 \textcolor{keywordtype}{  real} :: Kddt\_h\_newt  \textcolor{comment}{! The Newton's method next guess for Kddt\_h(K) [H ~> m or kg m-\/2].}}
\DoxyCodeLine{739 \textcolor{keywordtype}{  real} :: exp\_kh    \textcolor{comment}{! The nondimensional decay of TKE across a layer [nondim].}}
\DoxyCodeLine{740 \textcolor{keywordtype}{  real} :: vstar\_unit\_scale \textcolor{comment}{! A unit converion factor for turbulent velocities [Z T-\/1 s m-\/1 ~> 1]}}
\DoxyCodeLine{741   \textcolor{keywordtype}{logical} :: use\_Newt  \textcolor{comment}{! Use Newton's method for the next guess at Kddt\_h(K).}}
\DoxyCodeLine{742   \textcolor{keywordtype}{logical} :: convectively\_stable \textcolor{comment}{! If true the water column is convectively stable at this interface.}}
\DoxyCodeLine{743   \textcolor{keywordtype}{logical} :: sfc\_connected   \textcolor{comment}{! If true the ocean is actively turbulent from the present}}
\DoxyCodeLine{744                     \textcolor{comment}{! interface all the way up to the surface.}}
\DoxyCodeLine{745   \textcolor{keywordtype}{logical} :: sfc\_disconnect \textcolor{comment}{! If true, any turbulence has become disconnected}}
\DoxyCodeLine{746                     \textcolor{comment}{! from the surface.}}
\DoxyCodeLine{747 }
\DoxyCodeLine{748 \textcolor{comment}{! The following are only used for diagnostics.}}
\DoxyCodeLine{749 \textcolor{keywordtype}{  real} :: dt\_\_diag  \textcolor{comment}{! A copy of dt\_diag (if present) or dt [T ~> s].}}
\DoxyCodeLine{750 \textcolor{keywordtype}{  real} :: I\_dtdiag  \textcolor{comment}{!  = 1.0 / dt\_\_diag [T-\/1 ~> s-\/1].}}
\DoxyCodeLine{751 }
\DoxyCodeLine{752   \textcolor{comment}{!-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}}
\DoxyCodeLine{753   \textcolor{comment}{!/BGR added Aug24,2016 for adding iteration to get boundary layer depth}}
\DoxyCodeLine{754   \textcolor{comment}{!    -\/ needed to compute new mixing length.}}
\DoxyCodeLine{755 \textcolor{keywordtype}{  real} :: MLD\_guess, MLD\_found \textcolor{comment}{! Mixing Layer depth guessed/found for iteration [Z ~> m].}}
\DoxyCodeLine{756 \textcolor{keywordtype}{  real} :: min\_MLD   \textcolor{comment}{! Iteration bounds [Z ~> m], which are adjusted at each step}}
\DoxyCodeLine{757 \textcolor{keywordtype}{  real} :: max\_MLD   \textcolor{comment}{!  -\/ These are initialized based on surface/bottom}}
\DoxyCodeLine{758                     \textcolor{comment}{!  1. The iteration guesses a value (possibly from prev step or neighbor).}}
\DoxyCodeLine{759                     \textcolor{comment}{!  2. The iteration checks if value is converged, too shallow, or too deep.}}
\DoxyCodeLine{760                     \textcolor{comment}{!  3. Based on result adjusts the Max/Min and searches through the water column.}}
\DoxyCodeLine{761                     \textcolor{comment}{!  -\/ If using an accurate guess the iteration is very quick (e.g. if MLD doesn't}}
\DoxyCodeLine{762                     \textcolor{comment}{!    change over timestep).  Otherwise it takes 5-\/10 passes, but has a high}}
\DoxyCodeLine{763                     \textcolor{comment}{!    convergence rate.  Other iteration may be tried, but this method seems to}}
\DoxyCodeLine{764                     \textcolor{comment}{!    fail very rarely and the added cost is likely not significant.}}
\DoxyCodeLine{765                     \textcolor{comment}{!    Additionally, when it fails to converge it does so in a reasonable}}
\DoxyCodeLine{766                     \textcolor{comment}{!    manner giving a usable guess. When it does fail, it is due to convection}}
\DoxyCodeLine{767                     \textcolor{comment}{!    within the boundary layer.  Likely, a new method e.g. surface\_disconnect,}}
\DoxyCodeLine{768                     \textcolor{comment}{!    can improve this.}}
\DoxyCodeLine{769 \textcolor{keywordtype}{  real} :: dMLD\_min  \textcolor{comment}{! The change in diagnosed mixed layer depth when the guess is min\_MLD [Z ~> m]}}
\DoxyCodeLine{770 \textcolor{keywordtype}{  real} :: dMLD\_max  \textcolor{comment}{! The change in diagnosed mixed layer depth when the guess is max\_MLD [Z ~> m]}}
\DoxyCodeLine{771   \textcolor{keywordtype}{logical} :: FIRST\_OBL     \textcolor{comment}{! Flag for computing "found" Mixing layer depth}}
\DoxyCodeLine{772   \textcolor{keywordtype}{logical} :: OBL\_converged \textcolor{comment}{! Flag for convergence of MLD}}
\DoxyCodeLine{773   \textcolor{keywordtype}{integer} :: OBL\_it        \textcolor{comment}{! Iteration counter}}
\DoxyCodeLine{774 }
\DoxyCodeLine{775 \textcolor{keywordtype}{  real} :: Surface\_Scale \textcolor{comment}{! Surface decay scale for vstar}}
\DoxyCodeLine{776   \textcolor{keywordtype}{logical} :: calc\_dT\_expect \textcolor{comment}{! If true calculate the expected changes in temperature and salinity.}}
\DoxyCodeLine{777   \textcolor{keywordtype}{logical} :: calc\_Te        \textcolor{comment}{! If true calculate the expected final temperature and salinity values.}}
\DoxyCodeLine{778   \textcolor{keywordtype}{logical} :: debug=.false.  \textcolor{comment}{! Change this hard-\/coded value for debugging.}}
\DoxyCodeLine{779 }
\DoxyCodeLine{780   \textcolor{comment}{!  The following arrays are used only for debugging purposes.}}
\DoxyCodeLine{781 \textcolor{keywordtype}{  real} :: dPE\_debug, mixing\_debug, taux2, tauy2}
\DoxyCodeLine{782 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(20)} :: TKE\_left\_itt, PE\_chg\_itt, Kddt\_h\_itt, dPEa\_dKd\_itt, MKE\_src\_itt}
\DoxyCodeLine{783 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: mech\_TKE\_k, conv\_PErel\_k, nstar\_k}
\DoxyCodeLine{784   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: num\_itts}
\DoxyCodeLine{785 }
\DoxyCodeLine{786   \textcolor{keywordtype}{integer} :: k, nz, itt, max\_itt}
\DoxyCodeLine{787 }
\DoxyCodeLine{788   nz = gv\%ke}
\DoxyCodeLine{789 }
\DoxyCodeLine{790   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(cs)) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"energetic\_PBL: "}//\&}
\DoxyCodeLine{791          \textcolor{stringliteral}{"Module must be initialized before it is used."})}
\DoxyCodeLine{792 }
\DoxyCodeLine{793   calc\_dt\_expect = debug ; \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(ecd\%dT\_expect) .or. \textcolor{keyword}{allocated}(ecd\%dS\_expect)) calc\_dt\_expect = .true.}
\DoxyCodeLine{794   calc\_te = (calc\_dt\_expect .or. (.not.cs\%orig\_PE\_calc))}
\DoxyCodeLine{795 }
\DoxyCodeLine{796   h\_neglect = gv\%H\_subroundoff}
\DoxyCodeLine{797 }
\DoxyCodeLine{798   c1\_3 = 1.0 / 3.0}
\DoxyCodeLine{799   dt\_\_diag = dt ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt\_diag)) dt\_\_diag = dt\_diag}
\DoxyCodeLine{800   i\_dtdiag = 1.0 / dt\_\_diag}
\DoxyCodeLine{801   max\_itt = 20}
\DoxyCodeLine{802 }
\DoxyCodeLine{803   h\_tt\_min = 0.0}
\DoxyCodeLine{804   i\_dtrho = 0.0 ; \textcolor{keywordflow}{if} (dt*gv\%Rho0 > 0.0) i\_dtrho = (us\%Z\_to\_m**3*us\%s\_to\_T**3) / (dt*gv\%Rho0)}
\DoxyCodeLine{805   vstar\_unit\_scale = us\%m\_to\_Z * us\%T\_to\_s}
\DoxyCodeLine{806 }
\DoxyCodeLine{807   mld\_guess = mld\_io}
\DoxyCodeLine{808 }
\DoxyCodeLine{809 \textcolor{comment}{!   Determine the initial mech\_TKE and conv\_PErel, including the energy required}}
\DoxyCodeLine{810 \textcolor{comment}{! to mix surface heating through the topmost cell, the energy released by mixing}}
\DoxyCodeLine{811 \textcolor{comment}{! surface cooling \& brine rejection down through the topmost cell, and}}
\DoxyCodeLine{812 \textcolor{comment}{! homogenizing the shortwave heating within that cell.  This sets the energy}}
\DoxyCodeLine{813 \textcolor{comment}{! and ustar and wstar available to drive mixing at the first interior}}
\DoxyCodeLine{814 \textcolor{comment}{! interface.}}
\DoxyCodeLine{815 }
\DoxyCodeLine{816   \textcolor{keywordflow}{do} k=1,nz+1 ; kd(k) = 0.0 ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{817 }
\DoxyCodeLine{818   pres\_z(1) = 0.0}
\DoxyCodeLine{819   \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{820     dmass = gv\%H\_to\_RZ * h(k)}
\DoxyCodeLine{821     dpres = us\%L\_to\_Z**2 * gv\%g\_Earth * dmass}
\DoxyCodeLine{822     dt\_to\_dpe(k) = (dmass * (pres\_z(k) + 0.5*dpres)) * dsv\_dt(k)}
\DoxyCodeLine{823     ds\_to\_dpe(k) = (dmass * (pres\_z(k) + 0.5*dpres)) * dsv\_ds(k)}
\DoxyCodeLine{824     dt\_to\_dcolht(k) = dmass * dsv\_dt(k)}
\DoxyCodeLine{825     ds\_to\_dcolht(k) = dmass * dsv\_ds(k)}
\DoxyCodeLine{826 }
\DoxyCodeLine{827     pres\_z(k+1) = pres\_z(k) + dpres}
\DoxyCodeLine{828 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{829 }
\DoxyCodeLine{830   \textcolor{comment}{! Determine the total thickness (h\_sum) and the fractional distance from the bottom (hb\_hs).}}
\DoxyCodeLine{831   h\_sum = h\_neglect ; \textcolor{keywordflow}{do} k=1,nz ; h\_sum = h\_sum + h(k) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{832   i\_hs = 0.0 ; \textcolor{keywordflow}{if} (h\_sum > 0.0) i\_hs = 1.0 / h\_sum}
\DoxyCodeLine{833   h\_bot = 0.0}
\DoxyCodeLine{834   hb\_hs(nz+1) = 0.0}
\DoxyCodeLine{835   \textcolor{keywordflow}{do} k=nz,1,-\/1}
\DoxyCodeLine{836     h\_bot = h\_bot + h(k)}
\DoxyCodeLine{837     hb\_hs(k) = h\_bot * i\_hs}
\DoxyCodeLine{838 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{839 }
\DoxyCodeLine{840   mld\_output = h(1)*gv\%H\_to\_Z}
\DoxyCodeLine{841 }
\DoxyCodeLine{842   \textcolor{comment}{!/The following lines are for the iteration over MLD}}
\DoxyCodeLine{843   \textcolor{comment}{! max\_MLD will initialized as ocean bottom depth}}
\DoxyCodeLine{844   max\_mld = 0.0 ; \textcolor{keywordflow}{do} k=1,nz ; max\_mld = max\_mld + h(k)*gv\%H\_to\_Z ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{845   \textcolor{comment}{! min\_MLD will be initialized to 0.}}
\DoxyCodeLine{846   min\_mld = 0.0}
\DoxyCodeLine{847   \textcolor{comment}{! Set values of the wrong signs to indicate that these changes are not based on valid estimates}}
\DoxyCodeLine{848   dmld\_min = -\/1.0*us\%m\_to\_Z ; dmld\_max = 1.0*us\%m\_to\_Z}
\DoxyCodeLine{849 }
\DoxyCodeLine{850   \textcolor{comment}{! If no first guess is provided for MLD, try the middle of the water column}}
\DoxyCodeLine{851   \textcolor{keywordflow}{if} (mld\_guess <= min\_mld) mld\_guess = 0.5 * (min\_mld + max\_mld)}
\DoxyCodeLine{852 }
\DoxyCodeLine{853   \textcolor{comment}{! Iterate to determine a converged EPBL depth.}}
\DoxyCodeLine{854   obl\_converged = .false.}
\DoxyCodeLine{855   \textcolor{keywordflow}{do} obl\_it=1,cs\%Max\_MLD\_Its}
\DoxyCodeLine{856 }
\DoxyCodeLine{857     \textcolor{keywordflow}{if} (.not. obl\_converged) \textcolor{keywordflow}{then}}
\DoxyCodeLine{858       \textcolor{comment}{! If not using MLD\_Iteration flag loop to only execute once.}}
\DoxyCodeLine{859       \textcolor{keywordflow}{if} (.not.cs\%Use\_MLD\_iteration) obl\_converged = .true.}
\DoxyCodeLine{860 }
\DoxyCodeLine{861       \textcolor{keywordflow}{if} (debug) \textcolor{keywordflow}{then} ; mech\_tke\_k(:) = 0.0 ; conv\_perel\_k(:) = 0.0 ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{862 }
\DoxyCodeLine{863       \textcolor{comment}{! Reset ML\_depth}}
\DoxyCodeLine{864       mld\_output = h(1)*gv\%H\_to\_Z}
\DoxyCodeLine{865       sfc\_connected = .true.}
\DoxyCodeLine{866 }
\DoxyCodeLine{867       \textcolor{comment}{!/ Here we get MStar, which is the ratio of convective TKE driven mixing to UStar**3}}
\DoxyCodeLine{868       \textcolor{keywordflow}{if} (cs\%Use\_LT) \textcolor{keywordflow}{then}}
\DoxyCodeLine{869         \textcolor{keyword}{call }get\_langmuir\_number(la, g, gv, us, abs(mld\_guess), u\_star\_mean, i, j, \&}
\DoxyCodeLine{870                                  h=h, u\_h=u, v\_h=v, waves=waves)}
\DoxyCodeLine{871         \textcolor{keyword}{call }find\_mstar(cs, us, b\_flux, u\_star, u\_star\_mean, mld\_guess, absf, \&}
\DoxyCodeLine{872                         mstar\_total, langmuir\_number=la, convect\_langmuir\_number=lamod,\&}
\DoxyCodeLine{873                         mstar\_lt=mstar\_lt)}
\DoxyCodeLine{874       \textcolor{keywordflow}{else}}
\DoxyCodeLine{875         \textcolor{keyword}{call }find\_mstar(cs, us, b\_flux, u\_star, u\_star\_mean, mld\_guess, absf, mstar\_total)}
\DoxyCodeLine{876 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{877 }
\DoxyCodeLine{878       \textcolor{comment}{!/ Apply MStar to get mech\_TKE}}
\DoxyCodeLine{879       \textcolor{keywordflow}{if} ((cs\%answers\_2018) .and. (cs\%mstar\_scheme==use\_fixed\_mstar)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{880         mech\_tke = (dt*mstar\_total*gv\%Rho0) * u\_star**3}
\DoxyCodeLine{881       \textcolor{keywordflow}{else}}
\DoxyCodeLine{882         mech\_tke = mstar\_total * (dt*gv\%Rho0* u\_star**3)}
\DoxyCodeLine{883 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{884 }
\DoxyCodeLine{885       \textcolor{keywordflow}{if} (cs\%TKE\_diagnostics) \textcolor{keywordflow}{then}}
\DoxyCodeLine{886         ecd\%dTKE\_conv = 0.0 ; ecd\%dTKE\_mixing = 0.0}
\DoxyCodeLine{887         ecd\%dTKE\_MKE = 0.0 ; ecd\%dTKE\_mech\_decay = 0.0 ; ecd\%dTKE\_conv\_decay = 0.0}
\DoxyCodeLine{888 }
\DoxyCodeLine{889         ecd\%dTKE\_wind = mech\_tke * i\_dtdiag}
\DoxyCodeLine{890         \textcolor{keywordflow}{if} (tke\_forcing(1) <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{891           ecd\%dTKE\_forcing = max(-\/mech\_tke, tke\_forcing(1)) * i\_dtdiag}
\DoxyCodeLine{892           \textcolor{comment}{! eCD\%dTKE\_unbalanced = min(0.0, TKE\_forcing(1) + mech\_TKE) * I\_dtdiag}}
\DoxyCodeLine{893         \textcolor{keywordflow}{else}}
\DoxyCodeLine{894           ecd\%dTKE\_forcing = cs\%nstar*tke\_forcing(1) * i\_dtdiag}
\DoxyCodeLine{895           \textcolor{comment}{! eCD\%dTKE\_unbalanced = 0.0}}
\DoxyCodeLine{896 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{897 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{898 }
\DoxyCodeLine{899       \textcolor{keywordflow}{if} (tke\_forcing(1) <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{900         mech\_tke = mech\_tke + tke\_forcing(1)}
\DoxyCodeLine{901         \textcolor{keywordflow}{if} (mech\_tke < 0.0) mech\_tke = 0.0}
\DoxyCodeLine{902         conv\_perel = 0.0}
\DoxyCodeLine{903       \textcolor{keywordflow}{else}}
\DoxyCodeLine{904         conv\_perel = tke\_forcing(1)}
\DoxyCodeLine{905 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{906 }
\DoxyCodeLine{907 }
\DoxyCodeLine{908       \textcolor{comment}{! Store in 1D arrays for output.}}
\DoxyCodeLine{909       \textcolor{keywordflow}{do} k=1,nz+1 ; mixvel(k) = 0.0 ; mixlen(k) = 0.0 ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{910 }
\DoxyCodeLine{911       \textcolor{comment}{! Determine the mixing shape function MixLen\_shape.}}
\DoxyCodeLine{912       \textcolor{keywordflow}{if} ((.not.cs\%Use\_MLD\_iteration) .or. \&}
\DoxyCodeLine{913           (cs\%transLay\_scale >= 1.0) .or. (cs\%transLay\_scale < 0.0) ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{914         \textcolor{keywordflow}{do} k=1,nz+1}
\DoxyCodeLine{915           mixlen\_shape(k) = 1.0}
\DoxyCodeLine{916 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{917       \textcolor{keywordflow}{elseif} (mld\_guess <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{918         \textcolor{keywordflow}{if} (cs\%transLay\_scale > 0.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} k=1,nz+1}
\DoxyCodeLine{919           mixlen\_shape(k) = cs\%transLay\_scale}
\DoxyCodeLine{920 \textcolor{keywordflow}{        enddo} ; \textcolor{keywordflow}{else} ; \textcolor{keywordflow}{do} k=1,nz+1}
\DoxyCodeLine{921           mixlen\_shape(k) = 1.0}
\DoxyCodeLine{922 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{923       \textcolor{keywordflow}{else}}
\DoxyCodeLine{924         \textcolor{comment}{! Reduce the mixing length based on MLD, with a quadratic}}
\DoxyCodeLine{925         \textcolor{comment}{! expression that follows KPP.}}
\DoxyCodeLine{926         i\_mld = 1.0 / mld\_guess}
\DoxyCodeLine{927         h\_rsum = 0.0}
\DoxyCodeLine{928         mixlen\_shape(1) = 1.0}
\DoxyCodeLine{929         \textcolor{keywordflow}{do} k=2,nz+1}
\DoxyCodeLine{930           h\_rsum = h\_rsum + h(k-\/1)*gv\%H\_to\_Z}
\DoxyCodeLine{931           \textcolor{keywordflow}{if} (cs\%MixLenExponent==2.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{932             mixlen\_shape(k) = cs\%transLay\_scale + (1.0 -\/ cs\%transLay\_scale) * \&}
\DoxyCodeLine{933                  (max(0.0, (mld\_guess -\/ h\_rsum)*i\_mld) )**2 \textcolor{comment}{! CS\%MixLenExponent}}
\DoxyCodeLine{934           \textcolor{keywordflow}{else}}
\DoxyCodeLine{935             mixlen\_shape(k) = cs\%transLay\_scale + (1.0 -\/ cs\%transLay\_scale) * \&}
\DoxyCodeLine{936                  (max(0.0, (mld\_guess -\/ h\_rsum)*i\_mld) )**cs\%MixLenExponent}
\DoxyCodeLine{937 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{938 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{939 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{940 }
\DoxyCodeLine{941       kd(1) = 0.0 ; kddt\_h(1) = 0.0}
\DoxyCodeLine{942       hp\_a = h(1)}
\DoxyCodeLine{943       dt\_to\_dpe\_a(1) = dt\_to\_dpe(1) ; dt\_to\_dcolht\_a(1) = dt\_to\_dcolht(1)}
\DoxyCodeLine{944       ds\_to\_dpe\_a(1) = ds\_to\_dpe(1) ; ds\_to\_dcolht\_a(1) = ds\_to\_dcolht(1)}
\DoxyCodeLine{945 }
\DoxyCodeLine{946       htot = h(1) ; uhtot = u(1)*h(1) ; vhtot = v(1)*h(1)}
\DoxyCodeLine{947 }
\DoxyCodeLine{948       \textcolor{keywordflow}{if} (debug) \textcolor{keywordflow}{then}}
\DoxyCodeLine{949         mech\_tke\_k(1) = mech\_tke ; conv\_perel\_k(1) = conv\_perel}
\DoxyCodeLine{950         nstar\_k(:) = 0.0 ; nstar\_k(1) = cs\%nstar ; num\_itts(:) = -\/1}
\DoxyCodeLine{951 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{952 }
\DoxyCodeLine{953       \textcolor{keywordflow}{do} k=2,nz}
\DoxyCodeLine{954         \textcolor{comment}{! Apply dissipation to the TKE, here applied as an exponential decay}}
\DoxyCodeLine{955         \textcolor{comment}{! due to 3-\/d turbulent energy being lost to inefficient rotational modes.}}
\DoxyCodeLine{956 }
\DoxyCodeLine{957         \textcolor{comment}{!   There should be several different "flavors" of TKE that decay at}}
\DoxyCodeLine{958         \textcolor{comment}{! different rates.  The following form is often used for mechanical}}
\DoxyCodeLine{959         \textcolor{comment}{! stirring from the surface, perhaps due to breaking surface gravity}}
\DoxyCodeLine{960         \textcolor{comment}{! waves and wind-\/driven turbulence.}}
\DoxyCodeLine{961         idecay\_len\_tke = (cs\%TKE\_decay * absf / u\_star) * gv\%H\_to\_Z}
\DoxyCodeLine{962         exp\_kh = 1.0}
\DoxyCodeLine{963         \textcolor{keywordflow}{if} (idecay\_len\_tke > 0.0) exp\_kh = exp(-\/h(k-\/1)*idecay\_len\_tke)}
\DoxyCodeLine{964         \textcolor{keywordflow}{if} (cs\%TKE\_diagnostics) \&}
\DoxyCodeLine{965           ecd\%dTKE\_mech\_decay = ecd\%dTKE\_mech\_decay + (exp\_kh-\/1.0) * mech\_tke * i\_dtdiag}
\DoxyCodeLine{966         mech\_tke = mech\_tke * exp\_kh}
\DoxyCodeLine{967 }
\DoxyCodeLine{968         \textcolor{comment}{!   Accumulate any convectively released potential energy to contribute}}
\DoxyCodeLine{969         \textcolor{comment}{! to wstar and to drive penetrating convection.}}
\DoxyCodeLine{970         \textcolor{keywordflow}{if} (tke\_forcing(k) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{971           conv\_perel = conv\_perel + tke\_forcing(k)}
\DoxyCodeLine{972           \textcolor{keywordflow}{if} (cs\%TKE\_diagnostics) \&}
\DoxyCodeLine{973             ecd\%dTKE\_forcing = ecd\%dTKE\_forcing + cs\%nstar*tke\_forcing(k) * i\_dtdiag}
\DoxyCodeLine{974 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{975 }
\DoxyCodeLine{976         \textcolor{keywordflow}{if} (debug) \textcolor{keywordflow}{then}}
\DoxyCodeLine{977           mech\_tke\_k(k) = mech\_tke ; conv\_perel\_k(k) = conv\_perel}
\DoxyCodeLine{978 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{979 }
\DoxyCodeLine{980         \textcolor{comment}{!  Determine the total energy}}
\DoxyCodeLine{981         nstar\_fc = cs\%nstar}
\DoxyCodeLine{982         \textcolor{keywordflow}{if} (cs\%nstar * conv\_perel > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{983           \textcolor{comment}{! Here nstar is a function of the natural Rossby number 0.2/(1+0.2/Ro), based}}
\DoxyCodeLine{984           \textcolor{comment}{! on a curve fit from the data of Wang (GRL, 2003).}}
\DoxyCodeLine{985           \textcolor{comment}{! Note:         Ro = 1.0 / sqrt(0.5 * dt * Rho0 * (absf*htot)**3 / conv\_PErel)}}
\DoxyCodeLine{986           nstar\_fc = cs\%nstar * conv\_perel / (conv\_perel + 0.2 * \&}
\DoxyCodeLine{987                      sqrt(0.5 * dt * gv\%Rho0 * (absf*(htot*gv\%H\_to\_Z))**3 * conv\_perel))}
\DoxyCodeLine{988 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{989 }
\DoxyCodeLine{990         \textcolor{keywordflow}{if} (debug) nstar\_k(k) = nstar\_fc}
\DoxyCodeLine{991 }
\DoxyCodeLine{992         tot\_tke = mech\_tke + nstar\_fc * conv\_perel}
\DoxyCodeLine{993 }
\DoxyCodeLine{994         \textcolor{comment}{!   For each interior interface, first discard the TKE to account for}}
\DoxyCodeLine{995         \textcolor{comment}{! mixing of shortwave radiation through the next denser cell.}}
\DoxyCodeLine{996         \textcolor{keywordflow}{if} (tke\_forcing(k) < 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{997           \textcolor{keywordflow}{if} (tke\_forcing(k) + tot\_tke < 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{998             \textcolor{comment}{! The shortwave requirements deplete all the energy in this layer.}}
\DoxyCodeLine{999             \textcolor{keywordflow}{if} (cs\%TKE\_diagnostics) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1000               ecd\%dTKE\_mixing = ecd\%dTKE\_mixing + tot\_tke * i\_dtdiag}
\DoxyCodeLine{1001               ecd\%dTKE\_forcing = ecd\%dTKE\_forcing -\/ tot\_tke * i\_dtdiag}
\DoxyCodeLine{1002               \textcolor{comment}{! eCD\%dTKE\_unbalanced = eCD\%dTKE\_unbalanced + (TKE\_forcing(k) + tot\_TKE) * I\_dtdiag}}
\DoxyCodeLine{1003               ecd\%dTKE\_conv\_decay = ecd\%dTKE\_conv\_decay + (cs\%nstar-\/nstar\_fc) * conv\_perel * i\_dtdiag}
\DoxyCodeLine{1004 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{1005             tot\_tke = 0.0 ; mech\_tke = 0.0 ; conv\_perel = 0.0}
\DoxyCodeLine{1006           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1007             \textcolor{comment}{! Reduce the mechanical and convective TKE proportionately.}}
\DoxyCodeLine{1008             tke\_reduc = (tot\_tke + tke\_forcing(k)) / tot\_tke}
\DoxyCodeLine{1009             \textcolor{keywordflow}{if} (cs\%TKE\_diagnostics) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1010               ecd\%dTKE\_mixing = ecd\%dTKE\_mixing -\/ tke\_forcing(k) * i\_dtdiag}
\DoxyCodeLine{1011               ecd\%dTKE\_forcing = ecd\%dTKE\_forcing + tke\_forcing(k) * i\_dtdiag}
\DoxyCodeLine{1012               ecd\%dTKE\_conv\_decay = ecd\%dTKE\_conv\_decay + \&}
\DoxyCodeLine{1013                   (1.0-\/tke\_reduc)*(cs\%nstar-\/nstar\_fc) * conv\_perel * i\_dtdiag}
\DoxyCodeLine{1014 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{1015             tot\_tke = tke\_reduc*tot\_tke   \textcolor{comment}{! = tot\_TKE + TKE\_forcing(k)}}
\DoxyCodeLine{1016             mech\_tke = tke\_reduc*mech\_tke}
\DoxyCodeLine{1017             conv\_perel = tke\_reduc*conv\_perel}
\DoxyCodeLine{1018 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1019 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1020 }
\DoxyCodeLine{1021         \textcolor{comment}{! Precalculate some temporary expressions that are independent of Kddt\_h(K).}}
\DoxyCodeLine{1022         \textcolor{keywordflow}{if} (cs\%orig\_PE\_calc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1023           \textcolor{keywordflow}{if} (k==2) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1024             dte\_t2 = 0.0 ; dse\_t2 = 0.0}
\DoxyCodeLine{1025           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1026             dte\_t2 = kddt\_h(k-\/1) * ((t0(k-\/2) -\/ t0(k-\/1)) + dte(k-\/2))}
\DoxyCodeLine{1027             dse\_t2 = kddt\_h(k-\/1) * ((s0(k-\/2) -\/ s0(k-\/1)) + dse(k-\/2))}
\DoxyCodeLine{1028 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1029 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1030         dt\_h = (gv\%Z\_to\_H**2*dt) / max(0.5*(h(k-\/1)+h(k)), 1e-\/15*h\_sum)}
\DoxyCodeLine{1031 }
\DoxyCodeLine{1032         \textcolor{comment}{!   This tests whether the layers above and below this interface are in}}
\DoxyCodeLine{1033         \textcolor{comment}{! a convetively stable configuration, without considering any effects of}}
\DoxyCodeLine{1034         \textcolor{comment}{! mixing at higher interfaces.  It is an approximation to the more}}
\DoxyCodeLine{1035         \textcolor{comment}{! complete test dPEc\_dKd\_Kd0 >= 0.0, that would include the effects of}}
\DoxyCodeLine{1036         \textcolor{comment}{! mixing across interface K-\/1.  The dT\_to\_dColHt here are effectively}}
\DoxyCodeLine{1037         \textcolor{comment}{! mass-\/weigted estimates of dSV\_dT.}}
\DoxyCodeLine{1038         convectively\_stable = ( 0.0 <= \&}
\DoxyCodeLine{1039              ( (dt\_to\_dcolht(k) + dt\_to\_dcolht(k-\/1) ) * (t0(k-\/1)-\/t0(k)) + \&}
\DoxyCodeLine{1040                (ds\_to\_dcolht(k) + ds\_to\_dcolht(k-\/1) ) * (s0(k-\/1)-\/s0(k)) ) )}
\DoxyCodeLine{1041 }
\DoxyCodeLine{1042         \textcolor{keywordflow}{if} ((mech\_tke + conv\_perel) <= 0.0 .and. convectively\_stable) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1043           \textcolor{comment}{! Energy is already exhausted, so set Kd = 0 and cycle or exit?}}
\DoxyCodeLine{1044           tot\_tke = 0.0 ; mech\_tke = 0.0 ; conv\_perel = 0.0}
\DoxyCodeLine{1045           kd(k) = 0.0 ; kddt\_h(k) = 0.0}
\DoxyCodeLine{1046           sfc\_disconnect = .true.}
\DoxyCodeLine{1047           \textcolor{comment}{! if (.not.debug) exit}}
\DoxyCodeLine{1048 }
\DoxyCodeLine{1049          \textcolor{comment}{!   The estimated properties for layer k-\/1 can be calculated, using}}
\DoxyCodeLine{1050          \textcolor{comment}{! greatly simplified expressions when Kddt\_h = 0.  This enables the}}
\DoxyCodeLine{1051          \textcolor{comment}{! tridiagonal solver for the whole column to be completed for debugging}}
\DoxyCodeLine{1052          \textcolor{comment}{! purposes, and also allows for something akin to convective adjustment}}
\DoxyCodeLine{1053          \textcolor{comment}{! in unstable interior regions?}}
\DoxyCodeLine{1054           b1 = 1.0 / hp\_a}
\DoxyCodeLine{1055           c1(k) = 0.0}
\DoxyCodeLine{1056           \textcolor{keywordflow}{if} (cs\%orig\_PE\_calc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1057             dte(k-\/1) = b1 * ( dte\_t2 )}
\DoxyCodeLine{1058             dse(k-\/1) = b1 * ( dse\_t2 )}
\DoxyCodeLine{1059 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1060 }
\DoxyCodeLine{1061           hp\_a = h(k)}
\DoxyCodeLine{1062           dt\_to\_dpe\_a(k) = dt\_to\_dpe(k)}
\DoxyCodeLine{1063           ds\_to\_dpe\_a(k) = ds\_to\_dpe(k)}
\DoxyCodeLine{1064           dt\_to\_dcolht\_a(k) = dt\_to\_dcolht(k)}
\DoxyCodeLine{1065           ds\_to\_dcolht\_a(k) = ds\_to\_dcolht(k)}
\DoxyCodeLine{1066 }
\DoxyCodeLine{1067         \textcolor{keywordflow}{else} \textcolor{comment}{! tot\_TKE > 0.0 or this is a potentially convectively unstable profile.}}
\DoxyCodeLine{1068           sfc\_disconnect = .false.}
\DoxyCodeLine{1069 }
\DoxyCodeLine{1070           \textcolor{comment}{! Precalculate some more temporary expressions that are independent of}}
\DoxyCodeLine{1071           \textcolor{comment}{! Kddt\_h(K).}}
\DoxyCodeLine{1072           \textcolor{keywordflow}{if} (cs\%orig\_PE\_calc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1073             \textcolor{keywordflow}{if} (k==2) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1074               dt\_km1\_t2 = (t0(k)-\/t0(k-\/1))}
\DoxyCodeLine{1075               ds\_km1\_t2 = (s0(k)-\/s0(k-\/1))}
\DoxyCodeLine{1076             \textcolor{keywordflow}{else}}
\DoxyCodeLine{1077               dt\_km1\_t2 = (t0(k)-\/t0(k-\/1)) -\/ \&}
\DoxyCodeLine{1078                     (kddt\_h(k-\/1) / hp\_a) * ((t0(k-\/2) -\/ t0(k-\/1)) + dte(k-\/2))}
\DoxyCodeLine{1079               ds\_km1\_t2 = (s0(k)-\/s0(k-\/1)) -\/ \&}
\DoxyCodeLine{1080                     (kddt\_h(k-\/1) / hp\_a) * ((s0(k-\/2) -\/ s0(k-\/1)) + dse(k-\/2))}
\DoxyCodeLine{1081 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{1082             dte\_term = dte\_t2 + hp\_a * (t0(k-\/1)-\/t0(k))}
\DoxyCodeLine{1083             dse\_term = dse\_t2 + hp\_a * (s0(k-\/1)-\/s0(k))}
\DoxyCodeLine{1084           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1085             \textcolor{keywordflow}{if} (k<=2) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1086               th\_a(k-\/1) = h(k-\/1) * t0(k-\/1) ; sh\_a(k-\/1) = h(k-\/1) * s0(k-\/1)}
\DoxyCodeLine{1087             \textcolor{keywordflow}{else}}
\DoxyCodeLine{1088               th\_a(k-\/1) = h(k-\/1) * t0(k-\/1) + kddt\_h(k-\/1) * te(k-\/2)}
\DoxyCodeLine{1089               sh\_a(k-\/1) = h(k-\/1) * s0(k-\/1) + kddt\_h(k-\/1) * se(k-\/2)}
\DoxyCodeLine{1090 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{1091             th\_b(k) = h(k) * t0(k) ; sh\_b(k) = h(k) * s0(k)}
\DoxyCodeLine{1092 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1093 }
\DoxyCodeLine{1094           \textcolor{comment}{!   Using Pr=1 and the diffusivity at the bottom interface (once it is}}
\DoxyCodeLine{1095           \textcolor{comment}{! known), determine how much resolved mean kinetic energy (MKE) will be}}
\DoxyCodeLine{1096           \textcolor{comment}{! extracted within a timestep and add a fraction CS\%MKE\_to\_TKE\_effic of}}
\DoxyCodeLine{1097           \textcolor{comment}{! this to the mTKE budget available for mixing in the next layer.}}
\DoxyCodeLine{1098 }
\DoxyCodeLine{1099           \textcolor{keywordflow}{if} ((cs\%MKE\_to\_TKE\_effic > 0.0) .and. (htot*h(k) > 0.0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1100             \textcolor{comment}{! This is the energy that would be available from homogenizing the}}
\DoxyCodeLine{1101             \textcolor{comment}{! velocities between layer k and the layers above.}}
\DoxyCodeLine{1102             dmke\_max = (us\%L\_to\_Z**2*gv\%H\_to\_RZ * cs\%MKE\_to\_TKE\_effic) * 0.5 * \&}
\DoxyCodeLine{1103                 (h(k) / ((htot + h(k))*htot)) * \&}
\DoxyCodeLine{1104                 ((uhtot-\/u(k)*htot)**2 + (vhtot-\/v(k)*htot)**2)}
\DoxyCodeLine{1105             \textcolor{comment}{! A fraction (1-\/exp(Kddt\_h*MKE2\_Hharm)) of this energy would be}}
\DoxyCodeLine{1106             \textcolor{comment}{! extracted by mixing with a finite viscosity.}}
\DoxyCodeLine{1107             mke2\_hharm = (htot + h(k) + 2.0*h\_neglect) / \&}
\DoxyCodeLine{1108                          ((htot+h\_neglect) * (h(k)+h\_neglect))}
\DoxyCodeLine{1109           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1110             dmke\_max = 0.0}
\DoxyCodeLine{1111             mke2\_hharm = 0.0}
\DoxyCodeLine{1112 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1113 }
\DoxyCodeLine{1114           \textcolor{comment}{! At this point, Kddt\_h(K) will be unknown because its value may depend}}
\DoxyCodeLine{1115           \textcolor{comment}{! on how much energy is available.  mech\_TKE might be negative due to}}
\DoxyCodeLine{1116           \textcolor{comment}{! contributions from TKE\_forced.}}
\DoxyCodeLine{1117           h\_tt = htot + h\_tt\_min}
\DoxyCodeLine{1118           tke\_here = mech\_tke + cs\%wstar\_ustar\_coef*conv\_perel}
\DoxyCodeLine{1119           \textcolor{keywordflow}{if} (tke\_here > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1120             \textcolor{keywordflow}{if} (cs\%wT\_scheme==wt\_from\_croot\_tke) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1121               vstar = cs\%vstar\_scale\_fac * vstar\_unit\_scale * (i\_dtrho*tke\_here)**c1\_3}
\DoxyCodeLine{1122             \textcolor{keywordflow}{elseif} (cs\%wT\_scheme==wt\_from\_rh18) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1123               surface\_scale = max(0.05, 1.0 -\/ htot/mld\_guess)}
\DoxyCodeLine{1124               vstar = cs\%vstar\_scale\_fac * surface\_scale * (cs\%vstar\_surf\_fac*u\_star + \&}
\DoxyCodeLine{1125                         vstar\_unit\_scale * (cs\%wstar\_ustar\_coef*conv\_perel*i\_dtrho)**c1\_3)}
\DoxyCodeLine{1126 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{1127             hbs\_here = gv\%H\_to\_Z * min(hb\_hs(k), mixlen\_shape(k))}
\DoxyCodeLine{1128             mixlen(k) = max(cs\%min\_mix\_len, ((h\_tt*hbs\_here)*vstar) / \&}
\DoxyCodeLine{1129                 ((cs\%Ekman\_scale\_coef * absf) * (h\_tt*hbs\_here) + vstar))}
\DoxyCodeLine{1130             \textcolor{comment}{!Note setting Kd\_guess0 to vstar * CS\%vonKar * mixlen(K) here will}}
\DoxyCodeLine{1131             \textcolor{comment}{! change the answers.  Therefore, skipping that.}}
\DoxyCodeLine{1132             \textcolor{keywordflow}{if} (.not.cs\%Use\_MLD\_iteration) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1133               kd\_guess0 = vstar * cs\%vonKar * ((h\_tt*hbs\_here)*vstar) / \&}
\DoxyCodeLine{1134                 ((cs\%Ekman\_scale\_coef * absf) * (h\_tt*hbs\_here) + vstar)}
\DoxyCodeLine{1135             \textcolor{keywordflow}{else}}
\DoxyCodeLine{1136               kd\_guess0 = vstar * cs\%vonKar * mixlen(k)}
\DoxyCodeLine{1137 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{1138           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1139             vstar = 0.0 ; kd\_guess0 = 0.0}
\DoxyCodeLine{1140 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1141           mixvel(k) = vstar \textcolor{comment}{! Track vstar}}
\DoxyCodeLine{1142           kddt\_h\_g0 = kd\_guess0 * dt\_h}
\DoxyCodeLine{1143 }
\DoxyCodeLine{1144           \textcolor{keywordflow}{if} (cs\%orig\_PE\_calc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1145             \textcolor{keyword}{call }find\_pe\_chg\_orig(kddt\_h\_g0, h(k), hp\_a, dte\_term, dse\_term, \&}
\DoxyCodeLine{1146                      dt\_km1\_t2, ds\_km1\_t2, dt\_to\_dpe(k), ds\_to\_dpe(k), \&}
\DoxyCodeLine{1147                      dt\_to\_dpe\_a(k-\/1), ds\_to\_dpe\_a(k-\/1), \&}
\DoxyCodeLine{1148                      pres\_z(k), dt\_to\_dcolht(k), ds\_to\_dcolht(k), \&}
\DoxyCodeLine{1149                      dt\_to\_dcolht\_a(k-\/1), ds\_to\_dcolht\_a(k-\/1), \&}
\DoxyCodeLine{1150                      pe\_chg=pe\_chg\_g0, dpe\_max=pe\_chg\_max, dpec\_dkd\_0=dpec\_dkd\_kd0 )}
\DoxyCodeLine{1151           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1152             \textcolor{keyword}{call }find\_pe\_chg(0.0, kddt\_h\_g0, hp\_a, h(k), \&}
\DoxyCodeLine{1153                      th\_a(k-\/1), sh\_a(k-\/1), th\_b(k), sh\_b(k), \&}
\DoxyCodeLine{1154                      dt\_to\_dpe\_a(k-\/1), ds\_to\_dpe\_a(k-\/1), dt\_to\_dpe(k), ds\_to\_dpe(k), \&}
\DoxyCodeLine{1155                      pres\_z(k), dt\_to\_dcolht\_a(k-\/1), ds\_to\_dcolht\_a(k-\/1), \&}
\DoxyCodeLine{1156                      dt\_to\_dcolht(k), ds\_to\_dcolht(k), \&}
\DoxyCodeLine{1157                      pe\_chg=pe\_chg\_g0, dpe\_max=pe\_chg\_max, dpec\_dkd\_0=dpec\_dkd\_kd0 )}
\DoxyCodeLine{1158 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1159 }
\DoxyCodeLine{1160           mke\_src = dmke\_max*(1.0 -\/ exp(-\/kddt\_h\_g0 * mke2\_hharm))}
\DoxyCodeLine{1161 }
\DoxyCodeLine{1162           \textcolor{comment}{! This block checks out different cases to determine Kd at the present interface.}}
\DoxyCodeLine{1163           \textcolor{keywordflow}{if} ((pe\_chg\_g0 < 0.0) .or. ((vstar == 0.0) .and. (dpec\_dkd\_kd0 < 0.0))) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1164             \textcolor{comment}{! This column is convectively unstable.}}
\DoxyCodeLine{1165             \textcolor{keywordflow}{if} (pe\_chg\_max <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1166               \textcolor{comment}{! Does MKE\_src need to be included in the calculation of vstar here?}}
\DoxyCodeLine{1167               tke\_here = mech\_tke + cs\%wstar\_ustar\_coef*(conv\_perel-\/pe\_chg\_max)}
\DoxyCodeLine{1168               \textcolor{keywordflow}{if} (tke\_here > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1169                 \textcolor{keywordflow}{if} (cs\%wT\_scheme==wt\_from\_croot\_tke) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1170                   vstar = cs\%vstar\_scale\_fac * vstar\_unit\_scale * (i\_dtrho*tke\_here)**c1\_3}
\DoxyCodeLine{1171                 \textcolor{keywordflow}{elseif} (cs\%wT\_scheme==wt\_from\_rh18) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1172                   surface\_scale = max(0.05, 1. -\/ htot/mld\_guess)}
\DoxyCodeLine{1173                   vstar = cs\%vstar\_scale\_fac * surface\_scale * (cs\%vstar\_surf\_fac*u\_star + \&}
\DoxyCodeLine{1174                                   vstar\_unit\_scale * (cs\%wstar\_ustar\_coef*conv\_perel*i\_dtrho)**c1\_3)}
\DoxyCodeLine{1175 \textcolor{keywordflow}{                endif}}
\DoxyCodeLine{1176                 hbs\_here = gv\%H\_to\_Z * min(hb\_hs(k), mixlen\_shape(k))}
\DoxyCodeLine{1177                 mixlen(k) = max(cs\%min\_mix\_len, ((h\_tt*hbs\_here)*vstar) / \&}
\DoxyCodeLine{1178                     ((cs\%Ekman\_scale\_coef * absf) * (h\_tt*hbs\_here) + vstar))}
\DoxyCodeLine{1179                 \textcolor{keywordflow}{if} (.not.cs\%Use\_MLD\_iteration) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1180                 \textcolor{comment}{! Note again (as prev) that using mixlen here}}
\DoxyCodeLine{1181                 \textcolor{comment}{!  instead of redoing the computation will change answers...}}
\DoxyCodeLine{1182                   kd(k) = vstar * cs\%vonKar *  ((h\_tt*hbs\_here)*vstar) / \&}
\DoxyCodeLine{1183                         ((cs\%Ekman\_scale\_coef * absf) * (h\_tt*hbs\_here) + vstar)}
\DoxyCodeLine{1184                 \textcolor{keywordflow}{else}}
\DoxyCodeLine{1185                   kd(k) = vstar * cs\%vonKar * mixlen(k)}
\DoxyCodeLine{1186 \textcolor{keywordflow}{                endif}}
\DoxyCodeLine{1187               \textcolor{keywordflow}{else}}
\DoxyCodeLine{1188                 vstar = 0.0 ; kd(k) = 0.0}
\DoxyCodeLine{1189 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{1190               mixvel(k) = vstar}
\DoxyCodeLine{1191 }
\DoxyCodeLine{1192               \textcolor{keywordflow}{if} (cs\%orig\_PE\_calc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1193                 \textcolor{keyword}{call }find\_pe\_chg\_orig(kd(k)*dt\_h, h(k), hp\_a, dte\_term, dse\_term, \&}
\DoxyCodeLine{1194                          dt\_km1\_t2, ds\_km1\_t2, dt\_to\_dpe(k), ds\_to\_dpe(k), \&}
\DoxyCodeLine{1195                          dt\_to\_dpe\_a(k-\/1), ds\_to\_dpe\_a(k-\/1), \&}
\DoxyCodeLine{1196                          pres\_z(k), dt\_to\_dcolht(k), ds\_to\_dcolht(k), \&}
\DoxyCodeLine{1197                          dt\_to\_dcolht\_a(k-\/1), ds\_to\_dcolht\_a(k-\/1), \&}
\DoxyCodeLine{1198                          pe\_chg=dpe\_conv)}
\DoxyCodeLine{1199               \textcolor{keywordflow}{else}}
\DoxyCodeLine{1200                 \textcolor{keyword}{call }find\_pe\_chg(0.0, kd(k)*dt\_h, hp\_a, h(k), \&}
\DoxyCodeLine{1201                          th\_a(k-\/1), sh\_a(k-\/1), th\_b(k), sh\_b(k), \&}
\DoxyCodeLine{1202                          dt\_to\_dpe\_a(k-\/1), ds\_to\_dpe\_a(k-\/1), dt\_to\_dpe(k), ds\_to\_dpe(k), \&}
\DoxyCodeLine{1203                          pres\_z(k), dt\_to\_dcolht\_a(k-\/1), ds\_to\_dcolht\_a(k-\/1), \&}
\DoxyCodeLine{1204                          dt\_to\_dcolht(k), ds\_to\_dcolht(k), \&}
\DoxyCodeLine{1205                          pe\_chg=dpe\_conv)}
\DoxyCodeLine{1206 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{1207               \textcolor{comment}{! Should this be iterated to convergence for Kd?}}
\DoxyCodeLine{1208               \textcolor{keywordflow}{if} (dpe\_conv > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1209                 kd(k) = kd\_guess0 ; dpe\_conv = pe\_chg\_g0}
\DoxyCodeLine{1210               \textcolor{keywordflow}{else}}
\DoxyCodeLine{1211                 mke\_src = dmke\_max*(1.0 -\/ exp(-\/(kd(k)*dt\_h) * mke2\_hharm))}
\DoxyCodeLine{1212 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{1213             \textcolor{keywordflow}{else}}
\DoxyCodeLine{1214               \textcolor{comment}{! The energy change does not vary monotonically with Kddt\_h.  Find the maximum?}}
\DoxyCodeLine{1215               kd(k) = kd\_guess0 ; dpe\_conv = pe\_chg\_g0}
\DoxyCodeLine{1216 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{1217 }
\DoxyCodeLine{1218             conv\_perel = conv\_perel -\/ dpe\_conv}
\DoxyCodeLine{1219             mech\_tke = mech\_tke + mke\_src}
\DoxyCodeLine{1220             \textcolor{keywordflow}{if} (cs\%TKE\_diagnostics) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1221               ecd\%dTKE\_conv = ecd\%dTKE\_conv -\/ cs\%nstar*dpe\_conv * i\_dtdiag}
\DoxyCodeLine{1222               ecd\%dTKE\_MKE = ecd\%dTKE\_MKE + mke\_src * i\_dtdiag}
\DoxyCodeLine{1223 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{1224             \textcolor{keywordflow}{if} (sfc\_connected) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1225               mld\_output = mld\_output + gv\%H\_to\_Z * h(k)}
\DoxyCodeLine{1226 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{1227 }
\DoxyCodeLine{1228             kddt\_h(k) = kd(k) * dt\_h}
\DoxyCodeLine{1229           \textcolor{keywordflow}{elseif} (tot\_tke + (mke\_src -\/ pe\_chg\_g0) >= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1230             \textcolor{comment}{! This column is convctively stable and there is energy to support the suggested}}
\DoxyCodeLine{1231             \textcolor{comment}{! mixing.  Keep that estimate.}}
\DoxyCodeLine{1232             kd(k) = kd\_guess0}
\DoxyCodeLine{1233             kddt\_h(k) = kddt\_h\_g0}
\DoxyCodeLine{1234 }
\DoxyCodeLine{1235             \textcolor{comment}{! Reduce the mechanical and convective TKE proportionately.}}
\DoxyCodeLine{1236             tot\_tke = tot\_tke + mke\_src}
\DoxyCodeLine{1237             tke\_reduc = 0.0   \textcolor{comment}{! tot\_TKE could be 0 if Convectively\_stable is false.}}
\DoxyCodeLine{1238             \textcolor{keywordflow}{if} (tot\_tke > 0.0) tke\_reduc = (tot\_tke -\/ pe\_chg\_g0) / tot\_tke}
\DoxyCodeLine{1239             \textcolor{keywordflow}{if} (cs\%TKE\_diagnostics) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1240               ecd\%dTKE\_mixing = ecd\%dTKE\_mixing -\/ pe\_chg\_g0 * i\_dtdiag}
\DoxyCodeLine{1241               ecd\%dTKE\_MKE = ecd\%dTKE\_MKE + mke\_src * i\_dtdiag}
\DoxyCodeLine{1242               ecd\%dTKE\_conv\_decay = ecd\%dTKE\_conv\_decay + \&}
\DoxyCodeLine{1243                   (1.0-\/tke\_reduc)*(cs\%nstar-\/nstar\_fc) * conv\_perel * i\_dtdiag}
\DoxyCodeLine{1244 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{1245             tot\_tke = tke\_reduc*tot\_tke}
\DoxyCodeLine{1246             mech\_tke = tke\_reduc*(mech\_tke + mke\_src)}
\DoxyCodeLine{1247             conv\_perel = tke\_reduc*conv\_perel}
\DoxyCodeLine{1248             \textcolor{keywordflow}{if} (sfc\_connected) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1249               mld\_output = mld\_output + gv\%H\_to\_Z * h(k)}
\DoxyCodeLine{1250 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{1251 }
\DoxyCodeLine{1252           \textcolor{keywordflow}{elseif} (tot\_tke == 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1253             \textcolor{comment}{! This can arise if nstar\_FC = 0, but it is not common.}}
\DoxyCodeLine{1254             kd(k) = 0.0 ; kddt\_h(k) = 0.0}
\DoxyCodeLine{1255             tot\_tke = 0.0 ; conv\_perel = 0.0 ; mech\_tke = 0.0}
\DoxyCodeLine{1256             sfc\_disconnect = .true.}
\DoxyCodeLine{1257           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1258             \textcolor{comment}{! There is not enough energy to support the mixing, so reduce the}}
\DoxyCodeLine{1259             \textcolor{comment}{! diffusivity to what can be supported.}}
\DoxyCodeLine{1260             kddt\_h\_max = kddt\_h\_g0 ; kddt\_h\_min = 0.0}
\DoxyCodeLine{1261             tke\_left\_max = tot\_tke + (mke\_src -\/ pe\_chg\_g0)}
\DoxyCodeLine{1262             tke\_left\_min = tot\_tke}
\DoxyCodeLine{1263 }
\DoxyCodeLine{1264             \textcolor{comment}{! As a starting guess, take the minimum of a false position estimate}}
\DoxyCodeLine{1265             \textcolor{comment}{! and a Newton's method estimate starting from Kddt\_h = 0.0.}}
\DoxyCodeLine{1266             kddt\_h\_guess = tot\_tke * kddt\_h\_max / max( pe\_chg\_g0  -\/ mke\_src, \&}
\DoxyCodeLine{1267                              kddt\_h\_max * (dpec\_dkd\_kd0 -\/ dmke\_max * mke2\_hharm) )}
\DoxyCodeLine{1268             \textcolor{comment}{! The above expression is mathematically the same as the following}}
\DoxyCodeLine{1269             \textcolor{comment}{! except it is not susceptible to division by zero when}}
\DoxyCodeLine{1270             \textcolor{comment}{!   dPEc\_dKd\_Kd0 = dMKE\_max = 0 .}}
\DoxyCodeLine{1271             \textcolor{comment}{!  Kddt\_h\_guess = tot\_TKE * min( Kddt\_h\_max / (PE\_chg\_g0 -\/ MKE\_src), \&}}
\DoxyCodeLine{1272             \textcolor{comment}{!                      1.0 / (dPEc\_dKd\_Kd0 -\/ dMKE\_max * MKE2\_Hharm) )}}
\DoxyCodeLine{1273             \textcolor{keywordflow}{if} (debug) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1274               tke\_left\_itt(:) = 0.0 ; dpea\_dkd\_itt(:) = 0.0 ; pe\_chg\_itt(:) = 0.0}
\DoxyCodeLine{1275               mke\_src\_itt(:) = 0.0 ; kddt\_h\_itt(:) = 0.0}
\DoxyCodeLine{1276 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{1277             \textcolor{keywordflow}{do} itt=1,max\_itt}
\DoxyCodeLine{1278               \textcolor{keywordflow}{if} (cs\%orig\_PE\_calc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1279                 \textcolor{keyword}{call }find\_pe\_chg\_orig(kddt\_h\_guess, h(k), hp\_a, dte\_term, dse\_term, \&}
\DoxyCodeLine{1280                          dt\_km1\_t2, ds\_km1\_t2, dt\_to\_dpe(k), ds\_to\_dpe(k), \&}
\DoxyCodeLine{1281                          dt\_to\_dpe\_a(k-\/1), ds\_to\_dpe\_a(k-\/1), \&}
\DoxyCodeLine{1282                          pres\_z(k), dt\_to\_dcolht(k), ds\_to\_dcolht(k), \&}
\DoxyCodeLine{1283                          dt\_to\_dcolht\_a(k-\/1), ds\_to\_dcolht\_a(k-\/1), \&}
\DoxyCodeLine{1284                          pe\_chg=pe\_chg, dpec\_dkd=dpec\_dkd )}
\DoxyCodeLine{1285               \textcolor{keywordflow}{else}}
\DoxyCodeLine{1286                 \textcolor{keyword}{call }find\_pe\_chg(0.0, kddt\_h\_guess, hp\_a, h(k), \&}
\DoxyCodeLine{1287                          th\_a(k-\/1), sh\_a(k-\/1), th\_b(k), sh\_b(k), \&}
\DoxyCodeLine{1288                          dt\_to\_dpe\_a(k-\/1), ds\_to\_dpe\_a(k-\/1), dt\_to\_dpe(k), ds\_to\_dpe(k), \&}
\DoxyCodeLine{1289                          pres\_z(k), dt\_to\_dcolht\_a(k-\/1), ds\_to\_dcolht\_a(k-\/1), \&}
\DoxyCodeLine{1290                          dt\_to\_dcolht(k), ds\_to\_dcolht(k), \&}
\DoxyCodeLine{1291                          pe\_chg=dpe\_conv, dpec\_dkd=dpec\_dkd)}
\DoxyCodeLine{1292 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{1293               mke\_src = dmke\_max * (1.0 -\/ exp(-\/mke2\_hharm * kddt\_h\_guess))}
\DoxyCodeLine{1294               dmke\_src\_dk = dmke\_max * mke2\_hharm * exp(-\/mke2\_hharm * kddt\_h\_guess)}
\DoxyCodeLine{1295 }
\DoxyCodeLine{1296               tke\_left = tot\_tke + (mke\_src -\/ pe\_chg)}
\DoxyCodeLine{1297               \textcolor{keywordflow}{if} (debug .and. itt<=20) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1298                 kddt\_h\_itt(itt) = kddt\_h\_guess ; mke\_src\_itt(itt) = mke\_src}
\DoxyCodeLine{1299                 pe\_chg\_itt(itt) = pe\_chg ; dpea\_dkd\_itt(itt) = dpec\_dkd}
\DoxyCodeLine{1300                 tke\_left\_itt(itt) = tke\_left}
\DoxyCodeLine{1301 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{1302               \textcolor{comment}{! Store the new bounding values, bearing in mind that min and max}}
\DoxyCodeLine{1303               \textcolor{comment}{! here refer to Kddt\_h and dTKE\_left/dKddt\_h < 0:}}
\DoxyCodeLine{1304               \textcolor{keywordflow}{if} (tke\_left >= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1305                 kddt\_h\_min = kddt\_h\_guess ; tke\_left\_min = tke\_left}
\DoxyCodeLine{1306               \textcolor{keywordflow}{else}}
\DoxyCodeLine{1307                 kddt\_h\_max = kddt\_h\_guess ; tke\_left\_max = tke\_left}
\DoxyCodeLine{1308 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{1309 }
\DoxyCodeLine{1310               \textcolor{comment}{! Try to use Newton's method, but if it would go outside the bracketed}}
\DoxyCodeLine{1311               \textcolor{comment}{! values use the false-\/position method instead.}}
\DoxyCodeLine{1312               use\_newt = .true.}
\DoxyCodeLine{1313               \textcolor{keywordflow}{if} (dpec\_dkd -\/ dmke\_src\_dk <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1314                 use\_newt = .false.}
\DoxyCodeLine{1315               \textcolor{keywordflow}{else}}
\DoxyCodeLine{1316                 dkddt\_h\_newt = tke\_left / (dpec\_dkd -\/ dmke\_src\_dk)}
\DoxyCodeLine{1317                 kddt\_h\_newt = kddt\_h\_guess + dkddt\_h\_newt}
\DoxyCodeLine{1318                 \textcolor{keywordflow}{if} ((kddt\_h\_newt > kddt\_h\_max) .or. (kddt\_h\_newt < kddt\_h\_min)) \&}
\DoxyCodeLine{1319                   use\_newt = .false.}
\DoxyCodeLine{1320 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{1321 }
\DoxyCodeLine{1322               \textcolor{keywordflow}{if} (use\_newt) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1323                 kddt\_h\_next = kddt\_h\_guess + dkddt\_h\_newt}
\DoxyCodeLine{1324                 dkddt\_h = dkddt\_h\_newt}
\DoxyCodeLine{1325               \textcolor{keywordflow}{else}}
\DoxyCodeLine{1326                 kddt\_h\_next = (tke\_left\_max * kddt\_h\_min -\/ kddt\_h\_max * tke\_left\_min) / \&}
\DoxyCodeLine{1327                               (tke\_left\_max -\/ tke\_left\_min)}
\DoxyCodeLine{1328                 dkddt\_h = kddt\_h\_next -\/ kddt\_h\_guess}
\DoxyCodeLine{1329 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{1330 }
\DoxyCodeLine{1331               \textcolor{keywordflow}{if} ((abs(dkddt\_h) < 1e-\/9*kddt\_h\_guess) .or. (itt==max\_itt)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1332                 \textcolor{comment}{! Use the old value so that the energy calculation does not need to be repeated.}}
\DoxyCodeLine{1333                 \textcolor{keywordflow}{if} (debug) num\_itts(k) = itt}
\DoxyCodeLine{1334                 \textcolor{keywordflow}{exit}}
\DoxyCodeLine{1335               \textcolor{keywordflow}{else}}
\DoxyCodeLine{1336                 kddt\_h\_guess = kddt\_h\_next}
\DoxyCodeLine{1337 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{1338 \textcolor{keywordflow}{            enddo} \textcolor{comment}{! Inner iteration loop on itt.}}
\DoxyCodeLine{1339             kd(k) = kddt\_h\_guess / dt\_h ; kddt\_h(k) = kd(k) * dt\_h}
\DoxyCodeLine{1340 }
\DoxyCodeLine{1341             \textcolor{comment}{! All TKE should have been consumed.}}
\DoxyCodeLine{1342             \textcolor{keywordflow}{if} (cs\%TKE\_diagnostics) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1343               ecd\%dTKE\_mixing = ecd\%dTKE\_mixing -\/ (tot\_tke + mke\_src) * i\_dtdiag}
\DoxyCodeLine{1344               ecd\%dTKE\_MKE = ecd\%dTKE\_MKE + mke\_src * i\_dtdiag}
\DoxyCodeLine{1345               ecd\%dTKE\_conv\_decay = ecd\%dTKE\_conv\_decay + \&}
\DoxyCodeLine{1346                   (cs\%nstar-\/nstar\_fc) * conv\_perel * i\_dtdiag}
\DoxyCodeLine{1347 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{1348 }
\DoxyCodeLine{1349             \textcolor{keywordflow}{if} (sfc\_connected) mld\_output = mld\_output + \&}
\DoxyCodeLine{1350                  (pe\_chg / (pe\_chg\_g0)) * gv\%H\_to\_Z * h(k)}
\DoxyCodeLine{1351 }
\DoxyCodeLine{1352             tot\_tke = 0.0 ; mech\_tke = 0.0 ; conv\_perel = 0.0}
\DoxyCodeLine{1353             sfc\_disconnect = .true.}
\DoxyCodeLine{1354 \textcolor{keywordflow}{          endif} \textcolor{comment}{! End of convective or forced mixing cases to determine Kd.}}
\DoxyCodeLine{1355 }
\DoxyCodeLine{1356           kddt\_h(k) = kd(k) * dt\_h}
\DoxyCodeLine{1357           \textcolor{comment}{!   At this point, the final value of Kddt\_h(K) is known, so the}}
\DoxyCodeLine{1358           \textcolor{comment}{! estimated properties for layer k-\/1 can be calculated.}}
\DoxyCodeLine{1359           b1 = 1.0 / (hp\_a + kddt\_h(k))}
\DoxyCodeLine{1360           c1(k) = kddt\_h(k) * b1}
\DoxyCodeLine{1361           \textcolor{keywordflow}{if} (cs\%orig\_PE\_calc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1362             dte(k-\/1) = b1 * ( kddt\_h(k)*(t0(k)-\/t0(k-\/1)) + dte\_t2 )}
\DoxyCodeLine{1363             dse(k-\/1) = b1 * ( kddt\_h(k)*(s0(k)-\/s0(k-\/1)) + dse\_t2 )}
\DoxyCodeLine{1364 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1365 }
\DoxyCodeLine{1366           hp\_a = h(k) + (hp\_a * b1) * kddt\_h(k)}
\DoxyCodeLine{1367           dt\_to\_dpe\_a(k) = dt\_to\_dpe(k) + c1(k)*dt\_to\_dpe\_a(k-\/1)}
\DoxyCodeLine{1368           ds\_to\_dpe\_a(k) = ds\_to\_dpe(k) + c1(k)*ds\_to\_dpe\_a(k-\/1)}
\DoxyCodeLine{1369           dt\_to\_dcolht\_a(k) = dt\_to\_dcolht(k) + c1(k)*dt\_to\_dcolht\_a(k-\/1)}
\DoxyCodeLine{1370           ds\_to\_dcolht\_a(k) = ds\_to\_dcolht(k) + c1(k)*ds\_to\_dcolht\_a(k-\/1)}
\DoxyCodeLine{1371 }
\DoxyCodeLine{1372 \textcolor{keywordflow}{        endif}  \textcolor{comment}{! tot\_TKT > 0.0 branch.  Kddt\_h(K) has been set.}}
\DoxyCodeLine{1373 }
\DoxyCodeLine{1374         \textcolor{comment}{! Store integrated velocities and thicknesses for MKE conversion calculations.}}
\DoxyCodeLine{1375         \textcolor{keywordflow}{if} (sfc\_disconnect) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1376           \textcolor{comment}{! There is no turbulence at this interface, so zero out the running sums.}}
\DoxyCodeLine{1377           uhtot = u(k)*h(k)}
\DoxyCodeLine{1378           vhtot = v(k)*h(k)}
\DoxyCodeLine{1379           htot  = h(k)}
\DoxyCodeLine{1380           sfc\_connected = .false.}
\DoxyCodeLine{1381         \textcolor{keywordflow}{else}}
\DoxyCodeLine{1382           uhtot = uhtot + u(k)*h(k)}
\DoxyCodeLine{1383           vhtot = vhtot + v(k)*h(k)}
\DoxyCodeLine{1384           htot  = htot + h(k)}
\DoxyCodeLine{1385 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1386 }
\DoxyCodeLine{1387         \textcolor{keywordflow}{if} (calc\_te) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1388           \textcolor{keywordflow}{if} (k==2) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1389             te(1) = b1*(h(1)*t0(1))}
\DoxyCodeLine{1390             se(1) = b1*(h(1)*s0(1))}
\DoxyCodeLine{1391           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1392             te(k-\/1) = b1 * (h(k-\/1) * t0(k-\/1) + kddt\_h(k-\/1) * te(k-\/2))}
\DoxyCodeLine{1393             se(k-\/1) = b1 * (h(k-\/1) * s0(k-\/1) + kddt\_h(k-\/1) * se(k-\/2))}
\DoxyCodeLine{1394 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1395 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1396 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{1397       kd(nz+1) = 0.0}
\DoxyCodeLine{1398 }
\DoxyCodeLine{1399       \textcolor{keywordflow}{if} (calc\_dt\_expect) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1400         \textcolor{comment}{! Complete the tridiagonal solve for Te.}}
\DoxyCodeLine{1401         b1 = 1.0 / hp\_a}
\DoxyCodeLine{1402         te(nz) = b1 * (h(nz) * t0(nz) + kddt\_h(nz) * te(nz-\/1))}
\DoxyCodeLine{1403         se(nz) = b1 * (h(nz) * s0(nz) + kddt\_h(nz) * se(nz-\/1))}
\DoxyCodeLine{1404         ecd\%dT\_expect(nz) = te(nz) -\/ t0(nz) ; ecd\%dS\_expect(nz) = se(nz) -\/ s0(nz)}
\DoxyCodeLine{1405         \textcolor{keywordflow}{do} k=nz-\/1,1,-\/1}
\DoxyCodeLine{1406           te(k) = te(k) + c1(k+1)*te(k+1)}
\DoxyCodeLine{1407           se(k) = se(k) + c1(k+1)*se(k+1)}
\DoxyCodeLine{1408           ecd\%dT\_expect(k) = te(k) -\/ t0(k) ; ecd\%dS\_expect(k) = se(k) -\/ s0(k)}
\DoxyCodeLine{1409 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{1410 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1411 }
\DoxyCodeLine{1412       \textcolor{keywordflow}{if} (debug) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1413         dpe\_debug = 0.0}
\DoxyCodeLine{1414         \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{1415           dpe\_debug = dpe\_debug + (dt\_to\_dpe(k) * (te(k) -\/ t0(k)) + \&}
\DoxyCodeLine{1416                                    ds\_to\_dpe(k) * (se(k) -\/ s0(k)))}
\DoxyCodeLine{1417 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{1418         mixing\_debug = dpe\_debug * i\_dtdiag}
\DoxyCodeLine{1419 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1420       k = nz \textcolor{comment}{! This is here to allow a breakpoint to be set.}}
\DoxyCodeLine{1421       \textcolor{comment}{!/BGR}}
\DoxyCodeLine{1422       \textcolor{comment}{! The following lines are used for the iteration}}
\DoxyCodeLine{1423       \textcolor{comment}{! note the iteration has been altered to use the value predicted by}}
\DoxyCodeLine{1424       \textcolor{comment}{! the TKE threshold (ML\_DEPTH).  This is because the MSTAR}}
\DoxyCodeLine{1425       \textcolor{comment}{! is now dependent on the ML, and therefore the ML needs to be estimated}}
\DoxyCodeLine{1426       \textcolor{comment}{! more precisely than the grid spacing.}}
\DoxyCodeLine{1427 }
\DoxyCodeLine{1428       \textcolor{comment}{!New method uses ML\_DEPTH as computed in ePBL routine}}
\DoxyCodeLine{1429       mld\_found = mld\_output}
\DoxyCodeLine{1430       \textcolor{keywordflow}{if} (mld\_found -\/ mld\_guess > cs\%MLD\_tol) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1431         min\_mld = mld\_guess ; dmld\_min = mld\_found -\/ mld\_guess}
\DoxyCodeLine{1432       \textcolor{keywordflow}{elseif} (abs(mld\_found -\/ mld\_guess) < cs\%MLD\_tol) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1433         obl\_converged = .true. \textcolor{comment}{! Break convergence loop}}
\DoxyCodeLine{1434       \textcolor{keywordflow}{else} \textcolor{comment}{! We know this guess was too deep}}
\DoxyCodeLine{1435         max\_mld = mld\_guess ; dmld\_max = mld\_found -\/ mld\_guess \textcolor{comment}{! < -\/CS\%MLD\_tol}}
\DoxyCodeLine{1436 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1437 }
\DoxyCodeLine{1438       \textcolor{keywordflow}{if} (.not.obl\_converged) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (cs\%MLD\_bisection) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1439         \textcolor{comment}{! For the next pass, guess the average of the minimum and maximum values.}}
\DoxyCodeLine{1440         mld\_guess = 0.5*(min\_mld + max\_mld)}
\DoxyCodeLine{1441       \textcolor{keywordflow}{else} \textcolor{comment}{! Try using the false position method or the returned value instead of simple bisection.}}
\DoxyCodeLine{1442         \textcolor{comment}{! Taking the occasional step with MLD\_output empirically helps to converge faster.}}
\DoxyCodeLine{1443         \textcolor{keywordflow}{if} ((dmld\_min > 0.0) .and. (dmld\_max < 0.0) .and. (obl\_it > 2) .and. (mod(obl\_it-\/1,4)>0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1444           \textcolor{comment}{! Both bounds have valid change estimates and are probably in the range of possible outputs.}}
\DoxyCodeLine{1445           mld\_guess = (dmld\_min*max\_mld -\/ dmld\_max*min\_mld) / (dmld\_min -\/ dmld\_max)}
\DoxyCodeLine{1446         \textcolor{keywordflow}{elseif} ((mld\_found > min\_mld) .and. (mld\_found < max\_mld)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1447           \textcolor{comment}{! The output MLD\_found is an interesting guess, as it likely to bracket the true solution}}
\DoxyCodeLine{1448           \textcolor{comment}{! along with the previous value of MLD\_guess and to be close to the solution.}}
\DoxyCodeLine{1449           mld\_guess = mld\_found}
\DoxyCodeLine{1450         \textcolor{keywordflow}{else} \textcolor{comment}{! Bisect if the other guesses would be out-\/of-\/bounds.  This does not happen much.}}
\DoxyCodeLine{1451           mld\_guess = 0.5*(min\_mld + max\_mld)}
\DoxyCodeLine{1452 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1453 \textcolor{keywordflow}{      endif} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{1454 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1455     \textcolor{keywordflow}{if} ((obl\_converged) .or. (obl\_it==cs\%Max\_MLD\_Its)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1456       \textcolor{keywordflow}{if} (report\_avg\_its) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1457         cs\%sum\_its(1) = cs\%sum\_its(1) + real\_to\_efp(real(obl\_it))}
\DoxyCodeLine{1458         cs\%sum\_its(2) = cs\%sum\_its(2) + real\_to\_efp(1.0)}
\DoxyCodeLine{1459 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1460       \textcolor{keywordflow}{exit}}
\DoxyCodeLine{1461 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1462 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! Iteration loop for converged boundary layer thickness.}}
\DoxyCodeLine{1463   \textcolor{keywordflow}{if} (cs\%Use\_LT) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1464     ecd\%LA = la ; ecd\%LAmod = lamod ; ecd\%mstar = mstar\_total ; ecd\%mstar\_LT = mstar\_lt}
\DoxyCodeLine{1465   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1466     ecd\%LA = 0.0 ; ecd\%LAmod = 0.0 ; ecd\%mstar = mstar\_total ; ecd\%mstar\_LT = 0.0}
\DoxyCodeLine{1467 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1468 }
\DoxyCodeLine{1469   mld\_io = mld\_output}
\DoxyCodeLine{1470 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__energetic__pbl_a7686c6a30a476068859f7a2a30e652df}\label{namespacemom__energetic__pbl_a7686c6a30a476068859f7a2a30e652df}} 
\index{mom\_energetic\_pbl@{mom\_energetic\_pbl}!find\_mstar@{find\_mstar}}
\index{find\_mstar@{find\_mstar}!mom\_energetic\_pbl@{mom\_energetic\_pbl}}
\doxysubsubsection{\texorpdfstring{find\_mstar()}{find\_mstar()}}
{\footnotesize\ttfamily subroutine mom\+\_\+energetic\+\_\+pbl\+::find\+\_\+mstar (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__energetic__pbl_1_1energetic__pbl__cs}{energetic\+\_\+pbl\+\_\+cs}}), pointer}]{CS,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, intent(in)}]{Buoyancy\+\_\+\+Flux,  }\item[{real, intent(in)}]{U\+Star,  }\item[{real, intent(in)}]{U\+Star\+\_\+\+Mean,  }\item[{real, intent(in)}]{B\+LD,  }\item[{real, intent(in)}]{Abs\+\_\+\+Coriolis,  }\item[{real, intent(out)}]{M\+Star,  }\item[{real, intent(in), optional}]{Langmuir\+\_\+\+Number,  }\item[{real, intent(out), optional}]{M\+Star\+\_\+\+LT,  }\item[{real, intent(out), optional}]{Convect\+\_\+\+Langmuir\+\_\+\+Number }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine finds the Mstar value for e\+P\+BL. 


\begin{DoxyParams}[1]{Parameters}
 & {\em cs} & Energetic\+\_\+\+P\+BL control structure. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em ustar} & ustar w/ gustiness \mbox{[}Z T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em ustar\+\_\+mean} & ustar w/o gustiness \mbox{[}Z T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em abs\+\_\+coriolis} & abolute value of the Coriolis parameter \mbox{[}T-\/1 $\sim$$>$ s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em buoyancy\+\_\+flux} & Buoyancy flux \mbox{[}Z2 T-\/3 $\sim$$>$ m2 s-\/3\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em bld} & boundary layer depth \mbox{[}Z $\sim$$>$ m\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em mstar} & Ouput mstar (Mixing/ustar$\ast$$\ast$3) \mbox{[}nondim\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em langmuir\+\_\+number} & Langmuir number \mbox{[}nondim\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em mstar\+\_\+lt} & Mstar increase due to Langmuir turbulence \mbox{[}nondim\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em convect\+\_\+langmuir\+\_\+number} & Langmuir number including buoyancy flux \mbox{[}nondim\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 1780 of file M\+O\+M\+\_\+energetic\+\_\+\+P\+B\+L.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1780   \textcolor{keywordtype}{type}(energetic\_PBL\_CS), \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{    !< Energetic\_PBL control structure.}}
\DoxyCodeLine{1781   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{    !< A dimensional unit scaling type}}
\DoxyCodeLine{1782 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}  :: UStar\textcolor{comment}{ !< ustar w/ gustiness [Z T-\/1 ~> m s-\/1]}}
\DoxyCodeLine{1783 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}  :: UStar\_Mean\textcolor{comment}{ !< ustar w/o gustiness [Z T-\/1 ~> m s-\/1]}}
\DoxyCodeLine{1784 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}  :: Abs\_Coriolis\textcolor{comment}{ !< abolute value of the Coriolis parameter [T-\/1 ~> s-\/1]}}
\DoxyCodeLine{1785 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}  :: Buoyancy\_Flux\textcolor{comment}{ !< Buoyancy flux [Z2 T-\/3 ~> m2 s-\/3]}}
\DoxyCodeLine{1786 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}  :: BLD\textcolor{comment}{   !< boundary layer depth [Z ~> m]}}
\DoxyCodeLine{1787 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(out)} :: Mstar\textcolor{comment}{ !< Ouput mstar (Mixing/ustar**3) [nondim]}}
\DoxyCodeLine{1788 \textcolor{keywordtype}{  real},        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: Langmuir\_Number\textcolor{comment}{ !< Langmuir number [nondim]}}
\DoxyCodeLine{1789 \textcolor{keywordtype}{  real},        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: MStar\_LT\textcolor{comment}{ !< Mstar increase due to Langmuir turbulence [nondim]}}
\DoxyCodeLine{1790 \textcolor{keywordtype}{  real},        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: Convect\_Langmuir\_number\textcolor{comment}{ !< Langmuir number including buoyancy flux [nondim]}}
\DoxyCodeLine{1791 }
\DoxyCodeLine{1792   \textcolor{comment}{!/ Variables used in computing mstar}}
\DoxyCodeLine{1793 \textcolor{keywordtype}{  real} :: MSN\_term       \textcolor{comment}{! Temporary terms [nondim]}}
\DoxyCodeLine{1794 \textcolor{keywordtype}{  real} :: MSCR\_term1, MSCR\_term2 \textcolor{comment}{! Temporary terms [Z3 T-\/3 ~> m3 s-\/3]}}
\DoxyCodeLine{1795 \textcolor{keywordtype}{  real} :: MStar\_Conv\_Red \textcolor{comment}{! Adjustment made to mstar due to convection reducing mechanical mixing [nondim]}}
\DoxyCodeLine{1796 \textcolor{keywordtype}{  real} :: MStar\_S, MStar\_N \textcolor{comment}{! Mstar in (S)tabilizing/(N)ot-\/stabilizing buoyancy flux [nondim]}}
\DoxyCodeLine{1797 }
\DoxyCodeLine{1798   \textcolor{comment}{!/  Integer options for how to find mstar}}
\DoxyCodeLine{1799 }
\DoxyCodeLine{1800   \textcolor{comment}{!/}}
\DoxyCodeLine{1801 }
\DoxyCodeLine{1802   \textcolor{keywordflow}{if} (cs\%mstar\_scheme == use\_fixed\_mstar) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1803     mstar = cs\%Fixed\_MStar}
\DoxyCodeLine{1804   \textcolor{comment}{!/ 1. Get mstar}}
\DoxyCodeLine{1805   \textcolor{keywordflow}{elseif} (cs\%mstar\_scheme == mstar\_from\_ekman) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1806 }
\DoxyCodeLine{1807     \textcolor{keywordflow}{if} (cs\%answers\_2018) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1808       \textcolor{comment}{! The limit for the balance of rotation and stabilizing is f(L\_Ekman,L\_Obukhov)}}
\DoxyCodeLine{1809       mstar\_s = cs\%MStar\_coef*sqrt(max(0.0,buoyancy\_flux) / ustar**2 / \&}
\DoxyCodeLine{1810                     (abs\_coriolis + 1.e-\/10*us\%T\_to\_s) )}
\DoxyCodeLine{1811       \textcolor{comment}{! The limit for rotation (Ekman length) limited mixing}}
\DoxyCodeLine{1812       mstar\_n =  cs\%C\_Ek * log( max( 1., ustar / (abs\_coriolis + 1.e-\/10*us\%T\_to\_s) / bld ) )}
\DoxyCodeLine{1813     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1814       \textcolor{comment}{! The limit for the balance of rotation and stabilizing is f(L\_Ekman,L\_Obukhov)}}
\DoxyCodeLine{1815       mstar\_s = cs\%MSTAR\_COEF*sqrt(max(0.0, buoyancy\_flux) / (ustar**2 * max(abs\_coriolis, 1.e-\/20*us\%T\_to\_s)))}
\DoxyCodeLine{1816       \textcolor{comment}{! The limit for rotation (Ekman length) limited mixing}}
\DoxyCodeLine{1817       mstar\_n = 0.0}
\DoxyCodeLine{1818       \textcolor{keywordflow}{if} (ustar > abs\_coriolis * bld) mstar\_n = cs\%C\_EK * log(ustar / (abs\_coriolis * bld))}
\DoxyCodeLine{1819 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1820 }
\DoxyCodeLine{1821     \textcolor{comment}{! Here 1.25 is about .5/von Karman, which gives the Obukhov limit.}}
\DoxyCodeLine{1822     mstar = max(mstar\_s, min(1.25, mstar\_n))}
\DoxyCodeLine{1823     \textcolor{keywordflow}{if} (cs\%MStar\_Cap > 0.0) mstar = min( cs\%MStar\_Cap,mstar )}
\DoxyCodeLine{1824   \textcolor{keywordflow}{elseif} ( cs\%mstar\_scheme == mstar\_from\_rh18 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1825     \textcolor{keywordflow}{if} (cs\%answers\_2018) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1826       mstar\_n = cs\%RH18\_MStar\_cn1 * ( 1.0 -\/ 1.0 / ( 1. + cs\%RH18\_MStar\_cn2 * \&}
\DoxyCodeLine{1827                 exp( cs\%RH18\_mstar\_CN3 * bld * abs\_coriolis / ustar) ) )}
\DoxyCodeLine{1828     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1829       msn\_term = cs\%RH18\_MStar\_cn2 * exp( cs\%RH18\_mstar\_CN3 * bld * abs\_coriolis / ustar)}
\DoxyCodeLine{1830       mstar\_n = (cs\%RH18\_MStar\_cn1 *  msn\_term) / ( 1. + msn\_term)}
\DoxyCodeLine{1831 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1832     mstar\_s = cs\%RH18\_MStar\_CS1 * ( max(0.0, buoyancy\_flux)**2 * bld / \&}
\DoxyCodeLine{1833              ( ustar**5 * max(abs\_coriolis,1.e-\/20*us\%T\_to\_s) ) )**cs\%RH18\_mstar\_cs2}
\DoxyCodeLine{1834     mstar = mstar\_n + mstar\_s}
\DoxyCodeLine{1835 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1836 }
\DoxyCodeLine{1837   \textcolor{comment}{!/ 2. Adjust mstar to account for convective turbulence}}
\DoxyCodeLine{1838   \textcolor{keywordflow}{if} (cs\%answers\_2018) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1839     mstar\_conv\_red = 1. -\/ cs\%MStar\_Convect\_coef * (-\/min(0.0,buoyancy\_flux) + 1.e-\/10*us\%T\_to\_s**3*us\%m\_to\_Z**2) / \&}
\DoxyCodeLine{1840                          ( (-\/min(0.0,buoyancy\_flux) + 1.e-\/10*us\%T\_to\_s**3*us\%m\_to\_Z**2) + \&}
\DoxyCodeLine{1841                          2.0 *mstar * ustar**3 / bld )}
\DoxyCodeLine{1842   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1843     mscr\_term1 = -\/bld * min(0.0, buoyancy\_flux)}
\DoxyCodeLine{1844     mscr\_term2 = 2.0*mstar * ustar**3}
\DoxyCodeLine{1845     \textcolor{keywordflow}{if} ( abs(mscr\_term2) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1846       mstar\_conv\_red = ((1.-\/cs\%mstar\_convect\_coef) * mscr\_term1 + mscr\_term2) / (mscr\_term1 + mscr\_term2)}
\DoxyCodeLine{1847     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1848       mstar\_conv\_red = 1.-\/cs\%mstar\_convect\_coef}
\DoxyCodeLine{1849 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1850 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1851 }
\DoxyCodeLine{1852   \textcolor{comment}{!/3. Combine various mstar terms to get final value}}
\DoxyCodeLine{1853   mstar = mstar * mstar\_conv\_red}
\DoxyCodeLine{1854 }
\DoxyCodeLine{1855   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(langmuir\_number)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1856     \textcolor{comment}{!\#\#\# In this call, ustar was previously ustar\_mean.  Is this change deliberate, Brandon?  -\/RWH}}
\DoxyCodeLine{1857     \textcolor{keyword}{call }mstar\_langmuir(cs, us, abs\_coriolis, buoyancy\_flux, ustar, bld, langmuir\_number, mstar, \&}
\DoxyCodeLine{1858                         mstar\_lt, convect\_langmuir\_number)}
\DoxyCodeLine{1859 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1860 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__energetic__pbl_a786e4381a925e3c84d0e99be09295627}\label{namespacemom__energetic__pbl_a786e4381a925e3c84d0e99be09295627}} 
\index{mom\_energetic\_pbl@{mom\_energetic\_pbl}!find\_pe\_chg@{find\_pe\_chg}}
\index{find\_pe\_chg@{find\_pe\_chg}!mom\_energetic\_pbl@{mom\_energetic\_pbl}}
\doxysubsubsection{\texorpdfstring{find\_pe\_chg()}{find\_pe\_chg()}}
{\footnotesize\ttfamily subroutine mom\+\_\+energetic\+\_\+pbl\+::find\+\_\+pe\+\_\+chg (\begin{DoxyParamCaption}\item[{real, intent(in)}]{Kddt\+\_\+h0,  }\item[{real, intent(in)}]{d\+Kddt\+\_\+h,  }\item[{real, intent(in)}]{hp\+\_\+a,  }\item[{real, intent(in)}]{hp\+\_\+b,  }\item[{real, intent(in)}]{Th\+\_\+a,  }\item[{real, intent(in)}]{Sh\+\_\+a,  }\item[{real, intent(in)}]{Th\+\_\+b,  }\item[{real, intent(in)}]{Sh\+\_\+b,  }\item[{real, intent(in)}]{d\+T\+\_\+to\+\_\+d\+P\+E\+\_\+a,  }\item[{real, intent(in)}]{d\+S\+\_\+to\+\_\+d\+P\+E\+\_\+a,  }\item[{real, intent(in)}]{d\+T\+\_\+to\+\_\+d\+P\+E\+\_\+b,  }\item[{real, intent(in)}]{d\+S\+\_\+to\+\_\+d\+P\+E\+\_\+b,  }\item[{real, intent(in)}]{pres\+\_\+Z,  }\item[{real, intent(in)}]{d\+T\+\_\+to\+\_\+d\+Col\+Ht\+\_\+a,  }\item[{real, intent(in)}]{d\+S\+\_\+to\+\_\+d\+Col\+Ht\+\_\+a,  }\item[{real, intent(in)}]{d\+T\+\_\+to\+\_\+d\+Col\+Ht\+\_\+b,  }\item[{real, intent(in)}]{d\+S\+\_\+to\+\_\+d\+Col\+Ht\+\_\+b,  }\item[{real, intent(out), optional}]{P\+E\+\_\+chg,  }\item[{real, intent(out), optional}]{d\+P\+Ec\+\_\+d\+Kd,  }\item[{real, intent(out), optional}]{d\+P\+E\+\_\+max,  }\item[{real, intent(out), optional}]{d\+P\+Ec\+\_\+d\+Kd\+\_\+0,  }\item[{real, intent(out), optional}]{P\+E\+\_\+\+Col\+Ht\+\_\+cor }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine calculates the change in potential energy and or derivatives for several changes in an interfaces\textquotesingle{}s diapycnal diffusivity times a timestep. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em kddt\+\_\+h0} & The previously used diffusivity at an interface times the time step and divided by the average of the thicknesses around the interface \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em dkddt\+\_\+h} & The trial change in the diffusivity at an interface times the time step and divided by the average of the thicknesses around the interface \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em hp\+\_\+a} & The effective pivot thickness of the layer above the interface, given by h\+\_\+k plus a term that is a fraction (determined from the tridiagonal solver) of Kddt\+\_\+h for the interface above \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em hp\+\_\+b} & The effective pivot thickness of the layer below the interface, given by h\+\_\+k plus a term that is a fraction (determined from the tridiagonal solver) of Kddt\+\_\+h for the interface above \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em th\+\_\+a} & An effective temperature times a thickness in the layer above, including implicit mixing effects with other yet higher layers \mbox{[}degC H $\sim$$>$ degC m or degC kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em sh\+\_\+a} & An effective salinity times a thickness in the layer above, including implicit mixing effects with other yet higher layers \mbox{[}degC H $\sim$$>$ degC m or degC kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em th\+\_\+b} & An effective temperature times a thickness in the layer below, including implicit mixfing effects with other yet lower layers \mbox{[}degC H $\sim$$>$ degC m or degC kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em sh\+\_\+b} & An effective salinity times a thickness in the layer below, including implicit mixing effects with other yet lower layers \mbox{[}degC H $\sim$$>$ degC m or degC kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em dt\+\_\+to\+\_\+dpe\+\_\+a} & A factor (pres\+\_\+lay$\ast$mass\+\_\+lay$\ast$d\+Spec\+\_\+vol/dT) relating a layer\textquotesingle{}s temperature change to the change in column potential energy, including all implicit diffusive changes in the temperatures of all the layers above \mbox{[}R Z3 T-\/2 deg\+C-\/1 $\sim$$>$ J m-\/2 deg\+C-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em ds\+\_\+to\+\_\+dpe\+\_\+a} & A factor (pres\+\_\+lay$\ast$mass\+\_\+lay$\ast$d\+Spec\+\_\+vol/dS) relating a layer\textquotesingle{}s salinity change to the change in column potential energy, including all implicit diffusive changes in the salinities of all the layers above \mbox{[}R Z3 T-\/2 ppt-\/1 $\sim$$>$ J m-\/2 ppt-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em dt\+\_\+to\+\_\+dpe\+\_\+b} & A factor (pres\+\_\+lay$\ast$mass\+\_\+lay$\ast$d\+Spec\+\_\+vol/dT) relating a layer\textquotesingle{}s temperature change to the change in column potential energy, including all implicit diffusive changes in the temperatures of all the layers below \mbox{[}R Z3 T-\/2 deg\+C-\/1 $\sim$$>$ J m-\/2 deg\+C-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em ds\+\_\+to\+\_\+dpe\+\_\+b} & A factor (pres\+\_\+lay$\ast$mass\+\_\+lay$\ast$d\+Spec\+\_\+vol/dS) relating a layer\textquotesingle{}s salinity change to the change in column potential energy, including all implicit diffusive changes in the salinities of all the layers below \mbox{[}R Z3 T-\/2 ppt-\/1 $\sim$$>$ J m-\/2 ppt-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em pres\+\_\+z} & The rescaled hydrostatic interface pressure, which relates the changes in column thickness to the energy that is radiated as gravity waves and unavailable to drive mixing \mbox{[}R Z2 T-\/2 $\sim$$>$ J m-\/3\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em dt\+\_\+to\+\_\+dcolht\+\_\+a} & A factor (mass\+\_\+lay$\ast$d\+S\+Col\+Htc\+\_\+vol/dT) relating a layer\textquotesingle{}s temperature change to the change in column height, including all implicit diffusive changes in the temperatures of all the layers above \mbox{[}Z deg\+C-\/1 $\sim$$>$ m deg\+C-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em ds\+\_\+to\+\_\+dcolht\+\_\+a} & A factor (mass\+\_\+lay$\ast$d\+S\+Col\+Htc\+\_\+vol/dS) relating a layer\textquotesingle{}s salinity change to the change in column height, including all implicit diffusive changes in the salinities of all the layers above \mbox{[}Z ppt-\/1 $\sim$$>$ m ppt-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em dt\+\_\+to\+\_\+dcolht\+\_\+b} & A factor (mass\+\_\+lay$\ast$d\+S\+Col\+Htc\+\_\+vol/dT) relating a layer\textquotesingle{}s temperature change to the change in column height, including all implicit diffusive changes in the temperatures of all the layers below \mbox{[}Z deg\+C-\/1 $\sim$$>$ m deg\+C-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em ds\+\_\+to\+\_\+dcolht\+\_\+b} & A factor (mass\+\_\+lay$\ast$d\+S\+Col\+Htc\+\_\+vol/dS) relating a layer\textquotesingle{}s salinity change to the change in column height, including all implicit diffusive changes in the salinities of all the layers below \mbox{[}Z ppt-\/1 $\sim$$>$ m ppt-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em pe\+\_\+chg} & The change in column potential energy from applying Kddt\+\_\+h at the present interface \mbox{[}R Z3 T-\/2 $\sim$$>$ J m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em dpec\+\_\+dkd} & The partial derivative of P\+E\+\_\+chg with Kddt\+\_\+h \mbox{[}R Z3 T-\/2 H-\/1 $\sim$$>$ J m-\/3 or J kg-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em dpe\+\_\+max} & The maximum change in column potential energy that could be realizedd by applying a huge value of Kddt\+\_\+h at the present interface \mbox{[}R Z3 T-\/2 $\sim$$>$ J m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em dpec\+\_\+dkd\+\_\+0} & The partial derivative of P\+E\+\_\+chg with Kddt\+\_\+h in the limit where Kddt\+\_\+h = 0 \mbox{[}R Z3 T-\/2 H-\/1 $\sim$$>$ J m-\/3 or J kg-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em pe\+\_\+colht\+\_\+cor} & The correction to P\+E\+\_\+chg that is made due to a net change in the column height \mbox{[}R Z3 T-\/2 $\sim$$>$ J m-\/2\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 1479 of file M\+O\+M\+\_\+energetic\+\_\+\+P\+B\+L.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1479 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: Kddt\_h0\textcolor{comment}{  !< The previously used diffusivity at an interface times}}
\DoxyCodeLine{1480 \textcolor{comment}{                                !! the time step and  divided by the average of the}}
\DoxyCodeLine{1481 \textcolor{comment}{                                !! thicknesses around the interface [H ~> m or kg m-\/2].}}
\DoxyCodeLine{1482 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: dKddt\_h\textcolor{comment}{  !< The trial change in the diffusivity at an interface times}}
\DoxyCodeLine{1483 \textcolor{comment}{                                !! the time step and  divided by the average of the}}
\DoxyCodeLine{1484 \textcolor{comment}{                                !! thicknesses around the interface [H ~> m or kg m-\/2].}}
\DoxyCodeLine{1485 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: hp\_a\textcolor{comment}{     !< The effective pivot thickness of the layer above the}}
\DoxyCodeLine{1486 \textcolor{comment}{                                !! interface, given by h\_k plus a term that}}
\DoxyCodeLine{1487 \textcolor{comment}{                                !! is a fraction (determined from the tridiagonal solver) of}}
\DoxyCodeLine{1488 \textcolor{comment}{                                !! Kddt\_h for the interface above [H ~> m or kg m-\/2].}}
\DoxyCodeLine{1489 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: hp\_b\textcolor{comment}{     !< The effective pivot thickness of the layer below the}}
\DoxyCodeLine{1490 \textcolor{comment}{                                !! interface, given by h\_k plus a term that}}
\DoxyCodeLine{1491 \textcolor{comment}{                                !! is a fraction (determined from the tridiagonal solver) of}}
\DoxyCodeLine{1492 \textcolor{comment}{                                !! Kddt\_h for the interface above [H ~> m or kg m-\/2].}}
\DoxyCodeLine{1493 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: Th\_a\textcolor{comment}{     !< An effective temperature times a thickness in the layer}}
\DoxyCodeLine{1494 \textcolor{comment}{                                !! above, including implicit mixing effects with other}}
\DoxyCodeLine{1495 \textcolor{comment}{                                !! yet higher layers [degC H ~> degC m or degC kg m-\/2].}}
\DoxyCodeLine{1496 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: Sh\_a\textcolor{comment}{     !< An effective salinity times a thickness in the layer}}
\DoxyCodeLine{1497 \textcolor{comment}{                                !! above, including implicit mixing effects with other}}
\DoxyCodeLine{1498 \textcolor{comment}{                                !! yet higher layers [degC H ~> degC m or degC kg m-\/2].}}
\DoxyCodeLine{1499 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: Th\_b\textcolor{comment}{     !< An effective temperature times a thickness in the layer}}
\DoxyCodeLine{1500 \textcolor{comment}{                                !! below, including implicit mixfing effects with other}}
\DoxyCodeLine{1501 \textcolor{comment}{                                !! yet lower layers [degC H ~> degC m or degC kg m-\/2].}}
\DoxyCodeLine{1502 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: Sh\_b\textcolor{comment}{     !< An effective salinity times a thickness in the layer}}
\DoxyCodeLine{1503 \textcolor{comment}{                                !! below, including implicit mixing effects with other}}
\DoxyCodeLine{1504 \textcolor{comment}{                                !! yet lower layers [degC H ~> degC m or degC kg m-\/2].}}
\DoxyCodeLine{1505 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: dT\_to\_dPE\_a\textcolor{comment}{ !< A factor (pres\_lay*mass\_lay*dSpec\_vol/dT) relating}}
\DoxyCodeLine{1506 \textcolor{comment}{                                !! a layer's temperature change to the change in column potential}}
\DoxyCodeLine{1507 \textcolor{comment}{                                !! energy, including all implicit diffusive changes in the}}
\DoxyCodeLine{1508 \textcolor{comment}{                                !! temperatures of all the layers above [R Z3 T-\/2 degC-\/1 ~> J m-\/2 degC-\/1].}}
\DoxyCodeLine{1509 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: dS\_to\_dPE\_a\textcolor{comment}{ !< A factor (pres\_lay*mass\_lay*dSpec\_vol/dS) relating}}
\DoxyCodeLine{1510 \textcolor{comment}{                                !! a layer's salinity change to the change in column potential}}
\DoxyCodeLine{1511 \textcolor{comment}{                                !! energy, including all implicit diffusive changes in the}}
\DoxyCodeLine{1512 \textcolor{comment}{                                !! salinities of all the layers above [R Z3 T-\/2 ppt-\/1 ~> J m-\/2 ppt-\/1].}}
\DoxyCodeLine{1513 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: dT\_to\_dPE\_b\textcolor{comment}{ !< A factor (pres\_lay*mass\_lay*dSpec\_vol/dT) relating}}
\DoxyCodeLine{1514 \textcolor{comment}{                                !! a layer's temperature change to the change in column potential}}
\DoxyCodeLine{1515 \textcolor{comment}{                                !! energy, including all implicit diffusive changes in the}}
\DoxyCodeLine{1516 \textcolor{comment}{                                !! temperatures of all the layers below [R Z3 T-\/2 degC-\/1 ~> J m-\/2 degC-\/1].}}
\DoxyCodeLine{1517 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: dS\_to\_dPE\_b\textcolor{comment}{ !< A factor (pres\_lay*mass\_lay*dSpec\_vol/dS) relating}}
\DoxyCodeLine{1518 \textcolor{comment}{                                !! a layer's salinity change to the change in column potential}}
\DoxyCodeLine{1519 \textcolor{comment}{                                !! energy, including all implicit diffusive changes in the}}
\DoxyCodeLine{1520 \textcolor{comment}{                                !! salinities of all the layers below [R Z3 T-\/2 ppt-\/1 ~> J m-\/2 ppt-\/1].}}
\DoxyCodeLine{1521 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: pres\_Z\textcolor{comment}{   !< The rescaled hydrostatic interface pressure, which relates}}
\DoxyCodeLine{1522 \textcolor{comment}{                                !! the changes in column thickness to the energy that is radiated}}
\DoxyCodeLine{1523 \textcolor{comment}{                                !! as gravity waves and unavailable to drive mixing [R Z2 T-\/2 ~> J m-\/3].}}
\DoxyCodeLine{1524 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: dT\_to\_dColHt\_a\textcolor{comment}{ !< A factor (mass\_lay*dSColHtc\_vol/dT) relating}}
\DoxyCodeLine{1525 \textcolor{comment}{                                !! a layer's temperature change to the change in column}}
\DoxyCodeLine{1526 \textcolor{comment}{                                !! height, including all implicit diffusive changes}}
\DoxyCodeLine{1527 \textcolor{comment}{                                !! in the temperatures of all the layers above [Z degC-\/1 ~> m degC-\/1].}}
\DoxyCodeLine{1528 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: dS\_to\_dColHt\_a\textcolor{comment}{ !< A factor (mass\_lay*dSColHtc\_vol/dS) relating}}
\DoxyCodeLine{1529 \textcolor{comment}{                                !! a layer's salinity change to the change in column}}
\DoxyCodeLine{1530 \textcolor{comment}{                                !! height, including all implicit diffusive changes}}
\DoxyCodeLine{1531 \textcolor{comment}{                                !! in the salinities of all the layers above [Z ppt-\/1 ~> m ppt-\/1].}}
\DoxyCodeLine{1532 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: dT\_to\_dColHt\_b\textcolor{comment}{ !< A factor (mass\_lay*dSColHtc\_vol/dT) relating}}
\DoxyCodeLine{1533 \textcolor{comment}{                                !! a layer's temperature change to the change in column}}
\DoxyCodeLine{1534 \textcolor{comment}{                                !! height, including all implicit diffusive changes}}
\DoxyCodeLine{1535 \textcolor{comment}{                                !! in the temperatures of all the layers below [Z degC-\/1 ~> m degC-\/1].}}
\DoxyCodeLine{1536 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: dS\_to\_dColHt\_b\textcolor{comment}{ !< A factor (mass\_lay*dSColHtc\_vol/dS) relating}}
\DoxyCodeLine{1537 \textcolor{comment}{                                !! a layer's salinity change to the change in column}}
\DoxyCodeLine{1538 \textcolor{comment}{                                !! height, including all implicit diffusive changes}}
\DoxyCodeLine{1539 \textcolor{comment}{                                !! in the salinities of all the layers below [Z ppt-\/1 ~> m ppt-\/1].}}
\DoxyCodeLine{1540 }
\DoxyCodeLine{1541 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: PE\_chg\textcolor{comment}{   !< The change in column potential energy from applying}}
\DoxyCodeLine{1542 \textcolor{comment}{                                          !! Kddt\_h at the present interface [R Z3 T-\/2 ~> J m-\/2].}}
\DoxyCodeLine{1543 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: dPEc\_dKd\textcolor{comment}{ !< The partial derivative of PE\_chg with Kddt\_h}}
\DoxyCodeLine{1544 \textcolor{comment}{                                          !! [R Z3 T-\/2 H-\/1 ~> J m-\/3 or J kg-\/1].}}
\DoxyCodeLine{1545 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: dPE\_max\textcolor{comment}{  !< The maximum change in column potential energy that could}}
\DoxyCodeLine{1546 \textcolor{comment}{                                          !! be realizedd by applying a huge value of Kddt\_h at the}}
\DoxyCodeLine{1547 \textcolor{comment}{                                          !! present interface [R Z3 T-\/2 ~> J m-\/2].}}
\DoxyCodeLine{1548 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: dPEc\_dKd\_0\textcolor{comment}{ !< The partial derivative of PE\_chg with Kddt\_h in the}}
\DoxyCodeLine{1549 \textcolor{comment}{                                            !! limit where Kddt\_h = 0 [R Z3 T-\/2 H-\/1 ~> J m-\/3 or J kg-\/1].}}
\DoxyCodeLine{1550 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: PE\_ColHt\_cor\textcolor{comment}{ !< The correction to PE\_chg that is made due to a net}}
\DoxyCodeLine{1551 \textcolor{comment}{                                            !! change in the column height [R Z3 T-\/2 ~> J m-\/2].}}
\DoxyCodeLine{1552 }
\DoxyCodeLine{1553 \textcolor{keywordtype}{  real} :: hps \textcolor{comment}{! The sum of the two effective pivot thicknesses [H ~> m or kg m-\/2].}}
\DoxyCodeLine{1554 \textcolor{keywordtype}{  real} :: bdt1 \textcolor{comment}{! A product of the two pivot thicknesses plus a diffusive term [H2 ~> m2 or kg2 m-\/4].}}
\DoxyCodeLine{1555 \textcolor{keywordtype}{  real} :: dT\_c \textcolor{comment}{! The core term in the expressions for the temperature changes [degC H2 ~> degC m2 or degC kg2 m-\/4].}}
\DoxyCodeLine{1556 \textcolor{keywordtype}{  real} :: dS\_c \textcolor{comment}{! The core term in the expressions for the salinity changes [ppt H2 ~> ppt m2 or ppt kg2 m-\/4].}}
\DoxyCodeLine{1557 \textcolor{keywordtype}{  real} :: PEc\_core \textcolor{comment}{! The diffusivity-\/independent core term in the expressions}}
\DoxyCodeLine{1558                    \textcolor{comment}{! for the potential energy changes [R Z2 T-\/2 ~> J m-\/3].}}
\DoxyCodeLine{1559 \textcolor{keywordtype}{  real} :: ColHt\_core \textcolor{comment}{! The diffusivity-\/independent core term in the expressions}}
\DoxyCodeLine{1560                      \textcolor{comment}{! for the column height changes [H Z ~> m2 or kg m-\/1].}}
\DoxyCodeLine{1561 \textcolor{keywordtype}{  real} :: ColHt\_chg  \textcolor{comment}{! The change in the column height [H ~> m or kg m-\/2].}}
\DoxyCodeLine{1562 \textcolor{keywordtype}{  real} :: y1\_3 \textcolor{comment}{! A local temporary term in [H-\/3 ~> m-\/3 or m6 kg-\/3].}}
\DoxyCodeLine{1563 \textcolor{keywordtype}{  real} :: y1\_4 \textcolor{comment}{! A local temporary term in [H-\/4 ~> m-\/4 or m8 kg-\/4].}}
\DoxyCodeLine{1564 }
\DoxyCodeLine{1565   \textcolor{comment}{!   The expression for the change in potential energy used here is derived}}
\DoxyCodeLine{1566   \textcolor{comment}{! from the expression for the final estimates of the changes in temperature}}
\DoxyCodeLine{1567   \textcolor{comment}{! and salinities, and then extensively manipulated to get it into its most}}
\DoxyCodeLine{1568   \textcolor{comment}{! succint form. The derivation is not necessarily obvious, but it demonstrably}}
\DoxyCodeLine{1569   \textcolor{comment}{! works by comparison with separate calculations of the energy changes after}}
\DoxyCodeLine{1570   \textcolor{comment}{! the tridiagonal solver for the final changes in temperature and salinity are}}
\DoxyCodeLine{1571   \textcolor{comment}{! applied.}}
\DoxyCodeLine{1572 }
\DoxyCodeLine{1573   hps = hp\_a + hp\_b}
\DoxyCodeLine{1574   bdt1 = hp\_a * hp\_b + kddt\_h0 * hps}
\DoxyCodeLine{1575   dt\_c = hp\_a * th\_b -\/ hp\_b * th\_a}
\DoxyCodeLine{1576   ds\_c = hp\_a * sh\_b -\/ hp\_b * sh\_a}
\DoxyCodeLine{1577   pec\_core = hp\_b * (dt\_to\_dpe\_a * dt\_c + ds\_to\_dpe\_a * ds\_c) -\/ \&}
\DoxyCodeLine{1578              hp\_a * (dt\_to\_dpe\_b * dt\_c + ds\_to\_dpe\_b * ds\_c)}
\DoxyCodeLine{1579   colht\_core = hp\_b * (dt\_to\_dcolht\_a * dt\_c + ds\_to\_dcolht\_a * ds\_c) -\/ \&}
\DoxyCodeLine{1580                hp\_a * (dt\_to\_dcolht\_b * dt\_c + ds\_to\_dcolht\_b * ds\_c)}
\DoxyCodeLine{1581 }
\DoxyCodeLine{1582   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(pe\_chg)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1583     \textcolor{comment}{! Find the change in column potential energy due to the change in the}}
\DoxyCodeLine{1584     \textcolor{comment}{! diffusivity at this interface by dKddt\_h.}}
\DoxyCodeLine{1585     y1\_3 = dkddt\_h / (bdt1 * (bdt1 + dkddt\_h * hps))}
\DoxyCodeLine{1586     pe\_chg = pec\_core * y1\_3}
\DoxyCodeLine{1587     colht\_chg = colht\_core * y1\_3}
\DoxyCodeLine{1588     \textcolor{keywordflow}{if} (colht\_chg < 0.0) pe\_chg = pe\_chg -\/ pres\_z * colht\_chg}
\DoxyCodeLine{1589     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(pe\_colht\_cor)) pe\_colht\_cor = -\/pres\_z * min(colht\_chg, 0.0)}
\DoxyCodeLine{1590   \textcolor{keywordflow}{elseif} (\textcolor{keyword}{present}(pe\_colht\_cor)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1591     y1\_3 = dkddt\_h / (bdt1 * (bdt1 + dkddt\_h * hps))}
\DoxyCodeLine{1592     pe\_colht\_cor = -\/pres\_z * min(colht\_core * y1\_3, 0.0)}
\DoxyCodeLine{1593 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1594 }
\DoxyCodeLine{1595   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dpec\_dkd)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1596     \textcolor{comment}{! Find the derivative of the potential energy change with dKddt\_h.}}
\DoxyCodeLine{1597     y1\_4 = 1.0 / (bdt1 + dkddt\_h * hps)**2}
\DoxyCodeLine{1598     dpec\_dkd = pec\_core * y1\_4}
\DoxyCodeLine{1599     colht\_chg = colht\_core * y1\_4}
\DoxyCodeLine{1600     \textcolor{keywordflow}{if} (colht\_chg < 0.0) dpec\_dkd = dpec\_dkd -\/ pres\_z * colht\_chg}
\DoxyCodeLine{1601 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1602 }
\DoxyCodeLine{1603   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dpe\_max)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1604     \textcolor{comment}{! This expression is the limit of PE\_chg for infinite dKddt\_h.}}
\DoxyCodeLine{1605     y1\_3 = 1.0 / (bdt1 * hps)}
\DoxyCodeLine{1606     dpe\_max = pec\_core * y1\_3}
\DoxyCodeLine{1607     colht\_chg = colht\_core * y1\_3}
\DoxyCodeLine{1608     \textcolor{keywordflow}{if} (colht\_chg < 0.0) dpe\_max = dpe\_max -\/ pres\_z * colht\_chg}
\DoxyCodeLine{1609 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1610 }
\DoxyCodeLine{1611   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dpec\_dkd\_0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1612     \textcolor{comment}{! This expression is the limit of dPEc\_dKd for dKddt\_h = 0.}}
\DoxyCodeLine{1613     y1\_4 = 1.0 / bdt1**2}
\DoxyCodeLine{1614     dpec\_dkd\_0 = pec\_core * y1\_4}
\DoxyCodeLine{1615     colht\_chg = colht\_core * y1\_4}
\DoxyCodeLine{1616     \textcolor{keywordflow}{if} (colht\_chg < 0.0) dpec\_dkd\_0 = dpec\_dkd\_0 -\/ pres\_z * colht\_chg}
\DoxyCodeLine{1617 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1618 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__energetic__pbl_a3eb660658d0677c55c6187dcf4a180b5}\label{namespacemom__energetic__pbl_a3eb660658d0677c55c6187dcf4a180b5}} 
\index{mom\_energetic\_pbl@{mom\_energetic\_pbl}!find\_pe\_chg\_orig@{find\_pe\_chg\_orig}}
\index{find\_pe\_chg\_orig@{find\_pe\_chg\_orig}!mom\_energetic\_pbl@{mom\_energetic\_pbl}}
\doxysubsubsection{\texorpdfstring{find\_pe\_chg\_orig()}{find\_pe\_chg\_orig()}}
{\footnotesize\ttfamily subroutine mom\+\_\+energetic\+\_\+pbl\+::find\+\_\+pe\+\_\+chg\+\_\+orig (\begin{DoxyParamCaption}\item[{real, intent(in)}]{Kddt\+\_\+h,  }\item[{real, intent(in)}]{h\+\_\+k,  }\item[{real, intent(in)}]{b\+\_\+den\+\_\+1,  }\item[{real, intent(in)}]{d\+Te\+\_\+term,  }\item[{real, intent(in)}]{d\+Se\+\_\+term,  }\item[{real, intent(in)}]{d\+T\+\_\+km1\+\_\+t2,  }\item[{real, intent(in)}]{d\+S\+\_\+km1\+\_\+t2,  }\item[{real, intent(in)}]{d\+T\+\_\+to\+\_\+d\+P\+E\+\_\+k,  }\item[{real, intent(in)}]{d\+S\+\_\+to\+\_\+d\+P\+E\+\_\+k,  }\item[{real, intent(in)}]{d\+T\+\_\+to\+\_\+d\+P\+Ea,  }\item[{real, intent(in)}]{d\+S\+\_\+to\+\_\+d\+P\+Ea,  }\item[{real, intent(in)}]{pres\+\_\+Z,  }\item[{real, intent(in)}]{d\+T\+\_\+to\+\_\+d\+Col\+Ht\+\_\+k,  }\item[{real, intent(in)}]{d\+S\+\_\+to\+\_\+d\+Col\+Ht\+\_\+k,  }\item[{real, intent(in)}]{d\+T\+\_\+to\+\_\+d\+Col\+Hta,  }\item[{real, intent(in)}]{d\+S\+\_\+to\+\_\+d\+Col\+Hta,  }\item[{real, intent(out), optional}]{P\+E\+\_\+chg,  }\item[{real, intent(out), optional}]{d\+P\+Ec\+\_\+d\+Kd,  }\item[{real, intent(out), optional}]{d\+P\+E\+\_\+max,  }\item[{real, intent(out), optional}]{d\+P\+Ec\+\_\+d\+Kd\+\_\+0 }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine calculates the change in potential energy and or derivatives for several changes in an interfaces\textquotesingle{}s diapycnal diffusivity times a timestep using the original form used in the first version of e\+P\+BL. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em kddt\+\_\+h} & The diffusivity at an interface times the time step and divided by the average of the thicknesses around the interface \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+k} & The thickness of the layer below the interface \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em b\+\_\+den\+\_\+1} & The first term in the denominator of the pivot for the tridiagonal solver, given by h\+\_\+k plus a term that is a fraction (determined from the tridiagonal solver) of Kddt\+\_\+h for the interface above \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em dte\+\_\+term} & A diffusivity-\/independent term related to the temperature change in the layer below the interface \mbox{[}degC H $\sim$$>$ degC m or degC kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em dse\+\_\+term} & A diffusivity-\/independent term related to the salinity change in the layer below the interface \mbox{[}ppt H $\sim$$>$ ppt m or ppt kg m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em dt\+\_\+km1\+\_\+t2} & A diffusivity-\/independent term related to the temperature change in the layer above the interface \mbox{[}degC\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em ds\+\_\+km1\+\_\+t2} & A diffusivity-\/independent term related to the salinity change in the layer above the interface \mbox{[}ppt\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em pres\+\_\+z} & The rescaled hydrostatic interface pressure, which relates the changes in column thickness to the energy that is radiated as gravity waves and unavailable to drive mixing \mbox{[}R Z2 T-\/2 $\sim$$>$ J m-\/3\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em dt\+\_\+to\+\_\+dpe\+\_\+k} & A factor (pres\+\_\+lay$\ast$mass\+\_\+lay$\ast$d\+Spec\+\_\+vol/dT) relating a layer\textquotesingle{}s temperature change to the change in column potential energy, including all implicit diffusive changes in the temperatures of all the layers below \mbox{[}R Z3 T-\/2 deg\+C-\/1 $\sim$$>$ J m-\/2 deg\+C-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em ds\+\_\+to\+\_\+dpe\+\_\+k} & A factor (pres\+\_\+lay$\ast$mass\+\_\+lay$\ast$d\+Spec\+\_\+vol/dS) relating a layer\textquotesingle{}s salinity change to the change in column potential energy, including all implicit diffusive changes in the in the salinities of all the layers below \mbox{[}R Z3 T-\/2 ppt-\/1 $\sim$$>$ J m-\/2 ppt-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em dt\+\_\+to\+\_\+dpea} & A factor (pres\+\_\+lay$\ast$mass\+\_\+lay$\ast$d\+Spec\+\_\+vol/dT) relating a layer\textquotesingle{}s temperature change to the change in column potential energy, including all implicit diffusive changes in the temperatures of all the layers above \mbox{[}R Z3 T-\/2 deg\+C-\/1 $\sim$$>$ J m-\/2 deg\+C-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em ds\+\_\+to\+\_\+dpea} & A factor (pres\+\_\+lay$\ast$mass\+\_\+lay$\ast$d\+Spec\+\_\+vol/dS) relating a layer\textquotesingle{}s salinity change to the change in column potential energy, including all implicit diffusive changes in the salinities of all the layers above \mbox{[}R Z3 T-\/2 ppt-\/1 $\sim$$>$ J m-\/2 ppt-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em dt\+\_\+to\+\_\+dcolht\+\_\+k} & A factor (mass\+\_\+lay$\ast$d\+S\+Col\+Htc\+\_\+vol/dT) relating a layer\textquotesingle{}s temperature change to the change in column height, including all implicit diffusive changes in the temperatures of all the layers below \mbox{[}Z deg\+C-\/1 $\sim$$>$ m deg\+C-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em ds\+\_\+to\+\_\+dcolht\+\_\+k} & A factor (mass\+\_\+lay$\ast$d\+S\+Col\+Htc\+\_\+vol/dS) relating a layer\textquotesingle{}s salinity change to the change in column height, including all implicit diffusive changes in the salinities of all the layers below \mbox{[}Z ppt-\/1 $\sim$$>$ m ppt-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em dt\+\_\+to\+\_\+dcolhta} & A factor (mass\+\_\+lay$\ast$d\+S\+Col\+Htc\+\_\+vol/dT) relating a layer\textquotesingle{}s temperature change to the change in column height, including all implicit diffusive changes in the temperatures of all the layers above \mbox{[}Z deg\+C-\/1 $\sim$$>$ m deg\+C-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em ds\+\_\+to\+\_\+dcolhta} & A factor (mass\+\_\+lay$\ast$d\+S\+Col\+Htc\+\_\+vol/dS) relating a layer\textquotesingle{}s salinity change to the change in column height, including all implicit diffusive changes in the salinities of all the layers above \mbox{[}Z ppt-\/1 $\sim$$>$ m ppt-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em pe\+\_\+chg} & The change in column potential energy from applying Kddt\+\_\+h at the present interface \mbox{[}R Z3 T-\/2 $\sim$$>$ J m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em dpec\+\_\+dkd} & The partial derivative of P\+E\+\_\+chg with Kddt\+\_\+h \mbox{[}R Z3 T-\/2 H-\/1 $\sim$$>$ J m-\/3 or J kg-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em dpe\+\_\+max} & The maximum change in column potential energy that could be realizedd by applying a huge value of Kddt\+\_\+h at the present interface \mbox{[}R Z3 T-\/2 $\sim$$>$ J m-\/2\mbox{]}. \\
\hline
\mbox{\texttt{ out}}  & {\em dpec\+\_\+dkd\+\_\+0} & The partial derivative of P\+E\+\_\+chg with Kddt\+\_\+h in the limit where Kddt\+\_\+h = 0 \mbox{[}R Z3 T-\/2 H-\/1 $\sim$$>$ J m-\/3 or J kg-\/1\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 1629 of file M\+O\+M\+\_\+energetic\+\_\+\+P\+B\+L.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1629 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: Kddt\_h\textcolor{comment}{   !< The diffusivity at an interface times the time step and}}
\DoxyCodeLine{1630 \textcolor{comment}{                                !! divided by the average of the thicknesses around the}}
\DoxyCodeLine{1631 \textcolor{comment}{                                !! interface [H ~> m or kg m-\/2].}}
\DoxyCodeLine{1632 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: h\_k\textcolor{comment}{      !< The thickness of the layer below the interface [H ~> m or kg m-\/2].}}
\DoxyCodeLine{1633 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: b\_den\_1\textcolor{comment}{  !< The first term in the denominator of the pivot}}
\DoxyCodeLine{1634 \textcolor{comment}{                                !! for the tridiagonal solver, given by h\_k plus a term that}}
\DoxyCodeLine{1635 \textcolor{comment}{                                !! is a fraction (determined from the tridiagonal solver) of}}
\DoxyCodeLine{1636 \textcolor{comment}{                                !! Kddt\_h for the interface above [H ~> m or kg m-\/2].}}
\DoxyCodeLine{1637 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: dTe\_term\textcolor{comment}{ !< A diffusivity-\/independent term related to the temperature change}}
\DoxyCodeLine{1638 \textcolor{comment}{                                !! in the layer below the interface [degC H ~> degC m or degC kg m-\/2].}}
\DoxyCodeLine{1639 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: dSe\_term\textcolor{comment}{ !< A diffusivity-\/independent term related to the salinity change}}
\DoxyCodeLine{1640 \textcolor{comment}{                                !! in the layer below the interface [ppt H ~> ppt m or ppt kg m-\/2].}}
\DoxyCodeLine{1641 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: dT\_km1\_t2\textcolor{comment}{ !< A diffusivity-\/independent term related to the}}
\DoxyCodeLine{1642 \textcolor{comment}{                                 !! temperature change in the layer above the interface [degC].}}
\DoxyCodeLine{1643 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: dS\_km1\_t2\textcolor{comment}{ !< A diffusivity-\/independent term related to the}}
\DoxyCodeLine{1644 \textcolor{comment}{                                 !! salinity change in the layer above the interface [ppt].}}
\DoxyCodeLine{1645 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: pres\_Z\textcolor{comment}{    !< The rescaled hydrostatic interface pressure, which relates}}
\DoxyCodeLine{1646 \textcolor{comment}{                                 !! the changes in column thickness to the energy that is radiated}}
\DoxyCodeLine{1647 \textcolor{comment}{                                 !! as gravity waves and unavailable to drive mixing [R Z2 T-\/2 ~> J m-\/3].}}
\DoxyCodeLine{1648 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: dT\_to\_dPE\_k\textcolor{comment}{ !< A factor (pres\_lay*mass\_lay*dSpec\_vol/dT) relating}}
\DoxyCodeLine{1649 \textcolor{comment}{                                 !! a layer's temperature change to the change in column potential}}
\DoxyCodeLine{1650 \textcolor{comment}{                                 !! energy, including all implicit diffusive changes in the}}
\DoxyCodeLine{1651 \textcolor{comment}{                                 !! temperatures of all the layers below [R Z3 T-\/2 degC-\/1 ~> J m-\/2 degC-\/1].}}
\DoxyCodeLine{1652 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: dS\_to\_dPE\_k\textcolor{comment}{ !< A factor (pres\_lay*mass\_lay*dSpec\_vol/dS) relating}}
\DoxyCodeLine{1653 \textcolor{comment}{                                 !! a layer's salinity change to the change in column potential}}
\DoxyCodeLine{1654 \textcolor{comment}{                                 !! energy, including all implicit diffusive changes in the}}
\DoxyCodeLine{1655 \textcolor{comment}{                                 !! in the salinities of all the layers below [R Z3 T-\/2 ppt-\/1 ~> J m-\/2 ppt-\/1].}}
\DoxyCodeLine{1656 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: dT\_to\_dPEa\textcolor{comment}{ !< A factor (pres\_lay*mass\_lay*dSpec\_vol/dT) relating}}
\DoxyCodeLine{1657 \textcolor{comment}{                                 !! a layer's temperature change to the change in column potential}}
\DoxyCodeLine{1658 \textcolor{comment}{                                 !! energy, including all implicit diffusive changes in the}}
\DoxyCodeLine{1659 \textcolor{comment}{                                 !! temperatures of all the layers above [R Z3 T-\/2 degC-\/1 ~> J m-\/2 degC-\/1].}}
\DoxyCodeLine{1660 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: dS\_to\_dPEa\textcolor{comment}{ !< A factor (pres\_lay*mass\_lay*dSpec\_vol/dS) relating}}
\DoxyCodeLine{1661 \textcolor{comment}{                                 !! a layer's salinity change to the change in column potential}}
\DoxyCodeLine{1662 \textcolor{comment}{                                 !! energy, including all implicit diffusive changes in the}}
\DoxyCodeLine{1663 \textcolor{comment}{                                 !! salinities of all the layers above [R Z3 T-\/2 ppt-\/1 ~> J m-\/2 ppt-\/1].}}
\DoxyCodeLine{1664 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: dT\_to\_dColHt\_k\textcolor{comment}{ !< A factor (mass\_lay*dSColHtc\_vol/dT) relating}}
\DoxyCodeLine{1665 \textcolor{comment}{                                 !! a layer's temperature change to the change in column}}
\DoxyCodeLine{1666 \textcolor{comment}{                                 !! height, including all implicit diffusive changes in the}}
\DoxyCodeLine{1667 \textcolor{comment}{                                 !! temperatures of all the layers below [Z degC-\/1 ~> m degC-\/1].}}
\DoxyCodeLine{1668 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: dS\_to\_dColHt\_k\textcolor{comment}{ !< A factor (mass\_lay*dSColHtc\_vol/dS) relating}}
\DoxyCodeLine{1669 \textcolor{comment}{                                 !! a layer's salinity change to the change in column}}
\DoxyCodeLine{1670 \textcolor{comment}{                                 !! height, including all implicit diffusive changes}}
\DoxyCodeLine{1671 \textcolor{comment}{                                 !! in the salinities of all the layers below [Z ppt-\/1 ~> m ppt-\/1].}}
\DoxyCodeLine{1672 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: dT\_to\_dColHta\textcolor{comment}{ !< A factor (mass\_lay*dSColHtc\_vol/dT) relating}}
\DoxyCodeLine{1673 \textcolor{comment}{                                 !! a layer's temperature change to the change in column}}
\DoxyCodeLine{1674 \textcolor{comment}{                                 !! height, including all implicit diffusive changes}}
\DoxyCodeLine{1675 \textcolor{comment}{                                 !! in the temperatures of all the layers above [Z degC-\/1 ~> m degC-\/1].}}
\DoxyCodeLine{1676 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)}  :: dS\_to\_dColHta\textcolor{comment}{ !< A factor (mass\_lay*dSColHtc\_vol/dS) relating}}
\DoxyCodeLine{1677 \textcolor{comment}{                                 !! a layer's salinity change to the change in column}}
\DoxyCodeLine{1678 \textcolor{comment}{                                 !! height, including all implicit diffusive changes}}
\DoxyCodeLine{1679 \textcolor{comment}{                                 !! in the salinities of all the layers above [Z ppt-\/1 ~> m ppt-\/1].}}
\DoxyCodeLine{1680 }
\DoxyCodeLine{1681 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: PE\_chg\textcolor{comment}{   !< The change in column potential energy from applying}}
\DoxyCodeLine{1682 \textcolor{comment}{                                          !! Kddt\_h at the present interface [R Z3 T-\/2 ~> J m-\/2].}}
\DoxyCodeLine{1683 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: dPEc\_dKd\textcolor{comment}{ !< The partial derivative of PE\_chg with Kddt\_h}}
\DoxyCodeLine{1684 \textcolor{comment}{                                          !! [R Z3 T-\/2 H-\/1 ~> J m-\/3 or J kg-\/1].}}
\DoxyCodeLine{1685 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: dPE\_max\textcolor{comment}{  !< The maximum change in column potential energy that could}}
\DoxyCodeLine{1686 \textcolor{comment}{                                          !! be realizedd by applying a huge value of Kddt\_h at the}}
\DoxyCodeLine{1687 \textcolor{comment}{                                          !! present interface [R Z3 T-\/2 ~> J m-\/2].}}
\DoxyCodeLine{1688 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: dPEc\_dKd\_0\textcolor{comment}{ !< The partial derivative of PE\_chg with Kddt\_h in the}}
\DoxyCodeLine{1689 \textcolor{comment}{                                          !! limit where Kddt\_h = 0 [R Z3 T-\/2 H-\/1 ~> J m-\/3 or J kg-\/1].}}
\DoxyCodeLine{1690 }
\DoxyCodeLine{1691 \textcolor{comment}{!   This subroutine determines the total potential energy change due to mixing}}
\DoxyCodeLine{1692 \textcolor{comment}{! at an interface, including all of the implicit effects of the prescribed}}
\DoxyCodeLine{1693 \textcolor{comment}{! mixing at interfaces above.  Everything here is derived by careful manipulation}}
\DoxyCodeLine{1694 \textcolor{comment}{! of the robust tridiagonal solvers used for tracers by MOM6.  The results are}}
\DoxyCodeLine{1695 \textcolor{comment}{! positive for mixing in a stably stratified environment.}}
\DoxyCodeLine{1696 \textcolor{comment}{!   The comments describing these arguments are for a downward mixing pass, but}}
\DoxyCodeLine{1697 \textcolor{comment}{! this routine can also be used for an upward pass with the sense of direction}}
\DoxyCodeLine{1698 \textcolor{comment}{! reversed.}}
\DoxyCodeLine{1699 }
\DoxyCodeLine{1700 \textcolor{keywordtype}{  real} :: b1            \textcolor{comment}{! b1 is used by the tridiagonal solver [H-\/1 ~> m-\/1 or m2 kg-\/1].}}
\DoxyCodeLine{1701 \textcolor{keywordtype}{  real} :: b1Kd          \textcolor{comment}{! Temporary array [nondim]}}
\DoxyCodeLine{1702 \textcolor{keywordtype}{  real} :: ColHt\_chg     \textcolor{comment}{! The change in column thickness [Z ~> m].}}
\DoxyCodeLine{1703 \textcolor{keywordtype}{  real} :: dColHt\_max    \textcolor{comment}{! The change in column thickness for infinite diffusivity [Z ~> m].}}
\DoxyCodeLine{1704 \textcolor{keywordtype}{  real} :: dColHt\_dKd    \textcolor{comment}{! The partial derivative of column thickness with Kddt\_h [Z H-\/1 ~> 1 or m3 kg-\/2].}}
\DoxyCodeLine{1705 \textcolor{keywordtype}{  real} :: dT\_k, dT\_km1  \textcolor{comment}{! Temporary arrays [degC].}}
\DoxyCodeLine{1706 \textcolor{keywordtype}{  real} :: dS\_k, dS\_km1  \textcolor{comment}{! Temporary arrays [ppt].}}
\DoxyCodeLine{1707 \textcolor{keywordtype}{  real} :: I\_Kr\_denom    \textcolor{comment}{! Temporary array [H-\/2 ~> m-\/2 or m4 kg-\/2]}}
\DoxyCodeLine{1708 \textcolor{keywordtype}{  real} :: dKr\_dKd       \textcolor{comment}{! Nondimensional temporary array.}}
\DoxyCodeLine{1709 \textcolor{keywordtype}{  real} :: ddT\_k\_dKd, ddT\_km1\_dKd \textcolor{comment}{! Temporary arrays [degC H-\/1 ~> m-\/1 or m2 kg-\/1].}}
\DoxyCodeLine{1710 \textcolor{keywordtype}{  real} :: ddS\_k\_dKd, ddS\_km1\_dKd \textcolor{comment}{! Temporary arrays [ppt H-\/1 ~> ppt m-\/1 or ppt m2 kg-\/1].}}
\DoxyCodeLine{1711 }
\DoxyCodeLine{1712   b1 = 1.0 / (b\_den\_1 + kddt\_h)}
\DoxyCodeLine{1713   b1kd = kddt\_h*b1}
\DoxyCodeLine{1714 }
\DoxyCodeLine{1715   \textcolor{comment}{! Start with the temperature change in layer k-\/1 due to the diffusivity at}}
\DoxyCodeLine{1716   \textcolor{comment}{! interface K without considering the effects of changes in layer k.}}
\DoxyCodeLine{1717 }
\DoxyCodeLine{1718   \textcolor{comment}{! Calculate the change in PE due to the diffusion at interface K}}
\DoxyCodeLine{1719   \textcolor{comment}{! if Kddt\_h(K+1) = 0.}}
\DoxyCodeLine{1720   i\_kr\_denom = 1.0 / (h\_k*b\_den\_1 + (b\_den\_1 + h\_k)*kddt\_h)}
\DoxyCodeLine{1721 }
\DoxyCodeLine{1722   dt\_k = (kddt\_h*i\_kr\_denom) * dte\_term}
\DoxyCodeLine{1723   ds\_k = (kddt\_h*i\_kr\_denom) * dse\_term}
\DoxyCodeLine{1724 }
\DoxyCodeLine{1725   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(pe\_chg)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1726     \textcolor{comment}{! Find the change in energy due to diffusion with strength Kddt\_h at this interface.}}
\DoxyCodeLine{1727     \textcolor{comment}{! Increment the temperature changes in layer k-\/1 due the changes in layer k.}}
\DoxyCodeLine{1728     dt\_km1 = b1kd * ( dt\_k + dt\_km1\_t2 )}
\DoxyCodeLine{1729     ds\_km1 = b1kd * ( ds\_k + ds\_km1\_t2 )}
\DoxyCodeLine{1730     pe\_chg = (dt\_to\_dpe\_k * dt\_k + dt\_to\_dpea * dt\_km1) + \&}
\DoxyCodeLine{1731              (ds\_to\_dpe\_k * ds\_k + ds\_to\_dpea * ds\_km1)}
\DoxyCodeLine{1732     colht\_chg = (dt\_to\_dcolht\_k * dt\_k + dt\_to\_dcolhta * dt\_km1) + \&}
\DoxyCodeLine{1733                 (ds\_to\_dcolht\_k * ds\_k + ds\_to\_dcolhta * ds\_km1)}
\DoxyCodeLine{1734     \textcolor{keywordflow}{if} (colht\_chg < 0.0) pe\_chg = pe\_chg -\/ pres\_z * colht\_chg}
\DoxyCodeLine{1735 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1736 }
\DoxyCodeLine{1737   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dpec\_dkd)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1738     \textcolor{comment}{! Find the derivatives of the temperature and salinity changes with Kddt\_h.}}
\DoxyCodeLine{1739     dkr\_dkd = (h\_k*b\_den\_1) * i\_kr\_denom**2}
\DoxyCodeLine{1740 }
\DoxyCodeLine{1741     ddt\_k\_dkd = dkr\_dkd * dte\_term}
\DoxyCodeLine{1742     dds\_k\_dkd = dkr\_dkd * dse\_term}
\DoxyCodeLine{1743     ddt\_km1\_dkd = (b1**2 * b\_den\_1) * ( dt\_k + dt\_km1\_t2 ) + b1kd * ddt\_k\_dkd}
\DoxyCodeLine{1744     dds\_km1\_dkd = (b1**2 * b\_den\_1) * ( ds\_k + ds\_km1\_t2 ) + b1kd * dds\_k\_dkd}
\DoxyCodeLine{1745 }
\DoxyCodeLine{1746     \textcolor{comment}{! Calculate the partial derivative of Pe\_chg with Kddt\_h.}}
\DoxyCodeLine{1747     dpec\_dkd = (dt\_to\_dpe\_k * ddt\_k\_dkd + dt\_to\_dpea * ddt\_km1\_dkd) + \&}
\DoxyCodeLine{1748                (ds\_to\_dpe\_k * dds\_k\_dkd + ds\_to\_dpea * dds\_km1\_dkd)}
\DoxyCodeLine{1749     dcolht\_dkd = (dt\_to\_dcolht\_k * ddt\_k\_dkd + dt\_to\_dcolhta * ddt\_km1\_dkd) + \&}
\DoxyCodeLine{1750                  (ds\_to\_dcolht\_k * dds\_k\_dkd + ds\_to\_dcolhta * dds\_km1\_dkd)}
\DoxyCodeLine{1751     \textcolor{keywordflow}{if} (dcolht\_dkd < 0.0) dpec\_dkd = dpec\_dkd -\/ pres\_z * dcolht\_dkd}
\DoxyCodeLine{1752 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1753 }
\DoxyCodeLine{1754   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dpe\_max)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1755     \textcolor{comment}{! This expression is the limit of PE\_chg for infinite Kddt\_h.}}
\DoxyCodeLine{1756     dpe\_max = (dt\_to\_dpea * dt\_km1\_t2 + ds\_to\_dpea * ds\_km1\_t2) + \&}
\DoxyCodeLine{1757               ((dt\_to\_dpe\_k + dt\_to\_dpea) * dte\_term + \&}
\DoxyCodeLine{1758                (ds\_to\_dpe\_k + ds\_to\_dpea) * dse\_term) / (b\_den\_1 + h\_k)}
\DoxyCodeLine{1759     dcolht\_max = (dt\_to\_dcolhta * dt\_km1\_t2 + ds\_to\_dcolhta * ds\_km1\_t2) + \&}
\DoxyCodeLine{1760               ((dt\_to\_dcolht\_k + dt\_to\_dcolhta) * dte\_term + \&}
\DoxyCodeLine{1761                (ds\_to\_dcolht\_k + ds\_to\_dcolhta) * dse\_term) / (b\_den\_1 + h\_k)}
\DoxyCodeLine{1762     \textcolor{keywordflow}{if} (dcolht\_max < 0.0) dpe\_max = dpe\_max -\/ pres\_z*dcolht\_max}
\DoxyCodeLine{1763 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1764 }
\DoxyCodeLine{1765   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dpec\_dkd\_0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1766     \textcolor{comment}{! This expression is the limit of dPEc\_dKd for Kddt\_h = 0.}}
\DoxyCodeLine{1767     dpec\_dkd\_0 = (dt\_to\_dpea * dt\_km1\_t2 + ds\_to\_dpea * ds\_km1\_t2) / (b\_den\_1) + \&}
\DoxyCodeLine{1768                  (dt\_to\_dpe\_k * dte\_term + ds\_to\_dpe\_k * dse\_term) / (h\_k*b\_den\_1)}
\DoxyCodeLine{1769     dcolht\_dkd = (dt\_to\_dcolhta * dt\_km1\_t2 + ds\_to\_dcolhta * ds\_km1\_t2) / (b\_den\_1) + \&}
\DoxyCodeLine{1770                  (dt\_to\_dcolht\_k * dte\_term + ds\_to\_dcolht\_k * dse\_term) / (h\_k*b\_den\_1)}
\DoxyCodeLine{1771     \textcolor{keywordflow}{if} (dcolht\_dkd < 0.0) dpec\_dkd\_0 = dpec\_dkd\_0 -\/ pres\_z*dcolht\_dkd}
\DoxyCodeLine{1772 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1773 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__energetic__pbl_ac7fd166f015884862a3798882ad1c977}\label{namespacemom__energetic__pbl_ac7fd166f015884862a3798882ad1c977}} 
\index{mom\_energetic\_pbl@{mom\_energetic\_pbl}!mstar\_langmuir@{mstar\_langmuir}}
\index{mstar\_langmuir@{mstar\_langmuir}!mom\_energetic\_pbl@{mom\_energetic\_pbl}}
\doxysubsubsection{\texorpdfstring{mstar\_langmuir()}{mstar\_langmuir()}}
{\footnotesize\ttfamily subroutine mom\+\_\+energetic\+\_\+pbl\+::mstar\+\_\+langmuir (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__energetic__pbl_1_1energetic__pbl__cs}{energetic\+\_\+pbl\+\_\+cs}}), pointer}]{CS,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, intent(in)}]{Abs\+\_\+\+Coriolis,  }\item[{real, intent(in)}]{Buoyancy\+\_\+\+Flux,  }\item[{real, intent(in)}]{U\+Star,  }\item[{real, intent(in)}]{B\+LD,  }\item[{real, intent(in)}]{Langmuir\+\_\+\+Number,  }\item[{real, intent(inout)}]{Mstar,  }\item[{real, intent(out)}]{M\+Star\+\_\+\+LT,  }\item[{real, intent(out)}]{Convect\+\_\+\+Langmuir\+\_\+\+Number }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine modifies the Mstar value if the Langmuir number is present. 


\begin{DoxyParams}[1]{Parameters}
 & {\em cs} & Energetic\+\_\+\+P\+BL control structure. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em abs\+\_\+coriolis} & Absolute value of the Coriolis parameter \mbox{[}T-\/1 $\sim$$>$ s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em buoyancy\+\_\+flux} & Buoyancy flux \mbox{[}Z2 T-\/3 $\sim$$>$ m2 s-\/3\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em ustar} & Surface friction velocity with? gustiness \mbox{[}Z T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em bld} & boundary layer depth \mbox{[}Z $\sim$$>$ m\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em mstar} & Input/output mstar (Mixing/ustar$\ast$$\ast$3) \mbox{[}nondim\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em langmuir\+\_\+number} & Langmuir number \mbox{[}nondim\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em mstar\+\_\+lt} & Mstar increase due to Langmuir turbulence \mbox{[}nondim\mbox{]} \\
\hline
\mbox{\texttt{ out}}  & {\em convect\+\_\+langmuir\+\_\+number} & Langmuir number including buoyancy flux \mbox{[}nondim\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 1866 of file M\+O\+M\+\_\+energetic\+\_\+\+P\+B\+L.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1866   \textcolor{keywordtype}{type}(energetic\_PBL\_CS), \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{    !< Energetic\_PBL control structure.}}
\DoxyCodeLine{1867   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{    !< A dimensional unit scaling type}}
\DoxyCodeLine{1868 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}  :: Abs\_Coriolis\textcolor{comment}{ !< Absolute value of the Coriolis parameter [T-\/1 ~> s-\/1]}}
\DoxyCodeLine{1869 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}  :: Buoyancy\_Flux\textcolor{comment}{ !< Buoyancy flux [Z2 T-\/3 ~> m2 s-\/3]}}
\DoxyCodeLine{1870 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}  :: UStar\textcolor{comment}{ !< Surface friction velocity with? gustiness [Z T-\/1 ~> m s-\/1]}}
\DoxyCodeLine{1871 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}  :: BLD\textcolor{comment}{   !< boundary layer depth [Z ~> m]}}
\DoxyCodeLine{1872 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(inout)} :: Mstar\textcolor{comment}{ !< Input/output mstar (Mixing/ustar**3) [nondim]}}
\DoxyCodeLine{1873 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}  :: Langmuir\_Number\textcolor{comment}{ !< Langmuir number [nondim]}}
\DoxyCodeLine{1874 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(out)} :: MStar\_LT\textcolor{comment}{ !< Mstar increase due to Langmuir turbulence [nondim]}}
\DoxyCodeLine{1875 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(out)} :: Convect\_Langmuir\_number\textcolor{comment}{ !< Langmuir number including buoyancy flux [nondim]}}
\DoxyCodeLine{1876 }
\DoxyCodeLine{1877   \textcolor{comment}{!/}}
\DoxyCodeLine{1878 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{parameter} :: Max\_ratio = 1.0e16  \textcolor{comment}{! The maximum value of a nondimensional ratio.}}
\DoxyCodeLine{1879 \textcolor{keywordtype}{  real} :: enhance\_mstar \textcolor{comment}{! A multiplicative scaling of mstar due to Langmuir turbulence.}}
\DoxyCodeLine{1880 \textcolor{keywordtype}{  real} :: mstar\_LT\_add \textcolor{comment}{! A value that is added to mstar due to Langmuir turbulence.}}
\DoxyCodeLine{1881 \textcolor{keywordtype}{  real} :: iL\_Ekman    \textcolor{comment}{! Inverse of Ekman length scale [Z-\/1 ~> m-\/1].}}
\DoxyCodeLine{1882 \textcolor{keywordtype}{  real} :: iL\_Obukhov  \textcolor{comment}{! Inverse of Obukhov length scale [Z-\/1 ~> m-\/1].}}
\DoxyCodeLine{1883 \textcolor{keywordtype}{  real} :: I\_ustar     \textcolor{comment}{! The Adcroft reciprocal of ustar [T Z-\/1 ~> s m-\/1]}}
\DoxyCodeLine{1884 \textcolor{keywordtype}{  real} :: I\_f         \textcolor{comment}{! The Adcroft reciprocal of the Coriolis parameter [T ~> s]}}
\DoxyCodeLine{1885 \textcolor{keywordtype}{  real} :: MLD\_Ekman          \textcolor{comment}{! The ratio of the mixed layer depth to the Ekman layer depth [nondim].}}
\DoxyCodeLine{1886 \textcolor{keywordtype}{  real} :: Ekman\_Obukhov      \textcolor{comment}{! The Ekman layer thickness divided by the Obukhov depth [nondim].}}
\DoxyCodeLine{1887 \textcolor{keywordtype}{  real} :: MLD\_Obukhov        \textcolor{comment}{! The mixed layer depth divided by the Obukhov depth [nondim].}}
\DoxyCodeLine{1888 \textcolor{keywordtype}{  real} :: MLD\_Obukhov\_stab   \textcolor{comment}{! Ratios of length scales where MLD is boundary layer depth [nondim].}}
\DoxyCodeLine{1889 \textcolor{keywordtype}{  real} :: Ekman\_Obukhov\_stab \textcolor{comment}{! >}}
\DoxyCodeLine{1890 \textcolor{keywordtype}{  real} :: MLD\_Obukhov\_un     \textcolor{comment}{! Ratios of length scales where MLD is boundary layer depth}}
\DoxyCodeLine{1891 \textcolor{keywordtype}{  real} :: Ekman\_Obukhov\_un   \textcolor{comment}{! >}}
\DoxyCodeLine{1892 }
\DoxyCodeLine{1893   \textcolor{comment}{! Set default values for no Langmuir effects.}}
\DoxyCodeLine{1894   enhance\_mstar = 1.0 ; mstar\_lt\_add = 0.0}
\DoxyCodeLine{1895 }
\DoxyCodeLine{1896   \textcolor{keywordflow}{if} (cs\%LT\_Enhance\_Form /= no\_langmuir) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1897     \textcolor{comment}{! a. Get parameters for modified LA}}
\DoxyCodeLine{1898     \textcolor{keywordflow}{if} (cs\%answers\_2018) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1899       il\_ekman   = abs\_coriolis / ustar}
\DoxyCodeLine{1900       il\_obukhov = buoyancy\_flux*cs\%vonkar / ustar**3}
\DoxyCodeLine{1901       ekman\_obukhov\_stab = abs(max(0., il\_obukhov / (il\_ekman + 1.e-\/10*us\%Z\_to\_m)))}
\DoxyCodeLine{1902       ekman\_obukhov\_un = abs(min(0., il\_obukhov / (il\_ekman + 1.e-\/10*us\%Z\_to\_m)))}
\DoxyCodeLine{1903       mld\_obukhov\_stab = abs(max(0., bld*il\_obukhov))}
\DoxyCodeLine{1904       mld\_obukhov\_un = abs(min(0., bld*il\_obukhov))}
\DoxyCodeLine{1905       mld\_ekman = abs( bld*il\_ekman )}
\DoxyCodeLine{1906     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1907       ekman\_obukhov = max\_ratio ; mld\_obukhov = max\_ratio ; mld\_ekman = max\_ratio}
\DoxyCodeLine{1908       i\_f = 0.0 ; \textcolor{keywordflow}{if} (abs(abs\_coriolis) > 0.0) i\_f = 1.0 / abs\_coriolis}
\DoxyCodeLine{1909       i\_ustar = 0.0 ; \textcolor{keywordflow}{if} (abs(ustar) > 0.0) i\_ustar = 1.0 / ustar}
\DoxyCodeLine{1910       \textcolor{keywordflow}{if} (abs(buoyancy\_flux*cs\%vonkar) < max\_ratio*(abs\_coriolis * ustar**2)) \&}
\DoxyCodeLine{1911         ekman\_obukhov = abs(buoyancy\_flux*cs\%vonkar) * (i\_f * i\_ustar**2)}
\DoxyCodeLine{1912       \textcolor{keywordflow}{if} (abs(bld*buoyancy\_flux*cs\%vonkar) < max\_ratio*ustar**3) \&}
\DoxyCodeLine{1913         mld\_obukhov = abs(bld*buoyancy\_flux*cs\%vonkar) * i\_ustar**3}
\DoxyCodeLine{1914       \textcolor{keywordflow}{if} (bld*abs\_coriolis < max\_ratio*ustar) \&}
\DoxyCodeLine{1915         mld\_ekman = bld*abs\_coriolis * i\_ustar}
\DoxyCodeLine{1916 }
\DoxyCodeLine{1917       \textcolor{keywordflow}{if} (buoyancy\_flux > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1918         ekman\_obukhov\_stab = ekman\_obukhov ; ekman\_obukhov\_un = 0.0}
\DoxyCodeLine{1919         mld\_obukhov\_stab = mld\_obukhov ; mld\_obukhov\_un = 0.0}
\DoxyCodeLine{1920       \textcolor{keywordflow}{else}}
\DoxyCodeLine{1921         ekman\_obukhov\_un = ekman\_obukhov ; ekman\_obukhov\_stab = 0.0}
\DoxyCodeLine{1922         mld\_obukhov\_un = mld\_obukhov ; mld\_obukhov\_stab = 0.0}
\DoxyCodeLine{1923 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1924 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1925 }
\DoxyCodeLine{1926     \textcolor{comment}{! b. Adjust LA based on various parameters.}}
\DoxyCodeLine{1927     \textcolor{comment}{!    Assumes linear factors based on length scale ratios to adjust LA}}
\DoxyCodeLine{1928     \textcolor{comment}{!    Note when these coefficients are set to 0 recovers simple LA.}}
\DoxyCodeLine{1929     convect\_langmuir\_number = langmuir\_number * \&}
\DoxyCodeLine{1930                     ( (1.0 + max(-\/0.5, cs\%LaC\_MLDoEK * mld\_ekman)) + \&}
\DoxyCodeLine{1931                    ((cs\%LaC\_EKoOB\_stab * ekman\_obukhov\_stab + cs\%LaC\_EKoOB\_un * ekman\_obukhov\_un) + \&}
\DoxyCodeLine{1932                     (cs\%LaC\_MLDoOB\_stab * mld\_obukhov\_stab  + cs\%LaC\_MLDoOB\_un * mld\_obukhov\_un)) )}
\DoxyCodeLine{1933 }
\DoxyCodeLine{1934     \textcolor{keywordflow}{if} (cs\%LT\_Enhance\_Form == langmuir\_rescale) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1935       \textcolor{comment}{! Enhancement is multiplied (added mst\_lt set to 0)}}
\DoxyCodeLine{1936       enhance\_mstar = min(cs\%Max\_Enhance\_M, \&}
\DoxyCodeLine{1937                           (1. + cs\%LT\_ENHANCE\_COEF * convect\_langmuir\_number**cs\%LT\_ENHANCE\_EXP) )}
\DoxyCodeLine{1938     \textcolor{keywordflow}{elseif} (cs\%LT\_ENHANCE\_Form == langmuir\_add) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1939       \textcolor{comment}{! or Enhancement is additive (multiplied enhance\_m set to 1)}}
\DoxyCodeLine{1940       mstar\_lt\_add = cs\%LT\_ENHANCE\_COEF * convect\_langmuir\_number**cs\%LT\_ENHANCE\_EXP}
\DoxyCodeLine{1941 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1942 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1943 }
\DoxyCodeLine{1944   mstar\_lt = (enhance\_mstar -\/ 1.0)*mstar + mstar\_lt\_add  \textcolor{comment}{! Diagnose the full increase in mstar.}}
\DoxyCodeLine{1945   mstar = mstar*enhance\_mstar + mstar\_lt\_add}
\DoxyCodeLine{1946 }

\end{DoxyCode}


\doxysubsection{Variable Documentation}
\mbox{\Hypertarget{namespacemom__energetic__pbl_a54d8529555fee1f2ada7a7107f3c266c}\label{namespacemom__energetic__pbl_a54d8529555fee1f2ada7a7107f3c266c}} 
\index{mom\_energetic\_pbl@{mom\_energetic\_pbl}!additive\_string@{additive\_string}}
\index{additive\_string@{additive\_string}!mom\_energetic\_pbl@{mom\_energetic\_pbl}}
\doxysubsubsection{\texorpdfstring{additive\_string}{additive\_string}}
{\footnotesize\ttfamily character$\ast$(20), parameter mom\+\_\+energetic\+\_\+pbl\+::additive\+\_\+string = \char`\"{}A\+D\+D\+I\+T\+I\+VE\char`\"{}\hspace{0.3cm}{\ttfamily [private]}}



Enumeration values for mstar\+\_\+\+Scheme. 

The value of mstar\+\_\+scheme to use a constant mstar 

Definition at line 223 of file M\+O\+M\+\_\+energetic\+\_\+\+P\+B\+L.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{223 \textcolor{comment}{character*(20), parameter :: ADDITIVE\_STRING = "ADDITIVE"}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__energetic__pbl_a1242b6400e7d01529a3d19b85e0d5b5b}\label{namespacemom__energetic__pbl_a1242b6400e7d01529a3d19b85e0d5b5b}} 
\index{mom\_energetic\_pbl@{mom\_energetic\_pbl}!constant\_string@{constant\_string}}
\index{constant\_string@{constant\_string}!mom\_energetic\_pbl@{mom\_energetic\_pbl}}
\doxysubsubsection{\texorpdfstring{constant\_string}{constant\_string}}
{\footnotesize\ttfamily character$\ast$(20), parameter mom\+\_\+energetic\+\_\+pbl\+::constant\+\_\+string = \char`\"{}C\+O\+N\+S\+T\+A\+NT\char`\"{}\hspace{0.3cm}{\ttfamily [private]}}



Enumeration values for mstar\+\_\+\+Scheme. 

The value of mstar\+\_\+scheme to use a constant mstar 

Definition at line 217 of file M\+O\+M\+\_\+energetic\+\_\+\+P\+B\+L.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{217 \textcolor{comment}{character*(20), parameter :: CONSTANT\_STRING = "CONSTANT"}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__energetic__pbl_a4299f4ef5bbeabb5d0ca7e6016546ac4}\label{namespacemom__energetic__pbl_a4299f4ef5bbeabb5d0ca7e6016546ac4}} 
\index{mom\_energetic\_pbl@{mom\_energetic\_pbl}!none\_string@{none\_string}}
\index{none\_string@{none\_string}!mom\_energetic\_pbl@{mom\_energetic\_pbl}}
\doxysubsubsection{\texorpdfstring{none\_string}{none\_string}}
{\footnotesize\ttfamily character$\ast$(20), parameter mom\+\_\+energetic\+\_\+pbl\+::none\+\_\+string = \char`\"{}N\+O\+NE\char`\"{}\hspace{0.3cm}{\ttfamily [private]}}



Enumeration values for mstar\+\_\+\+Scheme. 

The value of mstar\+\_\+scheme to use a constant mstar 

Definition at line 221 of file M\+O\+M\+\_\+energetic\+\_\+\+P\+B\+L.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{221 \textcolor{comment}{character*(20), parameter :: NONE\_STRING = "NONE"}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__energetic__pbl_a193184bbe6bba5bfcb7b077d620cbfe7}\label{namespacemom__energetic__pbl_a193184bbe6bba5bfcb7b077d620cbfe7}} 
\index{mom\_energetic\_pbl@{mom\_energetic\_pbl}!om4\_string@{om4\_string}}
\index{om4\_string@{om4\_string}!mom\_energetic\_pbl@{mom\_energetic\_pbl}}
\doxysubsubsection{\texorpdfstring{om4\_string}{om4\_string}}
{\footnotesize\ttfamily character$\ast$(20), parameter mom\+\_\+energetic\+\_\+pbl\+::om4\+\_\+string = \char`\"{}O\+M4\char`\"{}\hspace{0.3cm}{\ttfamily [private]}}



Enumeration values for mstar\+\_\+\+Scheme. 

The value of mstar\+\_\+scheme to use a constant mstar 

Definition at line 218 of file M\+O\+M\+\_\+energetic\+\_\+\+P\+B\+L.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{218 \textcolor{comment}{character*(20), parameter :: OM4\_STRING = "OM4"}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__energetic__pbl_a6e1dc5a516a3ea979f425084c1291139}\label{namespacemom__energetic__pbl_a6e1dc5a516a3ea979f425084c1291139}} 
\index{mom\_energetic\_pbl@{mom\_energetic\_pbl}!rescaled\_string@{rescaled\_string}}
\index{rescaled\_string@{rescaled\_string}!mom\_energetic\_pbl@{mom\_energetic\_pbl}}
\doxysubsubsection{\texorpdfstring{rescaled\_string}{rescaled\_string}}
{\footnotesize\ttfamily character$\ast$(20), parameter mom\+\_\+energetic\+\_\+pbl\+::rescaled\+\_\+string = \char`\"{}R\+E\+S\+C\+A\+LE\char`\"{}\hspace{0.3cm}{\ttfamily [private]}}



Enumeration values for mstar\+\_\+\+Scheme. 

The value of mstar\+\_\+scheme to use a constant mstar 

Definition at line 222 of file M\+O\+M\+\_\+energetic\+\_\+\+P\+B\+L.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{222 \textcolor{comment}{character*(20), parameter :: RESCALED\_STRING = "RESCALE"}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__energetic__pbl_a6fc8bff404f05376f1f3b4c90cb169a0}\label{namespacemom__energetic__pbl_a6fc8bff404f05376f1f3b4c90cb169a0}} 
\index{mom\_energetic\_pbl@{mom\_energetic\_pbl}!rh18\_string@{rh18\_string}}
\index{rh18\_string@{rh18\_string}!mom\_energetic\_pbl@{mom\_energetic\_pbl}}
\doxysubsubsection{\texorpdfstring{rh18\_string}{rh18\_string}}
{\footnotesize\ttfamily character$\ast$(20), parameter mom\+\_\+energetic\+\_\+pbl\+::rh18\+\_\+string = \char`\"{}R\+E\+I\+C\+H\+L\+\_\+\+H18\char`\"{}\hspace{0.3cm}{\ttfamily [private]}}



Enumeration values for mstar\+\_\+\+Scheme. 

The value of mstar\+\_\+scheme to use a constant mstar 

Definition at line 219 of file M\+O\+M\+\_\+energetic\+\_\+\+P\+B\+L.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{219 \textcolor{comment}{character*(20), parameter :: RH18\_STRING = "REICHL\_H18"}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__energetic__pbl_a6617f3587ab57c34581cd76bd80b9249}\label{namespacemom__energetic__pbl_a6617f3587ab57c34581cd76bd80b9249}} 
\index{mom\_energetic\_pbl@{mom\_energetic\_pbl}!root\_tke\_string@{root\_tke\_string}}
\index{root\_tke\_string@{root\_tke\_string}!mom\_energetic\_pbl@{mom\_energetic\_pbl}}
\doxysubsubsection{\texorpdfstring{root\_tke\_string}{root\_tke\_string}}
{\footnotesize\ttfamily character$\ast$(20), parameter mom\+\_\+energetic\+\_\+pbl\+::root\+\_\+tke\+\_\+string = \char`\"{}C\+U\+B\+E\+\_\+\+R\+O\+O\+T\+\_\+\+T\+KE\char`\"{}\hspace{0.3cm}{\ttfamily [private]}}



Enumeration values for mstar\+\_\+\+Scheme. 

The value of mstar\+\_\+scheme to use a constant mstar 

Definition at line 220 of file M\+O\+M\+\_\+energetic\+\_\+\+P\+B\+L.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{220 \textcolor{comment}{character*(20), parameter :: ROOT\_TKE\_STRING = "CUBE\_ROOT\_TKE"}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__energetic__pbl_a62611ee2449d47b4ac347ecc5815c927}\label{namespacemom__energetic__pbl_a62611ee2449d47b4ac347ecc5815c927}} 
\index{mom\_energetic\_pbl@{mom\_energetic\_pbl}!use\_fixed\_mstar@{use\_fixed\_mstar}}
\index{use\_fixed\_mstar@{use\_fixed\_mstar}!mom\_energetic\_pbl@{mom\_energetic\_pbl}}
\doxysubsubsection{\texorpdfstring{use\_fixed\_mstar}{use\_fixed\_mstar}}
{\footnotesize\ttfamily integer, parameter mom\+\_\+energetic\+\_\+pbl\+::use\+\_\+fixed\+\_\+mstar = 0}



Enumeration values for mstar\+\_\+\+Scheme. 

The value of mstar\+\_\+scheme to use a constant mstar 

Definition at line 203 of file M\+O\+M\+\_\+energetic\+\_\+\+P\+B\+L.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{203 \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: Use\_Fixed\_MStar = 0\textcolor{comment}{  !< The value of mstar\_scheme to use a constant mstar}}

\end{DoxyCode}
