\hypertarget{namespacemom__energetic__pbl}{}\section{mom\+\_\+energetic\+\_\+pbl Module Reference}
\label{namespacemom__energetic__pbl}\index{mom\+\_\+energetic\+\_\+pbl@{mom\+\_\+energetic\+\_\+pbl}}


\subsection{Detailed Description}
Energetically consistent planetary boundary layer parameterization. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \hyperlink{structmom__energetic__pbl_1_1energetic__pbl__cs}{energetic\+\_\+pbl\+\_\+cs}
\begin{DoxyCompactList}\small\item\em This control structure holds parameters for the \hyperlink{namespaceMOM__energetic__PBL}{M\+O\+M\+\_\+energetic\+\_\+\+P\+BL} module. \end{DoxyCompactList}\item 
type \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}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \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 \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 \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 \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 \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 \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 \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 \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 \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}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacemom__energetic__pbl_ac8feb21d88c79d5b112c512a19c810a6}\label{namespacemom__energetic__pbl_ac8feb21d88c79d5b112c512a19c810a6}} 
logical \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 \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 \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 \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 \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 \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 \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 \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 \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 \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 \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 \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 \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 \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 \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 \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}



\subsection{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}}
\subsubsection{\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(\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{\tt in,out}  & {\em g} & The ocean\textquotesingle{}s grid structure.\\
\hline
\mbox{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure.\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in,out}  & {\em h\+\_\+3d} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em u\+\_\+3d} & Zonal velocities interpolated to h points\\
\hline
\mbox{\tt in}  & {\em v\+\_\+3d} & Zonal velocities interpolated to h points\\
\hline
\mbox{\tt in}  & {\em dsv\+\_\+dt} & The partial derivative of in-\/situ specific\\
\hline
\mbox{\tt in}  & {\em dsv\+\_\+ds} & The partial derivative of in-\/situ specific\\
\hline
\mbox{\tt in}  & {\em tke\+\_\+forced} & The forcing requirements to homogenize the\\
\hline
\mbox{\tt in,out}  & {\em tv} & A structure containing pointers to any available thermodynamic fields. Absent fields have N\+U\+LL ptrs.\\
\hline
\mbox{\tt in,out}  & {\em fluxes} & A structure containing pointers to any possible forcing fields. Unused fields have N\+U\+LL ptrs.\\
\hline
\mbox{\tt in}  & {\em dt} & Time increment \mbox{[}T $\sim$$>$ s\mbox{]}.\\
\hline
\mbox{\tt 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{\tt in}  & {\em buoy\+\_\+flux} & The surface buoyancy flux \mbox{[}Z2 T-\/3 $\sim$$>$ m2 s-\/3\mbox{]}.\\
\hline
\mbox{\tt 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{\tt 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{\tt out}  & {\em dt\+\_\+expected} & The values of temperature change that\\
\hline
\mbox{\tt 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}
251   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{      !< The ocean's grid structure.}
252   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{     !< The ocean's vertical grid structure.}
253   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{     !< A dimensional unit scaling type}
254   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
255                            \textcolor{keywordtype}{intent(inout)} :: h\_3d\textcolor{comment}{   !< Layer thicknesses [H ~> m or kg m-2].}
256   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
257                            \textcolor{keywordtype}{intent(in)}    :: u\_3d\textcolor{comment}{   !< Zonal velocities interpolated to h points}
258 \textcolor{comment}{                                                   !! [L T-1 ~> m s-1].}
259   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
260                            \textcolor{keywordtype}{intent(in)}    :: v\_3d\textcolor{comment}{   !< Zonal velocities interpolated to h points}
261 \textcolor{comment}{                                                   !! [L T-1 ~> m s-1].}
262   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
263                            \textcolor{keywordtype}{intent(in)}    :: dsv\_dt\textcolor{comment}{ !< The partial derivative of in-situ specific}
264 \textcolor{comment}{                                                   !! volume with potential temperature}
265 \textcolor{comment}{                                                   !! [R-1 degC-1 ~> m3 kg-1 degC-1].}
266   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
267                            \textcolor{keywordtype}{intent(in)}    :: dsv\_ds\textcolor{comment}{ !< The partial derivative of in-situ specific}
268 \textcolor{comment}{                                                   !! volume with salinity [R-1 ppt-1 ~> m3 kg-1 ppt-1].}
269   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
270                            \textcolor{keywordtype}{intent(in)}    :: tke\_forced\textcolor{comment}{ !< The forcing requirements to homogenize the}
271 \textcolor{comment}{                                                   !! forcing that has been applied to each layer}
272 \textcolor{comment}{                                                   !! [R Z3 T-2 ~> J m-2].}
273   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{     !< A structure containing pointers to any}
274 \textcolor{comment}{                                                   !! available thermodynamic fields. Absent fields}
275 \textcolor{comment}{                                                   !! have NULL ptrs.}
276   \textcolor{keywordtype}{type}(forcing),           \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< A structure containing pointers to any}
277 \textcolor{comment}{                                                   !! possible forcing fields. Unused fields have}
278 \textcolor{comment}{                                                   !! NULL ptrs.}
279   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{     !< Time increment [T ~> s].}
280   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)}, &
281                            \textcolor{keywordtype}{intent(out)}   :: kd\_int\textcolor{comment}{ !< The diagnosed diffusivities at interfaces}
282 \textcolor{comment}{                                                   !! [Z2 s-1 ~> m2 s-1].}
283   \textcolor{keywordtype}{type}(energetic\_pbl\_cs),  \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{     !< The control structure returned by a previous}
284 \textcolor{comment}{                                                   !! call to mixedlayer\_init.}
285   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, &
286                            \textcolor{keywordtype}{intent(in)}    :: buoy\_flux\textcolor{comment}{ !< The surface buoyancy flux [Z2 T-3 ~> m2 s-3].}
287   \textcolor{keywordtype}{real},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dt\_diag\textcolor{comment}{   !< The diagnostic time step, which may be less}
288 \textcolor{comment}{                                                   !! than dt if there are two calls to mixedlayer [T ~>
       s].}
289   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: last\_call\textcolor{comment}{ !< If true, this is the last call to}
290 \textcolor{comment}{                                                   !! mixedlayer in the current time step, so}
291 \textcolor{comment}{                                                   !! diagnostics will be written. The default}
292 \textcolor{comment}{                                                   !! is .true.}
293   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
294                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)}   :: dt\_expected\textcolor{comment}{ !< The values of temperature change that}
295 \textcolor{comment}{                                                   !! should be expected when the returned}
296 \textcolor{comment}{                                                   !! diffusivities are applied [degC].}
297   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
298                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)}   :: ds\_expected\textcolor{comment}{ !< The values of salinity change that}
299 \textcolor{comment}{                                                   !! should be expected when the returned}
300 \textcolor{comment}{                                                   !! diffusivities are applied [ppt].}
301   \textcolor{keywordtype}{type}(wave\_parameters\_cs), &
302                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}       :: waves\textcolor{comment}{  !< Wave CS}
303 
304 \textcolor{comment}{!    This subroutine determines the diffusivities from the integrated energetics}
305 \textcolor{comment}{!  mixed layer model.  It assumes that heating, cooling and freshwater fluxes}
306 \textcolor{comment}{!  have already been applied.  All calculations are done implicitly, and there}
307 \textcolor{comment}{!  is no stability limit on the time step.}
308 \textcolor{comment}{!}
309 \textcolor{comment}{!    For each interior interface, first discard the TKE to account for mixing}
310 \textcolor{comment}{! of shortwave radiation through the next denser cell.  Next drive mixing based}
311 \textcolor{comment}{! on the local? values of ustar + wstar, subject to available energy.  This}
312 \textcolor{comment}{! step sets the value of Kd(K).  Any remaining energy is then subject to decay}
313 \textcolor{comment}{! before being handed off to the next interface.  mech\_TKE and conv\_PErel are treated}
314 \textcolor{comment}{! separately for the purposes of decay, but are used proportionately to drive}
315 \textcolor{comment}{! mixing.}
316 \textcolor{comment}{!}
317 \textcolor{comment}{!   The key parameters for the mixed layer are found in the control structure.}
318 \textcolor{comment}{!   To use the classic constant mstar mixied layers choose MSTAR\_SCHEME=CONSTANT.}
319 \textcolor{comment}{! The key parameters then include mstar, nstar, TKE\_decay, and conv\_decay.}
320 \textcolor{comment}{! For the Oberhuber (1993) mixed layer,the values of these are:}
321 \textcolor{comment}{!      mstar = 1.25,  nstar = 1, TKE\_decay = 2.5, conv\_decay = 0.5}
322 \textcolor{comment}{! TKE\_decay is 1/kappa in eq. 28 of Oberhuber (1993), while conv\_decay is 1/mu.}
323 \textcolor{comment}{! For a traditional Kraus-Turner mixed layer, the values are:}
324 \textcolor{comment}{!      mstar = 1.25, nstar = 0.4, TKE\_decay = 0.0, conv\_decay = 0.0}
325 
326   \textcolor{comment}{! Local variables}
327   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZK\_(GV))} :: &
328     h\_2d, &         \textcolor{comment}{! A 2-d slice of the layer thickness [H ~> m or kg m-2].}
329     t\_2d, &         \textcolor{comment}{! A 2-d slice of the layer temperatures [degC].}
330     s\_2d, &         \textcolor{comment}{! A 2-d slice of the layer salinities [ppt].}
331     tke\_forced\_2d, & \textcolor{comment}{! A 2-d slice of TKE\_forced [R Z3 T-2 ~> J m-2].}
332     dsv\_dt\_2d, &    \textcolor{comment}{! A 2-d slice of dSV\_dT [R-1 degC-1 ~> m3 kg-1 degC-1].}
333     dsv\_ds\_2d, &    \textcolor{comment}{! A 2-d slice of dSV\_dS [R-1 ppt-1 ~> m3 kg-1 ppt-1].}
334     u\_2d, &         \textcolor{comment}{! A 2-d slice of the zonal velocity [L T-1 ~> m s-1].}
335     v\_2d            \textcolor{comment}{! A 2-d slice of the meridional velocity [L T-1 ~> m s-1].}
336   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZK\_(GV)+1)} :: &
337     kd\_2d           \textcolor{comment}{! A 2-d version of the diapycnal diffusivity [Z2 T-1 ~> m2 s-1].}
338   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: &
339     h, &            \textcolor{comment}{! The layer thickness [H ~> m or kg m-2].}
340     t0, &           \textcolor{comment}{! The initial layer temperatures [degC].}
341     s0, &           \textcolor{comment}{! The initial layer salinities [ppt].}
342     dsv\_dt\_1d, &    \textcolor{comment}{! The partial derivatives of specific volume with temperature [R-1 degC-1 ~> m3 kg-1
       degC-1].}
343     dsv\_ds\_1d, &    \textcolor{comment}{! The partial derivatives of specific volume with salinity [R-1 ppt-1 ~> m3 kg-1
       ppt-1].}
344     tke\_forcing, &  \textcolor{comment}{! Forcing of the TKE in the layer coming from TKE\_forced [R Z3 T-2 ~> J m-2].}
345     u, &            \textcolor{comment}{! The zonal velocity [L T-1 ~> m s-1].}
346     v               \textcolor{comment}{! The meridional velocity [L T-1 ~> m s-1].}
347   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV)+1)} :: &
348     kd, &           \textcolor{comment}{! The diapycnal diffusivity [Z2 T-1 ~> m2 s-1].}
349     mixvel, &       \textcolor{comment}{! A turbulent mixing veloxity [Z T-1 ~> m s-1].}
350     mixlen          \textcolor{comment}{! A turbulent mixing length [Z ~> m].}
351   \textcolor{keywordtype}{real} :: h\_neglect \textcolor{comment}{! A thickness that is so small it is usually lost}
352                     \textcolor{comment}{! in roundoff and can be neglected [H ~> m or kg m-2].}
353 
354   \textcolor{keywordtype}{real} :: absf      \textcolor{comment}{! The absolute value of f [T-1 ~> s-1].}
355   \textcolor{keywordtype}{real} :: u\_star    \textcolor{comment}{! The surface friction velocity [Z T-1 ~> m s-1].}
356   \textcolor{keywordtype}{real} :: u\_star\_mean \textcolor{comment}{! The surface friction without gustiness [Z T-1 ~> m s-1].}
357   \textcolor{keywordtype}{real} :: b\_flux    \textcolor{comment}{! The surface buoyancy flux [Z2 T-3 ~> m2 s-3]}
358   \textcolor{keywordtype}{real} :: mld\_io    \textcolor{comment}{! The mixed layer depth found by ePBL\_column [Z ~> m].}
359 
360 \textcolor{comment}{! The following are only used for diagnostics.}
361   \textcolor{keywordtype}{real} :: dt\_\_diag  \textcolor{comment}{! A copy of dt\_diag (if present) or dt [T ~> s].}
362   \textcolor{keywordtype}{logical} :: write\_diags  \textcolor{comment}{! If true, write out diagnostics with this step.}
363   \textcolor{keywordtype}{logical} :: reset\_diags  \textcolor{comment}{! If true, zero out the accumulated diagnostics.}
364 
365   \textcolor{keywordtype}{logical} :: debug=.false.  \textcolor{comment}{! Change this hard-coded value for debugging.}
366   \textcolor{keywordtype}{type}(epbl\_column\_diags) :: ecd \textcolor{comment}{! A container for passing around diagnostics.}
367 
368   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz
369 
370   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = gv%ke
371 
372   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(cs)) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"energetic\_PBL: "}//&
373          \textcolor{stringliteral}{"Module must be initialized before it is used."})
374 
375   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(tv%eqn\_of\_state)) \textcolor{keyword}{call }mom\_error(fatal, &
376       \textcolor{stringliteral}{"energetic\_PBL: Temperature, salinity and an equation of state "}//&
377       \textcolor{stringliteral}{"must now be used."})
378   \textcolor{keywordflow}{if} (.NOT. \textcolor{keyword}{associated}(fluxes%ustar)) \textcolor{keyword}{call }mom\_error(fatal, &
379       \textcolor{stringliteral}{"energetic\_PBL: No surface TKE fluxes (ustar) defined in mixedlayer!"})
380   debug = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt\_expected) .or. \textcolor{keyword}{present}(ds\_expected)) debug = .true.
381 
382   \textcolor{keywordflow}{if} (debug) \textcolor{keyword}{allocate}(ecd%dT\_expect(nz), ecd%dS\_expect(nz))
383 
384   h\_neglect = gv%H\_subroundoff
385 
386   dt\_\_diag = dt ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt\_diag)) dt\_\_diag = dt\_diag
387   write\_diags = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(last\_call)) write\_diags = last\_call
388 
389 
390   \textcolor{comment}{! Determine whether to zero out diagnostics before accumulation.}
391   reset\_diags = .true.
392   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt\_diag) .and. write\_diags .and. (dt\_\_diag > dt)) &
393     reset\_diags = .false.  \textcolor{comment}{! This is the second call to mixedlayer.}
394 
395   \textcolor{keywordflow}{if} (reset\_diags) \textcolor{keywordflow}{then}
396     \textcolor{keywordflow}{if} (cs%TKE\_diagnostics) \textcolor{keywordflow}{then}
397 \textcolor{comment}{!!OMP parallel do default(none) shared(is,ie,js,je,CS)}
398       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
399         cs%diag\_TKE\_wind(i,j) = 0.0 ; cs%diag\_TKE\_MKE(i,j) = 0.0
400         cs%diag\_TKE\_conv(i,j) = 0.0 ; cs%diag\_TKE\_forcing(i,j) = 0.0
401         cs%diag\_TKE\_mixing(i,j) = 0.0 ; cs%diag\_TKE\_mech\_decay(i,j) = 0.0
402         cs%diag\_TKE\_conv\_decay(i,j) = 0.0 \textcolor{comment}{!; CS%diag\_TKE\_unbalanced(i,j) = 0.0}
403 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
404 \textcolor{keywordflow}{    endif}
405 \textcolor{keywordflow}{  endif}
406   \textcolor{comment}{! if (CS%id\_Mixing\_Length>0) CS%Mixing\_Length(:,:,:) = 0.0}
407   \textcolor{comment}{! if (CS%id\_Velocity\_Scale>0) CS%Velocity\_Scale(:,:,:) = 0.0}
408 
409 \textcolor{comment}{!!OMP parallel do default(private) shared(js,je,nz,is,ie,h\_3d,u\_3d,v\_3d,tv,dt, &}
410 \textcolor{comment}{!!OMP                                  CS,G,GV,US,fluxes,debug, &}
411 \textcolor{comment}{!!OMP                                  TKE\_forced,dSV\_dT,dSV\_dS,Kd\_int)}
412   \textcolor{keywordflow}{do} j=js,je
413     \textcolor{comment}{! Copy the thicknesses and other fields to 2-d arrays.}
414     \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=is,ie
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)
416       t\_2d(i,k) = tv%T(i,j,k) ; s\_2d(i,k) = tv%S(i,j,k)
417       tke\_forced\_2d(i,k) = tke\_forced(i,j,k)
418       dsv\_dt\_2d(i,k) = dsv\_dt(i,j,k) ; dsv\_ds\_2d(i,k) = dsv\_ds(i,j,k)
419 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
420 
421     \textcolor{comment}{!   Determine the initial mech\_TKE and conv\_PErel, including the energy required}
422     \textcolor{comment}{! to mix surface heating through the topmost cell, the energy released by mixing}
423     \textcolor{comment}{! surface cooling & brine rejection down through the topmost cell, and}
424     \textcolor{comment}{! homogenizing the shortwave heating within that cell.  This sets the energy}
425     \textcolor{comment}{! and ustar and wstar available to drive mixing at the first interior}
426     \textcolor{comment}{! interface.}
427     \textcolor{keywordflow}{do} i=is,ie ; \textcolor{keywordflow}{if} (g%mask2dT(i,j) > 0.5) \textcolor{keywordflow}{then}
428 
429       \textcolor{comment}{! Copy the thicknesses and other fields to 1-d arrays.}
430       \textcolor{keywordflow}{do} k=1,nz
431         h(k) = h\_2d(i,k) + gv%H\_subroundoff ; u(k) = u\_2d(i,k) ; v(k) = v\_2d(i,k)
432         t0(k) = t\_2d(i,k) ; s0(k) = s\_2d(i,k) ; tke\_forcing(k) =  tke\_forced\_2d(i,k)
433         dsv\_dt\_1d(k) = dsv\_dt\_2d(i,k) ; dsv\_ds\_1d(k) = dsv\_ds\_2d(i,k)
434 \textcolor{keywordflow}{      enddo}
435       \textcolor{keywordflow}{do} k=1,nz+1 ; kd(k) = 0.0 ;\textcolor{keywordflow}{ enddo}
436 
437       \textcolor{comment}{! Make local copies of surface forcing and process them.}
438       u\_star = fluxes%ustar(i,j)
439       u\_star\_mean = fluxes%ustar\_gustless(i,j)
440       b\_flux = buoy\_flux(i,j)
441       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(fluxes%ustar\_shelf) .and. \textcolor{keyword}{associated}(fluxes%frac\_shelf\_h)) \textcolor{keywordflow}{then}
442         \textcolor{keywordflow}{if} (fluxes%frac\_shelf\_h(i,j) > 0.0) &
443           u\_star = (1.0 - fluxes%frac\_shelf\_h(i,j)) * u\_star + &
444                    fluxes%frac\_shelf\_h(i,j) * fluxes%ustar\_shelf(i,j)
445 \textcolor{keywordflow}{      endif}
446       \textcolor{keywordflow}{if} (u\_star < cs%ustar\_min) u\_star = cs%ustar\_min
447       \textcolor{keywordflow}{if} (cs%omega\_frac >= 1.0) \textcolor{keywordflow}{then}
448         absf = 2.0*cs%omega
449       \textcolor{keywordflow}{else}
450         absf = 0.25*((abs(g%CoriolisBu(i,j)) + abs(g%CoriolisBu(i-1,j-1))) + &
451                      (abs(g%CoriolisBu(i,j-1)) + abs(g%CoriolisBu(i-1,j))))
452         \textcolor{keywordflow}{if} (cs%omega\_frac > 0.0) &
453           absf = sqrt(cs%omega\_frac*4.0*cs%omega**2 + (1.0-cs%omega\_frac)*absf**2)
454 \textcolor{keywordflow}{      endif}
455 
456       \textcolor{comment}{! Perhaps provide a first guess for MLD based on a stored previous value.}
457       mld\_io = -1.0
458       \textcolor{keywordflow}{if} (cs%MLD\_iteration\_guess .and. (cs%ML\_Depth(i,j) > 0.0))  mld\_io = cs%ML\_Depth(i,j)
459 
460       \textcolor{keyword}{call }epbl\_column(h, u, v, t0, s0, dsv\_dt\_1d, dsv\_ds\_1d, tke\_forcing, b\_flux, absf, &
461                        u\_star, u\_star\_mean, dt, mld\_io, kd, mixvel, mixlen, gv, &
462                        us, cs, ecd, dt\_diag=dt\_diag, waves=waves, g=g, i=i, j=j)
463 
464 
465       \textcolor{comment}{! Copy the diffusivities to a 2-d array.}
466       \textcolor{keywordflow}{do} k=1,nz+1
467         kd\_2d(i,k) = kd(k)
468 \textcolor{keywordflow}{      enddo}
469       cs%ML\_depth(i,j) = mld\_io
470 
471       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt\_expected)) \textcolor{keywordflow}{then}
472         \textcolor{keywordflow}{do} k=1,nz ; dt\_expected(i,j,k) = ecd%dT\_expect(k) ;\textcolor{keywordflow}{ enddo}
473 \textcolor{keywordflow}{      endif}
474       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(ds\_expected)) \textcolor{keywordflow}{then}
475         \textcolor{keywordflow}{do} k=1,nz ; ds\_expected(i,j,k) = ecd%dS\_expect(k) ;\textcolor{keywordflow}{ enddo}
476 \textcolor{keywordflow}{      endif}
477 
478       \textcolor{keywordflow}{if} (cs%TKE\_diagnostics) \textcolor{keywordflow}{then}
479         cs%diag\_TKE\_MKE(i,j) = cs%diag\_TKE\_MKE(i,j) + ecd%dTKE\_MKE
480         cs%diag\_TKE\_conv(i,j) = cs%diag\_TKE\_conv(i,j) + ecd%dTKE\_conv
481         cs%diag\_TKE\_forcing(i,j) = cs%diag\_TKE\_forcing(i,j) + ecd%dTKE\_forcing
482         cs%diag\_TKE\_wind(i,j) = cs%diag\_TKE\_wind(i,j) + ecd%dTKE\_wind
483         cs%diag\_TKE\_mixing(i,j) = cs%diag\_TKE\_mixing(i,j) + ecd%dTKE\_mixing
484         cs%diag\_TKE\_mech\_decay(i,j) = cs%diag\_TKE\_mech\_decay(i,j) + ecd%dTKE\_mech\_decay
485         cs%diag\_TKE\_conv\_decay(i,j) = cs%diag\_TKE\_conv\_decay(i,j) + ecd%dTKE\_conv\_decay
486        \textcolor{comment}{! CS%diag\_TKE\_unbalanced(i,j) = CS%diag\_TKE\_unbalanced(i,j) + eCD%dTKE\_unbalanced}
487 \textcolor{keywordflow}{      endif}
488       \textcolor{comment}{! Write to 3-D for outputing Mixing length and velocity scale.}
489       \textcolor{keywordflow}{if} (cs%id\_Mixing\_Length>0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} k=1,nz
490         cs%Mixing\_Length(i,j,k) = mixlen(k)
491 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ endif}
492       \textcolor{keywordflow}{if} (cs%id\_Velocity\_Scale>0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} k=1,nz
493         cs%Velocity\_Scale(i,j,k) = mixvel(k)
494 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ endif}
495       \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs%mstar\_mix)) cs%mstar\_mix(i,j) = ecd%mstar
496       \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs%mstar\_lt)) cs%mstar\_lt(i,j) = ecd%mstar\_LT
497       \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs%La)) cs%La(i,j) = ecd%LA
498       \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs%La\_mod)) cs%La\_mod(i,j) = ecd%LAmod
499     \textcolor{keywordflow}{else} \textcolor{comment}{! End of the ocean-point part of the i-loop}
500       \textcolor{comment}{! For masked points, Kd\_int must still be set (to 0) because it has intent out.}
501       \textcolor{keywordflow}{do} k=1,nz+1 ; kd\_2d(i,k) = 0. ;\textcolor{keywordflow}{ enddo}
502       cs%ML\_depth(i,j) = 0.0
503 
504       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt\_expected)) \textcolor{keywordflow}{then}
505         \textcolor{keywordflow}{do} k=1,nz ; dt\_expected(i,j,k) = 0.0 ;\textcolor{keywordflow}{ enddo}
506 \textcolor{keywordflow}{      endif}
507       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(ds\_expected)) \textcolor{keywordflow}{then}
508         \textcolor{keywordflow}{do} k=1,nz ; ds\_expected(i,j,k) = 0.0 ;\textcolor{keywordflow}{ enddo}
509 \textcolor{keywordflow}{      endif}
510 \textcolor{keywordflow}{    endif} ;\textcolor{keywordflow}{ enddo} \textcolor{comment}{! Close of i-loop - Note unusual loop order!}
511 
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}
513 
514 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! j-loop}
515 
516   \textcolor{keywordflow}{if} (write\_diags) \textcolor{keywordflow}{then}
517     \textcolor{keywordflow}{if} (cs%id\_ML\_depth > 0) \textcolor{keyword}{call }post\_data(cs%id\_ML\_depth, cs%ML\_depth, cs%diag)
518     \textcolor{keywordflow}{if} (cs%id\_hML\_depth > 0) \textcolor{keyword}{call }post\_data(cs%id\_hML\_depth, cs%ML\_depth, cs%diag)
519     \textcolor{keywordflow}{if} (cs%id\_TKE\_wind > 0) \textcolor{keyword}{call }post\_data(cs%id\_TKE\_wind, cs%diag\_TKE\_wind, cs%diag)
520     \textcolor{keywordflow}{if} (cs%id\_TKE\_MKE > 0)  \textcolor{keyword}{call }post\_data(cs%id\_TKE\_MKE, cs%diag\_TKE\_MKE, cs%diag)
521     \textcolor{keywordflow}{if} (cs%id\_TKE\_conv > 0) \textcolor{keyword}{call }post\_data(cs%id\_TKE\_conv, cs%diag\_TKE\_conv, cs%diag)
522     \textcolor{keywordflow}{if} (cs%id\_TKE\_forcing > 0) \textcolor{keyword}{call }post\_data(cs%id\_TKE\_forcing, cs%diag\_TKE\_forcing, cs%diag)
523     \textcolor{keywordflow}{if} (cs%id\_TKE\_mixing > 0) \textcolor{keyword}{call }post\_data(cs%id\_TKE\_mixing, cs%diag\_TKE\_mixing, cs%diag)
524     \textcolor{keywordflow}{if} (cs%id\_TKE\_mech\_decay > 0) &
525       \textcolor{keyword}{call }post\_data(cs%id\_TKE\_mech\_decay, cs%diag\_TKE\_mech\_decay, cs%diag)
526     \textcolor{keywordflow}{if} (cs%id\_TKE\_conv\_decay > 0) &
527       \textcolor{keyword}{call }post\_data(cs%id\_TKE\_conv\_decay, cs%diag\_TKE\_conv\_decay, cs%diag)
528     \textcolor{keywordflow}{if} (cs%id\_Mixing\_Length > 0) \textcolor{keyword}{call }post\_data(cs%id\_Mixing\_Length, cs%Mixing\_Length, cs%diag)
529     \textcolor{keywordflow}{if} (cs%id\_Velocity\_Scale >0) \textcolor{keyword}{call }post\_data(cs%id\_Velocity\_Scale, cs%Velocity\_Scale, cs%diag)
530     \textcolor{keywordflow}{if} (cs%id\_MSTAR\_MIX > 0)     \textcolor{keyword}{call }post\_data(cs%id\_MSTAR\_MIX, cs%MSTAR\_MIX, cs%diag)
531     \textcolor{keywordflow}{if} (cs%id\_LA > 0)       \textcolor{keyword}{call }post\_data(cs%id\_LA, cs%LA, cs%diag)
532     \textcolor{keywordflow}{if} (cs%id\_LA\_MOD > 0)   \textcolor{keyword}{call }post\_data(cs%id\_LA\_MOD, cs%LA\_MOD, cs%diag)
533     \textcolor{keywordflow}{if} (cs%id\_MSTAR\_LT > 0) \textcolor{keyword}{call }post\_data(cs%id\_MSTAR\_LT, cs%MSTAR\_LT, cs%diag)
534 \textcolor{keywordflow}{  endif}
535 
536   \textcolor{keywordflow}{if} (debug) \textcolor{keyword}{deallocate}(ecd%dT\_expect, ecd%dS\_expect)
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}}
\subsubsection{\texorpdfstring{energetic\+\_\+pbl\+\_\+end()}{energetic\_pbl\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+energetic\+\_\+pbl\+::energetic\+\_\+pbl\+\_\+end (\begin{DoxyParamCaption}\item[{type(\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}
2422   \textcolor{keywordtype}{type}(energetic\_pbl\_cs), \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{ !< Energetic\_PBL control structure that}
2423 \textcolor{comment}{                                        !! will be deallocated in this subroutine.}
2424 
2425   \textcolor{keywordtype}{character(len=256)} :: mesg
2426   \textcolor{keywordtype}{real} :: avg\_its
2427 
2428   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}
2429 
2430   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs%ML\_depth))            \textcolor{keyword}{deallocate}(cs%ML\_depth)
2431   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs%LA))                  \textcolor{keyword}{deallocate}(cs%LA)
2432   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs%LA\_MOD))              \textcolor{keyword}{deallocate}(cs%LA\_MOD)
2433   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs%MSTAR\_MIX))           \textcolor{keyword}{deallocate}(cs%MSTAR\_MIX)
2434   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs%MSTAR\_LT))            \textcolor{keyword}{deallocate}(cs%MSTAR\_LT)
2435   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs%diag\_TKE\_wind))       \textcolor{keyword}{deallocate}(cs%diag\_TKE\_wind)
2436   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs%diag\_TKE\_MKE))        \textcolor{keyword}{deallocate}(cs%diag\_TKE\_MKE)
2437   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs%diag\_TKE\_conv))       \textcolor{keyword}{deallocate}(cs%diag\_TKE\_conv)
2438   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs%diag\_TKE\_forcing))    \textcolor{keyword}{deallocate}(cs%diag\_TKE\_forcing)
2439   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs%diag\_TKE\_mixing))     \textcolor{keyword}{deallocate}(cs%diag\_TKE\_mixing)
2440   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs%diag\_TKE\_mech\_decay)) \textcolor{keyword}{deallocate}(cs%diag\_TKE\_mech\_decay)
2441   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs%diag\_TKE\_conv\_decay)) \textcolor{keyword}{deallocate}(cs%diag\_TKE\_conv\_decay)
2442   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs%Mixing\_Length))       \textcolor{keyword}{deallocate}(cs%Mixing\_Length)
2443   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(cs%Velocity\_Scale))      \textcolor{keyword}{deallocate}(cs%Velocity\_Scale)
2444 
2445   \textcolor{keywordflow}{if} (report\_avg\_its) \textcolor{keywordflow}{then}
2446     \textcolor{keyword}{call }efp\_sum\_across\_pes(cs%sum\_its, 2)
2447 
2448     avg\_its = efp\_to\_real(cs%sum\_its(1)) / efp\_to\_real(cs%sum\_its(2))
2449     \textcolor{keyword}{write} (mesg,*) \textcolor{stringliteral}{"Average ePBL iterations = "}, avg\_its
2450     \textcolor{keyword}{call }mom\_mesg(mesg)
2451 \textcolor{keywordflow}{  endif}
2452 
2453   \textcolor{keyword}{deallocate}(cs)
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}}
\subsubsection{\texorpdfstring{energetic\+\_\+pbl\+\_\+get\+\_\+mld()}{energetic\_pbl\_get\_mld()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+energetic\+\_\+pbl\+::energetic\+\_\+pbl\+\_\+get\+\_\+mld (\begin{DoxyParamCaption}\item[{type(\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{\tt in}  & {\em g} & Grid structure\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt out}  & {\em mld} & Depth of e\+P\+BL active mixing layer \mbox{[}Z $\sim$$>$ m\mbox{]} or other units\\
\hline
\mbox{\tt 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}
1952   \textcolor{keywordtype}{type}(energetic\_pbl\_cs),           \textcolor{keywordtype}{pointer}     :: cs\textcolor{comment}{  !< Control structure for ePBL}
1953   \textcolor{keywordtype}{type}(ocean\_grid\_type),            \textcolor{keywordtype}{intent(in)}  :: g\textcolor{comment}{   !< Grid structure}
1954   \textcolor{keywordtype}{type}(unit\_scale\_type),            \textcolor{keywordtype}{intent(in)}  :: us\textcolor{comment}{  !< A dimensional unit scaling type}
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}
1956   \textcolor{keywordtype}{real},                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: m\_to\_mld\_units\textcolor{comment}{ !< A conversion factor from meters}
1957 \textcolor{comment}{                                                       !! to the desired units for MLD}
1958   \textcolor{comment}{! Local variables}
1959   \textcolor{keywordtype}{real} :: scale  \textcolor{comment}{! A dimensional rescaling factor}
1960   \textcolor{keywordtype}{integer} :: i,j
1961 
1962   scale = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(m\_to\_mld\_units)) scale = us%Z\_to\_m * m\_to\_mld\_units
1963 
1964   \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
1965     mld(i,j) = scale*cs%ML\_Depth(i,j)
1966 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
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}}
\subsubsection{\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(\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{\tt in}  & {\em time} & The current model time\\
\hline
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters\\
\hline
\mbox{\tt 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}
1973   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)}    :: time\textcolor{comment}{ !< The current model time}
1974   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{    !< The ocean's grid structure}
1975   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{   !< The ocean's vertical grid structure}
1976   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A dimensional unit scaling type}
1977   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}
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}
1979   \textcolor{keywordtype}{type}(energetic\_pbl\_cs),  \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{   !< A pointer that is set to point to the control}
1980 \textcolor{comment}{                                                 !! structure for this module}
1981   \textcolor{comment}{! Local variables}
1982   \textcolor{comment}{! This include declares and sets the variable "version".}
1983 \textcolor{preprocessor}{# include "version\_variable.h"}
1984 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_energetic\_PBL"}  \textcolor{comment}{! This module's name.}
1985   \textcolor{keywordtype}{character(len=20)}  :: tmpstr
1986   \textcolor{keywordtype}{real} :: omega\_frac\_dflt
1987   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed
1988   \textcolor{keywordtype}{integer} :: mstar\_mode, lt\_enhance, wt\_mode
1989   \textcolor{keywordtype}{logical} :: default\_2018\_answers
1990   \textcolor{keywordtype}{logical} :: use\_temperature, use\_omega
1991   \textcolor{keywordtype}{logical} :: use\_la\_windsea
1992   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
1993 
1994   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
1995     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"mixedlayer\_init called with an associated"}//&
1996                             \textcolor{stringliteral}{"associated control structure."})
1997     \textcolor{keywordflow}{return}
1998   \textcolor{keywordflow}{else} ; \textcolor{keyword}{allocate}(cs) ;\textcolor{keywordflow}{ endif}
1999 
2000   cs%diag => diag
2001   cs%Time => time
2002 
2003 \textcolor{comment}{! Set default, read and log parameters}
2004   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})
2005 
2006 
2007 \textcolor{comment}{!/1. General ePBL settings}
2008   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"OMEGA"}, cs%omega, &
2009                  \textcolor{stringliteral}{"The rotation rate of the earth."}, units=\textcolor{stringliteral}{"s-1"}, &
2010                  default=7.2921e-5, scale=us%T\_to\_S)
2011   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ML\_USE\_OMEGA"}, use\_omega, &
2012                  \textcolor{stringliteral}{"If true, use the absolute rotation rate instead of the "}//&
2013                  \textcolor{stringliteral}{"vertical component of rotation when setting the decay "}//&
2014                  \textcolor{stringliteral}{"scale for turbulence."}, default=.false., do\_not\_log=.true.)
2015   omega\_frac\_dflt = 0.0
2016   \textcolor{keywordflow}{if} (use\_omega) \textcolor{keywordflow}{then}
2017     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"ML\_USE\_OMEGA is depricated; use ML\_OMEGA\_FRAC=1.0 instead."})
2018     omega\_frac\_dflt = 1.0
2019 \textcolor{keywordflow}{  endif}
2020   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ML\_OMEGA\_FRAC"}, cs%omega\_frac, &
2021                  \textcolor{stringliteral}{"When setting the decay scale for turbulence, use this "}//&
2022                  \textcolor{stringliteral}{"fraction of the absolute rotation rate blended with the "}//&
2023                  \textcolor{stringliteral}{"local value of f, as sqrt((1-of)*f^2 + of*4*omega^2)."}, &
2024                  units=\textcolor{stringliteral}{"nondim"}, default=omega\_frac\_dflt)
2025   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EKMAN\_SCALE\_COEF"}, cs%Ekman\_scale\_coef, &
2026                  \textcolor{stringliteral}{"A nondimensional scaling factor controlling the inhibition "}//&
2027                  \textcolor{stringliteral}{"of the diffusive length scale by rotation. Making this larger "}//&
2028                  \textcolor{stringliteral}{"decreases the PBL diffusivity."}, units=\textcolor{stringliteral}{"nondim"}, default=1.0)
2029   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEFAULT\_2018\_ANSWERS"}, default\_2018\_answers, &
2030                  \textcolor{stringliteral}{"This sets the default value for the various \_2018\_ANSWERS parameters."}, &
2031                  default=.false.)
2032   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_2018\_ANSWERS"}, cs%answers\_2018, &
2033                  \textcolor{stringliteral}{"If true, use the order of arithmetic and expressions that recover the "}//&
2034                  \textcolor{stringliteral}{"answers from the end of 2018.  Otherwise, use updated and more robust "}//&
2035                  \textcolor{stringliteral}{"forms of the same expressions."}, default=default\_2018\_answers)
2036 
2037 
2038   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_ORIGINAL\_PE\_CALC"}, cs%orig\_PE\_calc, &
2039                  \textcolor{stringliteral}{"If true, the ePBL code uses the original form of the "}//&
2040                  \textcolor{stringliteral}{"potential energy change code.  Otherwise, the newer "}//&
2041                  \textcolor{stringliteral}{"version that can work with successive increments to the "}//&
2042                  \textcolor{stringliteral}{"diffusivity in upward or downward passes is used."}, default=.true.)
2043 
2044   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MKE\_TO\_TKE\_EFFIC"}, cs%MKE\_to\_TKE\_effic, &
2045                  \textcolor{stringliteral}{"The efficiency with which mean kinetic energy released "}//&
2046                  \textcolor{stringliteral}{"by mechanically forced entrainment of the mixed layer "}//&
2047                  \textcolor{stringliteral}{"is converted to turbulent kinetic energy."}, units=\textcolor{stringliteral}{"nondim"}, &
2048                  default=0.0)
2049   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TKE\_DECAY"}, cs%TKE\_decay, &
2050                  \textcolor{stringliteral}{"TKE\_DECAY relates the vertical rate of decay of the "}//&
2051                  \textcolor{stringliteral}{"TKE available for mechanical entrainment to the natural "}//&
2052                  \textcolor{stringliteral}{"Ekman depth."}, units=\textcolor{stringliteral}{"nondim"}, default=2.5)
2053 
2054 
2055 \textcolor{comment}{!/2. Options related to setting MSTAR}
2056   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_MSTAR\_SCHEME"}, tmpstr, &
2057                  \textcolor{stringliteral}{"EPBL\_MSTAR\_SCHEME selects the method for setting mstar.  Valid values are: \(\backslash\)n"}//&
2058                  \textcolor{stringliteral}{"\(\backslash\)t CONSTANT   - Use a fixed mstar given by MSTAR \(\backslash\)n"}//&
2059                  \textcolor{stringliteral}{"\(\backslash\)t OM4        - Use L\_Ekman/L\_Obukhov in the sabilizing limit, as in OM4 \(\backslash\)n"}//&
2060                  \textcolor{stringliteral}{"\(\backslash\)t REICHL\_H18 - Use the scheme documented in Reichl & Hallberg, 2018."}, &
2061                  default=constant\_string, do\_not\_log=.true.)
2062   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MSTAR\_MODE"}, mstar\_mode, default=-1)
2063   \textcolor{keywordflow}{if} (mstar\_mode == 0) \textcolor{keywordflow}{then}
2064     tmpstr = constant\_string
2065     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"Use EPBL\_MSTAR\_SCHEME = CONSTANT instead of the archaic MSTAR\_MODE = 0."})
2066   \textcolor{keywordflow}{elseif} (mstar\_mode == 1) \textcolor{keywordflow}{then}
2067     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"You are using a legacy mstar mode in ePBL that has been phased out. "}//&
2068                           \textcolor{stringliteral}{"If you need to use this setting please report this error.  Also use "}//&
2069                           \textcolor{stringliteral}{"EPBL\_MSTAR\_SCHEME to specify the scheme for mstar."})
2070   \textcolor{keywordflow}{elseif} (mstar\_mode == 2) \textcolor{keywordflow}{then}
2071     tmpstr = om4\_string
2072     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"Use EPBL\_MSTAR\_SCHEME = OM4 instead of the archaic MSTAR\_MODE = 2."})
2073   \textcolor{keywordflow}{elseif} (mstar\_mode == 3) \textcolor{keywordflow}{then}
2074     tmpstr = rh18\_string
2075     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"Use EPBL\_MSTAR\_SCHEME = REICHL\_H18 instead of the archaic MSTAR\_MODE = 3."})
2076   \textcolor{keywordflow}{elseif} (mstar\_mode > 3) \textcolor{keywordflow}{then}
2077     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"An unrecognized value of the obsolete parameter MSTAR\_MODE was specified."})
2078 \textcolor{keywordflow}{  endif}
2079   \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_MSTAR\_SCHEME"}, tmpstr, &
2080                  \textcolor{stringliteral}{"EPBL\_MSTAR\_SCHEME selects the method for setting mstar.  Valid values are: \(\backslash\)n"}//&
2081                  \textcolor{stringliteral}{"\(\backslash\)t CONSTANT   - Use a fixed mstar given by MSTAR \(\backslash\)n"}//&
2082                  \textcolor{stringliteral}{"\(\backslash\)t OM4        - Use L\_Ekman/L\_Obukhov in the sabilizing limit, as in OM4 \(\backslash\)n"}//&
2083                  \textcolor{stringliteral}{"\(\backslash\)t REICHL\_H18 - Use the scheme documented in Reichl & Hallberg, 2018."}, &
2084                  default=constant\_string)
2085   tmpstr = uppercase(tmpstr)
2086   \textcolor{keywordflow}{select case} (tmpstr)
2087     \textcolor{keywordflow}{case} (constant\_string)
2088       cs%mstar\_Scheme = use\_fixed\_mstar
2089     \textcolor{keywordflow}{case} (om4\_string)
2090       cs%mstar\_Scheme = mstar\_from\_ekman
2091     \textcolor{keywordflow}{case} (rh18\_string)
2092       cs%mstar\_Scheme = mstar\_from\_rh18
2093 \textcolor{keywordflow}{    case default}
2094       \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{'energetic\_PBL\_init: EPBL\_MSTAR\_SCHEME ="'}//trim(tmpstr)//\textcolor{stringliteral}{'"'}, 0)
2095       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"energetic\_PBL\_init: Unrecognized setting "}// &
2096             \textcolor{stringliteral}{"EPBL\_MSTAR\_SCHEME = "}//trim(tmpstr)//\textcolor{stringliteral}{" found in input file."})
2097 \textcolor{keywordflow}{  end select}
2098 
2099   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MSTAR"}, cs%fixed\_mstar, &
2100                  \textcolor{stringliteral}{"The ratio of the friction velocity cubed to the TKE input to the "}//&
2101                  \textcolor{stringliteral}{"mixed layer.  This option is used if EPBL\_MSTAR\_SCHEME = CONSTANT."}, &
2102                  units=\textcolor{stringliteral}{"nondim"}, default=1.2, do\_not\_log=(cs%mstar\_scheme/=use\_fixed\_mstar))
2103   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MSTAR\_CAP"}, cs%mstar\_cap, &
2104                  \textcolor{stringliteral}{"If this value is positive, it sets the maximum value of mstar "}//&
2105                  \textcolor{stringliteral}{"allowed in ePBL.  (This is not used if EPBL\_MSTAR\_SCHEME = CONSTANT)."}, &
2106                  units=\textcolor{stringliteral}{"nondim"}, default=-1.0, do\_not\_log=(cs%mstar\_scheme==use\_fixed\_mstar))
2107   \textcolor{comment}{! mstar\_scheme==MStar\_from\_Ekman options}
2108   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MSTAR2\_COEF1"}, cs%MSTAR\_COEF, &
2109                  \textcolor{stringliteral}{"Coefficient in computing mstar when rotation and stabilizing "}//&
2110                  \textcolor{stringliteral}{"effects are both important (used if EPBL\_MSTAR\_SCHEME = OM4)."}, &
2111                  units=\textcolor{stringliteral}{"nondim"}, default=0.3, do\_not\_log=(cs%mstar\_scheme/=mstar\_from\_ekman))
2112   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MSTAR2\_COEF2"}, cs%C\_EK, &
2113                  \textcolor{stringliteral}{"Coefficient in computing mstar when only rotation limits "}// &
2114                  \textcolor{stringliteral}{"the total mixing (used if EPBL\_MSTAR\_SCHEME = OM4)"}, &
2115                  units=\textcolor{stringliteral}{"nondim"}, default=0.085, do\_not\_log=(cs%mstar\_scheme/=mstar\_from\_ekman))
2116   \textcolor{comment}{! mstar\_scheme==MStar\_from\_RH18 options}
2117   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RH18\_MSTAR\_CN1"}, cs%RH18\_mstar\_cn1,&
2118                  \textcolor{stringliteral}{"MSTAR\_N coefficient 1 (outter-most coefficient for fit). "}//&
2119                  \textcolor{stringliteral}{"The value of 0.275 is given in RH18.  Increasing this "}//&
2120                  \textcolor{stringliteral}{"coefficient increases MSTAR for all values of Hf/ust, but more "}//&
2121                  \textcolor{stringliteral}{"effectively at low values (weakly developed OSBLs)."}, &
2122                  units=\textcolor{stringliteral}{"nondim"}, default=0.275, do\_not\_log=(cs%mstar\_scheme/=mstar\_from\_rh18))
2123   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RH18\_MSTAR\_CN2"}, cs%RH18\_mstar\_cn2,&
2124                  \textcolor{stringliteral}{"MSTAR\_N coefficient 2 (coefficient outside of exponential decay). "}//&
2125                  \textcolor{stringliteral}{"The value of 8.0 is given in RH18.  Increasing this coefficient "}//&
2126                  \textcolor{stringliteral}{"increases MSTAR for all values of HF/ust, with a much more even "}//&
2127                  \textcolor{stringliteral}{"effect across a wide range of Hf/ust than CN1."}, &
2128                  units=\textcolor{stringliteral}{"nondim"}, default=8.0, do\_not\_log=(cs%mstar\_scheme/=mstar\_from\_rh18))
2129   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RH18\_MSTAR\_CN3"}, cs%RH18\_mstar\_CN3,&
2130                  \textcolor{stringliteral}{"MSTAR\_N coefficient 3 (exponential decay coefficient). "}//&
2131                  \textcolor{stringliteral}{"The value of -5.0 is given in RH18.  Increasing this increases how "}//&
2132                  \textcolor{stringliteral}{"quickly the value of MSTAR decreases as Hf/ust increases."}, &
2133                   units=\textcolor{stringliteral}{"nondim"}, default=-5.0, do\_not\_log=(cs%mstar\_scheme/=mstar\_from\_rh18))
2134   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RH18\_MSTAR\_CS1"}, cs%RH18\_mstar\_cs1,&
2135                  \textcolor{stringliteral}{"MSTAR\_S coefficient for RH18 in stabilizing limit. "}//&
2136                  \textcolor{stringliteral}{"The value of 0.2 is given in RH18 and increasing it increases "}//&
2137                  \textcolor{stringliteral}{"MSTAR in the presence of a stabilizing surface buoyancy flux."}, &
2138                  units=\textcolor{stringliteral}{"nondim"}, default=0.2, do\_not\_log=(cs%mstar\_scheme/=mstar\_from\_rh18))
2139   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RH18\_MSTAR\_CS2"}, cs%RH18\_mstar\_cs2,&
2140                  \textcolor{stringliteral}{"MSTAR\_S exponent for RH18 in stabilizing limit. "}//&
2141                  \textcolor{stringliteral}{"The value of 0.4 is given in RH18 and increasing it increases MSTAR "}//&
2142                  \textcolor{stringliteral}{"exponentially in the presence of a stabilizing surface buoyancy flux."}, &
2143                  units=\textcolor{stringliteral}{"nondim"}, default=0.4, do\_not\_log=(cs%mstar\_scheme/=mstar\_from\_rh18))
2144 
2145 
2146 \textcolor{comment}{!/ Convective turbulence related options}
2147   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"NSTAR"}, cs%nstar, &
2148                  \textcolor{stringliteral}{"The portion of the buoyant potential energy imparted by "}//&
2149                  \textcolor{stringliteral}{"surface fluxes that is available to drive entrainment "}//&
2150                  \textcolor{stringliteral}{"at the base of mixed layer when that energy is positive."}, &
2151                  units=\textcolor{stringliteral}{"nondim"}, default=0.2)
2152   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MSTAR\_CONV\_ADJ"}, cs%mstar\_convect\_coef, &
2153                  \textcolor{stringliteral}{"Coefficient used for reducing mstar during convection "}//&
2154                  \textcolor{stringliteral}{"due to reduction of stable density gradient."}, &
2155                  units=\textcolor{stringliteral}{"nondim"}, default=0.0)
2156 
2157 \textcolor{comment}{!/ Mixing Length Options}
2158   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"USE\_MLD\_ITERATION"}, cs%Use\_MLD\_iteration, &
2159                  \textcolor{stringliteral}{"A logical that specifies whether or not to use the "}//&
2160                  \textcolor{stringliteral}{"distance to the bottom of the actively turbulent boundary "}//&
2161                  \textcolor{stringliteral}{"layer to help set the EPBL length scale."}, default=.true.)
2162   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_TRANSITION\_SCALE"}, cs%transLay\_scale, &
2163                  \textcolor{stringliteral}{"A scale for the mixing length in the transition layer "}//&
2164                  \textcolor{stringliteral}{"at the edge of the boundary layer as a fraction of the "}//&
2165                  \textcolor{stringliteral}{"boundary layer thickness."}, units=\textcolor{stringliteral}{"nondim"}, default=0.1)
2166   \textcolor{keywordflow}{if} ( cs%Use\_MLD\_iteration .and. abs(cs%transLay\_scale-0.5) >= 0.5) \textcolor{keywordflow}{then}
2167     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"If flag USE\_MLD\_ITERATION is true, then "}//&
2168                  \textcolor{stringliteral}{"EPBL\_TRANSITION should be greater than 0 and less than 1."})
2169 \textcolor{keywordflow}{  endif}
2170 
2171   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MLD\_ITERATION\_GUESS"}, cs%MLD\_ITERATION\_GUESS, &
2172                  \textcolor{stringliteral}{"If true, use the previous timestep MLD as a first guess in the MLD iteration, "}//&
2173                  \textcolor{stringliteral}{"otherwise use half the ocean depth as the first guess of the boundary layer "}//&
2174                  \textcolor{stringliteral}{"depth.  The default is false to facilitate reproducibility."}, &
2175                  default=.false., do\_not\_log=.not.cs%Use\_MLD\_iteration)
2176   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_MLD\_TOLERANCE"}, cs%MLD\_tol, &
2177                  \textcolor{stringliteral}{"The tolerance for the iteratively determined mixed "}//&
2178                  \textcolor{stringliteral}{"layer depth.  This is only used with USE\_MLD\_ITERATION."}, &
2179                  units=\textcolor{stringliteral}{"meter"}, default=1.0, scale=us%m\_to\_Z, do\_not\_log=.not.cs%Use\_MLD\_iteration)
2180   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_MLD\_BISECTION"}, cs%MLD\_bisection, &
2181                  \textcolor{stringliteral}{"If true, use bisection with the iterative determination of the self-consistent "}//&
2182                  \textcolor{stringliteral}{"mixed layer depth.  Otherwise use the false position after a maximum and minimum "}//&
2183                  \textcolor{stringliteral}{"bound have been evaluated and the returned value or bisection before this."}, &
2184                  default=.true., do\_not\_log=.not.cs%Use\_MLD\_iteration) \textcolor{comment}{!### The default should become
       false.}
2185   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_MLD\_MAX\_ITS"}, cs%max\_MLD\_its, &
2186                  \textcolor{stringliteral}{"The maximum number of iterations that can be used to find a self-consistent "}//&
2187                  \textcolor{stringliteral}{"mixed layer depth.  If EPBL\_MLD\_BISECTION is true, the maximum number "}//&
2188                  \textcolor{stringliteral}{"iteractions needed is set by Depth/2^MAX\_ITS < EPBL\_MLD\_TOLERANCE."}, &
2189                  default=20, do\_not\_log=.not.cs%Use\_MLD\_iteration)
2190   \textcolor{keywordflow}{if} (.not.cs%Use\_MLD\_iteration) cs%Max\_MLD\_Its = 1
2191   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_MIN\_MIX\_LEN"}, cs%min\_mix\_len, &
2192                  \textcolor{stringliteral}{"The minimum mixing length scale that will be used "}//&
2193                  \textcolor{stringliteral}{"by ePBL.  The default (0) does not set a minimum."}, &
2194                  units=\textcolor{stringliteral}{"meter"}, default=0.0, scale=us%m\_to\_Z)
2195 
2196   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MIX\_LEN\_EXPONENT"}, cs%MixLenExponent, &
2197                  \textcolor{stringliteral}{"The exponent applied to the ratio of the distance to the MLD "}//&
2198                  \textcolor{stringliteral}{"and the MLD depth which determines the shape of the mixing length. "}//&
2199                  \textcolor{stringliteral}{"This is only used if USE\_MLD\_ITERATION is True."}, &
2200                  units=\textcolor{stringliteral}{"nondim"}, default=2.0)
2201 
2202 \textcolor{comment}{!/ Turbulent velocity scale in mixing coefficient}
2203   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_VEL\_SCALE\_SCHEME"}, tmpstr, &
2204                  \textcolor{stringliteral}{"Selects the method for translating TKE into turbulent velocities. "}//&
2205                  \textcolor{stringliteral}{"Valid values are: \(\backslash\)n"}//&
2206                  \textcolor{stringliteral}{"\(\backslash\)t CUBE\_ROOT\_TKE  - A constant times the cube root of remaining TKE. \(\backslash\)n"}//&
2207                  \textcolor{stringliteral}{"\(\backslash\)t REICHL\_H18 - Use the scheme based on a combination of w* and v* as \(\backslash\)n"}//&
2208                  \textcolor{stringliteral}{"\(\backslash\)t              documented in Reichl & Hallberg, 2018."}, &
2209                  default=root\_tke\_string, do\_not\_log=.true.)
2210   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_VEL\_SCALE\_MODE"}, wt\_mode, default=-1)
2211   \textcolor{keywordflow}{if} (wt\_mode == 0) \textcolor{keywordflow}{then}
2212     tmpstr = root\_tke\_string
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."})
2214   \textcolor{keywordflow}{elseif} (wt\_mode == 1) \textcolor{keywordflow}{then}
2215     tmpstr = rh18\_string
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."})
2217   \textcolor{keywordflow}{elseif} (wt\_mode >= 2) \textcolor{keywordflow}{then}
2218     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"An unrecognized value of the obsolete parameter EPBL\_VEL\_SCALE\_MODE was
       specified."})
2219 \textcolor{keywordflow}{  endif}
2220   \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_VEL\_SCALE\_SCHEME"}, tmpstr, &
2221                  \textcolor{stringliteral}{"Selects the method for translating TKE into turbulent velocities. "}//&
2222                  \textcolor{stringliteral}{"Valid values are: \(\backslash\)n"}//&
2223                  \textcolor{stringliteral}{"\(\backslash\)t CUBE\_ROOT\_TKE  - A constant times the cube root of remaining TKE. \(\backslash\)n"}//&
2224                  \textcolor{stringliteral}{"\(\backslash\)t REICHL\_H18 - Use the scheme based on a combination of w* and v* as \(\backslash\)n"}//&
2225                  \textcolor{stringliteral}{"\(\backslash\)t              documented in Reichl & Hallberg, 2018."}, &
2226                  default=root\_tke\_string)
2227   tmpstr = uppercase(tmpstr)
2228   \textcolor{keywordflow}{select case} (tmpstr)
2229     \textcolor{keywordflow}{case} (root\_tke\_string)
2230       cs%wT\_scheme = wt\_from\_croot\_tke
2231     \textcolor{keywordflow}{case} (rh18\_string)
2232       cs%wT\_scheme = wt\_from\_rh18
2233 \textcolor{keywordflow}{    case default}
2234       \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{'energetic\_PBL\_init: EPBL\_VEL\_SCALE\_SCHEME ="'}//trim(tmpstr)//\textcolor{stringliteral}{'"'}, 0)
2235       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"energetic\_PBL\_init: Unrecognized setting "}// &
2236             \textcolor{stringliteral}{"EPBL\_VEL\_SCALE\_SCHEME = "}//trim(tmpstr)//\textcolor{stringliteral}{" found in input file."})
2237 \textcolor{keywordflow}{  end select}
2238 
2239   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"WSTAR\_USTAR\_COEF"}, cs%wstar\_ustar\_coef, &
2240                  \textcolor{stringliteral}{"A ratio relating the efficiency with which convectively "}//&
2241                  \textcolor{stringliteral}{"released energy is converted to a turbulent velocity, "}//&
2242                  \textcolor{stringliteral}{"relative to mechanically forced TKE. Making this larger "}//&
2243                  \textcolor{stringliteral}{"increases the BL diffusivity"}, units=\textcolor{stringliteral}{"nondim"}, default=1.0)
2244   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_VEL\_SCALE\_FACTOR"}, cs%vstar\_scale\_fac, &
2245                  \textcolor{stringliteral}{"An overall nondimensional scaling factor for wT. "}//&
2246                  \textcolor{stringliteral}{"Making this larger increases the PBL diffusivity."}, &
2247                  units=\textcolor{stringliteral}{"nondim"}, default=1.0)
2248   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"VSTAR\_SURF\_FAC"}, cs%vstar\_surf\_fac,&
2249                  \textcolor{stringliteral}{"The proportionality times ustar to set vstar at the surface."}, &
2250                  units=\textcolor{stringliteral}{"nondim"}, default=1.2)
2251 
2252   \textcolor{comment}{!/ Options related to Langmuir turbulence}
2253   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"USE\_LA\_LI2016"}, use\_la\_windsea, &
2254        \textcolor{stringliteral}{"A logical to use the Li et al. 2016 (submitted) formula to "}//&
2255        \textcolor{stringliteral}{"determine the Langmuir number."}, units=\textcolor{stringliteral}{"nondim"}, default=.false.)
2256   \textcolor{comment}{! Note this can be activated in other ways, but this preserves the old method.}
2257   \textcolor{keywordflow}{if} (use\_la\_windsea) \textcolor{keywordflow}{then}
2258     cs%USE\_LT = .true.
2259   \textcolor{keywordflow}{else}
2260     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_LT"}, cs%USE\_LT, &
2261                  \textcolor{stringliteral}{"A logical to use a LT parameterization."}, &
2262                  units=\textcolor{stringliteral}{"nondim"}, default=.false.)
2263 \textcolor{keywordflow}{  endif}
2264   \textcolor{keywordflow}{if} (cs%USE\_LT) \textcolor{keywordflow}{then}
2265     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_LANGMUIR\_SCHEME"}, tmpstr, &
2266                  \textcolor{stringliteral}{"EPBL\_LANGMUIR\_SCHEME selects the method for including Langmuir turbulence. "}//&
2267                  \textcolor{stringliteral}{"Valid values are: \(\backslash\)n"}//&
2268                  \textcolor{stringliteral}{"\(\backslash\)t NONE     - Do not do any extra mixing due to Langmuir turbulence \(\backslash\)n"}//&
2269                  \textcolor{stringliteral}{"\(\backslash\)t RESCALE  - Use a multiplicative rescaling of mstar to account for Langmuir turbulence
       \(\backslash\)n"}//&
2270                  \textcolor{stringliteral}{"\(\backslash\)t ADDITIVE - Add a Langmuir turblence contribution to mstar to other contributions"}, &
2271                  default=none\_string, do\_not\_log=.true.)
2272     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LT\_ENHANCE"}, lt\_enhance, default=-1)
2273     \textcolor{keywordflow}{if} (lt\_enhance == 0) \textcolor{keywordflow}{then}
2274       tmpstr = none\_string
2275       \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"Use EPBL\_LANGMUIR\_SCHEME = NONE instead of the archaic LT\_ENHANCE = 0."})
2276     \textcolor{keywordflow}{elseif} (lt\_enhance == 1) \textcolor{keywordflow}{then}
2277       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"You are using a legacy LT\_ENHANCE mode in ePBL that has been phased out. "}//&
2278                             \textcolor{stringliteral}{"If you need to use this setting please report this error.  Also use "}//&
2279                             \textcolor{stringliteral}{"EPBL\_LANGMUIR\_SCHEME to specify the scheme for mstar."})
2280     \textcolor{keywordflow}{elseif} (lt\_enhance == 2) \textcolor{keywordflow}{then}
2281       tmpstr = rescaled\_string
2282       \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"Use EPBL\_LANGMUIR\_SCHEME = RESCALE instead of the archaic LT\_ENHANCE = 2."})
2283     \textcolor{keywordflow}{elseif} (lt\_enhance == 3) \textcolor{keywordflow}{then}
2284       tmpstr = additive\_string
2285       \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"Use EPBL\_LANGMUIR\_SCHEME = ADDITIVE instead of the archaic LT\_ENHANCE = 3."})
2286     \textcolor{keywordflow}{elseif} (lt\_enhance > 3) \textcolor{keywordflow}{then}
2287       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"An unrecognized value of the obsolete parameter LT\_ENHANCE was specified."})
2288 \textcolor{keywordflow}{    endif}
2289     \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"EPBL\_LANGMUIR\_SCHEME"}, tmpstr, &
2290                  \textcolor{stringliteral}{"EPBL\_LANGMUIR\_SCHEME selects the method for including Langmuir turbulence. "}//&
2291                  \textcolor{stringliteral}{"Valid values are: \(\backslash\)n"}//&
2292                  \textcolor{stringliteral}{"\(\backslash\)t NONE     - Do not do any extra mixing due to Langmuir turbulence \(\backslash\)n"}//&
2293                  \textcolor{stringliteral}{"\(\backslash\)t RESCALE  - Use a multiplicative rescaling of mstar to account for Langmuir turbulence
       \(\backslash\)n"}//&
2294                  \textcolor{stringliteral}{"\(\backslash\)t ADDITIVE - Add a Langmuir turblence contribution to mstar to other contributions"}, &
2295                  default=none\_string)
2296     tmpstr = uppercase(tmpstr)
2297     \textcolor{keywordflow}{select case} (tmpstr)
2298       \textcolor{keywordflow}{case} (none\_string)
2299         cs%LT\_enhance\_form = no\_langmuir
2300       \textcolor{keywordflow}{case} (rescaled\_string)
2301         cs%LT\_enhance\_form = langmuir\_rescale
2302       \textcolor{keywordflow}{case} (additive\_string)
2303         cs%LT\_enhance\_form = langmuir\_add
2304 \textcolor{keywordflow}{      case default}
2305         \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{'energetic\_PBL\_init: EPBL\_LANGMUIR\_SCHEME ="'}//trim(tmpstr)//\textcolor{stringliteral}{'"'}, 0)
2306         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"energetic\_PBL\_init: Unrecognized setting "}// &
2307               \textcolor{stringliteral}{"EPBL\_LANGMUIR\_SCHEME = "}//trim(tmpstr)//\textcolor{stringliteral}{" found in input file."})
2308 \textcolor{keywordflow}{    end select}
2309 
2310     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LT\_ENHANCE\_COEF"}, cs%LT\_ENHANCE\_COEF, &
2311                  \textcolor{stringliteral}{"Coefficient for Langmuir enhancement of mstar"}, &
2312                  units=\textcolor{stringliteral}{"nondim"}, default=0.447, do\_not\_log=(cs%LT\_enhance\_form==no\_langmuir))
2313     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LT\_ENHANCE\_EXP"}, cs%LT\_ENHANCE\_EXP, &
2314                  \textcolor{stringliteral}{"Exponent for Langmuir enhancementt of mstar"}, &
2315                  units=\textcolor{stringliteral}{"nondim"}, default=-1.33,  do\_not\_log=(cs%LT\_enhance\_form==no\_langmuir))
2316     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LT\_MOD\_LAC1"}, cs%LaC\_MLDoEK, &
2317                  \textcolor{stringliteral}{"Coefficient for modification of Langmuir number due to "}//&
2318                  \textcolor{stringliteral}{"MLD approaching Ekman depth."}, &
2319                  units=\textcolor{stringliteral}{"nondim"}, default=-0.87,  do\_not\_log=(cs%LT\_enhance\_form==no\_langmuir))
2320     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LT\_MOD\_LAC2"}, cs%LaC\_MLDoOB\_stab, &
2321                  \textcolor{stringliteral}{"Coefficient for modification of Langmuir number due to "}//&
2322                  \textcolor{stringliteral}{"MLD approaching stable Obukhov depth."}, &
2323                  units=\textcolor{stringliteral}{"nondim"}, default=0.0,  do\_not\_log=(cs%LT\_enhance\_form==no\_langmuir))
2324     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LT\_MOD\_LAC3"}, cs%LaC\_MLDoOB\_un, &
2325                  \textcolor{stringliteral}{"Coefficient for modification of Langmuir number due to "}//&
2326                  \textcolor{stringliteral}{"MLD approaching unstable Obukhov depth."}, &
2327                  units=\textcolor{stringliteral}{"nondim"}, default=0.0,  do\_not\_log=(cs%LT\_enhance\_form==no\_langmuir))
2328     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LT\_MOD\_LAC4"}, cs%Lac\_EKoOB\_stab, &
2329                  \textcolor{stringliteral}{"Coefficient for modification of Langmuir number due to "}//&
2330                  \textcolor{stringliteral}{"ratio of Ekman to stable Obukhov depth."}, &
2331                  units=\textcolor{stringliteral}{"nondim"}, default=0.95,  do\_not\_log=(cs%LT\_enhance\_form==no\_langmuir))
2332     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LT\_MOD\_LAC5"}, cs%Lac\_EKoOB\_un, &
2333                  \textcolor{stringliteral}{"Coefficient for modification of Langmuir number due to "}//&
2334                  \textcolor{stringliteral}{"ratio of Ekman to unstable Obukhov depth."}, &
2335                  units=\textcolor{stringliteral}{"nondim"}, default=0.95,  do\_not\_log=(cs%LT\_enhance\_form==no\_langmuir))
2336 \textcolor{keywordflow}{  endif}
2337 
2338 
2339 \textcolor{comment}{!/ Logging parameters}
2340   \textcolor{comment}{! This gives a minimum decay scale that is typically much less than Angstrom.}
2341   cs%ustar\_min = 2e-4*cs%omega*(gv%Angstrom\_Z + gv%H\_to\_Z*gv%H\_subroundoff)
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, &
2343                  \textcolor{stringliteral}{"The (tiny) minimum friction velocity used within the "}//&
2344                  \textcolor{stringliteral}{"ePBL code, derived from OMEGA and ANGSTROM."}, units=\textcolor{stringliteral}{"m s-1"}, &
2345                  like\_default=.true.)
2346 
2347 
2348 \textcolor{comment}{!/ Checking output flags}
2349   cs%id\_ML\_depth = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ePBL\_h\_ML'}, diag%axesT1, &
2350       time, \textcolor{stringliteral}{'Surface boundary layer depth'}, \textcolor{stringliteral}{'m'}, conversion=us%Z\_to\_m, &
2351       cmor\_long\_name=\textcolor{stringliteral}{'Ocean Mixed Layer Thickness Defined by Mixing Scheme'})
2352   \textcolor{comment}{! This is an alias for the same variable as ePBL\_h\_ML}
2353   cs%id\_hML\_depth = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'h\_ML'}, diag%axesT1, &
2354       time, \textcolor{stringliteral}{'Surface mixed layer depth based on active turbulence'}, \textcolor{stringliteral}{'m'}, conversion=us%Z\_to\_m)
2355   cs%id\_TKE\_wind = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ePBL\_TKE\_wind'}, diag%axesT1, &
2356       time, \textcolor{stringliteral}{'Wind-stirring source of mixed layer TKE'}, \textcolor{stringliteral}{'W m-2'}, conversion=us%RZ3\_T3\_to\_W\_m2)
2357   cs%id\_TKE\_MKE = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ePBL\_TKE\_MKE'}, diag%axesT1, &
2358       time, \textcolor{stringliteral}{'Mean kinetic energy source of mixed layer TKE'}, \textcolor{stringliteral}{'W m-2'}, conversion=us%RZ3\_T3\_to\_W\_m2)
2359   cs%id\_TKE\_conv = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ePBL\_TKE\_conv'}, diag%axesT1, &
2360       time, \textcolor{stringliteral}{'Convective source of mixed layer TKE'}, \textcolor{stringliteral}{'W m-2'}, conversion=us%RZ3\_T3\_to\_W\_m2)
2361   cs%id\_TKE\_forcing = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ePBL\_TKE\_forcing'}, diag%axesT1, &
2362       time, \textcolor{stringliteral}{'TKE consumed by mixing surface forcing or penetrative shortwave radation '}//&
2363             \textcolor{stringliteral}{'through model layers'}, \textcolor{stringliteral}{'W m-2'}, conversion=us%RZ3\_T3\_to\_W\_m2)
2364   cs%id\_TKE\_mixing = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ePBL\_TKE\_mixing'}, diag%axesT1, &
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)
2366   cs%id\_TKE\_mech\_decay = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ePBL\_TKE\_mech\_decay'}, diag%axesT1, &
2367       time, \textcolor{stringliteral}{'Mechanical energy decay sink of mixed layer TKE'}, \textcolor{stringliteral}{'W m-2'}, conversion=us%RZ3\_T3\_to\_W\_m2)
2368   cs%id\_TKE\_conv\_decay = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'ePBL\_TKE\_conv\_decay'}, diag%axesT1, &
2369       time, \textcolor{stringliteral}{'Convective energy decay sink of mixed layer TKE'}, \textcolor{stringliteral}{'W m-2'}, conversion=us%RZ3\_T3\_to\_W\_m2)
2370   cs%id\_Mixing\_Length = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'Mixing\_Length'}, diag%axesTi, &
2371       time, \textcolor{stringliteral}{'Mixing Length that is used'}, \textcolor{stringliteral}{'m'}, conversion=us%Z\_to\_m)
2372   cs%id\_Velocity\_Scale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'Velocity\_Scale'}, diag%axesTi, &
2373       time, \textcolor{stringliteral}{'Velocity Scale that is used.'}, \textcolor{stringliteral}{'m s-1'}, conversion=us%Z\_to\_m*us%s\_to\_T)
2374   cs%id\_MSTAR\_mix = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'MSTAR'}, diag%axesT1, &
2375       time, \textcolor{stringliteral}{'Total mstar that is used.'}, \textcolor{stringliteral}{'nondim'})
2376 
2377   \textcolor{keywordflow}{if} (cs%use\_LT) \textcolor{keywordflow}{then}
2378     cs%id\_LA = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'LA'}, diag%axesT1, &
2379         time, \textcolor{stringliteral}{'Langmuir number.'}, \textcolor{stringliteral}{'nondim'})
2380     cs%id\_LA\_mod = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'LA\_MOD'}, diag%axesT1, &
2381         time, \textcolor{stringliteral}{'Modified Langmuir number.'}, \textcolor{stringliteral}{'nondim'})
2382     cs%id\_MSTAR\_LT = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'MSTAR\_LT'}, diag%axesT1, &
2383         time, \textcolor{stringliteral}{'Increase in mstar due to Langmuir Turbulence.'}, \textcolor{stringliteral}{'nondim'})
2384 \textcolor{keywordflow}{  endif}
2385 
2386   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ENABLE\_THERMODYNAMICS"}, use\_temperature, &
2387                  \textcolor{stringliteral}{"If true, temperature and salinity are used as state "}//&
2388                  \textcolor{stringliteral}{"variables."}, default=.true.)
2389 
2390   \textcolor{keywordflow}{if} (report\_avg\_its) \textcolor{keywordflow}{then}
2391     cs%sum\_its(1) = real\_to\_efp(0.0) ; cs%sum\_its(2) = real\_to\_efp(0.0)
2392 \textcolor{keywordflow}{  endif}
2393 
2394   \textcolor{keywordflow}{if} (max(cs%id\_TKE\_wind, cs%id\_TKE\_MKE, cs%id\_TKE\_conv, &
2395           cs%id\_TKE\_mixing, cs%id\_TKE\_mech\_decay, cs%id\_TKE\_forcing, &
2396           cs%id\_TKE\_conv\_decay) > 0) \textcolor{keywordflow}{then}
2397     \textcolor{keyword}{call }safe\_alloc\_alloc(cs%diag\_TKE\_wind, isd, ied, jsd, jed)
2398     \textcolor{keyword}{call }safe\_alloc\_alloc(cs%diag\_TKE\_MKE, isd, ied, jsd, jed)
2399     \textcolor{keyword}{call }safe\_alloc\_alloc(cs%diag\_TKE\_conv, isd, ied, jsd, jed)
2400     \textcolor{keyword}{call }safe\_alloc\_alloc(cs%diag\_TKE\_forcing, isd, ied, jsd, jed)
2401     \textcolor{keyword}{call }safe\_alloc\_alloc(cs%diag\_TKE\_mixing, isd, ied, jsd, jed)
2402     \textcolor{keyword}{call }safe\_alloc\_alloc(cs%diag\_TKE\_mech\_decay, isd, ied, jsd, jed)
2403     \textcolor{keyword}{call }safe\_alloc\_alloc(cs%diag\_TKE\_conv\_decay, isd, ied, jsd, jed)
2404 
2405     cs%TKE\_diagnostics = .true.
2406 \textcolor{keywordflow}{  endif}
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)
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)
2409 
2410   \textcolor{keyword}{call }safe\_alloc\_alloc(cs%ML\_depth, isd, ied, jsd, jed)
2411   \textcolor{keywordflow}{if} (max(cs%id\_mstar\_mix, cs%id\_LA, cs%id\_LA\_mod, cs%id\_MSTAR\_LT ) >0) \textcolor{keywordflow}{then}
2412     \textcolor{keyword}{call }safe\_alloc\_alloc(cs%Mstar\_mix, isd, ied, jsd, jed)
2413     \textcolor{keyword}{call }safe\_alloc\_alloc(cs%LA, isd, ied, jsd, jed)
2414     \textcolor{keyword}{call }safe\_alloc\_alloc(cs%LA\_MOD, isd, ied, jsd, jed)
2415     \textcolor{keyword}{call }safe\_alloc\_alloc(cs%MSTAR\_LT, isd, ied, jsd, jed)
2416 \textcolor{keywordflow}{  endif}
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}}
\subsubsection{\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(\hyperlink{structmom__energetic__pbl_1_1energetic__pbl__cs}{energetic\+\_\+pbl\+\_\+cs}), pointer}]{CS,  }\item[{type(\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{\tt in}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure.\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em u} & Zonal velocities interpolated to h points \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em v} & Zonal velocities interpolated to h points \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em t0} & The initial layer temperatures \mbox{[}degC\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em s0} & The initial layer salinities \mbox{[}ppt\mbox{]}.\\
\hline
\mbox{\tt 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{\tt 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{\tt 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{\tt in}  & {\em b\+\_\+flux} & The surface buoyancy flux \mbox{[}Z2 T-\/3 $\sim$$>$ m2 s-\/3\mbox{]}\\
\hline
\mbox{\tt in}  & {\em absf} & The absolute value of the Coriolis parameter \mbox{[}T-\/1 $\sim$$>$ s-\/1\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em u\+\_\+star} & The surface friction velocity \mbox{[}Z T-\/1 $\sim$$>$ m s-\/1\mbox{]}.\\
\hline
\mbox{\tt 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{\tt 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{\tt in}  & {\em dt} & Time increment \mbox{[}T $\sim$$>$ s\mbox{]}.\\
\hline
\mbox{\tt out}  & {\em kd} & The diagnosed diffusivities at interfaces\\
\hline
\mbox{\tt out}  & {\em mixvel} & The mixing velocity scale used in Kd\\
\hline
\mbox{\tt 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{\tt in,out}  & {\em ecd} & A container for passing around diagnostics.\\
\hline
\mbox{\tt 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{\tt in,out}  & {\em g} & The ocean\textquotesingle{}s grid structure.\\
\hline
\mbox{\tt in}  & {\em i} & The i-\/index to work on (used for Waves)\\
\hline
\mbox{\tt 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}
547   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{     !< The ocean's vertical grid structure.}
548   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{     !< A dimensional unit scaling type}
549   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}  :: h\textcolor{comment}{      !< Layer thicknesses [H ~> m or kg m-2].}
550   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}  :: u\textcolor{comment}{      !< Zonal velocities interpolated to h points}
551 \textcolor{comment}{                                                   !! [L T-1 ~> m s-1].}
552   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}  :: v\textcolor{comment}{      !< Zonal velocities interpolated to h points}
553 \textcolor{comment}{                                                   !! [L T-1 ~> m s-1].}
554   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}  :: t0\textcolor{comment}{     !< The initial layer temperatures [degC].}
555   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}  :: s0\textcolor{comment}{     !< The initial layer salinities [ppt].}
556 
557   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}  :: dsv\_dt\textcolor{comment}{ !< The partial derivative of in-situ specific}
558 \textcolor{comment}{                                                   !! volume with potential temperature}
559 \textcolor{comment}{                                                   !! [R-1 degC-1 ~> m3 kg-1 degC-1].}
560   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}  :: dsv\_ds\textcolor{comment}{ !< The partial derivative of in-situ specific}
561 \textcolor{comment}{                                                   !! volume with salinity [R-1 ppt-1 ~> m3 kg-1 ppt-1].}
562   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}  :: tke\_forcing\textcolor{comment}{ !< The forcing requirements to homogenize the}
563 \textcolor{comment}{                                                   !! forcing that has been applied to each layer}
564 \textcolor{comment}{                                                   !! [R Z3 T-2 ~> J m-2].}
565   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{intent(in)}    :: b\_flux\textcolor{comment}{ !< The surface buoyancy flux [Z2 T-3 ~> m2 s-3]}
566   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{intent(in)}    :: absf\textcolor{comment}{   !< The absolute value of the Coriolis parameter [T-1 ~>
       s-1].}
567   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{intent(in)}    :: u\_star\textcolor{comment}{ !< The surface friction velocity [Z T-1 ~> m s-1].}
568   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{intent(in)}    :: u\_star\_mean\textcolor{comment}{ !< The surface friction velocity without any}
569 \textcolor{comment}{                                                   !! contribution from unresolved gustiness  [Z T-1 ~> m
       s-1].}
570   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{intent(inout)} :: mld\_io\textcolor{comment}{ !< A first guess at the mixed layer depth on input, and}
571 \textcolor{comment}{                                                   !! the calculated mixed layer depth on output [Z ~> m].}
572   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{     !< Time increment [T ~> s].}
573   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV)+1)}, &
574                            \textcolor{keywordtype}{intent(out)}   :: kd\textcolor{comment}{     !< The diagnosed diffusivities at interfaces}
575 \textcolor{comment}{                                                   !! [Z2 T-1 ~> m2 s-1].}
576   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV)+1)}, &
577                            \textcolor{keywordtype}{intent(out)}   :: mixvel\textcolor{comment}{ !< The mixing velocity scale used in Kd}
578 \textcolor{comment}{                                                   !! [Z T-1 ~> m s-1].}
579   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV)+1)}, &
580                            \textcolor{keywordtype}{intent(out)}   :: mixlen\textcolor{comment}{ !< The mixing length scale used in Kd [Z ~> m].}
581   \textcolor{keywordtype}{type}(energetic\_pbl\_cs),  \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{     !< The control structure returned by a previous}
582 \textcolor{comment}{                                                   !! call to mixedlayer\_init.}
583   \textcolor{keywordtype}{type}(epbl\_column\_diags), \textcolor{keywordtype}{intent(inout)} :: ecd\textcolor{comment}{    !< A container for passing around diagnostics.}
584   \textcolor{keywordtype}{real},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dt\_diag\textcolor{comment}{   !< The diagnostic time step, which may be less}
585 \textcolor{comment}{                                                   !! than dt if there are two calls to mixedlayer [T ~>
       s].}
586   \textcolor{keywordtype}{type}(wave\_parameters\_cs), &
587                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}       :: waves\textcolor{comment}{  !< Wave CS for Langmuir turbulence}
588   \textcolor{keywordtype}{type}(ocean\_grid\_type), &
589                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{      !< The ocean's grid structure.}
590   \textcolor{keywordtype}{integer},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: i\textcolor{comment}{      !< The i-index to work on (used for Waves)}
591   \textcolor{keywordtype}{integer},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: j\textcolor{comment}{      !< The i-index to work on (used for Waves)}
592 
593 \textcolor{comment}{!    This subroutine determines the diffusivities in a single column from the integrated energetics}
594 \textcolor{comment}{!  planetary boundary layer (ePBL) model.  It assumes that heating, cooling and freshwater fluxes}
595 \textcolor{comment}{!  have already been applied.  All calculations are done implicitly, and there}
596 \textcolor{comment}{!  is no stability limit on the time step.}
597 \textcolor{comment}{!}
598 \textcolor{comment}{!    For each interior interface, first discard the TKE to account for mixing}
599 \textcolor{comment}{! of shortwave radiation through the next denser cell.  Next drive mixing based}
600 \textcolor{comment}{! on the local? values of ustar + wstar, subject to available energy.  This}
601 \textcolor{comment}{! step sets the value of Kd(K).  Any remaining energy is then subject to decay}
602 \textcolor{comment}{! before being handed off to the next interface.  mech\_TKE and conv\_PErel are treated}
603 \textcolor{comment}{! separately for the purposes of decay, but are used proportionately to drive}
604 \textcolor{comment}{! mixing.}
605 
606   \textcolor{comment}{! Local variables}
607   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV)+1)} :: &
608     pres\_z, &       \textcolor{comment}{! Interface pressures with a rescaling factor to convert interface height}
609                     \textcolor{comment}{! movements into changes in column potential energy [R Z2 T-2 ~> kg m-1 s-2].}
610     hb\_hs           \textcolor{comment}{! The distance from the bottom over the thickness of the}
611                     \textcolor{comment}{! water column [nondim].}
612   \textcolor{keywordtype}{real} :: mech\_tke  \textcolor{comment}{!   The mechanically generated turbulent kinetic energy}
613                     \textcolor{comment}{! available for mixing over a time step [R Z3 T-2 ~> J m-2].}
614   \textcolor{keywordtype}{real} :: conv\_perel \textcolor{comment}{! The potential energy that has been convectively released}
615                     \textcolor{comment}{! during this timestep [R Z3 T-2 ~> J m-2]. A portion nstar\_FC}
616                     \textcolor{comment}{! of conv\_PErel is available to drive mixing.}
617   \textcolor{keywordtype}{real} :: htot      \textcolor{comment}{!   The total depth of the layers above an interface [H ~> m or kg m-2].}
618   \textcolor{keywordtype}{real} :: uhtot     \textcolor{comment}{!   The depth integrated zonal and meridional velocities in the}
619   \textcolor{keywordtype}{real} :: vhtot     \textcolor{comment}{! layers above [H L T-1 ~> m2 s-1 or kg m-1 s-1].}
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].}
621   \textcolor{keywordtype}{real} :: h\_sum     \textcolor{comment}{! The total thickness of the water column [H ~> m or kg m-2].}
622 
623   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: &
624     dt\_to\_dcolht, & \textcolor{comment}{! Partial derivative of the total column height with the temperature changes}
625                     \textcolor{comment}{! within a layer [Z degC-1 ~> m degC-1].}
626     ds\_to\_dcolht, & \textcolor{comment}{! Partial derivative of the total column height with the salinity changes}
627                     \textcolor{comment}{! within a layer  [Z ppt-1 ~> m ppt-1].}
628     dt\_to\_dpe, &    \textcolor{comment}{! Partial derivatives of column potential energy with the temperature}
629                     \textcolor{comment}{! changes within a layer, in [R Z3 T-2 degC-1 ~> J m-2 degC-1].}
630     ds\_to\_dpe, &    \textcolor{comment}{! Partial derivatives of column potential energy with the salinity changes}
631                     \textcolor{comment}{! within a layer, in [R Z3 T-2 ppt-1 ~> J m-2 ppt-1].}
632     dt\_to\_dcolht\_a, & \textcolor{comment}{! Partial derivative of the total column height with the temperature changes}
633                     \textcolor{comment}{! within a layer, including the implicit effects  of mixing with layers higher}
634                     \textcolor{comment}{! in the water column [Z degC-1 ~> m degC-1].}
635     ds\_to\_dcolht\_a, & \textcolor{comment}{! Partial derivative of the total column height with the salinity changes}
636                     \textcolor{comment}{! within a layer, including the implicit effects  of mixing with layers higher}
637                     \textcolor{comment}{! in the water column [Z ppt-1 ~> m ppt-1].}
638     dt\_to\_dpe\_a, &  \textcolor{comment}{! Partial derivatives of column potential energy with the temperature changes}
639                     \textcolor{comment}{! within a layer, including the implicit effects of mixing with layers higher}
640                     \textcolor{comment}{! in the water column [R Z3 T-2 degC-1 ~> J m-2 degC-1].}
641     ds\_to\_dpe\_a, &  \textcolor{comment}{! Partial derivative of column potential energy with the salinity changes}
642                     \textcolor{comment}{! within a layer, including the implicit effects of mixing with layers higher}
643                     \textcolor{comment}{! in the water column [R Z3 T-2 ppt-1 ~> J m-2 ppt-1].}
644     c1, &           \textcolor{comment}{! c1 is used by the tridiagonal solver [nondim].}
645     te, &           \textcolor{comment}{! Estimated final values of T in the column [degC].}
646     se, &           \textcolor{comment}{! Estimated final values of S in the column [ppt].}
647     dte, &          \textcolor{comment}{! Running (1-way) estimates of temperature change [degC].}
648     dse, &          \textcolor{comment}{! Running (1-way) estimates of salinity change [ppt].}
649     th\_a, &         \textcolor{comment}{! An effective temperature times a thickness in the layer above, including implicit}
650                     \textcolor{comment}{! mixing effects with other yet higher layers [degC H ~> degC m or degC kg m-2].}
651     sh\_a, &         \textcolor{comment}{! An effective salinity times a thickness in the layer above, including implicit}
652                     \textcolor{comment}{! mixing effects with other yet higher layers [ppt H ~> ppt m or ppt kg m-2].}
653     th\_b, &         \textcolor{comment}{! An effective temperature times a thickness in the layer below, including implicit}
654                     \textcolor{comment}{! mixing effects with other yet lower layers [degC H ~> degC m or degC kg m-2].}
655     sh\_b            \textcolor{comment}{! An effective salinity times a thickness in the layer below, including implicit}
656                     \textcolor{comment}{! mixing effects with other yet lower layers [ppt H ~> ppt m or ppt kg m-2].}
657   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV)+1)} :: &
658     mixlen\_shape, & \textcolor{comment}{! A nondimensional shape factor for the mixing length that}
659                     \textcolor{comment}{! gives it an appropriate assymptotic value at the bottom of}
660                     \textcolor{comment}{! the boundary layer.}
661     kddt\_h          \textcolor{comment}{! The diapycnal diffusivity times a timestep divided by the}
662                     \textcolor{comment}{! average thicknesses around a layer [H ~> m or kg m-2].}
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].}
664   \textcolor{keywordtype}{real} :: hp\_a      \textcolor{comment}{! An effective pivot thickness of the layer including the effects}
665                     \textcolor{comment}{! of coupling with layers above [H ~> m or kg m-2].  This is the first term}
666                     \textcolor{comment}{! in the denominator of b1 in a downward-oriented tridiagonal solver.}
667   \textcolor{keywordtype}{real} :: h\_neglect \textcolor{comment}{! A thickness that is so small it is usually lost}
668                     \textcolor{comment}{! in roundoff and can be neglected [H ~> m or kg m-2].}
669   \textcolor{keywordtype}{real} :: dmass     \textcolor{comment}{! The mass per unit area within a layer [Z R ~> kg m-2].}
670   \textcolor{keywordtype}{real} :: dpres     \textcolor{comment}{! The hydrostatic pressure change across a layer [R Z2 T-2 ~> Pa = J m-3].}
671   \textcolor{keywordtype}{real} :: dmke\_max  \textcolor{comment}{! The maximum amount of mean kinetic energy that could be}
672                     \textcolor{comment}{! converted to turbulent kinetic energy if the velocity in}
673                     \textcolor{comment}{! the layer below an interface were homogenized with all of}
674                     \textcolor{comment}{! the water above the interface [R Z3 T-2 ~> J m-2].}
675   \textcolor{keywordtype}{real} :: mke2\_hharm \textcolor{comment}{! Twice the inverse of the harmonic mean of the thickness}
676                     \textcolor{comment}{! of a layer and the thickness of the water above, used in}
677                     \textcolor{comment}{! the MKE conversion equation [H-1 ~> m-1 or m2 kg-1].}
678 
679   \textcolor{keywordtype}{real} :: dt\_h      \textcolor{comment}{! The timestep divided by the averages of the thicknesses around}
680                     \textcolor{comment}{! a layer, times a thickness conversion factor [H T m-2 ~> s m-1 or kg s m-4].}
681   \textcolor{keywordtype}{real} :: h\_bot     \textcolor{comment}{! The distance from the bottom [H ~> m or kg m-2].}
682   \textcolor{keywordtype}{real} :: h\_rsum    \textcolor{comment}{! The running sum of h from the top [Z ~> m].}
683   \textcolor{keywordtype}{real} :: i\_hs      \textcolor{comment}{! The inverse of h\_sum [H-1 ~> m-1 or m2 kg-1].}
684   \textcolor{keywordtype}{real} :: i\_mld     \textcolor{comment}{! The inverse of the current value of MLD [Z-1 ~> m-1].}
685   \textcolor{keywordtype}{real} :: h\_tt      \textcolor{comment}{! The distance from the surface or up to the next interface}
686                     \textcolor{comment}{! that did not exhibit turbulent mixing from this scheme plus}
687                     \textcolor{comment}{! a surface mixing roughness length given by h\_tt\_min [H ~> m or kg m-2].}
688   \textcolor{keywordtype}{real} :: h\_tt\_min  \textcolor{comment}{! A surface roughness length [H ~> m or kg m-2].}
689 
690   \textcolor{keywordtype}{real} :: c1\_3      \textcolor{comment}{! = 1/3.}
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].}
692                     \textcolor{comment}{! This is used convert TKE back into ustar^3.}
693   \textcolor{keywordtype}{real} :: vstar     \textcolor{comment}{! An in-situ turbulent velocity [Z T-1 ~> m s-1].}
694   \textcolor{keywordtype}{real} :: mstar\_total \textcolor{comment}{! The value of mstar used in ePBL [nondim]}
695   \textcolor{keywordtype}{real} :: mstar\_lt  \textcolor{comment}{! An addition to mstar due to Langmuir turbulence [nondim] (output for diagnostic)}
696   \textcolor{keywordtype}{real} :: mld\_output \textcolor{comment}{! The mixed layer depth output from this routine [Z ~> m].}
697   \textcolor{keywordtype}{real} :: la        \textcolor{comment}{! The value of the Langmuir number [nondim]}
698   \textcolor{keywordtype}{real} :: lamod     \textcolor{comment}{! The modified Langmuir number by convection [nondim]}
699   \textcolor{keywordtype}{real} :: hbs\_here  \textcolor{comment}{! The local minimum of hb\_hs and MixLen\_shape, times a}
700                     \textcolor{comment}{! conversion factor from H to Z [Z H-1 ~> 1 or m3 kg-1].}
701   \textcolor{keywordtype}{real} :: nstar\_fc  \textcolor{comment}{! The fraction of conv\_PErel that can be converted to mixing [nondim].}
702   \textcolor{keywordtype}{real} :: tke\_reduc \textcolor{comment}{! The fraction by which TKE and other energy fields are}
703                     \textcolor{comment}{! reduced to support mixing [nondim]. between 0 and 1.}
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].}
705   \textcolor{keywordtype}{real} :: tke\_here  \textcolor{comment}{! The total TKE at this point in the algorithm [R Z3 T-2 ~> J m-2].}
706   \textcolor{keywordtype}{real} :: dt\_km1\_t2 \textcolor{comment}{! A diffusivity-independent term related to the temperature}
707                     \textcolor{comment}{! change in the layer above the interface [degC].}
708   \textcolor{keywordtype}{real} :: ds\_km1\_t2 \textcolor{comment}{! A diffusivity-independent term related to the salinity}
709                     \textcolor{comment}{! change in the layer above the interface [ppt].}
710   \textcolor{keywordtype}{real} :: dte\_term  \textcolor{comment}{! A diffusivity-independent term related to the temperature}
711                     \textcolor{comment}{! change in the layer below the interface [degC H ~> degC m or degC kg m-2].}
712   \textcolor{keywordtype}{real} :: dse\_term  \textcolor{comment}{! A diffusivity-independent term related to the salinity}
713                     \textcolor{comment}{! change in the layer above the interface [ppt H ~> ppt m or ppt kg m-2].}
714   \textcolor{keywordtype}{real} :: dte\_t2    \textcolor{comment}{! A part of dTe\_term [degC H ~> degC m or degC kg m-2].}
715   \textcolor{keywordtype}{real} :: dse\_t2    \textcolor{comment}{! A part of dSe\_term [ppt H ~> ppt m or ppt kg m-2].}
716   \textcolor{keywordtype}{real} :: dpe\_conv  \textcolor{comment}{! The convective change in column potential energy [R Z3 T-2 ~> J m-2].}
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].}
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].}
719   \textcolor{keywordtype}{real} :: kd\_guess0    \textcolor{comment}{! A first guess of the diapycnal diffusivity [Z2 T-1 ~> m2 s-1].}
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]}
721   \textcolor{keywordtype}{real} :: kddt\_h\_g0    \textcolor{comment}{! The first guess diapycnal diffusivity times a timestep divided}
722                        \textcolor{comment}{! by the average thicknesses around a layer [H ~> m or kg m-2].}
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].}
724   \textcolor{keywordtype}{real} :: dpec\_dkd\_kd0 \textcolor{comment}{! The partial derivative of PE change with Kddt\_h(K)}
725                        \textcolor{comment}{! for very small values of Kddt\_h(K) [R Z3 T-2 H-1 ~> J m-3 or J kg-1].}
726   \textcolor{keywordtype}{real} :: pe\_chg    \textcolor{comment}{! The change in potential energy due to mixing at an}
727                     \textcolor{comment}{! interface [R Z3 T-2 ~> J m-2], positive for the column increasing}
728                     \textcolor{comment}{! in potential energy (i.e., consuming TKE).}
729   \textcolor{keywordtype}{real} :: tke\_left  \textcolor{comment}{! The amount of turbulent kinetic energy left for the most}
730                     \textcolor{comment}{! recent guess at Kddt\_h(K) [R Z3 T-2 ~> J m-2].}
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].}
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].}
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].}
734   \textcolor{keywordtype}{real} :: kddt\_h\_guess \textcolor{comment}{! A guess at the value of Kddt\_h(K) [H ~> m or kg m-2].}
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].}
736   \textcolor{keywordtype}{real} :: dkddt\_h      \textcolor{comment}{! The change between guesses at Kddt\_h(K) [H ~> m or kg m-2].}
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].}
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].}
739   \textcolor{keywordtype}{real} :: exp\_kh    \textcolor{comment}{! The nondimensional decay of TKE across a layer [nondim].}
740   \textcolor{keywordtype}{real} :: vstar\_unit\_scale \textcolor{comment}{! A unit converion factor for turbulent velocities [Z T-1 s m-1 ~> 1]}
741   \textcolor{keywordtype}{logical} :: use\_newt  \textcolor{comment}{! Use Newton's method for the next guess at Kddt\_h(K).}
742   \textcolor{keywordtype}{logical} :: convectively\_stable \textcolor{comment}{! If true the water column is convectively stable at this interface.}
743   \textcolor{keywordtype}{logical} :: sfc\_connected   \textcolor{comment}{! If true the ocean is actively turbulent from the present}
744                     \textcolor{comment}{! interface all the way up to the surface.}
745   \textcolor{keywordtype}{logical} :: sfc\_disconnect \textcolor{comment}{! If true, any turbulence has become disconnected}
746                     \textcolor{comment}{! from the surface.}
747 
748 \textcolor{comment}{! The following are only used for diagnostics.}
749   \textcolor{keywordtype}{real} :: dt\_\_diag  \textcolor{comment}{! A copy of dt\_diag (if present) or dt [T ~> s].}
750   \textcolor{keywordtype}{real} :: i\_dtdiag  \textcolor{comment}{!  = 1.0 / dt\_\_diag [T-1 ~> s-1].}
751 
752   \textcolor{comment}{!----------------------------------------------------------------------}
753   \textcolor{comment}{!/BGR added Aug24,2016 for adding iteration to get boundary layer depth}
754   \textcolor{comment}{!    - needed to compute new mixing length.}
755   \textcolor{keywordtype}{real} :: mld\_guess, mld\_found \textcolor{comment}{! Mixing Layer depth guessed/found for iteration [Z ~> m].}
756   \textcolor{keywordtype}{real} :: min\_mld   \textcolor{comment}{! Iteration bounds [Z ~> m], which are adjusted at each step}
757   \textcolor{keywordtype}{real} :: max\_mld   \textcolor{comment}{!  - These are initialized based on surface/bottom}
758                     \textcolor{comment}{!  1. The iteration guesses a value (possibly from prev step or neighbor).}
759                     \textcolor{comment}{!  2. The iteration checks if value is converged, too shallow, or too deep.}
760                     \textcolor{comment}{!  3. Based on result adjusts the Max/Min and searches through the water column.}
761                     \textcolor{comment}{!  - If using an accurate guess the iteration is very quick (e.g. if MLD doesn't}
762                     \textcolor{comment}{!    change over timestep).  Otherwise it takes 5-10 passes, but has a high}
763                     \textcolor{comment}{!    convergence rate.  Other iteration may be tried, but this method seems to}
764                     \textcolor{comment}{!    fail very rarely and the added cost is likely not significant.}
765                     \textcolor{comment}{!    Additionally, when it fails to converge it does so in a reasonable}
766                     \textcolor{comment}{!    manner giving a usable guess. When it does fail, it is due to convection}
767                     \textcolor{comment}{!    within the boundary layer.  Likely, a new method e.g. surface\_disconnect,}
768                     \textcolor{comment}{!    can improve this.}
769   \textcolor{keywordtype}{real} :: dmld\_min  \textcolor{comment}{! The change in diagnosed mixed layer depth when the guess is min\_MLD [Z ~> m]}
770   \textcolor{keywordtype}{real} :: dmld\_max  \textcolor{comment}{! The change in diagnosed mixed layer depth when the guess is max\_MLD [Z ~> m]}
771   \textcolor{keywordtype}{logical} :: first\_obl     \textcolor{comment}{! Flag for computing "found" Mixing layer depth}
772   \textcolor{keywordtype}{logical} :: obl\_converged \textcolor{comment}{! Flag for convergence of MLD}
773   \textcolor{keywordtype}{integer} :: obl\_it        \textcolor{comment}{! Iteration counter}
774 
775   \textcolor{keywordtype}{real} :: surface\_scale \textcolor{comment}{! Surface decay scale for vstar}
776   \textcolor{keywordtype}{logical} :: calc\_dt\_expect \textcolor{comment}{! If true calculate the expected changes in temperature and salinity.}
777   \textcolor{keywordtype}{logical} :: calc\_te        \textcolor{comment}{! If true calculate the expected final temperature and salinity values.}
778   \textcolor{keywordtype}{logical} :: debug=.false.  \textcolor{comment}{! Change this hard-coded value for debugging.}
779 
780   \textcolor{comment}{!  The following arrays are used only for debugging purposes.}
781   \textcolor{keywordtype}{real} :: dpe\_debug, mixing\_debug, taux2, tauy2
782   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(20)} :: tke\_left\_itt, pe\_chg\_itt, kddt\_h\_itt, dpea\_dkd\_itt, mke\_src\_itt
783   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: mech\_tke\_k, conv\_perel\_k, nstar\_k
784   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: num\_itts
785 
786   \textcolor{keywordtype}{integer} :: k, nz, itt, max\_itt
787 
788   nz = gv%ke
789 
790   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(cs)) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"energetic\_PBL: "}//&
791          \textcolor{stringliteral}{"Module must be initialized before it is used."})
792 
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.
794   calc\_te = (calc\_dt\_expect .or. (.not.cs%orig\_PE\_calc))
795 
796   h\_neglect = gv%H\_subroundoff
797 
798   c1\_3 = 1.0 / 3.0
799   dt\_\_diag = dt ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt\_diag)) dt\_\_diag = dt\_diag
800   i\_dtdiag = 1.0 / dt\_\_diag
801   max\_itt = 20
802 
803   h\_tt\_min = 0.0
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)
805   vstar\_unit\_scale = us%m\_to\_Z * us%T\_to\_s
806 
807   mld\_guess = mld\_io
808 
809 \textcolor{comment}{!   Determine the initial mech\_TKE and conv\_PErel, including the energy required}
810 \textcolor{comment}{! to mix surface heating through the topmost cell, the energy released by mixing}
811 \textcolor{comment}{! surface cooling & brine rejection down through the topmost cell, and}
812 \textcolor{comment}{! homogenizing the shortwave heating within that cell.  This sets the energy}
813 \textcolor{comment}{! and ustar and wstar available to drive mixing at the first interior}
814 \textcolor{comment}{! interface.}
815 
816   \textcolor{keywordflow}{do} k=1,nz+1 ; kd(k) = 0.0 ;\textcolor{keywordflow}{ enddo}
817 
818   pres\_z(1) = 0.0
819   \textcolor{keywordflow}{do} k=1,nz
820     dmass = gv%H\_to\_RZ * h(k)
821     dpres = us%L\_to\_Z**2 * gv%g\_Earth * dmass
822     dt\_to\_dpe(k) = (dmass * (pres\_z(k) + 0.5*dpres)) * dsv\_dt(k)
823     ds\_to\_dpe(k) = (dmass * (pres\_z(k) + 0.5*dpres)) * dsv\_ds(k)
824     dt\_to\_dcolht(k) = dmass * dsv\_dt(k)
825     ds\_to\_dcolht(k) = dmass * dsv\_ds(k)
826 
827     pres\_z(k+1) = pres\_z(k) + dpres
828 \textcolor{keywordflow}{  enddo}
829 
830   \textcolor{comment}{! Determine the total thickness (h\_sum) and the fractional distance from the bottom (hb\_hs).}
831   h\_sum = h\_neglect ; \textcolor{keywordflow}{do} k=1,nz ; h\_sum = h\_sum + h(k) ;\textcolor{keywordflow}{ enddo}
832   i\_hs = 0.0 ; \textcolor{keywordflow}{if} (h\_sum > 0.0) i\_hs = 1.0 / h\_sum
833   h\_bot = 0.0
834   hb\_hs(nz+1) = 0.0
835   \textcolor{keywordflow}{do} k=nz,1,-1
836     h\_bot = h\_bot + h(k)
837     hb\_hs(k) = h\_bot * i\_hs
838 \textcolor{keywordflow}{  enddo}
839 
840   mld\_output = h(1)*gv%H\_to\_Z
841 
842   \textcolor{comment}{!/The following lines are for the iteration over MLD}
843   \textcolor{comment}{! max\_MLD will initialized as ocean bottom depth}
844   max\_mld = 0.0 ; \textcolor{keywordflow}{do} k=1,nz ; max\_mld = max\_mld + h(k)*gv%H\_to\_Z ;\textcolor{keywordflow}{ enddo}
845   \textcolor{comment}{! min\_MLD will be initialized to 0.}
846   min\_mld = 0.0
847   \textcolor{comment}{! Set values of the wrong signs to indicate that these changes are not based on valid estimates}
848   dmld\_min = -1.0*us%m\_to\_Z ; dmld\_max = 1.0*us%m\_to\_Z
849 
850   \textcolor{comment}{! If no first guess is provided for MLD, try the middle of the water column}
851   \textcolor{keywordflow}{if} (mld\_guess <= min\_mld) mld\_guess = 0.5 * (min\_mld + max\_mld)
852 
853   \textcolor{comment}{! Iterate to determine a converged EPBL depth.}
854   obl\_converged = .false.
855   \textcolor{keywordflow}{do} obl\_it=1,cs%Max\_MLD\_Its
856 
857     \textcolor{keywordflow}{if} (.not. obl\_converged) \textcolor{keywordflow}{then}
858       \textcolor{comment}{! If not using MLD\_Iteration flag loop to only execute once.}
859       \textcolor{keywordflow}{if} (.not.cs%Use\_MLD\_iteration) obl\_converged = .true.
860 
861       \textcolor{keywordflow}{if} (debug) \textcolor{keywordflow}{then} ; mech\_tke\_k(:) = 0.0 ; conv\_perel\_k(:) = 0.0 ;\textcolor{keywordflow}{ endif}
862 
863       \textcolor{comment}{! Reset ML\_depth}
864       mld\_output = h(1)*gv%H\_to\_Z
865       sfc\_connected = .true.
866 
867       \textcolor{comment}{!/ Here we get MStar, which is the ratio of convective TKE driven mixing to UStar**3}
868       \textcolor{keywordflow}{if} (cs%Use\_LT) \textcolor{keywordflow}{then}
869         \textcolor{keyword}{call }get\_langmuir\_number(la, g, gv, us, abs(mld\_guess), u\_star\_mean, i, j, &
870                                  h=h, u\_h=u, v\_h=v, waves=waves)
871         \textcolor{keyword}{call }find\_mstar(cs, us, b\_flux, u\_star, u\_star\_mean, mld\_guess, absf, &
872                         mstar\_total, langmuir\_number=la, convect\_langmuir\_number=lamod,&
873                         mstar\_lt=mstar\_lt)
874       \textcolor{keywordflow}{else}
875         \textcolor{keyword}{call }find\_mstar(cs, us, b\_flux, u\_star, u\_star\_mean, mld\_guess, absf, mstar\_total)
876 \textcolor{keywordflow}{      endif}
877 
878       \textcolor{comment}{!/ Apply MStar to get mech\_TKE}
879       \textcolor{keywordflow}{if} ((cs%answers\_2018) .and. (cs%mstar\_scheme==use\_fixed\_mstar)) \textcolor{keywordflow}{then}
880         mech\_tke = (dt*mstar\_total*gv%Rho0) * u\_star**3
881       \textcolor{keywordflow}{else}
882         mech\_tke = mstar\_total * (dt*gv%Rho0* u\_star**3)
883 \textcolor{keywordflow}{      endif}
884 
885       \textcolor{keywordflow}{if} (cs%TKE\_diagnostics) \textcolor{keywordflow}{then}
886         ecd%dTKE\_conv = 0.0 ; ecd%dTKE\_mixing = 0.0
887         ecd%dTKE\_MKE = 0.0 ; ecd%dTKE\_mech\_decay = 0.0 ; ecd%dTKE\_conv\_decay = 0.0
888 
889         ecd%dTKE\_wind = mech\_tke * i\_dtdiag
890         \textcolor{keywordflow}{if} (tke\_forcing(1) <= 0.0) \textcolor{keywordflow}{then}
891           ecd%dTKE\_forcing = max(-mech\_tke, tke\_forcing(1)) * i\_dtdiag
892           \textcolor{comment}{! eCD%dTKE\_unbalanced = min(0.0, TKE\_forcing(1) + mech\_TKE) * I\_dtdiag}
893         \textcolor{keywordflow}{else}
894           ecd%dTKE\_forcing = cs%nstar*tke\_forcing(1) * i\_dtdiag
895           \textcolor{comment}{! eCD%dTKE\_unbalanced = 0.0}
896 \textcolor{keywordflow}{        endif}
897 \textcolor{keywordflow}{      endif}
898 
899       \textcolor{keywordflow}{if} (tke\_forcing(1) <= 0.0) \textcolor{keywordflow}{then}
900         mech\_tke = mech\_tke + tke\_forcing(1)
901         \textcolor{keywordflow}{if} (mech\_tke < 0.0) mech\_tke = 0.0
902         conv\_perel = 0.0
903       \textcolor{keywordflow}{else}
904         conv\_perel = tke\_forcing(1)
905 \textcolor{keywordflow}{      endif}
906 
907 
908       \textcolor{comment}{! Store in 1D arrays for output.}
909       \textcolor{keywordflow}{do} k=1,nz+1 ; mixvel(k) = 0.0 ; mixlen(k) = 0.0 ;\textcolor{keywordflow}{ enddo}
910 
911       \textcolor{comment}{! Determine the mixing shape function MixLen\_shape.}
912       \textcolor{keywordflow}{if} ((.not.cs%Use\_MLD\_iteration) .or. &
913           (cs%transLay\_scale >= 1.0) .or. (cs%transLay\_scale < 0.0) ) \textcolor{keywordflow}{then}
914         \textcolor{keywordflow}{do} k=1,nz+1
915           mixlen\_shape(k) = 1.0
916 \textcolor{keywordflow}{        enddo}
917       \textcolor{keywordflow}{elseif} (mld\_guess <= 0.0) \textcolor{keywordflow}{then}
918         \textcolor{keywordflow}{if} (cs%transLay\_scale > 0.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} k=1,nz+1
919           mixlen\_shape(k) = cs%transLay\_scale
920 \textcolor{keywordflow}{        enddo} ; \textcolor{keywordflow}{else} ; \textcolor{keywordflow}{do} k=1,nz+1
921           mixlen\_shape(k) = 1.0
922 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ endif}
923       \textcolor{keywordflow}{else}
924         \textcolor{comment}{! Reduce the mixing length based on MLD, with a quadratic}
925         \textcolor{comment}{! expression that follows KPP.}
926         i\_mld = 1.0 / mld\_guess
927         h\_rsum = 0.0
928         mixlen\_shape(1) = 1.0
929         \textcolor{keywordflow}{do} k=2,nz+1
930           h\_rsum = h\_rsum + h(k-1)*gv%H\_to\_Z
931           \textcolor{keywordflow}{if} (cs%MixLenExponent==2.0) \textcolor{keywordflow}{then}
932             mixlen\_shape(k) = cs%transLay\_scale + (1.0 - cs%transLay\_scale) * &
933                  (max(0.0, (mld\_guess - h\_rsum)*i\_mld) )**2 \textcolor{comment}{! CS%MixLenExponent}
934           \textcolor{keywordflow}{else}
935             mixlen\_shape(k) = cs%transLay\_scale + (1.0 - cs%transLay\_scale) * &
936                  (max(0.0, (mld\_guess - h\_rsum)*i\_mld) )**cs%MixLenExponent
937 \textcolor{keywordflow}{          endif}
938 \textcolor{keywordflow}{        enddo}
939 \textcolor{keywordflow}{      endif}
940 
941       kd(1) = 0.0 ; kddt\_h(1) = 0.0
942       hp\_a = h(1)
943       dt\_to\_dpe\_a(1) = dt\_to\_dpe(1) ; dt\_to\_dcolht\_a(1) = dt\_to\_dcolht(1)
944       ds\_to\_dpe\_a(1) = ds\_to\_dpe(1) ; ds\_to\_dcolht\_a(1) = ds\_to\_dcolht(1)
945 
946       htot = h(1) ; uhtot = u(1)*h(1) ; vhtot = v(1)*h(1)
947 
948       \textcolor{keywordflow}{if} (debug) \textcolor{keywordflow}{then}
949         mech\_tke\_k(1) = mech\_tke ; conv\_perel\_k(1) = conv\_perel
950         nstar\_k(:) = 0.0 ; nstar\_k(1) = cs%nstar ; num\_itts(:) = -1
951 \textcolor{keywordflow}{      endif}
952 
953       \textcolor{keywordflow}{do} k=2,nz
954         \textcolor{comment}{! Apply dissipation to the TKE, here applied as an exponential decay}
955         \textcolor{comment}{! due to 3-d turbulent energy being lost to inefficient rotational modes.}
956 
957         \textcolor{comment}{!   There should be several different "flavors" of TKE that decay at}
958         \textcolor{comment}{! different rates.  The following form is often used for mechanical}
959         \textcolor{comment}{! stirring from the surface, perhaps due to breaking surface gravity}
960         \textcolor{comment}{! waves and wind-driven turbulence.}
961         idecay\_len\_tke = (cs%TKE\_decay * absf / u\_star) * gv%H\_to\_Z
962         exp\_kh = 1.0
963         \textcolor{keywordflow}{if} (idecay\_len\_tke > 0.0) exp\_kh = exp(-h(k-1)*idecay\_len\_tke)
964         \textcolor{keywordflow}{if} (cs%TKE\_diagnostics) &
965           ecd%dTKE\_mech\_decay = ecd%dTKE\_mech\_decay + (exp\_kh-1.0) * mech\_tke * i\_dtdiag
966         mech\_tke = mech\_tke * exp\_kh
967 
968         \textcolor{comment}{!   Accumulate any convectively released potential energy to contribute}
969         \textcolor{comment}{! to wstar and to drive penetrating convection.}
970         \textcolor{keywordflow}{if} (tke\_forcing(k) > 0.0) \textcolor{keywordflow}{then}
971           conv\_perel = conv\_perel + tke\_forcing(k)
972           \textcolor{keywordflow}{if} (cs%TKE\_diagnostics) &
973             ecd%dTKE\_forcing = ecd%dTKE\_forcing + cs%nstar*tke\_forcing(k) * i\_dtdiag
974 \textcolor{keywordflow}{        endif}
975 
976         \textcolor{keywordflow}{if} (debug) \textcolor{keywordflow}{then}
977           mech\_tke\_k(k) = mech\_tke ; conv\_perel\_k(k) = conv\_perel
978 \textcolor{keywordflow}{        endif}
979 
980         \textcolor{comment}{!  Determine the total energy}
981         nstar\_fc = cs%nstar
982         \textcolor{keywordflow}{if} (cs%nstar * conv\_perel > 0.0) \textcolor{keywordflow}{then}
983           \textcolor{comment}{! Here nstar is a function of the natural Rossby number 0.2/(1+0.2/Ro), based}
984           \textcolor{comment}{! on a curve fit from the data of Wang (GRL, 2003).}
985           \textcolor{comment}{! Note:         Ro = 1.0 / sqrt(0.5 * dt * Rho0 * (absf*htot)**3 / conv\_PErel)}
986           nstar\_fc = cs%nstar * conv\_perel / (conv\_perel + 0.2 * &
987                      sqrt(0.5 * dt * gv%Rho0 * (absf*(htot*gv%H\_to\_Z))**3 * conv\_perel))
988 \textcolor{keywordflow}{        endif}
989 
990         \textcolor{keywordflow}{if} (debug) nstar\_k(k) = nstar\_fc
991 
992         tot\_tke = mech\_tke + nstar\_fc * conv\_perel
993 
994         \textcolor{comment}{!   For each interior interface, first discard the TKE to account for}
995         \textcolor{comment}{! mixing of shortwave radiation through the next denser cell.}
996         \textcolor{keywordflow}{if} (tke\_forcing(k) < 0.0) \textcolor{keywordflow}{then}
997           \textcolor{keywordflow}{if} (tke\_forcing(k) + tot\_tke < 0.0) \textcolor{keywordflow}{then}
998             \textcolor{comment}{! The shortwave requirements deplete all the energy in this layer.}
999             \textcolor{keywordflow}{if} (cs%TKE\_diagnostics) \textcolor{keywordflow}{then}
1000               ecd%dTKE\_mixing = ecd%dTKE\_mixing + tot\_tke * i\_dtdiag
1001               ecd%dTKE\_forcing = ecd%dTKE\_forcing - tot\_tke * i\_dtdiag
1002               \textcolor{comment}{! eCD%dTKE\_unbalanced = eCD%dTKE\_unbalanced + (TKE\_forcing(k) + tot\_TKE) * I\_dtdiag}
1003               ecd%dTKE\_conv\_decay = ecd%dTKE\_conv\_decay + (cs%nstar-nstar\_fc) * conv\_perel * i\_dtdiag
1004 \textcolor{keywordflow}{            endif}
1005             tot\_tke = 0.0 ; mech\_tke = 0.0 ; conv\_perel = 0.0
1006           \textcolor{keywordflow}{else}
1007             \textcolor{comment}{! Reduce the mechanical and convective TKE proportionately.}
1008             tke\_reduc = (tot\_tke + tke\_forcing(k)) / tot\_tke
1009             \textcolor{keywordflow}{if} (cs%TKE\_diagnostics) \textcolor{keywordflow}{then}
1010               ecd%dTKE\_mixing = ecd%dTKE\_mixing - tke\_forcing(k) * i\_dtdiag
1011               ecd%dTKE\_forcing = ecd%dTKE\_forcing + tke\_forcing(k) * i\_dtdiag
1012               ecd%dTKE\_conv\_decay = ecd%dTKE\_conv\_decay + &
1013                   (1.0-tke\_reduc)*(cs%nstar-nstar\_fc) * conv\_perel * i\_dtdiag
1014 \textcolor{keywordflow}{            endif}
1015             tot\_tke = tke\_reduc*tot\_tke   \textcolor{comment}{! = tot\_TKE + TKE\_forcing(k)}
1016             mech\_tke = tke\_reduc*mech\_tke
1017             conv\_perel = tke\_reduc*conv\_perel
1018 \textcolor{keywordflow}{          endif}
1019 \textcolor{keywordflow}{        endif}
1020 
1021         \textcolor{comment}{! Precalculate some temporary expressions that are independent of Kddt\_h(K).}
1022         \textcolor{keywordflow}{if} (cs%orig\_PE\_calc) \textcolor{keywordflow}{then}
1023           \textcolor{keywordflow}{if} (k==2) \textcolor{keywordflow}{then}
1024             dte\_t2 = 0.0 ; dse\_t2 = 0.0
1025           \textcolor{keywordflow}{else}
1026             dte\_t2 = kddt\_h(k-1) * ((t0(k-2) - t0(k-1)) + dte(k-2))
1027             dse\_t2 = kddt\_h(k-1) * ((s0(k-2) - s0(k-1)) + dse(k-2))
1028 \textcolor{keywordflow}{          endif}
1029 \textcolor{keywordflow}{        endif}
1030         dt\_h = (gv%Z\_to\_H**2*dt) / max(0.5*(h(k-1)+h(k)), 1e-15*h\_sum)
1031 
1032         \textcolor{comment}{!   This tests whether the layers above and below this interface are in}
1033         \textcolor{comment}{! a convetively stable configuration, without considering any effects of}
1034         \textcolor{comment}{! mixing at higher interfaces.  It is an approximation to the more}
1035         \textcolor{comment}{! complete test dPEc\_dKd\_Kd0 >= 0.0, that would include the effects of}
1036         \textcolor{comment}{! mixing across interface K-1.  The dT\_to\_dColHt here are effectively}
1037         \textcolor{comment}{! mass-weigted estimates of dSV\_dT.}
1038         convectively\_stable = ( 0.0 <= &
1039              ( (dt\_to\_dcolht(k) + dt\_to\_dcolht(k-1) ) * (t0(k-1)-t0(k)) + &
1040                (ds\_to\_dcolht(k) + ds\_to\_dcolht(k-1) ) * (s0(k-1)-s0(k)) ) )
1041 
1042         \textcolor{keywordflow}{if} ((mech\_tke + conv\_perel) <= 0.0 .and. convectively\_stable) \textcolor{keywordflow}{then}
1043           \textcolor{comment}{! Energy is already exhausted, so set Kd = 0 and cycle or exit?}
1044           tot\_tke = 0.0 ; mech\_tke = 0.0 ; conv\_perel = 0.0
1045           kd(k) = 0.0 ; kddt\_h(k) = 0.0
1046           sfc\_disconnect = .true.
1047           \textcolor{comment}{! if (.not.debug) exit}
1048 
1049          \textcolor{comment}{!   The estimated properties for layer k-1 can be calculated, using}
1050          \textcolor{comment}{! greatly simplified expressions when Kddt\_h = 0.  This enables the}
1051          \textcolor{comment}{! tridiagonal solver for the whole column to be completed for debugging}
1052          \textcolor{comment}{! purposes, and also allows for something akin to convective adjustment}
1053          \textcolor{comment}{! in unstable interior regions?}
1054           b1 = 1.0 / hp\_a
1055           c1(k) = 0.0
1056           \textcolor{keywordflow}{if} (cs%orig\_PE\_calc) \textcolor{keywordflow}{then}
1057             dte(k-1) = b1 * ( dte\_t2 )
1058             dse(k-1) = b1 * ( dse\_t2 )
1059 \textcolor{keywordflow}{          endif}
1060 
1061           hp\_a = h(k)
1062           dt\_to\_dpe\_a(k) = dt\_to\_dpe(k)
1063           ds\_to\_dpe\_a(k) = ds\_to\_dpe(k)
1064           dt\_to\_dcolht\_a(k) = dt\_to\_dcolht(k)
1065           ds\_to\_dcolht\_a(k) = ds\_to\_dcolht(k)
1066 
1067         \textcolor{keywordflow}{else} \textcolor{comment}{! tot\_TKE > 0.0 or this is a potentially convectively unstable profile.}
1068           sfc\_disconnect = .false.
1069 
1070           \textcolor{comment}{! Precalculate some more temporary expressions that are independent of}
1071           \textcolor{comment}{! Kddt\_h(K).}
1072           \textcolor{keywordflow}{if} (cs%orig\_PE\_calc) \textcolor{keywordflow}{then}
1073             \textcolor{keywordflow}{if} (k==2) \textcolor{keywordflow}{then}
1074               dt\_km1\_t2 = (t0(k)-t0(k-1))
1075               ds\_km1\_t2 = (s0(k)-s0(k-1))
1076             \textcolor{keywordflow}{else}
1077               dt\_km1\_t2 = (t0(k)-t0(k-1)) - &
1078                     (kddt\_h(k-1) / hp\_a) * ((t0(k-2) - t0(k-1)) + dte(k-2))
1079               ds\_km1\_t2 = (s0(k)-s0(k-1)) - &
1080                     (kddt\_h(k-1) / hp\_a) * ((s0(k-2) - s0(k-1)) + dse(k-2))
1081 \textcolor{keywordflow}{            endif}
1082             dte\_term = dte\_t2 + hp\_a * (t0(k-1)-t0(k))
1083             dse\_term = dse\_t2 + hp\_a * (s0(k-1)-s0(k))
1084           \textcolor{keywordflow}{else}
1085             \textcolor{keywordflow}{if} (k<=2) \textcolor{keywordflow}{then}
1086               th\_a(k-1) = h(k-1) * t0(k-1) ; sh\_a(k-1) = h(k-1) * s0(k-1)
1087             \textcolor{keywordflow}{else}
1088               th\_a(k-1) = h(k-1) * t0(k-1) + kddt\_h(k-1) * te(k-2)
1089               sh\_a(k-1) = h(k-1) * s0(k-1) + kddt\_h(k-1) * se(k-2)
1090 \textcolor{keywordflow}{            endif}
1091             th\_b(k) = h(k) * t0(k) ; sh\_b(k) = h(k) * s0(k)
1092 \textcolor{keywordflow}{          endif}
1093 
1094           \textcolor{comment}{!   Using Pr=1 and the diffusivity at the bottom interface (once it is}
1095           \textcolor{comment}{! known), determine how much resolved mean kinetic energy (MKE) will be}
1096           \textcolor{comment}{! extracted within a timestep and add a fraction CS%MKE\_to\_TKE\_effic of}
1097           \textcolor{comment}{! this to the mTKE budget available for mixing in the next layer.}
1098 
1099           \textcolor{keywordflow}{if} ((cs%MKE\_to\_TKE\_effic > 0.0) .and. (htot*h(k) > 0.0)) \textcolor{keywordflow}{then}
1100             \textcolor{comment}{! This is the energy that would be available from homogenizing the}
1101             \textcolor{comment}{! velocities between layer k and the layers above.}
1102             dmke\_max = (us%L\_to\_Z**2*gv%H\_to\_RZ * cs%MKE\_to\_TKE\_effic) * 0.5 * &
1103                 (h(k) / ((htot + h(k))*htot)) * &
1104                 ((uhtot-u(k)*htot)**2 + (vhtot-v(k)*htot)**2)
1105             \textcolor{comment}{! A fraction (1-exp(Kddt\_h*MKE2\_Hharm)) of this energy would be}
1106             \textcolor{comment}{! extracted by mixing with a finite viscosity.}
1107             mke2\_hharm = (htot + h(k) + 2.0*h\_neglect) / &
1108                          ((htot+h\_neglect) * (h(k)+h\_neglect))
1109           \textcolor{keywordflow}{else}
1110             dmke\_max = 0.0
1111             mke2\_hharm = 0.0
1112 \textcolor{keywordflow}{          endif}
1113 
1114           \textcolor{comment}{! At this point, Kddt\_h(K) will be unknown because its value may depend}
1115           \textcolor{comment}{! on how much energy is available.  mech\_TKE might be negative due to}
1116           \textcolor{comment}{! contributions from TKE\_forced.}
1117           h\_tt = htot + h\_tt\_min
1118           tke\_here = mech\_tke + cs%wstar\_ustar\_coef*conv\_perel
1119           \textcolor{keywordflow}{if} (tke\_here > 0.0) \textcolor{keywordflow}{then}
1120             \textcolor{keywordflow}{if} (cs%wT\_scheme==wt\_from\_croot\_tke) \textcolor{keywordflow}{then}
1121               vstar = cs%vstar\_scale\_fac * vstar\_unit\_scale * (i\_dtrho*tke\_here)**c1\_3
1122             \textcolor{keywordflow}{elseif} (cs%wT\_scheme==wt\_from\_rh18) \textcolor{keywordflow}{then}
1123               surface\_scale = max(0.05, 1.0 - htot/mld\_guess)
1124               vstar = cs%vstar\_scale\_fac * surface\_scale * (cs%vstar\_surf\_fac*u\_star + &
1125                         vstar\_unit\_scale * (cs%wstar\_ustar\_coef*conv\_perel*i\_dtrho)**c1\_3)
1126 \textcolor{keywordflow}{            endif}
1127             hbs\_here = gv%H\_to\_Z * min(hb\_hs(k), mixlen\_shape(k))
1128             mixlen(k) = max(cs%min\_mix\_len, ((h\_tt*hbs\_here)*vstar) / &
1129                 ((cs%Ekman\_scale\_coef * absf) * (h\_tt*hbs\_here) + vstar))
1130             \textcolor{comment}{!Note setting Kd\_guess0 to vstar * CS%vonKar * mixlen(K) here will}
1131             \textcolor{comment}{! change the answers.  Therefore, skipping that.}
1132             \textcolor{keywordflow}{if} (.not.cs%Use\_MLD\_iteration) \textcolor{keywordflow}{then}
1133               kd\_guess0 = vstar * cs%vonKar * ((h\_tt*hbs\_here)*vstar) / &
1134                 ((cs%Ekman\_scale\_coef * absf) * (h\_tt*hbs\_here) + vstar)
1135             \textcolor{keywordflow}{else}
1136               kd\_guess0 = vstar * cs%vonKar * mixlen(k)
1137 \textcolor{keywordflow}{            endif}
1138           \textcolor{keywordflow}{else}
1139             vstar = 0.0 ; kd\_guess0 = 0.0
1140 \textcolor{keywordflow}{          endif}
1141           mixvel(k) = vstar \textcolor{comment}{! Track vstar}
1142           kddt\_h\_g0 = kd\_guess0 * dt\_h
1143 
1144           \textcolor{keywordflow}{if} (cs%orig\_PE\_calc) \textcolor{keywordflow}{then}
1145             \textcolor{keyword}{call }find\_pe\_chg\_orig(kddt\_h\_g0, h(k), hp\_a, dte\_term, dse\_term, &
1146                      dt\_km1\_t2, ds\_km1\_t2, dt\_to\_dpe(k), ds\_to\_dpe(k), &
1147                      dt\_to\_dpe\_a(k-1), ds\_to\_dpe\_a(k-1), &
1148                      pres\_z(k), dt\_to\_dcolht(k), ds\_to\_dcolht(k), &
1149                      dt\_to\_dcolht\_a(k-1), ds\_to\_dcolht\_a(k-1), &
1150                      pe\_chg=pe\_chg\_g0, dpe\_max=pe\_chg\_max, dpec\_dkd\_0=dpec\_dkd\_kd0 )
1151           \textcolor{keywordflow}{else}
1152             \textcolor{keyword}{call }find\_pe\_chg(0.0, kddt\_h\_g0, hp\_a, h(k), &
1153                      th\_a(k-1), sh\_a(k-1), th\_b(k), sh\_b(k), &
1154                      dt\_to\_dpe\_a(k-1), ds\_to\_dpe\_a(k-1), dt\_to\_dpe(k), ds\_to\_dpe(k), &
1155                      pres\_z(k), dt\_to\_dcolht\_a(k-1), ds\_to\_dcolht\_a(k-1), &
1156                      dt\_to\_dcolht(k), ds\_to\_dcolht(k), &
1157                      pe\_chg=pe\_chg\_g0, dpe\_max=pe\_chg\_max, dpec\_dkd\_0=dpec\_dkd\_kd0 )
1158 \textcolor{keywordflow}{          endif}
1159 
1160           mke\_src = dmke\_max*(1.0 - exp(-kddt\_h\_g0 * mke2\_hharm))
1161 
1162           \textcolor{comment}{! This block checks out different cases to determine Kd at the present interface.}
1163           \textcolor{keywordflow}{if} ((pe\_chg\_g0 < 0.0) .or. ((vstar == 0.0) .and. (dpec\_dkd\_kd0 < 0.0))) \textcolor{keywordflow}{then}
1164             \textcolor{comment}{! This column is convectively unstable.}
1165             \textcolor{keywordflow}{if} (pe\_chg\_max <= 0.0) \textcolor{keywordflow}{then}
1166               \textcolor{comment}{! Does MKE\_src need to be included in the calculation of vstar here?}
1167               tke\_here = mech\_tke + cs%wstar\_ustar\_coef*(conv\_perel-pe\_chg\_max)
1168               \textcolor{keywordflow}{if} (tke\_here > 0.0) \textcolor{keywordflow}{then}
1169                 \textcolor{keywordflow}{if} (cs%wT\_scheme==wt\_from\_croot\_tke) \textcolor{keywordflow}{then}
1170                   vstar = cs%vstar\_scale\_fac * vstar\_unit\_scale * (i\_dtrho*tke\_here)**c1\_3
1171                 \textcolor{keywordflow}{elseif} (cs%wT\_scheme==wt\_from\_rh18) \textcolor{keywordflow}{then}
1172                   surface\_scale = max(0.05, 1. - htot/mld\_guess)
1173                   vstar = cs%vstar\_scale\_fac * surface\_scale * (cs%vstar\_surf\_fac*u\_star + &
1174                                   vstar\_unit\_scale * (cs%wstar\_ustar\_coef*conv\_perel*i\_dtrho)**c1\_3)
1175 \textcolor{keywordflow}{                endif}
1176                 hbs\_here = gv%H\_to\_Z * min(hb\_hs(k), mixlen\_shape(k))
1177                 mixlen(k) = max(cs%min\_mix\_len, ((h\_tt*hbs\_here)*vstar) / &
1178                     ((cs%Ekman\_scale\_coef * absf) * (h\_tt*hbs\_here) + vstar))
1179                 \textcolor{keywordflow}{if} (.not.cs%Use\_MLD\_iteration) \textcolor{keywordflow}{then}
1180                 \textcolor{comment}{! Note again (as prev) that using mixlen here}
1181                 \textcolor{comment}{!  instead of redoing the computation will change answers...}
1182                   kd(k) = vstar * cs%vonKar *  ((h\_tt*hbs\_here)*vstar) / &
1183                         ((cs%Ekman\_scale\_coef * absf) * (h\_tt*hbs\_here) + vstar)
1184                 \textcolor{keywordflow}{else}
1185                   kd(k) = vstar * cs%vonKar * mixlen(k)
1186 \textcolor{keywordflow}{                endif}
1187               \textcolor{keywordflow}{else}
1188                 vstar = 0.0 ; kd(k) = 0.0
1189 \textcolor{keywordflow}{              endif}
1190               mixvel(k) = vstar
1191 
1192               \textcolor{keywordflow}{if} (cs%orig\_PE\_calc) \textcolor{keywordflow}{then}
1193                 \textcolor{keyword}{call }find\_pe\_chg\_orig(kd(k)*dt\_h, h(k), hp\_a, dte\_term, dse\_term, &
1194                          dt\_km1\_t2, ds\_km1\_t2, dt\_to\_dpe(k), ds\_to\_dpe(k), &
1195                          dt\_to\_dpe\_a(k-1), ds\_to\_dpe\_a(k-1), &
1196                          pres\_z(k), dt\_to\_dcolht(k), ds\_to\_dcolht(k), &
1197                          dt\_to\_dcolht\_a(k-1), ds\_to\_dcolht\_a(k-1), &
1198                          pe\_chg=dpe\_conv)
1199               \textcolor{keywordflow}{else}
1200                 \textcolor{keyword}{call }find\_pe\_chg(0.0, kd(k)*dt\_h, hp\_a, h(k), &
1201                          th\_a(k-1), sh\_a(k-1), th\_b(k), sh\_b(k), &
1202                          dt\_to\_dpe\_a(k-1), ds\_to\_dpe\_a(k-1), dt\_to\_dpe(k), ds\_to\_dpe(k), &
1203                          pres\_z(k), dt\_to\_dcolht\_a(k-1), ds\_to\_dcolht\_a(k-1), &
1204                          dt\_to\_dcolht(k), ds\_to\_dcolht(k), &
1205                          pe\_chg=dpe\_conv)
1206 \textcolor{keywordflow}{              endif}
1207               \textcolor{comment}{! Should this be iterated to convergence for Kd?}
1208               \textcolor{keywordflow}{if} (dpe\_conv > 0.0) \textcolor{keywordflow}{then}
1209                 kd(k) = kd\_guess0 ; dpe\_conv = pe\_chg\_g0
1210               \textcolor{keywordflow}{else}
1211                 mke\_src = dmke\_max*(1.0 - exp(-(kd(k)*dt\_h) * mke2\_hharm))
1212 \textcolor{keywordflow}{              endif}
1213             \textcolor{keywordflow}{else}
1214               \textcolor{comment}{! The energy change does not vary monotonically with Kddt\_h.  Find the maximum?}
1215               kd(k) = kd\_guess0 ; dpe\_conv = pe\_chg\_g0
1216 \textcolor{keywordflow}{            endif}
1217 
1218             conv\_perel = conv\_perel - dpe\_conv
1219             mech\_tke = mech\_tke + mke\_src
1220             \textcolor{keywordflow}{if} (cs%TKE\_diagnostics) \textcolor{keywordflow}{then}
1221               ecd%dTKE\_conv = ecd%dTKE\_conv - cs%nstar*dpe\_conv * i\_dtdiag
1222               ecd%dTKE\_MKE = ecd%dTKE\_MKE + mke\_src * i\_dtdiag
1223 \textcolor{keywordflow}{            endif}
1224             \textcolor{keywordflow}{if} (sfc\_connected) \textcolor{keywordflow}{then}
1225               mld\_output = mld\_output + gv%H\_to\_Z * h(k)
1226 \textcolor{keywordflow}{            endif}
1227 
1228             kddt\_h(k) = kd(k) * dt\_h
1229           \textcolor{keywordflow}{elseif} (tot\_tke + (mke\_src - pe\_chg\_g0) >= 0.0) \textcolor{keywordflow}{then}
1230             \textcolor{comment}{! This column is convctively stable and there is energy to support the suggested}
1231             \textcolor{comment}{! mixing.  Keep that estimate.}
1232             kd(k) = kd\_guess0
1233             kddt\_h(k) = kddt\_h\_g0
1234 
1235             \textcolor{comment}{! Reduce the mechanical and convective TKE proportionately.}
1236             tot\_tke = tot\_tke + mke\_src
1237             tke\_reduc = 0.0   \textcolor{comment}{! tot\_TKE could be 0 if Convectively\_stable is false.}
1238             \textcolor{keywordflow}{if} (tot\_tke > 0.0) tke\_reduc = (tot\_tke - pe\_chg\_g0) / tot\_tke
1239             \textcolor{keywordflow}{if} (cs%TKE\_diagnostics) \textcolor{keywordflow}{then}
1240               ecd%dTKE\_mixing = ecd%dTKE\_mixing - pe\_chg\_g0 * i\_dtdiag
1241               ecd%dTKE\_MKE = ecd%dTKE\_MKE + mke\_src * i\_dtdiag
1242               ecd%dTKE\_conv\_decay = ecd%dTKE\_conv\_decay + &
1243                   (1.0-tke\_reduc)*(cs%nstar-nstar\_fc) * conv\_perel * i\_dtdiag
1244 \textcolor{keywordflow}{            endif}
1245             tot\_tke = tke\_reduc*tot\_tke
1246             mech\_tke = tke\_reduc*(mech\_tke + mke\_src)
1247             conv\_perel = tke\_reduc*conv\_perel
1248             \textcolor{keywordflow}{if} (sfc\_connected) \textcolor{keywordflow}{then}
1249               mld\_output = mld\_output + gv%H\_to\_Z * h(k)
1250 \textcolor{keywordflow}{            endif}
1251 
1252           \textcolor{keywordflow}{elseif} (tot\_tke == 0.0) \textcolor{keywordflow}{then}
1253             \textcolor{comment}{! This can arise if nstar\_FC = 0, but it is not common.}
1254             kd(k) = 0.0 ; kddt\_h(k) = 0.0
1255             tot\_tke = 0.0 ; conv\_perel = 0.0 ; mech\_tke = 0.0
1256             sfc\_disconnect = .true.
1257           \textcolor{keywordflow}{else}
1258             \textcolor{comment}{! There is not enough energy to support the mixing, so reduce the}
1259             \textcolor{comment}{! diffusivity to what can be supported.}
1260             kddt\_h\_max = kddt\_h\_g0 ; kddt\_h\_min = 0.0
1261             tke\_left\_max = tot\_tke + (mke\_src - pe\_chg\_g0)
1262             tke\_left\_min = tot\_tke
1263 
1264             \textcolor{comment}{! As a starting guess, take the minimum of a false position estimate}
1265             \textcolor{comment}{! and a Newton's method estimate starting from Kddt\_h = 0.0.}
1266             kddt\_h\_guess = tot\_tke * kddt\_h\_max / max( pe\_chg\_g0  - mke\_src, &
1267                              kddt\_h\_max * (dpec\_dkd\_kd0 - dmke\_max * mke2\_hharm) )
1268             \textcolor{comment}{! The above expression is mathematically the same as the following}
1269             \textcolor{comment}{! except it is not susceptible to division by zero when}
1270             \textcolor{comment}{!   dPEc\_dKd\_Kd0 = dMKE\_max = 0 .}
1271             \textcolor{comment}{!  Kddt\_h\_guess = tot\_TKE * min( Kddt\_h\_max / (PE\_chg\_g0 - MKE\_src), &}
1272             \textcolor{comment}{!                      1.0 / (dPEc\_dKd\_Kd0 - dMKE\_max * MKE2\_Hharm) )}
1273             \textcolor{keywordflow}{if} (debug) \textcolor{keywordflow}{then}
1274               tke\_left\_itt(:) = 0.0 ; dpea\_dkd\_itt(:) = 0.0 ; pe\_chg\_itt(:) = 0.0
1275               mke\_src\_itt(:) = 0.0 ; kddt\_h\_itt(:) = 0.0
1276 \textcolor{keywordflow}{            endif}
1277             \textcolor{keywordflow}{do} itt=1,max\_itt
1278               \textcolor{keywordflow}{if} (cs%orig\_PE\_calc) \textcolor{keywordflow}{then}
1279                 \textcolor{keyword}{call }find\_pe\_chg\_orig(kddt\_h\_guess, h(k), hp\_a, dte\_term, dse\_term, &
1280                          dt\_km1\_t2, ds\_km1\_t2, dt\_to\_dpe(k), ds\_to\_dpe(k), &
1281                          dt\_to\_dpe\_a(k-1), ds\_to\_dpe\_a(k-1), &
1282                          pres\_z(k), dt\_to\_dcolht(k), ds\_to\_dcolht(k), &
1283                          dt\_to\_dcolht\_a(k-1), ds\_to\_dcolht\_a(k-1), &
1284                          pe\_chg=pe\_chg, dpec\_dkd=dpec\_dkd )
1285               \textcolor{keywordflow}{else}
1286                 \textcolor{keyword}{call }find\_pe\_chg(0.0, kddt\_h\_guess, hp\_a, h(k), &
1287                          th\_a(k-1), sh\_a(k-1), th\_b(k), sh\_b(k), &
1288                          dt\_to\_dpe\_a(k-1), ds\_to\_dpe\_a(k-1), dt\_to\_dpe(k), ds\_to\_dpe(k), &
1289                          pres\_z(k), dt\_to\_dcolht\_a(k-1), ds\_to\_dcolht\_a(k-1), &
1290                          dt\_to\_dcolht(k), ds\_to\_dcolht(k), &
1291                          pe\_chg=dpe\_conv, dpec\_dkd=dpec\_dkd)
1292 \textcolor{keywordflow}{              endif}
1293               mke\_src = dmke\_max * (1.0 - exp(-mke2\_hharm * kddt\_h\_guess))
1294               dmke\_src\_dk = dmke\_max * mke2\_hharm * exp(-mke2\_hharm * kddt\_h\_guess)
1295 
1296               tke\_left = tot\_tke + (mke\_src - pe\_chg)
1297               \textcolor{keywordflow}{if} (debug .and. itt<=20) \textcolor{keywordflow}{then}
1298                 kddt\_h\_itt(itt) = kddt\_h\_guess ; mke\_src\_itt(itt) = mke\_src
1299                 pe\_chg\_itt(itt) = pe\_chg ; dpea\_dkd\_itt(itt) = dpec\_dkd
1300                 tke\_left\_itt(itt) = tke\_left
1301 \textcolor{keywordflow}{              endif}
1302               \textcolor{comment}{! Store the new bounding values, bearing in mind that min and max}
1303               \textcolor{comment}{! here refer to Kddt\_h and dTKE\_left/dKddt\_h < 0:}
1304               \textcolor{keywordflow}{if} (tke\_left >= 0.0) \textcolor{keywordflow}{then}
1305                 kddt\_h\_min = kddt\_h\_guess ; tke\_left\_min = tke\_left
1306               \textcolor{keywordflow}{else}
1307                 kddt\_h\_max = kddt\_h\_guess ; tke\_left\_max = tke\_left
1308 \textcolor{keywordflow}{              endif}
1309 
1310               \textcolor{comment}{! Try to use Newton's method, but if it would go outside the bracketed}
1311               \textcolor{comment}{! values use the false-position method instead.}
1312               use\_newt = .true.
1313               \textcolor{keywordflow}{if} (dpec\_dkd - dmke\_src\_dk <= 0.0) \textcolor{keywordflow}{then}
1314                 use\_newt = .false.
1315               \textcolor{keywordflow}{else}
1316                 dkddt\_h\_newt = tke\_left / (dpec\_dkd - dmke\_src\_dk)
1317                 kddt\_h\_newt = kddt\_h\_guess + dkddt\_h\_newt
1318                 \textcolor{keywordflow}{if} ((kddt\_h\_newt > kddt\_h\_max) .or. (kddt\_h\_newt < kddt\_h\_min)) &
1319                   use\_newt = .false.
1320 \textcolor{keywordflow}{              endif}
1321 
1322               \textcolor{keywordflow}{if} (use\_newt) \textcolor{keywordflow}{then}
1323                 kddt\_h\_next = kddt\_h\_guess + dkddt\_h\_newt
1324                 dkddt\_h = dkddt\_h\_newt
1325               \textcolor{keywordflow}{else}
1326                 kddt\_h\_next = (tke\_left\_max * kddt\_h\_min - kddt\_h\_max * tke\_left\_min) / &
1327                               (tke\_left\_max - tke\_left\_min)
1328                 dkddt\_h = kddt\_h\_next - kddt\_h\_guess
1329 \textcolor{keywordflow}{              endif}
1330 
1331               \textcolor{keywordflow}{if} ((abs(dkddt\_h) < 1e-9*kddt\_h\_guess) .or. (itt==max\_itt)) \textcolor{keywordflow}{then}
1332                 \textcolor{comment}{! Use the old value so that the energy calculation does not need to be repeated.}
1333                 \textcolor{keywordflow}{if} (debug) num\_itts(k) = itt
1334                 \textcolor{keywordflow}{exit}
1335               \textcolor{keywordflow}{else}
1336                 kddt\_h\_guess = kddt\_h\_next
1337 \textcolor{keywordflow}{              endif}
1338 \textcolor{keywordflow}{            enddo} \textcolor{comment}{! Inner iteration loop on itt.}
1339             kd(k) = kddt\_h\_guess / dt\_h ; kddt\_h(k) = kd(k) * dt\_h
1340 
1341             \textcolor{comment}{! All TKE should have been consumed.}
1342             \textcolor{keywordflow}{if} (cs%TKE\_diagnostics) \textcolor{keywordflow}{then}
1343               ecd%dTKE\_mixing = ecd%dTKE\_mixing - (tot\_tke + mke\_src) * i\_dtdiag
1344               ecd%dTKE\_MKE = ecd%dTKE\_MKE + mke\_src * i\_dtdiag
1345               ecd%dTKE\_conv\_decay = ecd%dTKE\_conv\_decay + &
1346                   (cs%nstar-nstar\_fc) * conv\_perel * i\_dtdiag
1347 \textcolor{keywordflow}{            endif}
1348 
1349             \textcolor{keywordflow}{if} (sfc\_connected) mld\_output = mld\_output + &
1350                  (pe\_chg / (pe\_chg\_g0)) * gv%H\_to\_Z * h(k)
1351 
1352             tot\_tke = 0.0 ; mech\_tke = 0.0 ; conv\_perel = 0.0
1353             sfc\_disconnect = .true.
1354 \textcolor{keywordflow}{          endif} \textcolor{comment}{! End of convective or forced mixing cases to determine Kd.}
1355 
1356           kddt\_h(k) = kd(k) * dt\_h
1357           \textcolor{comment}{!   At this point, the final value of Kddt\_h(K) is known, so the}
1358           \textcolor{comment}{! estimated properties for layer k-1 can be calculated.}
1359           b1 = 1.0 / (hp\_a + kddt\_h(k))
1360           c1(k) = kddt\_h(k) * b1
1361           \textcolor{keywordflow}{if} (cs%orig\_PE\_calc) \textcolor{keywordflow}{then}
1362             dte(k-1) = b1 * ( kddt\_h(k)*(t0(k)-t0(k-1)) + dte\_t2 )
1363             dse(k-1) = b1 * ( kddt\_h(k)*(s0(k)-s0(k-1)) + dse\_t2 )
1364 \textcolor{keywordflow}{          endif}
1365 
1366           hp\_a = h(k) + (hp\_a * b1) * kddt\_h(k)
1367           dt\_to\_dpe\_a(k) = dt\_to\_dpe(k) + c1(k)*dt\_to\_dpe\_a(k-1)
1368           ds\_to\_dpe\_a(k) = ds\_to\_dpe(k) + c1(k)*ds\_to\_dpe\_a(k-1)
1369           dt\_to\_dcolht\_a(k) = dt\_to\_dcolht(k) + c1(k)*dt\_to\_dcolht\_a(k-1)
1370           ds\_to\_dcolht\_a(k) = ds\_to\_dcolht(k) + c1(k)*ds\_to\_dcolht\_a(k-1)
1371 
1372 \textcolor{keywordflow}{        endif}  \textcolor{comment}{! tot\_TKT > 0.0 branch.  Kddt\_h(K) has been set.}
1373 
1374         \textcolor{comment}{! Store integrated velocities and thicknesses for MKE conversion calculations.}
1375         \textcolor{keywordflow}{if} (sfc\_disconnect) \textcolor{keywordflow}{then}
1376           \textcolor{comment}{! There is no turbulence at this interface, so zero out the running sums.}
1377           uhtot = u(k)*h(k)
1378           vhtot = v(k)*h(k)
1379           htot  = h(k)
1380           sfc\_connected = .false.
1381         \textcolor{keywordflow}{else}
1382           uhtot = uhtot + u(k)*h(k)
1383           vhtot = vhtot + v(k)*h(k)
1384           htot  = htot + h(k)
1385 \textcolor{keywordflow}{        endif}
1386 
1387         \textcolor{keywordflow}{if} (calc\_te) \textcolor{keywordflow}{then}
1388           \textcolor{keywordflow}{if} (k==2) \textcolor{keywordflow}{then}
1389             te(1) = b1*(h(1)*t0(1))
1390             se(1) = b1*(h(1)*s0(1))
1391           \textcolor{keywordflow}{else}
1392             te(k-1) = b1 * (h(k-1) * t0(k-1) + kddt\_h(k-1) * te(k-2))
1393             se(k-1) = b1 * (h(k-1) * s0(k-1) + kddt\_h(k-1) * se(k-2))
1394 \textcolor{keywordflow}{          endif}
1395 \textcolor{keywordflow}{        endif}
1396 \textcolor{keywordflow}{      enddo}
1397       kd(nz+1) = 0.0
1398 
1399       \textcolor{keywordflow}{if} (calc\_dt\_expect) \textcolor{keywordflow}{then}
1400         \textcolor{comment}{! Complete the tridiagonal solve for Te.}
1401         b1 = 1.0 / hp\_a
1402         te(nz) = b1 * (h(nz) * t0(nz) + kddt\_h(nz) * te(nz-1))
1403         se(nz) = b1 * (h(nz) * s0(nz) + kddt\_h(nz) * se(nz-1))
1404         ecd%dT\_expect(nz) = te(nz) - t0(nz) ; ecd%dS\_expect(nz) = se(nz) - s0(nz)
1405         \textcolor{keywordflow}{do} k=nz-1,1,-1
1406           te(k) = te(k) + c1(k+1)*te(k+1)
1407           se(k) = se(k) + c1(k+1)*se(k+1)
1408           ecd%dT\_expect(k) = te(k) - t0(k) ; ecd%dS\_expect(k) = se(k) - s0(k)
1409 \textcolor{keywordflow}{        enddo}
1410 \textcolor{keywordflow}{      endif}
1411 
1412       \textcolor{keywordflow}{if} (debug) \textcolor{keywordflow}{then}
1413         dpe\_debug = 0.0
1414         \textcolor{keywordflow}{do} k=1,nz
1415           dpe\_debug = dpe\_debug + (dt\_to\_dpe(k) * (te(k) - t0(k)) + &
1416                                    ds\_to\_dpe(k) * (se(k) - s0(k)))
1417 \textcolor{keywordflow}{        enddo}
1418         mixing\_debug = dpe\_debug * i\_dtdiag
1419 \textcolor{keywordflow}{      endif}
1420       k = nz \textcolor{comment}{! This is here to allow a breakpoint to be set.}
1421       \textcolor{comment}{!/BGR}
1422       \textcolor{comment}{! The following lines are used for the iteration}
1423       \textcolor{comment}{! note the iteration has been altered to use the value predicted by}
1424       \textcolor{comment}{! the TKE threshold (ML\_DEPTH).  This is because the MSTAR}
1425       \textcolor{comment}{! is now dependent on the ML, and therefore the ML needs to be estimated}
1426       \textcolor{comment}{! more precisely than the grid spacing.}
1427 
1428       \textcolor{comment}{!New method uses ML\_DEPTH as computed in ePBL routine}
1429       mld\_found = mld\_output
1430       \textcolor{keywordflow}{if} (mld\_found - mld\_guess > cs%MLD\_tol) \textcolor{keywordflow}{then}
1431         min\_mld = mld\_guess ; dmld\_min = mld\_found - mld\_guess
1432       \textcolor{keywordflow}{elseif} (abs(mld\_found - mld\_guess) < cs%MLD\_tol) \textcolor{keywordflow}{then}
1433         obl\_converged = .true. \textcolor{comment}{! Break convergence loop}
1434       \textcolor{keywordflow}{else} \textcolor{comment}{! We know this guess was too deep}
1435         max\_mld = mld\_guess ; dmld\_max = mld\_found - mld\_guess \textcolor{comment}{! < -CS%MLD\_tol}
1436 \textcolor{keywordflow}{      endif}
1437 
1438       \textcolor{keywordflow}{if} (.not.obl\_converged) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (cs%MLD\_bisection) \textcolor{keywordflow}{then}
1439         \textcolor{comment}{! For the next pass, guess the average of the minimum and maximum values.}
1440         mld\_guess = 0.5*(min\_mld + max\_mld)
1441       \textcolor{keywordflow}{else} \textcolor{comment}{! Try using the false position method or the returned value instead of simple bisection.}
1442         \textcolor{comment}{! Taking the occasional step with MLD\_output empirically helps to converge faster.}
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}
1444           \textcolor{comment}{! Both bounds have valid change estimates and are probably in the range of possible outputs.}
1445           mld\_guess = (dmld\_min*max\_mld - dmld\_max*min\_mld) / (dmld\_min - dmld\_max)
1446         \textcolor{keywordflow}{elseif} ((mld\_found > min\_mld) .and. (mld\_found < max\_mld)) \textcolor{keywordflow}{then}
1447           \textcolor{comment}{! The output MLD\_found is an interesting guess, as it likely to bracket the true solution}
1448           \textcolor{comment}{! along with the previous value of MLD\_guess and to be close to the solution.}
1449           mld\_guess = mld\_found
1450         \textcolor{keywordflow}{else} \textcolor{comment}{! Bisect if the other guesses would be out-of-bounds.  This does not happen much.}
1451           mld\_guess = 0.5*(min\_mld + max\_mld)
1452 \textcolor{keywordflow}{        endif}
1453 \textcolor{keywordflow}{      endif} ;\textcolor{keywordflow}{ endif}
1454 \textcolor{keywordflow}{    endif}
1455     \textcolor{keywordflow}{if} ((obl\_converged) .or. (obl\_it==cs%Max\_MLD\_Its)) \textcolor{keywordflow}{then}
1456       \textcolor{keywordflow}{if} (report\_avg\_its) \textcolor{keywordflow}{then}
1457         cs%sum\_its(1) = cs%sum\_its(1) + real\_to\_efp(\textcolor{keywordtype}{real}(obl\_it))
1458         cs%sum\_its(2) = cs%sum\_its(2) + real\_to\_efp(1.0)
1459 \textcolor{keywordflow}{      endif}
1460       \textcolor{keywordflow}{exit}
1461 \textcolor{keywordflow}{    endif}
1462 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! Iteration loop for converged boundary layer thickness.}
1463   \textcolor{keywordflow}{if} (cs%Use\_LT) \textcolor{keywordflow}{then}
1464     ecd%LA = la ; ecd%LAmod = lamod ; ecd%mstar = mstar\_total ; ecd%mstar\_LT = mstar\_lt
1465   \textcolor{keywordflow}{else}
1466     ecd%LA = 0.0 ; ecd%LAmod = 0.0 ; ecd%mstar = mstar\_total ; ecd%mstar\_LT = 0.0
1467 \textcolor{keywordflow}{  endif}
1468 
1469   mld\_io = mld\_output
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}}
\subsubsection{\texorpdfstring{find\+\_\+mstar()}{find\_mstar()}}
{\footnotesize\ttfamily subroutine mom\+\_\+energetic\+\_\+pbl\+::find\+\_\+mstar (\begin{DoxyParamCaption}\item[{type(\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{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em ustar} & ustar w/ gustiness \mbox{[}Z T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em ustar\+\_\+mean} & ustar w/o gustiness \mbox{[}Z T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em abs\+\_\+coriolis} & abolute value of the Coriolis parameter \mbox{[}T-\/1 $\sim$$>$ s-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em buoyancy\+\_\+flux} & Buoyancy flux \mbox{[}Z2 T-\/3 $\sim$$>$ m2 s-\/3\mbox{]}\\
\hline
\mbox{\tt in}  & {\em bld} & boundary layer depth \mbox{[}Z $\sim$$>$ m\mbox{]}\\
\hline
\mbox{\tt out}  & {\em mstar} & Ouput mstar (Mixing/ustar$\ast$$\ast$3) \mbox{[}nondim\mbox{]}\\
\hline
\mbox{\tt in}  & {\em langmuir\+\_\+number} & Langmuir number \mbox{[}nondim\mbox{]}\\
\hline
\mbox{\tt out}  & {\em mstar\+\_\+lt} & Mstar increase due to Langmuir turbulence \mbox{[}nondim\mbox{]}\\
\hline
\mbox{\tt 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}
1780   \textcolor{keywordtype}{type}(energetic\_pbl\_cs), \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{    !< Energetic\_PBL control structure.}
1781   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}  :: us\textcolor{comment}{    !< A dimensional unit scaling type}
1782   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}  :: ustar\textcolor{comment}{ !< ustar w/ gustiness [Z T-1 ~> m s-1]}
1783   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}  :: ustar\_mean\textcolor{comment}{ !< ustar w/o gustiness [Z T-1 ~> m s-1]}
1784   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}  :: abs\_coriolis\textcolor{comment}{ !< abolute value of the Coriolis parameter [T-1 ~>
       s-1]}
1785   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}  :: buoyancy\_flux\textcolor{comment}{ !< Buoyancy flux [Z2 T-3 ~> m2 s-3]}
1786   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}  :: bld\textcolor{comment}{   !< boundary layer depth [Z ~> m]}
1787   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(out)} :: mstar\textcolor{comment}{ !< Ouput mstar (Mixing/ustar**3) [nondim]}
1788   \textcolor{keywordtype}{real},        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: langmuir\_number\textcolor{comment}{ !< Langmuir number [nondim]}
1789   \textcolor{keywordtype}{real},        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: mstar\_lt\textcolor{comment}{ !< Mstar increase due to Langmuir turbulence [nondim]}
1790   \textcolor{keywordtype}{real},        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: convect\_langmuir\_number\textcolor{comment}{ !< Langmuir number including buoyancy flux
       [nondim]}
1791 
1792   \textcolor{comment}{!/ Variables used in computing mstar}
1793   \textcolor{keywordtype}{real} :: msn\_term       \textcolor{comment}{! Temporary terms [nondim]}
1794   \textcolor{keywordtype}{real} :: mscr\_term1, mscr\_term2 \textcolor{comment}{! Temporary terms [Z3 T-3 ~> m3 s-3]}
1795   \textcolor{keywordtype}{real} :: mstar\_conv\_red \textcolor{comment}{! Adjustment made to mstar due to convection reducing mechanical mixing [nondim]}
1796   \textcolor{keywordtype}{real} :: mstar\_s, mstar\_n \textcolor{comment}{! Mstar in (S)tabilizing/(N)ot-stabilizing buoyancy flux [nondim]}
1797 
1798   \textcolor{comment}{!/  Integer options for how to find mstar}
1799 
1800   \textcolor{comment}{!/}
1801 
1802   \textcolor{keywordflow}{if} (cs%mstar\_scheme == use\_fixed\_mstar) \textcolor{keywordflow}{then}
1803     mstar = cs%Fixed\_MStar
1804   \textcolor{comment}{!/ 1. Get mstar}
1805   \textcolor{keywordflow}{elseif} (cs%mstar\_scheme == mstar\_from\_ekman) \textcolor{keywordflow}{then}
1806 
1807     \textcolor{keywordflow}{if} (cs%answers\_2018) \textcolor{keywordflow}{then}
1808       \textcolor{comment}{! The limit for the balance of rotation and stabilizing is f(L\_Ekman,L\_Obukhov)}
1809       mstar\_s = cs%MStar\_coef*sqrt(max(0.0,buoyancy\_flux) / ustar**2 / &
1810                     (abs\_coriolis + 1.e-10*us%T\_to\_s) )
1811       \textcolor{comment}{! The limit for rotation (Ekman length) limited mixing}
1812       mstar\_n =  cs%C\_Ek * log( max( 1., ustar / (abs\_coriolis + 1.e-10*us%T\_to\_s) / bld ) )
1813     \textcolor{keywordflow}{else}
1814       \textcolor{comment}{! The limit for the balance of rotation and stabilizing is f(L\_Ekman,L\_Obukhov)}
1815       mstar\_s = cs%MSTAR\_COEF*sqrt(max(0.0, buoyancy\_flux) / (ustar**2 * max(abs\_coriolis, 1.e-20*us%T\_to\_s
      )))
1816       \textcolor{comment}{! The limit for rotation (Ekman length) limited mixing}
1817       mstar\_n = 0.0
1818       \textcolor{keywordflow}{if} (ustar > abs\_coriolis * bld) mstar\_n = cs%C\_EK * log(ustar / (abs\_coriolis * bld))
1819 \textcolor{keywordflow}{    endif}
1820 
1821     \textcolor{comment}{! Here 1.25 is about .5/von Karman, which gives the Obukhov limit.}
1822     mstar = max(mstar\_s, min(1.25, mstar\_n))
1823     \textcolor{keywordflow}{if} (cs%MStar\_Cap > 0.0) mstar = min( cs%MStar\_Cap,mstar )
1824   \textcolor{keywordflow}{elseif} ( cs%mstar\_scheme == mstar\_from\_rh18 ) \textcolor{keywordflow}{then}
1825     \textcolor{keywordflow}{if} (cs%answers\_2018) \textcolor{keywordflow}{then}
1826       mstar\_n = cs%RH18\_MStar\_cn1 * ( 1.0 - 1.0 / ( 1. + cs%RH18\_MStar\_cn2 * &
1827                 exp( cs%RH18\_mstar\_CN3 * bld * abs\_coriolis / ustar) ) )
1828     \textcolor{keywordflow}{else}
1829       msn\_term = cs%RH18\_MStar\_cn2 * exp( cs%RH18\_mstar\_CN3 * bld * abs\_coriolis / ustar)
1830       mstar\_n = (cs%RH18\_MStar\_cn1 *  msn\_term) / ( 1. + msn\_term)
1831 \textcolor{keywordflow}{    endif}
1832     mstar\_s = cs%RH18\_MStar\_CS1 * ( max(0.0, buoyancy\_flux)**2 * bld / &
1833              ( ustar**5 * max(abs\_coriolis,1.e-20*us%T\_to\_s) ) )**cs%RH18\_mstar\_cs2
1834     mstar = mstar\_n + mstar\_s
1835 \textcolor{keywordflow}{  endif}
1836 
1837   \textcolor{comment}{!/ 2. Adjust mstar to account for convective turbulence}
1838   \textcolor{keywordflow}{if} (cs%answers\_2018) \textcolor{keywordflow}{then}
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) / &
1840                          ( (-min(0.0,buoyancy\_flux) + 1.e-10*us%T\_to\_s**3*us%m\_to\_Z**2) + &
1841                          2.0 *mstar * ustar**3 / bld )
1842   \textcolor{keywordflow}{else}
1843     mscr\_term1 = -bld * min(0.0, buoyancy\_flux)
1844     mscr\_term2 = 2.0*mstar * ustar**3
1845     \textcolor{keywordflow}{if} ( abs(mscr\_term2) > 0.0) \textcolor{keywordflow}{then}
1846       mstar\_conv\_red = ((1.-cs%mstar\_convect\_coef) * mscr\_term1 + mscr\_term2) / (mscr\_term1 + mscr\_term2)
1847     \textcolor{keywordflow}{else}
1848       mstar\_conv\_red = 1.-cs%mstar\_convect\_coef
1849 \textcolor{keywordflow}{    endif}
1850 \textcolor{keywordflow}{  endif}
1851 
1852   \textcolor{comment}{!/3. Combine various mstar terms to get final value}
1853   mstar = mstar * mstar\_conv\_red
1854 
1855   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(langmuir\_number)) \textcolor{keywordflow}{then}
1856     \textcolor{comment}{!### In this call, ustar was previously ustar\_mean.  Is this change deliberate, Brandon?  -RWH}
1857     \textcolor{keyword}{call }mstar\_langmuir(cs, us, abs\_coriolis, buoyancy\_flux, ustar, bld, langmuir\_number, mstar, &
1858                         mstar\_lt, convect\_langmuir\_number)
1859 \textcolor{keywordflow}{  endif}
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}}
\subsubsection{\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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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}
1479   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: kddt\_h0\textcolor{comment}{  !< The previously used diffusivity at an interface times}
1480 \textcolor{comment}{                                !! the time step and  divided by the average of the}
1481 \textcolor{comment}{                                !! thicknesses around the interface [H ~> m or kg m-2].}
1482   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: dkddt\_h\textcolor{comment}{  !< The trial change in the diffusivity at an interface times}
1483 \textcolor{comment}{                                !! the time step and  divided by the average of the}
1484 \textcolor{comment}{                                !! thicknesses around the interface [H ~> m or kg m-2].}
1485   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: hp\_a\textcolor{comment}{     !< The effective pivot thickness of the layer above the}
1486 \textcolor{comment}{                                !! interface, given by h\_k plus a term that}
1487 \textcolor{comment}{                                !! is a fraction (determined from the tridiagonal solver) of}
1488 \textcolor{comment}{                                !! Kddt\_h for the interface above [H ~> m or kg m-2].}
1489   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: hp\_b\textcolor{comment}{     !< The effective pivot thickness of the layer below the}
1490 \textcolor{comment}{                                !! interface, given by h\_k plus a term that}
1491 \textcolor{comment}{                                !! is a fraction (determined from the tridiagonal solver) of}
1492 \textcolor{comment}{                                !! Kddt\_h for the interface above [H ~> m or kg m-2].}
1493   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: th\_a\textcolor{comment}{     !< An effective temperature times a thickness in the layer}
1494 \textcolor{comment}{                                !! above, including implicit mixing effects with other}
1495 \textcolor{comment}{                                !! yet higher layers [degC H ~> degC m or degC kg m-2].}
1496   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: sh\_a\textcolor{comment}{     !< An effective salinity times a thickness in the layer}
1497 \textcolor{comment}{                                !! above, including implicit mixing effects with other}
1498 \textcolor{comment}{                                !! yet higher layers [degC H ~> degC m or degC kg m-2].}
1499   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: th\_b\textcolor{comment}{     !< An effective temperature times a thickness in the layer}
1500 \textcolor{comment}{                                !! below, including implicit mixfing effects with other}
1501 \textcolor{comment}{                                !! yet lower layers [degC H ~> degC m or degC kg m-2].}
1502   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: sh\_b\textcolor{comment}{     !< An effective salinity times a thickness in the layer}
1503 \textcolor{comment}{                                !! below, including implicit mixing effects with other}
1504 \textcolor{comment}{                                !! yet lower layers [degC H ~> degC m or degC kg m-2].}
1505   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: dt\_to\_dpe\_a\textcolor{comment}{ !< A factor (pres\_lay*mass\_lay*dSpec\_vol/dT) relating}
1506 \textcolor{comment}{                                !! a layer's temperature change to the change in column potential}
1507 \textcolor{comment}{                                !! energy, including all implicit diffusive changes in the}
1508 \textcolor{comment}{                                !! temperatures of all the layers above [R Z3 T-2 degC-1 ~> J m-2 degC-1].}
1509   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: ds\_to\_dpe\_a\textcolor{comment}{ !< A factor (pres\_lay*mass\_lay*dSpec\_vol/dS) relating}
1510 \textcolor{comment}{                                !! a layer's salinity change to the change in column potential}
1511 \textcolor{comment}{                                !! energy, including all implicit diffusive changes in the}
1512 \textcolor{comment}{                                !! salinities of all the layers above [R Z3 T-2 ppt-1 ~> J m-2 ppt-1].}
1513   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: dt\_to\_dpe\_b\textcolor{comment}{ !< A factor (pres\_lay*mass\_lay*dSpec\_vol/dT) relating}
1514 \textcolor{comment}{                                !! a layer's temperature change to the change in column potential}
1515 \textcolor{comment}{                                !! energy, including all implicit diffusive changes in the}
1516 \textcolor{comment}{                                !! temperatures of all the layers below [R Z3 T-2 degC-1 ~> J m-2 degC-1].}
1517   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: ds\_to\_dpe\_b\textcolor{comment}{ !< A factor (pres\_lay*mass\_lay*dSpec\_vol/dS) relating}
1518 \textcolor{comment}{                                !! a layer's salinity change to the change in column potential}
1519 \textcolor{comment}{                                !! energy, including all implicit diffusive changes in the}
1520 \textcolor{comment}{                                !! salinities of all the layers below [R Z3 T-2 ppt-1 ~> J m-2 ppt-1].}
1521   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: pres\_z\textcolor{comment}{   !< The rescaled hydrostatic interface pressure, which relates}
1522 \textcolor{comment}{                                !! the changes in column thickness to the energy that is radiated}
1523 \textcolor{comment}{                                !! as gravity waves and unavailable to drive mixing [R Z2 T-2 ~> J m-3].}
1524   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: dt\_to\_dcolht\_a\textcolor{comment}{ !< A factor (mass\_lay*dSColHtc\_vol/dT) relating}
1525 \textcolor{comment}{                                !! a layer's temperature change to the change in column}
1526 \textcolor{comment}{                                !! height, including all implicit diffusive changes}
1527 \textcolor{comment}{                                !! in the temperatures of all the layers above [Z degC-1 ~> m degC-1].}
1528   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: ds\_to\_dcolht\_a\textcolor{comment}{ !< A factor (mass\_lay*dSColHtc\_vol/dS) relating}
1529 \textcolor{comment}{                                !! a layer's salinity change to the change in column}
1530 \textcolor{comment}{                                !! height, including all implicit diffusive changes}
1531 \textcolor{comment}{                                !! in the salinities of all the layers above [Z ppt-1 ~> m ppt-1].}
1532   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: dt\_to\_dcolht\_b\textcolor{comment}{ !< A factor (mass\_lay*dSColHtc\_vol/dT) relating}
1533 \textcolor{comment}{                                !! a layer's temperature change to the change in column}
1534 \textcolor{comment}{                                !! height, including all implicit diffusive changes}
1535 \textcolor{comment}{                                !! in the temperatures of all the layers below [Z degC-1 ~> m degC-1].}
1536   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: ds\_to\_dcolht\_b\textcolor{comment}{ !< A factor (mass\_lay*dSColHtc\_vol/dS) relating}
1537 \textcolor{comment}{                                !! a layer's salinity change to the change in column}
1538 \textcolor{comment}{                                !! height, including all implicit diffusive changes}
1539 \textcolor{comment}{                                !! in the salinities of all the layers below [Z ppt-1 ~> m ppt-1].}
1540 
1541   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: pe\_chg\textcolor{comment}{   !< The change in column potential energy from applying}
1542 \textcolor{comment}{                                          !! Kddt\_h at the present interface [R Z3 T-2 ~> J m-2].}
1543   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: dpec\_dkd\textcolor{comment}{ !< The partial derivative of PE\_chg with Kddt\_h}
1544 \textcolor{comment}{                                          !! [R Z3 T-2 H-1 ~> J m-3 or J kg-1].}
1545   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: dpe\_max\textcolor{comment}{  !< The maximum change in column potential energy that could}
1546 \textcolor{comment}{                                          !! be realizedd by applying a huge value of Kddt\_h at the}
1547 \textcolor{comment}{                                          !! present interface [R Z3 T-2 ~> J m-2].}
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}
1549 \textcolor{comment}{                                            !! limit where Kddt\_h = 0 [R Z3 T-2 H-1 ~> J m-3 or J kg-1].}
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}
1551 \textcolor{comment}{                                            !! change in the column height [R Z3 T-2 ~> J m-2].}
1552 
1553   \textcolor{keywordtype}{real} :: hps \textcolor{comment}{! The sum of the two effective pivot thicknesses [H ~> m or kg m-2].}
1554   \textcolor{keywordtype}{real} :: bdt1 \textcolor{comment}{! A product of the two pivot thicknesses plus a diffusive term [H2 ~> m2 or kg2 m-4].}
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].}
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].}
1557   \textcolor{keywordtype}{real} :: pec\_core \textcolor{comment}{! The diffusivity-independent core term in the expressions}
1558                    \textcolor{comment}{! for the potential energy changes [R Z2 T-2 ~> J m-3].}
1559   \textcolor{keywordtype}{real} :: colht\_core \textcolor{comment}{! The diffusivity-independent core term in the expressions}
1560                      \textcolor{comment}{! for the column height changes [H Z ~> m2 or kg m-1].}
1561   \textcolor{keywordtype}{real} :: colht\_chg  \textcolor{comment}{! The change in the column height [H ~> m or kg m-2].}
1562   \textcolor{keywordtype}{real} :: y1\_3 \textcolor{comment}{! A local temporary term in [H-3 ~> m-3 or m6 kg-3].}
1563   \textcolor{keywordtype}{real} :: y1\_4 \textcolor{comment}{! A local temporary term in [H-4 ~> m-4 or m8 kg-4].}
1564 
1565   \textcolor{comment}{!   The expression for the change in potential energy used here is derived}
1566   \textcolor{comment}{! from the expression for the final estimates of the changes in temperature}
1567   \textcolor{comment}{! and salinities, and then extensively manipulated to get it into its most}
1568   \textcolor{comment}{! succint form. The derivation is not necessarily obvious, but it demonstrably}
1569   \textcolor{comment}{! works by comparison with separate calculations of the energy changes after}
1570   \textcolor{comment}{! the tridiagonal solver for the final changes in temperature and salinity are}
1571   \textcolor{comment}{! applied.}
1572 
1573   hps = hp\_a + hp\_b
1574   bdt1 = hp\_a * hp\_b + kddt\_h0 * hps
1575   dt\_c = hp\_a * th\_b - hp\_b * th\_a
1576   ds\_c = hp\_a * sh\_b - hp\_b * sh\_a
1577   pec\_core = hp\_b * (dt\_to\_dpe\_a * dt\_c + ds\_to\_dpe\_a * ds\_c) - &
1578              hp\_a * (dt\_to\_dpe\_b * dt\_c + ds\_to\_dpe\_b * ds\_c)
1579   colht\_core = hp\_b * (dt\_to\_dcolht\_a * dt\_c + ds\_to\_dcolht\_a * ds\_c) - &
1580                hp\_a * (dt\_to\_dcolht\_b * dt\_c + ds\_to\_dcolht\_b * ds\_c)
1581 
1582   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(pe\_chg)) \textcolor{keywordflow}{then}
1583     \textcolor{comment}{! Find the change in column potential energy due to the change in the}
1584     \textcolor{comment}{! diffusivity at this interface by dKddt\_h.}
1585     y1\_3 = dkddt\_h / (bdt1 * (bdt1 + dkddt\_h * hps))
1586     pe\_chg = pec\_core * y1\_3
1587     colht\_chg = colht\_core * y1\_3
1588     \textcolor{keywordflow}{if} (colht\_chg < 0.0) pe\_chg = pe\_chg - pres\_z * colht\_chg
1589     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(pe\_colht\_cor)) pe\_colht\_cor = -pres\_z * min(colht\_chg, 0.0)
1590   \textcolor{keywordflow}{elseif} (\textcolor{keyword}{present}(pe\_colht\_cor)) \textcolor{keywordflow}{then}
1591     y1\_3 = dkddt\_h / (bdt1 * (bdt1 + dkddt\_h * hps))
1592     pe\_colht\_cor = -pres\_z * min(colht\_core * y1\_3, 0.0)
1593 \textcolor{keywordflow}{  endif}
1594 
1595   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dpec\_dkd)) \textcolor{keywordflow}{then}
1596     \textcolor{comment}{! Find the derivative of the potential energy change with dKddt\_h.}
1597     y1\_4 = 1.0 / (bdt1 + dkddt\_h * hps)**2
1598     dpec\_dkd = pec\_core * y1\_4
1599     colht\_chg = colht\_core * y1\_4
1600     \textcolor{keywordflow}{if} (colht\_chg < 0.0) dpec\_dkd = dpec\_dkd - pres\_z * colht\_chg
1601 \textcolor{keywordflow}{  endif}
1602 
1603   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dpe\_max)) \textcolor{keywordflow}{then}
1604     \textcolor{comment}{! This expression is the limit of PE\_chg for infinite dKddt\_h.}
1605     y1\_3 = 1.0 / (bdt1 * hps)
1606     dpe\_max = pec\_core * y1\_3
1607     colht\_chg = colht\_core * y1\_3
1608     \textcolor{keywordflow}{if} (colht\_chg < 0.0) dpe\_max = dpe\_max - pres\_z * colht\_chg
1609 \textcolor{keywordflow}{  endif}
1610 
1611   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dpec\_dkd\_0)) \textcolor{keywordflow}{then}
1612     \textcolor{comment}{! This expression is the limit of dPEc\_dKd for dKddt\_h = 0.}
1613     y1\_4 = 1.0 / bdt1**2
1614     dpec\_dkd\_0 = pec\_core * y1\_4
1615     colht\_chg = colht\_core * y1\_4
1616     \textcolor{keywordflow}{if} (colht\_chg < 0.0) dpec\_dkd\_0 = dpec\_dkd\_0 - pres\_z * colht\_chg
1617 \textcolor{keywordflow}{  endif}
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}}
\subsubsection{\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{\tt 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{\tt in}  & {\em h\+\_\+k} & The thickness of the layer below the interface \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}.\\
\hline
\mbox{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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{\tt 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}
1629   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: kddt\_h\textcolor{comment}{   !< The diffusivity at an interface times the time step and}
1630 \textcolor{comment}{                                !! divided by the average of the thicknesses around the}
1631 \textcolor{comment}{                                !! interface [H ~> m or kg m-2].}
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].}
1633   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: b\_den\_1\textcolor{comment}{  !< The first term in the denominator of the pivot}
1634 \textcolor{comment}{                                !! for the tridiagonal solver, given by h\_k plus a term that}
1635 \textcolor{comment}{                                !! is a fraction (determined from the tridiagonal solver) of}
1636 \textcolor{comment}{                                !! Kddt\_h for the interface above [H ~> m or kg m-2].}
1637   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: dte\_term\textcolor{comment}{ !< A diffusivity-independent term related to the temperature change}
1638 \textcolor{comment}{                                !! in the layer below the interface [degC H ~> degC m or degC kg m-2].}
1639   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: dse\_term\textcolor{comment}{ !< A diffusivity-independent term related to the salinity change}
1640 \textcolor{comment}{                                !! in the layer below the interface [ppt H ~> ppt m or ppt kg m-2].}
1641   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: dt\_km1\_t2\textcolor{comment}{ !< A diffusivity-independent term related to the}
1642 \textcolor{comment}{                                 !! temperature change in the layer above the interface [degC].}
1643   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: ds\_km1\_t2\textcolor{comment}{ !< A diffusivity-independent term related to the}
1644 \textcolor{comment}{                                 !! salinity change in the layer above the interface [ppt].}
1645   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: pres\_z\textcolor{comment}{    !< The rescaled hydrostatic interface pressure, which relates}
1646 \textcolor{comment}{                                 !! the changes in column thickness to the energy that is radiated}
1647 \textcolor{comment}{                                 !! as gravity waves and unavailable to drive mixing [R Z2 T-2 ~> J m-3].}
1648   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: dt\_to\_dpe\_k\textcolor{comment}{ !< A factor (pres\_lay*mass\_lay*dSpec\_vol/dT) relating}
1649 \textcolor{comment}{                                 !! a layer's temperature change to the change in column potential}
1650 \textcolor{comment}{                                 !! energy, including all implicit diffusive changes in the}
1651 \textcolor{comment}{                                 !! temperatures of all the layers below [R Z3 T-2 degC-1 ~> J m-2 degC-1].}
1652   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: ds\_to\_dpe\_k\textcolor{comment}{ !< A factor (pres\_lay*mass\_lay*dSpec\_vol/dS) relating}
1653 \textcolor{comment}{                                 !! a layer's salinity change to the change in column potential}
1654 \textcolor{comment}{                                 !! energy, including all implicit diffusive changes in the}
1655 \textcolor{comment}{                                 !! in the salinities of all the layers below [R Z3 T-2 ppt-1 ~> J m-2
       ppt-1].}
1656   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: dt\_to\_dpea\textcolor{comment}{ !< A factor (pres\_lay*mass\_lay*dSpec\_vol/dT) relating}
1657 \textcolor{comment}{                                 !! a layer's temperature change to the change in column potential}
1658 \textcolor{comment}{                                 !! energy, including all implicit diffusive changes in the}
1659 \textcolor{comment}{                                 !! temperatures of all the layers above [R Z3 T-2 degC-1 ~> J m-2 degC-1].}
1660   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: ds\_to\_dpea\textcolor{comment}{ !< A factor (pres\_lay*mass\_lay*dSpec\_vol/dS) relating}
1661 \textcolor{comment}{                                 !! a layer's salinity change to the change in column potential}
1662 \textcolor{comment}{                                 !! energy, including all implicit diffusive changes in the}
1663 \textcolor{comment}{                                 !! salinities of all the layers above [R Z3 T-2 ppt-1 ~> J m-2 ppt-1].}
1664   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: dt\_to\_dcolht\_k\textcolor{comment}{ !< A factor (mass\_lay*dSColHtc\_vol/dT) relating}
1665 \textcolor{comment}{                                 !! a layer's temperature change to the change in column}
1666 \textcolor{comment}{                                 !! height, including all implicit diffusive changes in the}
1667 \textcolor{comment}{                                 !! temperatures of all the layers below [Z degC-1 ~> m degC-1].}
1668   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: ds\_to\_dcolht\_k\textcolor{comment}{ !< A factor (mass\_lay*dSColHtc\_vol/dS) relating}
1669 \textcolor{comment}{                                 !! a layer's salinity change to the change in column}
1670 \textcolor{comment}{                                 !! height, including all implicit diffusive changes}
1671 \textcolor{comment}{                                 !! in the salinities of all the layers below [Z ppt-1 ~> m ppt-1].}
1672   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: dt\_to\_dcolhta\textcolor{comment}{ !< A factor (mass\_lay*dSColHtc\_vol/dT) relating}
1673 \textcolor{comment}{                                 !! a layer's temperature change to the change in column}
1674 \textcolor{comment}{                                 !! height, including all implicit diffusive changes}
1675 \textcolor{comment}{                                 !! in the temperatures of all the layers above [Z degC-1 ~> m degC-1].}
1676   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: ds\_to\_dcolhta\textcolor{comment}{ !< A factor (mass\_lay*dSColHtc\_vol/dS) relating}
1677 \textcolor{comment}{                                 !! a layer's salinity change to the change in column}
1678 \textcolor{comment}{                                 !! height, including all implicit diffusive changes}
1679 \textcolor{comment}{                                 !! in the salinities of all the layers above [Z ppt-1 ~> m ppt-1].}
1680 
1681   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: pe\_chg\textcolor{comment}{   !< The change in column potential energy from applying}
1682 \textcolor{comment}{                                          !! Kddt\_h at the present interface [R Z3 T-2 ~> J m-2].}
1683   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: dpec\_dkd\textcolor{comment}{ !< The partial derivative of PE\_chg with Kddt\_h}
1684 \textcolor{comment}{                                          !! [R Z3 T-2 H-1 ~> J m-3 or J kg-1].}
1685   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: dpe\_max\textcolor{comment}{  !< The maximum change in column potential energy that could}
1686 \textcolor{comment}{                                          !! be realizedd by applying a huge value of Kddt\_h at the}
1687 \textcolor{comment}{                                          !! present interface [R Z3 T-2 ~> J m-2].}
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}
1689 \textcolor{comment}{                                          !! limit where Kddt\_h = 0 [R Z3 T-2 H-1 ~> J m-3 or J kg-1].}
1690 
1691 \textcolor{comment}{!   This subroutine determines the total potential energy change due to mixing}
1692 \textcolor{comment}{! at an interface, including all of the implicit effects of the prescribed}
1693 \textcolor{comment}{! mixing at interfaces above.  Everything here is derived by careful manipulation}
1694 \textcolor{comment}{! of the robust tridiagonal solvers used for tracers by MOM6.  The results are}
1695 \textcolor{comment}{! positive for mixing in a stably stratified environment.}
1696 \textcolor{comment}{!   The comments describing these arguments are for a downward mixing pass, but}
1697 \textcolor{comment}{! this routine can also be used for an upward pass with the sense of direction}
1698 \textcolor{comment}{! reversed.}
1699 
1700   \textcolor{keywordtype}{real} :: b1            \textcolor{comment}{! b1 is used by the tridiagonal solver [H-1 ~> m-1 or m2 kg-1].}
1701   \textcolor{keywordtype}{real} :: b1kd          \textcolor{comment}{! Temporary array [nondim]}
1702   \textcolor{keywordtype}{real} :: colht\_chg     \textcolor{comment}{! The change in column thickness [Z ~> m].}
1703   \textcolor{keywordtype}{real} :: dcolht\_max    \textcolor{comment}{! The change in column thickness for infinite diffusivity [Z ~> m].}
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].}
1705   \textcolor{keywordtype}{real} :: dt\_k, dt\_km1  \textcolor{comment}{! Temporary arrays [degC].}
1706   \textcolor{keywordtype}{real} :: ds\_k, ds\_km1  \textcolor{comment}{! Temporary arrays [ppt].}
1707   \textcolor{keywordtype}{real} :: i\_kr\_denom    \textcolor{comment}{! Temporary array [H-2 ~> m-2 or m4 kg-2]}
1708   \textcolor{keywordtype}{real} :: dkr\_dkd       \textcolor{comment}{! Nondimensional temporary array.}
1709   \textcolor{keywordtype}{real} :: ddt\_k\_dkd, ddt\_km1\_dkd \textcolor{comment}{! Temporary arrays [degC H-1 ~> m-1 or m2 kg-1].}
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].}
1711 
1712   b1 = 1.0 / (b\_den\_1 + kddt\_h)
1713   b1kd = kddt\_h*b1
1714 
1715   \textcolor{comment}{! Start with the temperature change in layer k-1 due to the diffusivity at}
1716   \textcolor{comment}{! interface K without considering the effects of changes in layer k.}
1717 
1718   \textcolor{comment}{! Calculate the change in PE due to the diffusion at interface K}
1719   \textcolor{comment}{! if Kddt\_h(K+1) = 0.}
1720   i\_kr\_denom = 1.0 / (h\_k*b\_den\_1 + (b\_den\_1 + h\_k)*kddt\_h)
1721 
1722   dt\_k = (kddt\_h*i\_kr\_denom) * dte\_term
1723   ds\_k = (kddt\_h*i\_kr\_denom) * dse\_term
1724 
1725   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(pe\_chg)) \textcolor{keywordflow}{then}
1726     \textcolor{comment}{! Find the change in energy due to diffusion with strength Kddt\_h at this interface.}
1727     \textcolor{comment}{! Increment the temperature changes in layer k-1 due the changes in layer k.}
1728     dt\_km1 = b1kd * ( dt\_k + dt\_km1\_t2 )
1729     ds\_km1 = b1kd * ( ds\_k + ds\_km1\_t2 )
1730     pe\_chg = (dt\_to\_dpe\_k * dt\_k + dt\_to\_dpea * dt\_km1) + &
1731              (ds\_to\_dpe\_k * ds\_k + ds\_to\_dpea * ds\_km1)
1732     colht\_chg = (dt\_to\_dcolht\_k * dt\_k + dt\_to\_dcolhta * dt\_km1) + &
1733                 (ds\_to\_dcolht\_k * ds\_k + ds\_to\_dcolhta * ds\_km1)
1734     \textcolor{keywordflow}{if} (colht\_chg < 0.0) pe\_chg = pe\_chg - pres\_z * colht\_chg
1735 \textcolor{keywordflow}{  endif}
1736 
1737   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dpec\_dkd)) \textcolor{keywordflow}{then}
1738     \textcolor{comment}{! Find the derivatives of the temperature and salinity changes with Kddt\_h.}
1739     dkr\_dkd = (h\_k*b\_den\_1) * i\_kr\_denom**2
1740 
1741     ddt\_k\_dkd = dkr\_dkd * dte\_term
1742     dds\_k\_dkd = dkr\_dkd * dse\_term
1743     ddt\_km1\_dkd = (b1**2 * b\_den\_1) * ( dt\_k + dt\_km1\_t2 ) + b1kd * ddt\_k\_dkd
1744     dds\_km1\_dkd = (b1**2 * b\_den\_1) * ( ds\_k + ds\_km1\_t2 ) + b1kd * dds\_k\_dkd
1745 
1746     \textcolor{comment}{! Calculate the partial derivative of Pe\_chg with Kddt\_h.}
1747     dpec\_dkd = (dt\_to\_dpe\_k * ddt\_k\_dkd + dt\_to\_dpea * ddt\_km1\_dkd) + &
1748                (ds\_to\_dpe\_k * dds\_k\_dkd + ds\_to\_dpea * dds\_km1\_dkd)
1749     dcolht\_dkd = (dt\_to\_dcolht\_k * ddt\_k\_dkd + dt\_to\_dcolhta * ddt\_km1\_dkd) + &
1750                  (ds\_to\_dcolht\_k * dds\_k\_dkd + ds\_to\_dcolhta * dds\_km1\_dkd)
1751     \textcolor{keywordflow}{if} (dcolht\_dkd < 0.0) dpec\_dkd = dpec\_dkd - pres\_z * dcolht\_dkd
1752 \textcolor{keywordflow}{  endif}
1753 
1754   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dpe\_max)) \textcolor{keywordflow}{then}
1755     \textcolor{comment}{! This expression is the limit of PE\_chg for infinite Kddt\_h.}
1756     dpe\_max = (dt\_to\_dpea * dt\_km1\_t2 + ds\_to\_dpea * ds\_km1\_t2) + &
1757               ((dt\_to\_dpe\_k + dt\_to\_dpea) * dte\_term + &
1758                (ds\_to\_dpe\_k + ds\_to\_dpea) * dse\_term) / (b\_den\_1 + h\_k)
1759     dcolht\_max = (dt\_to\_dcolhta * dt\_km1\_t2 + ds\_to\_dcolhta * ds\_km1\_t2) + &
1760               ((dt\_to\_dcolht\_k + dt\_to\_dcolhta) * dte\_term + &
1761                (ds\_to\_dcolht\_k + ds\_to\_dcolhta) * dse\_term) / (b\_den\_1 + h\_k)
1762     \textcolor{keywordflow}{if} (dcolht\_max < 0.0) dpe\_max = dpe\_max - pres\_z*dcolht\_max
1763 \textcolor{keywordflow}{  endif}
1764 
1765   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dpec\_dkd\_0)) \textcolor{keywordflow}{then}
1766     \textcolor{comment}{! This expression is the limit of dPEc\_dKd for Kddt\_h = 0.}
1767     dpec\_dkd\_0 = (dt\_to\_dpea * dt\_km1\_t2 + ds\_to\_dpea * ds\_km1\_t2) / (b\_den\_1) + &
1768                  (dt\_to\_dpe\_k * dte\_term + ds\_to\_dpe\_k * dse\_term) / (h\_k*b\_den\_1)
1769     dcolht\_dkd = (dt\_to\_dcolhta * dt\_km1\_t2 + ds\_to\_dcolhta * ds\_km1\_t2) / (b\_den\_1) + &
1770                  (dt\_to\_dcolht\_k * dte\_term + ds\_to\_dcolht\_k * dse\_term) / (h\_k*b\_den\_1)
1771     \textcolor{keywordflow}{if} (dcolht\_dkd < 0.0) dpec\_dkd\_0 = dpec\_dkd\_0 - pres\_z*dcolht\_dkd
1772 \textcolor{keywordflow}{  endif}
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}}
\subsubsection{\texorpdfstring{mstar\+\_\+langmuir()}{mstar\_langmuir()}}
{\footnotesize\ttfamily subroutine mom\+\_\+energetic\+\_\+pbl\+::mstar\+\_\+langmuir (\begin{DoxyParamCaption}\item[{type(\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{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em abs\+\_\+coriolis} & Absolute value of the Coriolis parameter \mbox{[}T-\/1 $\sim$$>$ s-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em buoyancy\+\_\+flux} & Buoyancy flux \mbox{[}Z2 T-\/3 $\sim$$>$ m2 s-\/3\mbox{]}\\
\hline
\mbox{\tt in}  & {\em ustar} & Surface friction velocity with? gustiness \mbox{[}Z T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em bld} & boundary layer depth \mbox{[}Z $\sim$$>$ m\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em mstar} & Input/output mstar (Mixing/ustar$\ast$$\ast$3) \mbox{[}nondim\mbox{]}\\
\hline
\mbox{\tt in}  & {\em langmuir\+\_\+number} & Langmuir number \mbox{[}nondim\mbox{]}\\
\hline
\mbox{\tt out}  & {\em mstar\+\_\+lt} & Mstar increase due to Langmuir turbulence \mbox{[}nondim\mbox{]}\\
\hline
\mbox{\tt 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}
1866   \textcolor{keywordtype}{type}(energetic\_pbl\_cs), \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{    !< Energetic\_PBL control structure.}
1867   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}  :: us\textcolor{comment}{    !< A dimensional unit scaling type}
1868   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}  :: abs\_coriolis\textcolor{comment}{ !< Absolute value of the Coriolis parameter [T-1 ~>
       s-1]}
1869   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}  :: buoyancy\_flux\textcolor{comment}{ !< Buoyancy flux [Z2 T-3 ~> m2 s-3]}
1870   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}  :: ustar\textcolor{comment}{ !< Surface friction velocity with? gustiness [Z T-1 ~> m s-1]}
1871   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}  :: bld\textcolor{comment}{   !< boundary layer depth [Z ~> m]}
1872   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(inout)} :: mstar\textcolor{comment}{ !< Input/output mstar (Mixing/ustar**3) [nondim]}
1873   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}  :: langmuir\_number\textcolor{comment}{ !< Langmuir number [nondim]}
1874   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(out)} :: mstar\_lt\textcolor{comment}{ !< Mstar increase due to Langmuir turbulence [nondim]}
1875   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(out)} :: convect\_langmuir\_number\textcolor{comment}{ !< Langmuir number including buoyancy flux
       [nondim]}
1876 
1877   \textcolor{comment}{!/}
1878   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{parameter} :: max\_ratio = 1.0e16  \textcolor{comment}{! The maximum value of a nondimensional ratio.}
1879   \textcolor{keywordtype}{real} :: enhance\_mstar \textcolor{comment}{! A multiplicative scaling of mstar due to Langmuir turbulence.}
1880   \textcolor{keywordtype}{real} :: mstar\_lt\_add \textcolor{comment}{! A value that is added to mstar due to Langmuir turbulence.}
1881   \textcolor{keywordtype}{real} :: il\_ekman    \textcolor{comment}{! Inverse of Ekman length scale [Z-1 ~> m-1].}
1882   \textcolor{keywordtype}{real} :: il\_obukhov  \textcolor{comment}{! Inverse of Obukhov length scale [Z-1 ~> m-1].}
1883   \textcolor{keywordtype}{real} :: i\_ustar     \textcolor{comment}{! The Adcroft reciprocal of ustar [T Z-1 ~> s m-1]}
1884   \textcolor{keywordtype}{real} :: i\_f         \textcolor{comment}{! The Adcroft reciprocal of the Coriolis parameter [T ~> s]}
1885   \textcolor{keywordtype}{real} :: mld\_ekman          \textcolor{comment}{! The ratio of the mixed layer depth to the Ekman layer depth [nondim].}
1886   \textcolor{keywordtype}{real} :: ekman\_obukhov      \textcolor{comment}{! The Ekman layer thickness divided by the Obukhov depth [nondim].}
1887   \textcolor{keywordtype}{real} :: mld\_obukhov        \textcolor{comment}{! The mixed layer depth divided by the Obukhov depth [nondim].}
1888   \textcolor{keywordtype}{real} :: mld\_obukhov\_stab   \textcolor{comment}{! Ratios of length scales where MLD is boundary layer depth [nondim].}
1889   \textcolor{keywordtype}{real} :: ekman\_obukhov\_stab \textcolor{comment}{! >}
1890   \textcolor{keywordtype}{real} :: mld\_obukhov\_un     \textcolor{comment}{! Ratios of length scales where MLD is boundary layer depth}
1891   \textcolor{keywordtype}{real} :: ekman\_obukhov\_un   \textcolor{comment}{! >}
1892 
1893   \textcolor{comment}{! Set default values for no Langmuir effects.}
1894   enhance\_mstar = 1.0 ; mstar\_lt\_add = 0.0
1895 
1896   \textcolor{keywordflow}{if} (cs%LT\_Enhance\_Form /= no\_langmuir) \textcolor{keywordflow}{then}
1897     \textcolor{comment}{! a. Get parameters for modified LA}
1898     \textcolor{keywordflow}{if} (cs%answers\_2018) \textcolor{keywordflow}{then}
1899       il\_ekman   = abs\_coriolis / ustar
1900       il\_obukhov = buoyancy\_flux*cs%vonkar / ustar**3
1901       ekman\_obukhov\_stab = abs(max(0., il\_obukhov / (il\_ekman + 1.e-10*us%Z\_to\_m)))
1902       ekman\_obukhov\_un = abs(min(0., il\_obukhov / (il\_ekman + 1.e-10*us%Z\_to\_m)))
1903       mld\_obukhov\_stab = abs(max(0., bld*il\_obukhov))
1904       mld\_obukhov\_un = abs(min(0., bld*il\_obukhov))
1905       mld\_ekman = abs( bld*il\_ekman )
1906     \textcolor{keywordflow}{else}
1907       ekman\_obukhov = max\_ratio ; mld\_obukhov = max\_ratio ; mld\_ekman = max\_ratio
1908       i\_f = 0.0 ; \textcolor{keywordflow}{if} (abs(abs\_coriolis) > 0.0) i\_f = 1.0 / abs\_coriolis
1909       i\_ustar = 0.0 ; \textcolor{keywordflow}{if} (abs(ustar) > 0.0) i\_ustar = 1.0 / ustar
1910       \textcolor{keywordflow}{if} (abs(buoyancy\_flux*cs%vonkar) < max\_ratio*(abs\_coriolis * ustar**2)) &
1911         ekman\_obukhov = abs(buoyancy\_flux*cs%vonkar) * (i\_f * i\_ustar**2)
1912       \textcolor{keywordflow}{if} (abs(bld*buoyancy\_flux*cs%vonkar) < max\_ratio*ustar**3) &
1913         mld\_obukhov = abs(bld*buoyancy\_flux*cs%vonkar) * i\_ustar**3
1914       \textcolor{keywordflow}{if} (bld*abs\_coriolis < max\_ratio*ustar) &
1915         mld\_ekman = bld*abs\_coriolis * i\_ustar
1916 
1917       \textcolor{keywordflow}{if} (buoyancy\_flux > 0.0) \textcolor{keywordflow}{then}
1918         ekman\_obukhov\_stab = ekman\_obukhov ; ekman\_obukhov\_un = 0.0
1919         mld\_obukhov\_stab = mld\_obukhov ; mld\_obukhov\_un = 0.0
1920       \textcolor{keywordflow}{else}
1921         ekman\_obukhov\_un = ekman\_obukhov ; ekman\_obukhov\_stab = 0.0
1922         mld\_obukhov\_un = mld\_obukhov ; mld\_obukhov\_stab = 0.0
1923 \textcolor{keywordflow}{      endif}
1924 \textcolor{keywordflow}{    endif}
1925 
1926     \textcolor{comment}{! b. Adjust LA based on various parameters.}
1927     \textcolor{comment}{!    Assumes linear factors based on length scale ratios to adjust LA}
1928     \textcolor{comment}{!    Note when these coefficients are set to 0 recovers simple LA.}
1929     convect\_langmuir\_number = langmuir\_number * &
1930                     ( (1.0 + max(-0.5, cs%LaC\_MLDoEK * mld\_ekman)) + &
1931                    ((cs%LaC\_EKoOB\_stab * ekman\_obukhov\_stab + cs%LaC\_EKoOB\_un * ekman\_obukhov\_un) + &
1932                     (cs%LaC\_MLDoOB\_stab * mld\_obukhov\_stab  + cs%LaC\_MLDoOB\_un * mld\_obukhov\_un)) )
1933 
1934     \textcolor{keywordflow}{if} (cs%LT\_Enhance\_Form == langmuir\_rescale) \textcolor{keywordflow}{then}
1935       \textcolor{comment}{! Enhancement is multiplied (added mst\_lt set to 0)}
1936       enhance\_mstar = min(cs%Max\_Enhance\_M, &
1937                           (1. + cs%LT\_ENHANCE\_COEF * convect\_langmuir\_number**cs%LT\_ENHANCE\_EXP) )
1938     \textcolor{keywordflow}{elseif} (cs%LT\_ENHANCE\_Form == langmuir\_add) \textcolor{keywordflow}{then}
1939       \textcolor{comment}{! or Enhancement is additive (multiplied enhance\_m set to 1)}
1940       mstar\_lt\_add = cs%LT\_ENHANCE\_COEF * convect\_langmuir\_number**cs%LT\_ENHANCE\_EXP
1941 \textcolor{keywordflow}{    endif}
1942 \textcolor{keywordflow}{  endif}
1943 
1944   mstar\_lt = (enhance\_mstar - 1.0)*mstar + mstar\_lt\_add  \textcolor{comment}{! Diagnose the full increase in mstar.}
1945   mstar = mstar*enhance\_mstar + mstar\_lt\_add
1946 
\end{DoxyCode}


\subsection{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}}
\subsubsection{\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}
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}}
\subsubsection{\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}
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}}
\subsubsection{\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}
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}}
\subsubsection{\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}
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}}
\subsubsection{\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}
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}}
\subsubsection{\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}
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}}
\subsubsection{\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}
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}}
\subsubsection{\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}
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}
