\hypertarget{namespacesamfshalcnv}{}\doxysubsection{samfshalcnv Module Reference}
\label{namespacesamfshalcnv}\index{samfshalcnv@{samfshalcnv}}
\doxysubsubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine \mbox{\hyperlink{namespacesamfshalcnv_a10c3a8aec8d4873fca062722c108a827_a10c3a8aec8d4873fca062722c108a827}{samfshalcnv\+\_\+init}} (imfshalcnv, imfshalcnv\+\_\+samf, errmsg, errflg)
\item 
subroutine \mbox{\hyperlink{group___s_a_m_f__shal_ga7c9c5f5be5cf7b4f28738a89a9103939_ga7c9c5f5be5cf7b4f28738a89a9103939}{samfshalcnv\+\_\+run}} (im, km, itc, ntc, cliq, cp, cvap, eps, epsm1, fv, grav, hvap, rd, rv, t0c, delt, ntk, ntr, delp, first\+\_\+time\+\_\+step, restart, tmf, qmicro, progsigma, prslp, psp, phil, qtr, prevsq, q, q1, t1, u1, v1, fscav, rn, kbot, ktop, kcnv, islimsk, garea, dot, ncloud, hpbl, ud\+\_\+mf, dt\+\_\+mf, cnvw, cnvc, clam, c0s, c1, evef, pgcon, asolfac, hwrf\+\_\+samfshal, sigmain, sigmaout, errmsg, errflg)
\end{DoxyCompactItemize}


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

\mbox{\Hypertarget{group___s_a_m_f__shal_ga7c9c5f5be5cf7b4f28738a89a9103939_ga7c9c5f5be5cf7b4f28738a89a9103939}\label{group___s_a_m_f__shal_ga7c9c5f5be5cf7b4f28738a89a9103939_ga7c9c5f5be5cf7b4f28738a89a9103939}} 
\index{samfshalcnv@{samfshalcnv}!samfshalcnv\_run@{samfshalcnv\_run}}
\index{samfshalcnv\_run@{samfshalcnv\_run}!samfshalcnv@{samfshalcnv}}
\doxyparagraph{\texorpdfstring{samfshalcnv\_run()}{samfshalcnv\_run()}}
{\footnotesize\ttfamily subroutine samfshalcnv\+::samfshalcnv\+\_\+run (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{im,  }\item[{integer, intent(in)}]{km,  }\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[{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[{logical, intent(in)}]{progsigma,  }\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[{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)}]{dt\+\_\+mf,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(out)}]{cnvw,  }\item[{real(kind=kind\+\_\+phys), dimension(\+:,\+:), intent(out)}]{cnvc,  }\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)}]{evef,  }\item[{real(kind=kind\+\_\+phys), intent(in)}]{pgcon,  }\item[{real(kind=kind\+\_\+phys), intent(in)}]{asolfac,  }\item[{logical, intent(in)}]{hwrf\+\_\+samfshal,  }\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_f__shal_autotoc_md26}{}\doxyparagraph{Determine whether to perform aerosol transport}\label{group___s_a_m_f__shal_autotoc_md26}
\hypertarget{group___s_a_m_f__shal_autotoc_md27}{}\doxyparagraph{Compute preliminary quantities needed for the static and feedback control portions of the algorithm.}\label{group___s_a_m_f__shal_autotoc_md27}

\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 Return to the calling routine if deep convection is present or the surface buoyancy flux is negative.
\item determine aerosol-\/aware rain conversion parameter over land
\item determine scale-\/aware rain conversion parameter decreasing with decreasing grid size
\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 mass fluxes to zero.
\item Determine maximum indices for the parcel starting point (kbm) 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 Find the index for the PBL top using the PBL height; enforce that it is lower than the maximum parcel starting level.
\item Convert prsl from centibar to millibar, set normalized mass flux 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_f__shal_autotoc_md28}{}\doxyparagraph{Perform calculations related to the updraft of the entraining/detraining cloud model (\char`\"{}static control\char`\"{}).}\label{group___s_a_m_f__shal_autotoc_md28}

\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 in the PBL for the level of maximum moist static energy to start the ascending parcel.


\begin{DoxyItemize}
\item Calculate the temperature, water vapor mixing ratio, 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.
\item Search below the index \char`\"{}kbm\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 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. The normalized mass flux increases upward below the cloud base and decreases upward above.
\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; the maximum possible value is at $p=0.7p_{sfc}$.
\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. Above the level of minimum moist static energy, some of the cloud water is detrained into the grid-\/scale cloud water from every cloud layer with a rate of 0.\+0005 $m^{-1}$ (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. Overshooting is also limited to the level where $p=0.7p_{sfc}$.
\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 in the overshooting layers.
\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 in pressure coordinates within the cloud (wc). ~\newline

\item For progsigma = T, calculate the xi term in Bengtsson et al. 2022 \cite{Bengtsson_2022} (equation 8)
\item =\texorpdfstring{$>$}{>} Separate the total updraft cloud water at cloud top into vapor and condensate.
\end{DoxyItemize}\hypertarget{group___s_a_m_f__shal_autotoc_md29}{}\doxyparagraph{Calculate the tendencies of the state variables (per unit cloud base mass flux) and the cloud base mass flux.}\label{group___s_a_m_f__shal_autotoc_md29}

\begin{DoxyItemize}
\item Calculate the change in moist static energy, moisture mixing ratio, and horizontal winds per unit cloud base mass flux for all layers below cloud top from equations B.\+14 and B.\+15 from Grell (1993) \cite{grell_1993}, and for the cloud top from B.\+16 and B.\+17.
\end{DoxyItemize}

Following Bechtold et al. (2008) \cite{bechtold_et_al_2008}, calculate the convective turnover time using the mean updraft velocity (wc) and the cloud depth. It is also proportional to the grid size (gdx).


\begin{DoxyItemize}
\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. 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 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_f__shal_autotoc_md30}{}\doxyparagraph{For the \char`\"{}feedback control\char`\"{}, 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_f__shal_autotoc_md30}

\begin{DoxyItemize}
\item Recalculate saturation specific humidity.
\end{DoxyItemize}

Calculate the temperature tendency from the moist static energy and specific humidity tendencies.
\begin{DoxyItemize}
\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 shallow 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 Store aerosol concentrations if present
\item Calculate and retain the updraft mass flux for dust transport by cumulus convection.
\item Calculate the updraft convective mass flux.
\item save the updraft convective mass flux at cloud top.
\end{DoxyItemize}

References \mbox{\hyperlink{group___s_a_m_f__shal_ga265583ac39816b7e1904c9dbeb3ffb73_ga265583ac39816b7e1904c9dbeb3ffb73}{progsigma\+::progsigma\+\_\+calc()}}.

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