\hypertarget{namespacesamfdeepcnv}{}\doxysubsection{samfdeepcnv Module Reference}
\label{namespacesamfdeepcnv}\index{samfdeepcnv@{samfdeepcnv}}


This module contains the CCPP-\/compliant scale-\/aware mass-\/flux deep convection scheme.  


\doxysubsubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine \mbox{\hyperlink{namespacesamfdeepcnv_a1d71c38526dcdb2d16e2fa8845df73d9_a1d71c38526dcdb2d16e2fa8845df73d9}{samfdeepcnv\+\_\+init}} (imfdeepcnv, imfdeepcnv\+\_\+samf, errmsg, errflg)
\item 
subroutine \mbox{\hyperlink{group___s_a_m_fdeep_gac55d92617a54178b719994b95b9e197f_gac55d92617a54178b719994b95b9e197f}{samfdeepcnv\+\_\+run}} (im, km, first\+\_\+time\+\_\+step, restart, tmf, qmicro, itc, ntc, cliq, cp, cvap, eps, epsm1, fv, grav, hvap, rd, rv, t0c, delt, ntk, ntr, delp, prslp, psp, phil, qtr, prevsq, q, q1, t1, u1, v1, fscav, hwrf\+\_\+samfdeep, progsigma, cldwrk, rn, kbot, ktop, kcnv, islimsk, garea, dot, ncloud, hpbl, ud\+\_\+mf, dd\+\_\+mf, dt\+\_\+mf, cnvw, cnvc, QLCN, QICN, w\+\_\+upi, cf\+\_\+upi, CNV\+\_\+\+MFD, CNV\+\_\+\+DQLDT, CLCN, CNV\+\_\+\+FICE, CNV\+\_\+\+NDROP, CNV\+\_\+\+NICE, mp\+\_\+phys, mp\+\_\+phys\+\_\+mg, clam, c0s, c1, betal, betas, evef, pgcon, asolfac, do\+\_\+ca, ca\+\_\+closure, ca\+\_\+entr, ca\+\_\+trigger, nthresh, ca\+\_\+deep, rainevap, sigmain, sigmaout, errmsg, errflg)
\end{DoxyCompactItemize}


\doxysubsubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacesamfdeepcnv_a1d71c38526dcdb2d16e2fa8845df73d9_a1d71c38526dcdb2d16e2fa8845df73d9}\label{namespacesamfdeepcnv_a1d71c38526dcdb2d16e2fa8845df73d9_a1d71c38526dcdb2d16e2fa8845df73d9}} 
\index{samfdeepcnv@{samfdeepcnv}!samfdeepcnv\_init@{samfdeepcnv\_init}}
\index{samfdeepcnv\_init@{samfdeepcnv\_init}!samfdeepcnv@{samfdeepcnv}}
\doxyparagraph{\texorpdfstring{samfdeepcnv\_init()}{samfdeepcnv\_init()}}
{\footnotesize\ttfamily subroutine samfdeepcnv\+::samfdeepcnv\+\_\+init (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{imfdeepcnv,  }\item[{integer, intent(in)}]{imfdeepcnv\+\_\+samf,  }\item[{character(len=$\ast$), intent(out)}]{errmsg,  }\item[{integer, intent(out)}]{errflg }\end{DoxyParamCaption})}

\mbox{\Hypertarget{group___s_a_m_fdeep_gac55d92617a54178b719994b95b9e197f_gac55d92617a54178b719994b95b9e197f}\label{group___s_a_m_fdeep_gac55d92617a54178b719994b95b9e197f_gac55d92617a54178b719994b95b9e197f}} 
\index{samfdeepcnv@{samfdeepcnv}!samfdeepcnv\_run@{samfdeepcnv\_run}}
\index{samfdeepcnv\_run@{samfdeepcnv\_run}!samfdeepcnv@{samfdeepcnv}}
\doxyparagraph{\texorpdfstring{samfdeepcnv\_run()}{samfdeepcnv\_run()}}
{\footnotesize\ttfamily subroutine samfdeepcnv\+::samfdeepcnv\+\_\+run (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{im,  }\item[{integer, intent(in)}]{km,  }\item[{logical, intent(in)}]{first\+\_\+time\+\_\+step,  }\item[{logical, intent(in)}]{restart,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:,\+:), intent(in)}]{tmf,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(in)}]{qmicro,  }\item[{integer, intent(in)}]{itc,  }\item[{integer, intent(in)}]{ntc,  }\item[{real(kind=kind\+\_\+phys), intent(in)}]{cliq,  }\item[{real(kind=kind\+\_\+phys), intent(in)}]{cp,  }\item[{real(kind=kind\+\_\+phys), intent(in)}]{cvap,  }\item[{real(kind=kind\+\_\+phys), intent(in)}]{eps,  }\item[{real(kind=kind\+\_\+phys), intent(in)}]{epsm1,  }\item[{real(kind=kind\+\_\+phys), intent(in)}]{fv,  }\item[{real(kind=kind\+\_\+phys), intent(in)}]{grav,  }\item[{real(kind=kind\+\_\+phys), intent(in)}]{hvap,  }\item[{real(kind=kind\+\_\+phys), intent(in)}]{rd,  }\item[{real(kind=kind\+\_\+phys), intent(in)}]{rv,  }\item[{real(kind=kind\+\_\+phys), intent(in)}]{t0c,  }\item[{real(kind=kind\+\_\+phys), intent(in)}]{delt,  }\item[{integer, intent(in)}]{ntk,  }\item[{integer, intent(in)}]{ntr,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(in)}]{delp,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(in)}]{prslp,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:), intent(in)}]{psp,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(in)}]{phil,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:,\+:), intent(inout)}]{qtr,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(in)}]{prevsq,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(in)}]{q,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(inout)}]{q1,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(inout)}]{t1,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(inout)}]{u1,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(inout)}]{v1,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:), intent(in)}]{fscav,  }\item[{logical, intent(in)}]{hwrf\+\_\+samfdeep,  }\item[{logical, intent(in)}]{progsigma,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:), intent(out)}]{cldwrk,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:), intent(out)}]{rn,  }\item[{integer, dimension(\+:), intent(out)}]{kbot,  }\item[{integer, dimension(\+:), intent(out)}]{ktop,  }\item[{integer, dimension(\+:), intent(inout)}]{kcnv,  }\item[{integer, dimension(\+:), intent(in)}]{islimsk,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:), intent(in)}]{garea,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(in)}]{dot,  }\item[{integer, intent(in)}]{ncloud,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:), intent(in)}]{hpbl,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(out)}]{ud\+\_\+mf,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(out)}]{dd\+\_\+mf,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(out)}]{dt\+\_\+mf,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(inout)}]{cnvw,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(inout)}]{cnvc,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(inout)}]{QLCN,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(inout)}]{QICN,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(inout)}]{w\+\_\+upi,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(inout)}]{cf\+\_\+upi,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(inout)}]{CNV\+\_\+\+MFD,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(inout)}]{CNV\+\_\+\+DQLDT,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(inout)}]{CLCN,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(inout)}]{CNV\+\_\+\+FICE,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(inout)}]{CNV\+\_\+\+NDROP,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(inout)}]{CNV\+\_\+\+NICE,  }\item[{integer, intent(in)}]{mp\+\_\+phys,  }\item[{integer, intent(in)}]{mp\+\_\+phys\+\_\+mg,  }\item[{real(kind=kind\+\_\+phys), intent(in)}]{clam,  }\item[{real(kind=kind\+\_\+phys), intent(in)}]{c0s,  }\item[{real(kind=kind\+\_\+phys), intent(in)}]{c1,  }\item[{real(kind=kind\+\_\+phys), intent(in)}]{betal,  }\item[{real(kind=kind\+\_\+phys), intent(in)}]{betas,  }\item[{real(kind=kind\+\_\+phys), intent(in)}]{evef,  }\item[{real(kind=kind\+\_\+phys), intent(in)}]{pgcon,  }\item[{real(kind=kind\+\_\+phys), intent(in)}]{asolfac,  }\item[{logical, intent(in)}]{do\+\_\+ca,  }\item[{logical, intent(in)}]{ca\+\_\+closure,  }\item[{logical, intent(in)}]{ca\+\_\+entr,  }\item[{logical, intent(in)}]{ca\+\_\+trigger,  }\item[{real(kind=kind\+\_\+phys), intent(in)}]{nthresh,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:), intent(in)}]{ca\+\_\+deep,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:), intent(out)}]{rainevap,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(in)}]{sigmain,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(out)}]{sigmaout,  }\item[{character(len=$\ast$), intent(out)}]{errmsg,  }\item[{integer, intent(out)}]{errflg }\end{DoxyParamCaption})}

\hypertarget{group___s_a_m_fdeep_autotoc_md20}{}\doxyparagraph{Determine whether to perform aerosol transport}\label{group___s_a_m_fdeep_autotoc_md20}
\hypertarget{group___s_a_m_fdeep_autotoc_md21}{}\doxyparagraph{Compute preliminary quantities needed for static, dynamic, and feedback control portions of the algorithm.}\label{group___s_a_m_fdeep_autotoc_md21}

\begin{DoxyItemize}
\item Convert input pressure terms to centibar units.
\end{DoxyItemize}

Initialize column-\/integrated and other single-\/value-\/per-\/column variable arrays.


\begin{DoxyItemize}
\item determine aerosol-\/aware rain conversion parameter over land
\item determine rain conversion parameter above the freezing level which exponentially decreases with decreasing temperature from Han et al.\textquotesingle{}s (2017) \cite{han_et_al_2017} equation 8.
\item Initialize convective cloud water and cloud cover to zero.
\item Initialize updraft and downdraft mass fluxes to zero.
\item Determine maximum indices for the parcel starting point (kbm), LFC (kbmax), and cloud top (kmax).
\item Calculate hydrostatic height at layer centers assuming a flat surface (no terrain) from the geopotential.
\item Calculate interface height
\item Convert prsl from centibar to millibar, set normalized mass fluxes to 1, cloud properties to 0, and save model state variables (after advection/turbulence).
\item Calculate saturation specific humidity and enforce minimum moisture values.
\item Calculate moist static energy (heo) and saturation moist static energy (heso).
\end{DoxyItemize}\hypertarget{group___s_a_m_fdeep_autotoc_md22}{}\doxyparagraph{Perform calculations related to the updraft of the entraining/detraining cloud model (\char`\"{}static control\char`\"{}).}\label{group___s_a_m_fdeep_autotoc_md22}

\begin{DoxyItemize}
\item Find the index for a level of sfclfac$\ast$hpbl which is initial guess for the parcel starting level.
\end{DoxyItemize}

Search below index \char`\"{}kbm\char`\"{} and above kb1 for the level of maximum moist static energy. ~\newline



\begin{DoxyItemize}
\item Calculate the temperature, specific humidity, and pressure at interface levels.
\item Recalculate saturation specific humidity, moist static energy, saturation moist static energy, and horizontal momentum on interface levels. Enforce minimum specific humidity and calculate $(1 - RH)$.
\item Search below the index \char`\"{}kbmax\char`\"{} for the level of free convection (LFC) where the condition $h_b > h^*$ is first met, where $h_b, h^*$ are the state moist static energy at the parcel\textquotesingle{}s starting level and saturation moist static energy, respectively. Set \char`\"{}kbcon\char`\"{} to the index of the LFC.
\item If no LFC, return to the calling routine without modifying state variables.
\item Determine the vertical pressure velocity at the LFC. After Han and Pan (2011) \cite{han_and_pan_2011} , determine the maximum pressure thickness between a parcel\textquotesingle{}s starting level and the LFC. If a parcel doesn\textquotesingle{}t reach the LFC within the critical thickness, then the convective inhibition is deemed too great for convection to be triggered, and the subroutine returns to the calling routine without modifying the state variables.
\item if the mean relative humidity in the subcloud layers is less than a threshold value (rhcrt), convection is not triggered.
\item In HWRF samfdeep, calculate the entrainment rate according to Han and Pan (2011) \cite{han_and_pan_2011} , equation 8, after Bechtold et al. (2008) \cite{bechtold_et_al_2008}, equation 2 given by\+: \[ \epsilon = \epsilon_0F_0 + d_1\left(1-RH\right)F_1 \] where $\epsilon_0$ is the cloud base entrainment rate, $d_1$ is a tunable constant, and $F_0=\left(\frac{q_s}{q_{s,b}}\right)^2$ and $F_1=\left(\frac{q_s}{q_{s,b}}\right)^3$ where $q_s$ and $q_{s,b}$ are the saturation specific humidities at a given level and cloud base, respectively. The detrainment rate in the cloud is assumed to be equal to the entrainment rate at cloud base.
\item The updraft detrainment rate is vertically constant and proportional to clamt
\item Calculate the normalized mass flux for subcloud and in-\/cloud layers according to Pan and Wu (1995) \cite{pan_and_wu_1995} equation 1\+: \[ \frac{1}{\eta}\frac{\partial \eta}{\partial z} = \lambda_e - \lambda_d \] where $\eta$ is the normalized mass flux, $\lambda_e$ is the entrainment rate and $\lambda_d$ is the detrainment rate.
\item Set cloud properties equal to the state variables at updraft starting level (kb).
\item Calculate the cloud properties as a parcel ascends, modified by entrainment and detrainment. Discretization follows Appendix B of Grell (1993) \cite{grell_1993} . Following Han and Pan (2006) \cite{han_and_pan_2006}, the convective momentum transport is reduced by the convection-\/induced pressure gradient force by the constant \char`\"{}pgcon\char`\"{}, currently set to 0.\+55 after Zhang and Wu (2003) \cite{zhang_and_wu_2003} .
\item With entrainment, recalculate the LFC as the first level where buoyancy is positive. The difference in pressure levels between LFCs calculated with/without entrainment must be less than a threshold (currently 25 h\+Pa). Otherwise, convection is inhibited and the scheme returns to the calling routine without modifying the state variables. This is the subcloud dryness trigger modification discussed in Han and Pan (2011) \cite{han_and_pan_2011}.
\item Calculate additional trigger condition of the convective inhibition (CIN) according to Han et al.\textquotesingle{}s (2017) \cite{han_et_al_2017} equation 13.
\item Turn off convection if the CIN is less than a critical value (cinacr) which is inversely proportional to the large-\/scale vertical velocity.
\item Calculate the cloud top as the first level where parcel buoyancy becomes negative. If the thickness of the calculated convection is less than a threshold (currently 200 h\+Pa), then convection is inhibited, and the scheme returns to the calling routine.
\item To originate the downdraft, search for the level above the minimum in moist static energy. Return to the calling routine without modification if this level is determined to be outside of the convective cloud layers.
\item Calculate the maximum value of the cloud base mass flux using the CFL-\/criterion-\/based formula of Han and Pan (2011) \cite{han_and_pan_2011}, equation 7.
\item Set cloud moisture property equal to the enviromental moisture at updraft starting level (kb).
\item Calculate the moisture content of the entraining/detraining parcel (qcko) and the value it would have if just saturated (qrch), according to equation A.\+14 in Grell (1993) \cite{grell_1993} . Their difference is the amount of convective cloud water (qlk = rain + condensate). Determine the portion of convective cloud water that remains suspended and the portion that is converted into convective precipitation (pwo). Calculate and save the negative cloud work function (aa1) due to water loading. The liquid water in the updraft layer is assumed to be detrained from the layers above the level of the minimum moist static energy into the grid-\/scale cloud water (dellal).
\item Calculate the cloud work function according to Pan and Wu (1995) \cite{pan_and_wu_1995} equation 4\+: \[ A_u=\int_{z_0}^{z_t}\frac{g}{c_pT(z)}\frac{\eta}{1 + \gamma}[h(z)-h^*(z)]dz \] (discretized according to Grell (1993) \cite{grell_1993} equation B.\+10 using B.\+2 and B.\+3 of Arakawa and Schubert (1974) \cite{arakawa_and_schubert_1974} and assuming $\eta=1$) where $A_u$ is the updraft cloud work function, $z_0$ and $z_t$ are cloud base and cloud top, respectively, $\gamma = \frac{L}{c_p}\left(\frac{\partial \overline{q_s}}{\partial T}\right)_p$ and other quantities are previously defined.
\item If the updraft cloud work function is negative, convection does not occur, and the scheme returns to the calling routine.
\item Continue calculating the cloud work function past the point of neutral buoyancy to represent overshooting according to Han and Pan (2011) \cite{han_and_pan_2011} . Convective overshooting stops when $ cA_u < 0$ where $c$ is currently 10\%, or when 10\% of the updraft cloud work function has been consumed by the stable buoyancy force.
\item For the overshooting convection, calculate the moisture content of the entraining/detraining parcel as before. Partition convective cloud water and precipitation and detrain convective cloud water above the mimimum in moist static energy.
\item Calculate updraft velocity square(wu2) according to Han et al.\textquotesingle{}s (2017) \cite{han_et_al_2017} equation 7.
\item Calculate the mean updraft velocity within the cloud (wc).
\item For progsigma = T, calculate the mean updraft velocity within the cloud (omegac),cast in pressure coordinates. ~\newline

\item For progsigma = T, calculate the xi term in Bengtsson et al. 2022 \cite{Bengtsson_2022} (equation 8)
\item Swap the indices of the convective cloud top (ktcon) and the overshooting convection top (ktcon1) to use the same cloud top level in the calculations of $A^+$ and $A^*$.
\item Separate the total updraft cloud water at cloud top into vapor and condensate.
\end{DoxyItemize}\hypertarget{group___s_a_m_fdeep_autotoc_md23}{}\doxyparagraph{Perform calculations related to the downdraft of the entraining/detraining cloud model (\char`\"{}static control\char`\"{}).}\label{group___s_a_m_fdeep_autotoc_md23}

\begin{DoxyItemize}
\item First, in order to calculate the downdraft mass flux (as a fraction of the updraft mass flux), calculate the wind shear and precipitation efficiency according to equation 58 in Fritsch and Chappell (1980) \cite{fritsch_and_chappell_1980} \+: \[ E = 1.591 - 0.639\frac{\Delta V}{\Delta z} + 0.0953\left(\frac{\Delta V}{\Delta z}\right)^2 - 0.00496\left(\frac{\Delta V}{\Delta z}\right)^3 \] where $\Delta V$ is the integrated horizontal shear over the cloud depth, $\Delta z$, (the ratio is converted to units of $10^{-3} s^{-1}$). The variable \char`\"{}edto\char`\"{} is $1-E$ and is constrained to the range $[0,0.9]$.
\end{DoxyItemize}

Next, calculate the variable detrainment rate between the surface and the LFC according to\+: \[ \lambda_d = \frac{1-\beta^{\frac{1}{k_{LFC}}}}{\overline{\Delta z}} \] $\lambda_d$ is the detrainment rate, $\beta$ is a constant currently set to 0.\+05, implying that only 5\% of downdraft mass flux at LFC reaches the ground surface due to detrainment, $k_{LFC}$ is the vertical index of the LFC level, and $\overline{\Delta z}$ is the average vertical grid spacing below the LFC.


\begin{DoxyItemize}
\item Calculate the normalized downdraft mass flux from equation 1 of Pan and Wu (1995) \cite{pan_and_wu_1995} . Downdraft entrainment and detrainment rates are constants from the downdraft origination to the level of 60mb above the ground surface (kd94).
\item Set initial cloud downdraft properties equal to the state variables at the downdraft origination level.
\item Calculate the cloud properties as a parcel descends, modified by entrainment and detrainment. Discretization follows Appendix B of Grell (1993) \cite{grell_1993} .
\item Compute the amount of moisture that is necessary to keep the downdraft saturated.
\item Update the precipitation efficiency (edto) based on the ratio of normalized cloud condensate (pwavo) to normalized cloud evaporate (pwevo).
\item Calculate downdraft cloud work function ( $A_d$) according to equation A.\+42 (discretized by B.\+11) in Grell (1993) \cite{grell_1993} . Add it to the updraft cloud work function, $A_u$.
\item Check for negative total cloud work function; if found, return to calling routine without modifying state variables.
\item Calculate the change in moist static energy, moisture mixing ratio, and horizontal winds per unit cloud base mass flux near the surface using equations B.\+18 and B.\+19 from Grell (1993) \cite{grell_1993}, for all layers below cloud top from equations B.\+14 and B.\+15, and for the cloud top from B.\+16 and B.\+17.
\item If grid size is less than a threshold value (dxcrtas\+: currently 8km if progsigma is not used and 30km if progsigma is used), the quasi-\/equilibrium assumption of Arakawa-\/\+Schubert is not used any longer.
\item If grid size is larger than the threshold value (i.\+e., asqecflg=.true.), the quasi-\/equilibrium assumption is used to obtain the cloud base mass flux. To begin with, calculate the change in the temperature and moisture profiles per unit cloud base mass flux.
\end{DoxyItemize}\hypertarget{group___s_a_m_fdeep_autotoc_md24}{}\doxyparagraph{Using the updated temperature and moisture profiles that were modified by the convection on a short time-\/scale, recalculate the total cloud work function to determine the change in the cloud work function due to convection, or the stabilizing effect of the cumulus.}\label{group___s_a_m_fdeep_autotoc_md24}

\begin{DoxyItemize}
\item Using notation from Pan and Wu (1995) \cite{pan_and_wu_1995}, the previously calculated cloud work function is denoted by $A^+$. Now, it is necessary to use the entraining/detraining cloud model (\char`\"{}static control\char`\"{}) to determine the cloud work function of the environment after the stabilization of the arbitrary convective element (per unit cloud base mass flux) has been applied, denoted by $A^*$.
\item Recalculate saturation specific humidity.
\end{DoxyItemize}

As before, recalculate the updraft cloud work function.


\begin{DoxyItemize}
\item As before, recalculate the downdraft cloud work function.
\item Following Bechtold et al. (2008) \cite{bechtold_et_al_2008}, the convective adjustment time (dtconv) is set to be proportional to the convective turnover time, which is computed using the mean updraft velocity (wc) and the cloud depth. It is also proportional to the grid size (gdx).
\item Calculate advective time scale (tauadv) using a mean cloud layer wind speed.
\item From Bengtsson et al. (2022) \cite{Bengtsson_2022} prognostic closure scheme, equation 8, call \mbox{\hyperlink{group___s_a_m_f__shal_ga265583ac39816b7e1904c9dbeb3ffb73_ga265583ac39816b7e1904c9dbeb3ffb73}{progsigma\+\_\+calc()}} to compute updraft area fraction based on a moisture budget
\item From Han et al.\textquotesingle{}s (2017) \cite{han_et_al_2017} equation 6, calculate cloud base mass flux as a function of the mean updraft velcoity for the grid sizes where the quasi-\/equilibrium assumption of Arakawa-\/\+Schubert is not valid any longer. As discussed in Han et al. (2017) \cite{han_et_al_2017} , when dtconv is larger than tauadv, the convective mixing is not fully conducted before the cumulus cloud is advected out of the grid cell. In this case, therefore, the cloud base mass flux is further reduced in proportion to the ratio of tauadv to dtconv.
\item For the cases where the quasi-\/equilibrium assumption of Arakawa-\/\+Schubert is valid, first calculate the large scale destabilization as in equation 5 of Pan and Wu (1995) \cite{pan_and_wu_1995} \+: \[ \frac{\partial A}{\partial t}_{LS}=\frac{A^+-cA^0}{\Delta t_{LS}} \] Here $A^0$ is set to zero following Han et al.\textquotesingle{}s (2017) \cite{han_et_al_2017} , implying that the instability is completely eliminated after the convective adjustment time, $\Delta t_{LS}$.
\item Calculate the stabilization effect of the convection (per unit cloud base mass flux) as in equation 6 of Pan and Wu (1995) \cite{pan_and_wu_1995} \+: \[ \frac{\partial A}{\partial t}_{cu}=\frac{A^*-A^+}{\Delta t_{cu}} \] $\Delta t_{cu}$ is the short timescale of the convection.
\item The cloud base mass flux (xmb) is then calculated from equation 7 of Pan and Wu (1995) \cite{pan_and_wu_1995} \[ M_c=\frac{-\frac{\partial A}{\partial t}_{LS}}{\frac{\partial A}{\partial t}_{cu}} \]

Again when dtconv is larger than tauadv, the cloud base mass flux is further reduced in proportion to the ratio of tauadv to dtconv.
\item If the large scale destabilization is less than zero, or the stabilization by the convection is greater than zero, then the scheme returns to the calling routine without modifying the state variables.
\item For scale-\/aware parameterization, the updraft fraction (sigmagfm) is first computed as a function of the lateral entrainment rate at cloud base (see Han et al.\textquotesingle{}s (2017) \cite{han_et_al_2017} equation 4 and 5), following the study by Grell and Freitas (2014) \cite{grell_and_freitas_2014}.
\item Then, calculate the reduction factor (scaldfunc) of the vertical convective eddy transport of mass flux as a function of updraft fraction from the studies by Arakawa and Wu (2013) \cite{arakawa_and_wu_2013} (also see Han et al.\textquotesingle{}s (2017) \cite{han_et_al_2017} equation 1 and 2). The final cloud base mass flux with scale-\/aware parameterization is obtained from the mass flux when sigmagfm \texorpdfstring{$<$}{<}\texorpdfstring{$<$}{<} 1, multiplied by the reduction factor (Han et al.\textquotesingle{}s (2017) \cite{han_et_al_2017} equation 2).
\item Transport aerosols if present
\end{DoxyItemize}\hypertarget{group___s_a_m_fdeep_autotoc_md25}{}\doxyparagraph{For the \char`\"{}feedback\char`\"{} control, calculate updated values of the state variables by multiplying the cloud base mass flux and the tendencies calculated per unit cloud base mass flux from the static control.}\label{group___s_a_m_fdeep_autotoc_md25}

\begin{DoxyItemize}
\item Calculate the temperature tendency from the moist static energy and specific humidity tendencies.
\item Update the temperature, specific humidity, and horiztonal wind state variables by multiplying the cloud base mass flux-\/normalized tendencies by the cloud base mass flux.
\item Accumulate column-\/integrated tendencies.
\end{DoxyItemize}

Recalculate saturation specific humidity using the updated temperature.


\begin{DoxyItemize}
\item Add up column-\/integrated convective precipitation by multiplying the normalized value by the cloud base mass flux.
\item Determine the evaporation of the convective precipitation and update the integrated convective precipitation.
\begin{DoxyItemize}
\item Update state temperature and moisture to account for evaporation of convective precipitation.
\item Update column-\/integrated tendencies to account for evaporation of convective precipitation.
\end{DoxyItemize}
\item Calculate convective cloud water.
\item Calculate convective cloud cover, which is used when pdf-\/based cloud fraction is used (i.\+e., pdfcld=.true.).
\item Separate detrained cloud water into liquid and ice species as a function of temperature only.
\item If convective precipitation is zero or negative, reset the updated state variables back to their original values (negating convective changes).
\item Store aerosol concentrations if present
\item Calculate and retain the updraft and downdraft mass fluxes for dust transport by cumulus convection.
\item Calculate the updraft convective mass flux.
\item save the updraft convective mass flux at cloud top.
\item Calculate the downdraft convective mass flux.
\end{DoxyItemize}

References \mbox{\hyperlink{group___s_a_m_f__shal_ga265583ac39816b7e1904c9dbeb3ffb73_ga265583ac39816b7e1904c9dbeb3ffb73}{progsigma\+::progsigma\+\_\+calc()}}, and \mbox{\hyperlink{group__mod__sfcsub_gafcd2cbb61816537aafd9bd35cb0f4304_gafcd2cbb61816537aafd9bd35cb0f4304}{scale()}}.

Here is the call graph for this function\+:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{group___s_a_m_fdeep_gac55d92617a54178b719994b95b9e197f_gac55d92617a54178b719994b95b9e197f_cgraph}
\end{center}
\end{figure}
