76 & tmf,qmicro,itc,ntc,cliq,cp,cvap, &
77 & eps,epsm1,fv,grav,hvap,rd,rv, &
78 & t0c,delt,ntk,ntr,delp, &
79 & prslp,psp,phil,qtr,prevsq,q,q1,t1,u1,v1,fscav, &
80 & hwrf_samfdeep,progsigma,cldwrk,rn,kbot,ktop,kcnv, &
81 & islimsk,garea,dot,ncloud,hpbl,ud_mf,dd_mf,dt_mf,cnvw,cnvc, &
82 & QLCN, QICN, w_upi, cf_upi, CNV_MFD, &
83 & CNV_DQLDT,CLCN,CNV_FICE,CNV_NDROP,CNV_NICE,mp_phys,mp_phys_mg,&
84 & clam,c0s,c1,betal,betas,evef,pgcon,asolfac, &
85 & do_ca, ca_closure, ca_entr, ca_trigger, nthresh,ca_deep, &
86 & rainevap,sigmain,sigmaout,betadcu,betamcu,betascu, &
87 & maxMF, do_mynnedmf,errmsg,errflg)
89 use machine ,
only : kind_phys
90 use funcphys ,
only : fpvs
94 integer,
intent(in) :: im, km, itc, ntc, ntk, ntr, ncloud
95 integer,
intent(in) :: islimsk(:)
96 real(kind=kind_phys),
intent(in) :: cliq, cp, cvap, eps, epsm1, &
97 & fv, grav, hvap, rd, rv, t0c
98 real(kind=kind_phys),
intent(in) :: delt
99 real(kind=kind_phys),
intent(in) :: psp(:), delp(:,:), &
100 & prslp(:,:), garea(:), hpbl(:), dot(:,:), phil(:,:)
101 real(kind=kind_phys),
dimension(:),
intent(in) :: fscav
102 logical,
intent(in) :: first_time_step,restart,hwrf_samfdeep, &
103 & progsigma,do_mynnedmf
104 real(kind=kind_phys),
intent(in) :: nthresh,betadcu,betamcu, &
106 real(kind=kind_phys),
intent(in),
optional :: ca_deep(:)
107 real(kind=kind_phys),
intent(in),
optional :: sigmain(:,:), &
108 & qmicro(:,:), prevsq(:,:)
109 real(kind=kind_phys),
intent(in) :: tmf(:,:,:),q(:,:)
110 real(kind=kind_phys),
dimension (:),
intent(in),
optional :: maxmf
111 real(kind=kind_phys),
intent(out) :: rainevap(:)
112 real(kind=kind_phys),
intent(out),
optional :: sigmaout(:,:)
113 logical,
intent(in) :: do_ca,ca_closure,ca_entr,ca_trigger
114 integer,
intent(inout) :: kcnv(:)
116 real(kind=kind_phys),
intent(inout) :: qtr(:,:,:), &
117 & q1(:,:), t1(:,:), u1(:,:), v1(:,:), &
118 & cnvw(:,:), cnvc(:,:)
120 integer,
intent(out) :: kbot(:), ktop(:)
121 real(kind=kind_phys),
intent(out) :: cldwrk(:), &
123 & dd_mf(:,:), dt_mf(:,:)
124 real(kind=kind_phys),
intent(out),
optional :: ud_mf(:,:)
128 real(kind=kind_phys),
dimension(:,:),
intent(inout),
optional :: &
129 & qlcn, qicn, w_upi, cnv_mfd, cnv_dqldt, clcn &
130 &, cnv_fice, cnv_ndrop, cnv_nice, cf_upi
132 integer,
intent(in) :: mp_phys, mp_phys_mg
134 real(kind=kind_phys),
intent(in) :: clam, c0s, c1, &
135 & betal, betas, asolfac, &
137 character(len=*),
intent(out) :: errmsg
138 integer,
intent(out) :: errflg
141 integer i, indx, jmn, k, kk, km1, n
144 real(kind=kind_phys) clamd, tkemx, tkemn, dtke,
151 real(kind=kind_phys) adw, aup, aafac, d0,
154 & dq, dqsdp, dqsdt, dt,
158 & dz, dz1, e1, edtmax,
159 & edtmaxl, edtmaxs, el2orc, elocp,
163 & fact1, fact2, factor,
164 & gamma, pprime, cm, cq,
166 & rain, rfact, shear, tfac,
171 & rho, betaw, tauadv,
174 & xqrch, tem, tem1, tem2,
177 integer kb(im), kb1(im), kbcon(im), kbcon1(im),
178 & ktcon(im), ktcon1(im), ktconn(im),
179 & jmin(im), lmin(im), kbmax(im),
180 & kbm(im), kmax(im), kd94(im)
183 real(kind=kind_phys) aa1(im), tkemean(im),clamt(im),
184 & ps(im), del(im,km), prsl(im,km),
185 & umean(im), advfac(im), gdx(im),
186 & delhbar(im), delq(im), delq2(im),
187 & delqbar(im), delqev(im), deltbar(im),
188 & deltv(im), dtconv(im), edt(im),
189 & edto(im), edtx(im), fld(im),
190 & hcdo(im,km), hmax(im), hmin(im),
191 & ucdo(im,km), vcdo(im,km),aa2(im),
193 & pdot(im), po(im,km),
194 & pwavo(im), pwevo(im), mbdt(im),
195 & qcdo(im,km), qcond(im), qevap(im),
196 & rntot(im), vshear(im), xaa0(im),
197 & xlamd(im), xlamdet(im),xlamddt(im),
198 & cxlamet(im), cxlamdt(im),
200 & xmb(im), xmbmax(im), xpwav(im),
201 & xpwev(im), xlamx(im), delebar(im,ntr),
203 & delubar(im), delvbar(im)
205 real(kind=kind_phys) c0(im), sfcpbl(im)
207 real(kind=kind_phys) cinpcr, cinpcrmx, cinpcrmn,
208 & cinacr, cinacrmx, cinacrmn,
214 real(kind=kind_phys) bb1, bb2, csmf, wucb
217 real(kind=kind_phys) omega_u(im,km),zdqca(im,km),tmfq(im,km),
218 & omegac(im),zeta(im,km),dbyo1(im,km),sigmab(im),qadv(im,km)
219 real(kind=kind_phys) gravinv,invdelt,sigmind,sigminm,sigmins
220 parameter(sigmind=0.01,sigmins=0.03,sigminm=0.01)
221 logical flag_shallow, flag_mid
237 parameter(cm=1.0,cq=1.0)
239 parameter(clamd=0.03,tkemx=0.65,tkemn=0.05)
240 parameter(clamca=0.03)
241 parameter(dtke=tkemx-tkemn)
242 parameter(cthk=200.,dthk=25.,sfclfac=0.2,rhcrt=0.75)
243 parameter(cinpcrmx=180.,cinpcrmn=120.)
245 parameter(cinacrmx=-120.,cinacrmn=-80.)
246 parameter(bb1=4.0,bb2=0.8,csmf=0.2)
247 parameter(tkcrt=2.,cmxfac=15.)
252 real(kind=kind_phys) pfld(im,km), to(im,km), qo(im,km),
253 & uo(im,km), vo(im,km), qeso(im,km),
254 & ctr(im,km,ntr), ctro(im,km,ntr)
257c variables for tracer wet deposition,
258 real(kind=kind_phys),
dimension(im,km,ntc) :: chem_c, chem_pw,
262 real(kind=kind_phys) wu2(im,km), buo(im,km), drag(im,km),
263 & wush(im,km), wc(im)
266 real(kind=kind_phys) scaldfunc(im), sigmagfm(im)
270 real(kind=kind_phys) qlko_ktcon(im), dellal(im,km), tvo(im,km),
271 & dbyo(im,km), zo(im,km),
272 & xlamue(im,km), xlamud(im,km),
273 & fent1(im,km), fent2(im,km),
274 & rh(im,km), frh(im,km),
275 & heo(im,km), heso(im,km),
276 & qrcd(im,km), dellah(im,km), dellaq(im,km),
278 & dellau(im,km), dellav(im,km), hcko(im,km),
279 & ucko(im,km), vcko(im,km), qcko(im,km),
280 & ecko(im,km,ntr),ercko(im,km,ntr),
281 & eta(im,km), etad(im,km), zi(im,km),
282 & qrcko(im,km), qrcdo(im,km),
283 & pwo(im,km), pwdo(im,km), c0t(im,km),
284 & tx1(im), sumx(im), cnvwt(im,km)
290 real(kind=kind_phys) q_diff(im,0:km-1), e_diff(im,0:km-1,ntr),
292 real(kind=kind_phys) rrkp, phkp
293 real(kind=kind_phys) tsumn(im), tsump(im), rtnp(im)
295 logical do_aerosols, totflg, cnvflg(im), asqecflg(im), flg(im)
306c
data acritt/.203,.515,.521,.566,.625,.665,.659,.688,
307c & .743,.813,.886,.947,1.138,1.377,1.896/
308 real(kind=kind_phys) tf, tcr, tcrf
309 parameter(tf=233.16, tcr=263.16, tcrf=1.0/(tcr-tf))
319 el2orc = hvap*hvap/(rv*cp)
321 fact1 = (cvap-cliq)/rv
322 fact2 = hvap/rv-fact1*t0c
323c-----------------------------------------------------------------------
325 if(hwrf_samfdeep)
then
326 do_aerosols = .false.
328 do_aerosols = (itc > 0) .and. (ntc > 0) .and. (ntr > 0)
329 if (do_aerosols) do_aerosols = (ntr >= itc + ntc - 3)
332c-----------------------------------------------------------------------
355 if(maxmf(i).gt.0.)cnvflg(i)=.false.
357 sfcpbl(i) = sfclfac * hpbl(i)
389 gdx(i) = sqrt(garea(i))
399 if (hwrf_samfdeep)
then
409 if(islimsk(i) == 1)
then
419 if(t1(i,k) > 273.16)
then
422 tem = d0 * (t1(i,k) - 273.16)
424 c0t(i,k) = c0(i) * tem1
444 if(mp_phys == mp_phys_mg)
then
447 qlcn(i,k) = qtr(i,k,2)
448 qicn(i,k) = qtr(i,k,1)
469 dtmin = max(dt2, val )
472 dtmax = max(dt2, val )
479 if (hwrf_samfdeep)
then
502c define top layer for search of the downdraft originating layer
503c and the maximum thetae for updraft
516 if (prsl(i,k)*tx1(i) > 0.04) kmax(i) = k + 1
517 if (prsl(i,k)*tx1(i) > 0.45) kbmax(i) = k + 1
518 if (prsl(i,k)*tx1(i) > 0.70) kbm(i) = k + 1
519 if (prsl(i,k)*tx1(i) > 0.94) kd94(i) = k + 1
523 kmax(i) = min(km,kmax(i))
524 kbmax(i) = min(kbmax(i),kmax(i))
525 kbm(i) = min(kbm(i),kmax(i))
526 kd94(i) = min(kd94(i),kmax(i))
529c hydrostatic height assume zero terr and initially assume
530c updraft entrainment rate as an inverse
function of height
535 zo(i,k) = phil(i,k) / grav
541 zi(i,k) = 0.5*(zo(i,k)+zo(i,k+1))
544 if (hwrf_samfdeep)
then
547 xlamue(i,k) = clam / zi(i,k)
553c convert surface pressure to mb from cb
558 if (k <= kmax(i))
then
559 pfld(i,k) = prsl(i,k) * 10.0
608 if(.not.hwrf_samfdeep)
then
613 if (k <= kmax(i))
then
614 ctr(i,k,kk) = qtr(i,k,n)
615 ctro(i,k,kk) = qtr(i,k,n)
628 if (k <= kmax(i))
then
629 qeso(i,k) = 0.01 * fpvs(to(i,k))
630 qeso(i,k) = eps * qeso(i,k) / (pfld(i,k) + epsm1*qeso(i,k))
632 qeso(i,k) = max(qeso(i,k), val1)
634 qo(i,k) = max(qo(i,k), val2 )
641c compute moist static
energy
646 if (k <= kmax(i))
then
648 tem = phil(i,k) + cp * to(i,k)
649 heo(i,k) = tem + hvap * qo(i,k)
650 heso(i,k) = tem + hvap * qeso(i,k)
651c heo(i,k) = min(heo(i,k),heso(i,k))
656c determine level with largest moist static
energy
657c this is the level
where updraft starts
667 if (flg(i) .and. zo(i,k) <= sfcpbl(i))
then
675 kb1(i) = min(kb1(i),kbm(i))
680 hmax(i) = heo(i,kb1(i))
685 if (k > kb1(i) .and. k <= kbm(i))
then
686 if(heo(i,k) > hmax(i))
then
697 if (k <= kmax(i)-1)
then
698 dz = .5 * (zo(i,k+1) - zo(i,k))
699 dp = .5 * (pfld(i,k+1) - pfld(i,k))
700 es = 0.01 * fpvs(to(i,k+1))
701 pprime = pfld(i,k+1) + epsm1 * es
702 qs = eps * es / pprime
703 dqsdp = - qs / pprime
704 desdt = es * (fact1 / to(i,k+1) + fact2 / (to(i,k+1)**2))
705 dqsdt = qs * pfld(i,k+1) * desdt / (es * pprime)
706 gamma = el2orc * qeso(i,k+1) / (to(i,k+1)**2)
707 dt = (grav*dz + hvap*dqsdp*dp) / (cp * (1. + gamma))
708 dq = dqsdt * dt + dqsdp * dp
709 to(i,k) = to(i,k+1) + dt
710 qo(i,k) = qo(i,k+1) + dq
711 po(i,k) = .5 * (pfld(i,k) + pfld(i,k+1))
719 if (k <= kmax(i)-1)
then
720 qeso(i,k) = 0.01 * fpvs(to(i,k))
721 qeso(i,k) = eps * qeso(i,k) / (po(i,k) + epsm1*qeso(i,k))
723 qeso(i,k) = max(qeso(i,k), val1)
725 qo(i,k) = max(qo(i,k), val2 )
727 rh(i,k) = min(qo(i,k)/qeso(i,k), 1.)
728 frh(i,k) = 1. - rh(i,k)
729 heo(i,k) = .5 * grav * (zo(i,k) + zo(i,k+1)) +
730 & cp * to(i,k) + hvap * qo(i,k)
731 heso(i,k) = .5 * grav * (zo(i,k) + zo(i,k+1)) +
732 & cp * to(i,k) + hvap * qeso(i,k)
733 uo(i,k) = .5 * (uo(i,k) + uo(i,k+1))
734 vo(i,k) = .5 * (vo(i,k) + vo(i,k+1))
738 if (.not.hwrf_samfdeep)
then
742 if (k <= kmax(i)-1)
then
743 ctro(i,k,n) = .5 * (ctro(i,k,n) + ctro(i,k+1,n))
750c look for the level of free convection as cloud base
759 if (flg(i) .and. k <= kbmax(i))
then
760 if(k > kb(i) .and. heo(i,kb(i)) > heso(i,k))
then
770 if(kbcon(i) == kmax(i)) cnvflg(i) = .false.
775 totflg = totflg .and. (.not. cnvflg(i))
783 pdot(i) = 0.01 * dot(i,kbcon(i))
787c turn off convection
if pressure depth between parcel source level
788c and cloud base is larger than a critical
value, cinpcr
792 if(islimsk(i) == 1)
then
803 if(pdot(i) <= w4)
then
804 tem = (pdot(i) - w4) / (w3 - w4)
805 elseif(pdot(i) >= -w4)
then
806 tem = - (pdot(i) + w4) / (w4 - w3)
815 ptem1= .5*(cinpcrmx-cinpcrmn)
816 cinpcr = cinpcrmx - ptem * ptem1
817 tem1 = pfld(i,kb(i)) - pfld(i,kbcon(i))
818 if(tem1 > cinpcr .and.
819 & zi(i,kbcon(i)) > hpbl(i))
then
825 if(do_ca .and. ca_trigger)
then
827 if(ca_deep(i) > nthresh) cnvflg(i) = .true.
828 if(kbcon(i) == kmax(i)) cnvflg(i) = .false.
834 totflg = totflg .and. (.not. cnvflg(i))
849 if (cnvflg(i) .and. k <= kbm(i))
then
850 if(heo(i,k) > hmax(i))
then
860 if(flg(i)) kbcon(i) = kmax(i)
864 if (flg(i) .and. k <= kbmax(i))
then
865 if(k > kb(i) .and. heo(i,kb(i)) > heso(i,k))
then
874 if(cnvflg(i) .and. kbcon(i) == kmax(i))
then
879 if(do_ca .and. ca_trigger)
then
881 if(ca_deep(i) > nthresh) cnvflg(i) = .true.
882 if(kbcon(i) == kmax(i)) cnvflg(i) = .false.
888 totflg = totflg .and. (.not. cnvflg(i))
895 pdot(i) = 0.01 * dot(i,kbcon(i))
908 if(k >= kb(i) .and. k < kbcon(i))
then
909 dz = zo(i,k+1) - zo(i,k)
910 rhbar(i) = rhbar(i) + rh(i,k) * dz
911 sumx(i) = sumx(i) + dz
918 rhbar(i) = rhbar(i) / sumx(i)
919 if(rhbar(i) < rhcrt)
then
925 if(do_ca .and. ca_trigger)
then
927 if(ca_deep(i) > nthresh) cnvflg(i) = .true.
928 if(kbcon(i) == kmax(i)) cnvflg(i) = .false.
934 totflg = totflg .and. (.not. cnvflg(i))
942 if(.not. hwrf_samfdeep .and. ntk > 0)
then
953 if(k >= kb(i) .and. k < kbcon(i))
then
954 dz = zo(i,k+1) - zo(i,k)
955 tem = 0.5 * (qtr(i,k,ntk)+qtr(i,k+1,ntk))
956 tkemean(i) = tkemean(i) + tem * dz
957 sumx(i) = sumx(i) + dz
965 tkemean(i) = tkemean(i) / sumx(i)
966 if(tkemean(i) > tkemx)
then
967 clamt(i) = clam + clamd
968 else if(tkemean(i) < tkemn)
then
969 clamt(i) = clam - clamd
971 tem = tkemx - tkemean(i)
972 tem1 = 1. - 2. * tem / dtke
973 clamt(i) = clam + clamd * tem1
978 if(do_ca .and. ca_entr)
then
981 if(ca_deep(i) > nthresh)
then
982 clamt(i) = clam - clamca
996 if(tkemean(i) > tkcrt)
then
997 tem = 1. + tkemean(i)/tkcrt
998 tem1 = min(tem, cmxfac)
999 clamt(i) = tem1 * clam
1000 xlamdet(i) = tem1 * xlamdet(i)
1001 xlamddt(i) = tem1 * xlamddt(i)
1002 cxlamet(i) = tem1 * cxlamet(i)
1003 cxlamdt(i) = tem1 * cxlamdt(i)
1010 if(do_ca .and. ca_entr)
then
1013 if(ca_deep(i) > nthresh)
then
1014 clamt(i) = clam - clamca
1045 dz =zo(i,k+1) - zo(i,k)
1046 xlamue(i,k) = clamt(i) / (zi(i,k) + dz)
1047 xlamue(i,k) = max(xlamue(i,k), crtlame)
1052c assume that updraft entrainment rate above cloud base is
1053c same as that at cloud base
1060 if (hwrf_samfdeep)
then
1063 xlamx(i) = xlamue(i,kbcon(i))
1069 & (k > kbcon(i) .and. k < kmax(i)))
then
1070 xlamue(i,k) = xlamx(i)
1076c specify detrainment rate for the updrafts
1081 if (hwrf_samfdeep)
then
1084 if(cnvflg(i) .and. k < kmax(i))
then
1085 xlamud(i,k) = xlamx(i)
1092 if(cnvflg(i) .and. k < kmax(i))
then
1094 xlamud(i,k) = 0.001 * clamt(i)
1100c entrainment functions decreasing with height(fent),
1101c mimicking a cloud ensemble
1102c(bechtold et al., 2008)
1107 & (k > kbcon(i) .and. k < kmax(i)))
then
1108 tem = qeso(i,k)/qeso(i,kbcon(i))
1115c final entrainment and detrainment rates as the sum of turbulent part and
1116c organized one depending on the environmental relative humidity
1117c(bechtold et al., 2008; derbyshire et al., 2011)
1119 if (hwrf_samfdeep)
then
1123 & (k > kbcon(i) .and. k < kmax(i)))
then
1124 tem = cxlamet(i) * frh(i,k) * fent2(i,k)
1125 xlamue(i,k) = xlamue(i,k)*fent1(i,k) + tem
1133 & (k > kbcon(i) .and. k < kmax(i)))
then
1134 tem = cxlamet(i) * frh(i,k) * fent2(i,k)
1135 xlamue(i,k) = xlamue(i,k)*fent1(i,k) + tem
1136 tem1 = cxlamdt(i) * frh(i,k)
1137 xlamud(i,k) = xlamud(i,k) + tem1
1145c determine updraft mass flux for the subcloud layers
1155 if(k < kbcon(i) .and. k >= kb(i))
then
1156 dz = zi(i,k+1) - zi(i,k)
1157 tem = 0.5*(xlamud(i,k)+xlamud(i,k+1))
1158 ptem = 0.5*(xlamue(i,k)+xlamue(i,k+1))-tem
1159 eta(i,k) = eta(i,k+1) / (1. + ptem * dz)
1165c compute mass flux above cloud base
1173 if(k > kbcon(i) .and. k < kmax(i))
then
1174 dz = zi(i,k) - zi(i,k-1)
1175 tem = 0.5*(xlamud(i,k)+xlamud(i,k-1))
1176 ptem = 0.5*(xlamue(i,k)+xlamue(i,k-1))-tem
1177 eta(i,k) = eta(i,k-1) * (1 + ptem * dz)
1178 if(eta(i,k) <= 0.)
then
1188c compute updraft cloud properties
1194 hcko(i,indx) = heo(i,indx)
1195 ucko(i,indx) = uo(i,indx)
1196 vcko(i,indx) = vo(i,indx)
1200 if (.not.hwrf_samfdeep)
then
1206 ecko(i,indx,n) = ctro(i,indx,n)
1207 ercko(i,indx,n) = ctro(i,indx,n)
1213c cloud property is modified by the entrainment process
1221 if(k > kb(i) .and. k < kmax(i))
then
1222 dz = zi(i,k) - zi(i,k-1)
1223 tem = 0.5 * (xlamue(i,k)+xlamue(i,k-1)) * dz
1224 tem1 = 0.25 * (xlamud(i,k)+xlamud(i,k-1)) * dz
1225 factor = 1. + tem - tem1
1226 hcko(i,k) = ((1.-tem1)*hcko(i,k-1)+tem*0.5*
1227 & (heo(i,k)+heo(i,k-1)))/factor
1228 dbyo(i,k) = hcko(i,k) - heso(i,k)
1230 tem = 0.5 * cm * tem
1234 ucko(i,k) = ((1.-tem)*ucko(i,k-1)+ptem*uo(i,k)
1235 & +ptem1*uo(i,k-1))/factor
1236 vcko(i,k) = ((1.-tem)*vcko(i,k-1)+ptem*vo(i,k)
1237 & +ptem1*vo(i,k-1))/factor
1242 if (.not.hwrf_samfdeep)
then
1243 if (do_aerosols)
then
1252 if(k > kb(i) .and. k < kmax(i))
then
1253 dz = zi(i,k) - zi(i,k-1)
1254 tem = 0.25 * (xlamue(i,k)+xlamue(i,k-1)) * dz
1257 ecko(i,k,n) = ((1.-tem)*ecko(i,k-1,n)+tem*
1258 & (ctro(i,k,n)+ctro(i,k-1,n)))/factor
1259 ercko(i,k,n) = ecko(i,k,n)
1265 if (do_aerosols)
then
1271 if(k > kb(i) .and. k < kmax(i))
then
1272 dz = zi(i,k) - zi(i,k-1)
1273 tem = 0.25 * (xlamue(i,k)+xlamue(i,k-1)) * dz
1276 ecko(i,k,kk) = ((1. - tem) * ecko(i,k-1,kk) + tem *
1277 & (ctro(i,k,kk) + ctro(i,k-1,kk))) / factor
1278 ercko(i,k,kk) = ecko(i,k,kk)
1279 chem_c(i,k,n) = fscav(n) * ecko(i,k,kk)
1280 tem = chem_c(i,k,n) / (1. + c0t(i,k) * dz)
1281 chem_pw(i,k,n) = c0t(i,k) * dz * tem * eta(i,k-1)
1282 ecko(i,k,kk) = tem + ecko(i,k,kk) - chem_c(i,k,n)
1291c taking account into convection inhibition due to existence of
1292c dry layers below cloud base
1301 if (flg(i) .and. k < kmax(i))
then
1302 if(k >= kbcon(i) .and. dbyo(i,k) > 0.)
then
1311 if(kbcon1(i) == kmax(i)) cnvflg(i) = .false.
1316 tem = pfld(i,kbcon(i)) - pfld(i,kbcon1(i))
1324 if(do_ca .and. ca_trigger)
then
1326 if(ca_deep(i) > nthresh) cnvflg(i) = .true.
1327 if(kbcon(i) == kmax(i)) cnvflg(i) = .false.
1333 totflg = totflg .and. (.not. cnvflg(i))
1338c calculate convective inhibition
1344 if(k > kb(i) .and. k < kbcon1(i))
then
1345 dz1 = zo(i,k+1) - zo(i,k)
1346 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
1347 rfact = 1. + fv * cp * gamma
1351 & dz1 * (grav / (cp * to(i,k)))
1352 & * dbyo(i,k) / (1. + gamma)
1358 & max(val,(qeso(i,k) - qo(i,k)))
1364 if(hwrf_samfdeep)
then
1368 if(cina(i) < cinacr) cnvflg(i) = .false.
1374 if(islimsk(i) == 1)
then
1385 if(pdot(i) <= w4)
then
1386 tem = (pdot(i) - w4) / (w3 - w4)
1387 elseif(pdot(i) >= -w4)
then
1388 tem = - (pdot(i) + w4) / (w4 - w3)
1398 tem1= .5*(cinacrmx-cinacrmn)
1399 cinacr = cinacrmx - tem * tem1
1400 if(cina(i) < cinacr) cnvflg(i) = .false.
1405 if(do_ca .and. ca_trigger)
then
1407 if(ca_deep(i) > nthresh) cnvflg(i) = .true.
1408 if(kbcon(i) == kmax(i)) cnvflg(i) = .false.
1414 totflg = totflg .and. (.not. cnvflg(i))
1419c determine first guess cloud top as the level of zero buoyancy
1428 if (flg(i) .and. k < kmax(i))
then
1429 if(k > kbcon1(i) .and. dbyo(i,k) < 0.)
then
1439 if(ktcon(i) == 1 .and. ktconn(i) > 1)
then
1440 ktcon(i) = ktconn(i)
1442 tem = pfld(i,kbcon(i))-pfld(i,ktcon(i))
1443 if(tem < cthk) cnvflg(i) = .false.
1448 if(do_ca .and. ca_trigger)
then
1450 if(ca_deep(i) > nthresh) cnvflg(i) = .true.
1451 if(kbcon(i) == kmax(i)) cnvflg(i) = .false.
1457 totflg = totflg .and. (.not. cnvflg(i))
1463c search for downdraft originating level above theta-e minimum
1468 hmin(i) = heo(i,kbcon1(i))
1475 if (cnvflg(i) .and. k <= kbmax(i))
then
1476 if(k > kbcon1(i) .and. heo(i,k) < hmin(i))
then
1484c make sure that jmin is within the cloud
1488 jmin(i) = min(lmin(i),ktcon(i)-1)
1489 jmin(i) = max(jmin(i),kbcon1(i)+1)
1490 if(jmin(i) >= ktcon(i)) cnvflg(i) = .false.
1494c specify upper limit of mass flux at cloud base
1500 dp = 1000. * del(i,k)
1501 xmbmax(i) = dp / (grav * dt2)
1505c compute cloud moisture property and precipitation
1511 qcko(i,kb(i)) = qo(i,kb(i))
1512 qrcko(i,kb(i)) = qo(i,kb(i))
1520 if(k > kb(i) .and. k < ktcon(i))
then
1521 dz = zi(i,k) - zi(i,k-1)
1522 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
1524 & + gamma * dbyo(i,k) / (hvap * (1. + gamma))
1526 tem = 0.25 * (xlamue(i,k)+xlamue(i,k-1)) * dz
1529 qcko(i,k) = ((1.-tem)*qcko(i,k-1)+tem*
1530 & (qo(i,k)+qo(i,k-1)))/factor
1531 qrcko(i,k) = qcko(i,k)
1533 dq = eta(i,k) * (qcko(i,k) - qrch)
1537c check
if there is excess moisture to release latent heat
1539 if(k >= kbcon(i) .and. dq > 0.)
then
1540 etah = .5 * (eta(i,k) + eta(i,k-1))
1541 dp = 1000. * del(i,k)
1542 if(ncloud > 0 .and. k > jmin(i))
then
1543 ptem = c0t(i,k) + c1
1544 qlk = dq / (eta(i,k) + etah * ptem * dz)
1545 dellal(i,k) = etah * c1 * dz * qlk * grav / dp
1547 qlk = dq / (eta(i,k) + etah * c0t(i,k) * dz)
1551 buo(i,k) = buo(i,k) - grav * qlk
1552 qcko(i,k) = qlk + qrch
1553 pwo(i,k) = etah * c0t(i,k) * dz * qlk
1554 pwavo(i) = pwavo(i) + pwo(i,k)
1556 cnvwt(i,k) = etah * qlk * grav / dp
1557 zdqca(i,k)=dq/eta(i,k)
1562 if(k >= kbcon(i))
then
1563 rfact = 1. + fv * cp * gamma
1565 buo(i,k) = buo(i,k) + (grav / (cp * to(i,k)))
1566 & * dbyo(i,k) / (1. + gamma)
1569 buo(i,k) = buo(i,k) + grav * fv *
1570 & max(val,(qeso(i,k) - qo(i,k)))
1571 drag(i,k) = max(xlamue(i,k),xlamud(i,k))
1573 tem = ((uo(i,k)-uo(i,k-1))/dz)**2
1574 tem = tem+((vo(i,k)-vo(i,k-1))/dz)**2
1575 wush(i,k) = csmf * sqrt(tem)
1591c calculate cloud work function
1631 if(k >= kbcon(i) .and. k < ktcon(i))
then
1632 dz1 = zo(i,k+1) - zo(i,k)
1634 aa1(i) = aa1(i) + buo(i,k) * dz1
1635 dbyo1(i,k) = hcko(i,k) - heso(i,k)
1643 if(cnvflg(i) .and. aa1(i) <= 0.) cnvflg(i) = .false.
1648 totflg = totflg .and. (.not. cnvflg(i))
1653c estimate the onvective overshooting as the level
1654c
where the [aafac * cloud work function] becomes zero,
1655c which is the final cloud top
1660 aa2(i) = aafac * aa1(i)
1666 ktcon1(i) = ktcon(i)
1671 if(k >= ktcon(i) .and. k < kmax(i))
then
1672 dz1 = zo(i,k+1) - zo(i,k)
1673 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
1674 rfact = 1. + fv * cp * gamma
1678 & dz1 * (grav / (cp * to(i,k)))
1679 & * dbyo(i,k) / (1. + gamma)
1687 tem = 0.5 * (zi(i,ktcon(i))-zi(i,kbcon(i)))
1688 tem1 = zi(i,k)-zi(i,ktcon(i))
1689 if(aa2(i) < 0. .or. tem1 >= tem)
then
1698c compute cloud moisture property, detraining cloud
water
1699c and precipitation in overshooting layers
1705 if(k >= ktcon(i) .and. k < ktcon1(i))
then
1706 dz = zi(i,k) - zi(i,k-1)
1707 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
1709 & + gamma * dbyo(i,k) / (hvap * (1. + gamma))
1711 tem = 0.25 * (xlamue(i,k)+xlamue(i,k-1)) * dz
1714 qcko(i,k) = ((1.-tem)*qcko(i,k-1)+tem*
1715 & (qo(i,k)+qo(i,k-1)))/factor
1716 qrcko(i,k) = qcko(i,k)
1718 dq = eta(i,k) * (qcko(i,k) - qrch)
1720c check
if there is excess moisture to release latent heat
1723 etah = .5 * (eta(i,k) + eta(i,k-1))
1724 dp = 1000. * del(i,k)
1726 ptem = c0t(i,k) + c1
1727 qlk = dq / (eta(i,k) + etah * ptem * dz)
1728 dellal(i,k) = etah * c1 * dz * qlk * grav / dp
1730 qlk = dq / (eta(i,k) + etah * c0t(i,k) * dz)
1732 qcko(i,k) = qlk + qrch
1733 pwo(i,k) = etah * c0t(i,k) * dz * qlk
1734 pwavo(i) = pwavo(i) + pwo(i,k)
1736 cnvwt(i,k) = etah * qlk * grav / dp
1737 zdqca(i,k)=dq/eta(i,k)
1747 if (hwrf_samfdeep)
then
1751 tem = po(i,k) / (rd * to(i,k))
1752 wucb = -0.01 * dot(i,k) / (tem * grav)
1754 wu2(i,k) = wucb * wucb
1765 if(k > kbcon1(i) .and. k < ktcon(i))
then
1766 dz = zi(i,k) - zi(i,k-1)
1767 tem = 0.25 * bb1 * (drag(i,k-1)+drag(i,k)) * dz
1768 tem1 = 0.5 * bb2 * (buo(i,k-1)+buo(i,k))
1769 tem2 = wush(i,k) * sqrt(wu2(i,k-1))
1770 tem2 = (tem1 - tem2) * dz
1771 ptem = (1. - tem) * wu2(i,k-1)
1773 wu2(i,k) = (ptem + tem2) / ptem1
1774 wu2(i,k) = max(wu2(i,k), 0.)
1784 if(k > kbcon1(i) .and. k < ktcon(i))
then
1785 rho = po(i,k)*100. / (rd * to(i,k))
1786 omega_u(i,k)=-1.0*sqrt(wu2(i,k))*rho*grav
1787 omega_u(i,k)=max(omega_u(i,k),-80.)
1804 if(k > kbcon1(i) .and. k < ktcon(i))
then
1805 dz = zi(i,k) - zi(i,k-1)
1806 tem = 0.5 * (sqrt(wu2(i,k)) + sqrt(wu2(i,k-1)))
1807 wc(i) = wc(i) + tem * dz
1808 sumx(i) = sumx(i) + dz
1815 if(sumx(i) == 0.)
then
1818 wc(i) = wc(i) / sumx(i)
1821 if (wc(i) < val) cnvflg(i)=.false.
1835 if(k > kbcon1(i) .and. k < ktcon(i))
then
1836 dp = 1000. * del(i,k)
1837 tem = 0.5 * (omega_u(i,k) + omega_u(i,k-1))
1838 omegac(i) = omegac(i) + tem * dp
1839 sumx(i) = sumx(i) + dp
1846 if(sumx(i) == 0.)
then
1849 omegac(i) = omegac(i) / sumx(i)
1852 if (omegac(i) > val) cnvflg(i)=.false.
1860 if(k >= kbcon1(i) .and. k < ktcon(i))
then
1861 if(omega_u(i,k) .ne. 0.)
then
1862 zeta(i,k)=eta(i,k)*(omegac(i)/omega_u(i,k))
1866 zeta(i,k)=max(0.,zeta(i,k))
1867 zeta(i,k)=min(1.,zeta(i,k))
1876c exchange ktcon with ktcon1
1882 ktcon(i) = ktcon1(i)
1887c this section is ready for cloud
water
1892c compute liquid and vapor separation at cloud top
1897 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
1899 & + gamma * dbyo(i,k) / (hvap * (1. + gamma))
1900 dq = qcko(i,k) - qrch
1902c check
if there is excess moisture to release latent heat
1914ccccc
if(lat.==.latd.and.lon.==.lond.and.cnvflg(i))
then
1915ccccc print *,
' aa1(i) before dwndrft =', aa1(i)
1918c------- downdraft calculations
1920c--- compute precipitation efficiency in terms of windshear
1936 if(k > kb(i) .and. k <= ktcon(i))
then
1937 shear = sqrt((uo(i,k)-uo(i,k-1)) ** 2
1938 & + (vo(i,k)-vo(i,k-1)) ** 2)
1939 vshear(i) = vshear(i) + shear
1946 vshear(i) = 1.e3 * vshear(i) / (zi(i,ktcon(i))-zi(i,kb(i)))
1947 e1=1.591-.639*vshear(i)
1948 & +.0953*(vshear(i)**2)-.00496*(vshear(i)**3)
1951 edt(i) = min(edt(i),val)
1953 edt(i) = max(edt(i),val)
1959c determine detrainment rate between 1 and kbcon
1974 if(k >= 1 .and. k < kd94(i))
then
1975 dz = zi(i,k+1) - zi(i,k)
1976 sumx(i) = sumx(i) + dz
1983 if(islimsk(i) == 1) beta = betal
1985 dz = (sumx(i)+zi(i,1))/float(kd94(i))
1986 tem = 1./float(kd94(i))
1987 xlamd(i) = (1.-beta**tem)/dz
1991c determine downdraft mass flux
1996 if (cnvflg(i) .and. k <= kmax(i)-1)
then
1997 if(k < jmin(i) .and. k >= kd94(i))
then
1998 dz = zi(i,k+1) - zi(i,k)
1999 ptem = xlamddt(i) - xlamdet(i)
2000 etad(i,k) = etad(i,k+1) * (1. - ptem * dz)
2001 else if(k < kd94(i))
then
2002 dz = zi(i,k+1) - zi(i,k)
2003 ptem = xlamd(i) + xlamddt(i) - xlamdet(i)
2004 etad(i,k) = etad(i,k+1) * (1. - ptem * dz)
2010c--- downdraft moisture properties
2016 hcdo(i,jmn) = heo(i,jmn)
2017 qcdo(i,jmn) = qo(i,jmn)
2018 qrcdo(i,jmn)= qo(i,jmn)
2019 ucdo(i,jmn) = uo(i,jmn)
2020 vcdo(i,jmn) = vo(i,jmn)
2025 if (.not.hwrf_samfdeep)
then
2030 ecdo(i,jmn,n) = ctro(i,jmn,n)
2039 if (cnvflg(i) .and. k < jmin(i))
then
2040 dz = zi(i,k+1) - zi(i,k)
2041 if(k >= kd94(i))
then
2042 tem = xlamdet(i) * dz
2043 tem1 = 0.5 * xlamddt(i) * dz
2045 tem = xlamdet(i) * dz
2046 tem1 = 0.5 * (xlamd(i)+xlamddt(i)) * dz
2048 factor = 1. + tem - tem1
2049 hcdo(i,k) = ((1.-tem1)*hcdo(i,k+1)+tem*0.5*
2050 & (heo(i,k)+heo(i,k+1)))/factor
2051 dbyo(i,k) = hcdo(i,k) - heso(i,k)
2053 tem = 0.5 * cm * tem
2057 ucdo(i,k) = ((1.-tem)*ucdo(i,k+1)+ptem*uo(i,k+1)
2058 & +ptem1*uo(i,k))/factor
2059 vcdo(i,k) = ((1.-tem)*vcdo(i,k+1)+ptem*vo(i,k+1)
2060 & +ptem1*vo(i,k))/factor
2064 if(.not.hwrf_samfdeep)
then
2068 if (cnvflg(i) .and. k < jmin(i))
then
2069 dz = zi(i,k+1) - zi(i,k)
2070 tem = 0.5 * xlamdet(i) * dz
2073 ecdo(i,k,n) = ((1.-tem)*ecdo(i,k+1,n)+tem*
2074 & (ctro(i,k,n)+ctro(i,k+1,n)))/factor
2084 if (cnvflg(i) .and. k < jmin(i))
then
2085 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
2086 qrcdo(i,k) = qeso(i,k)+
2087 & (1./hvap)*(gamma/(1.+gamma))*dbyo(i,k)
2090 dz = zi(i,k+1) - zi(i,k)
2091 tem = 0.5 * xlamdet(i) * dz
2094 qcdo(i,k) = ((1.-tem)*qrcdo(i,k+1)+tem*
2095 & (qo(i,k)+qo(i,k+1)))/factor
2102 pwdo(i,k) = etad(i,k) * (qcdo(i,k) - qrcdo(i,k))
2103 pwevo(i) = pwevo(i) + pwdo(i,k)
2108c--- final downdraft strength dependent on precip
2109c--- efficiency(edt), normalized condensate(pwav), and
2115 if(islimsk(i) == 0) edtmax = edtmaxs
2117 if(pwevo(i) < 0.)
then
2118 edto(i) = -edto(i) * pwavo(i) / pwevo(i)
2119 edto(i) = min(edto(i),edtmax)
2126c--- downdraft cloudwork functions
2131 if (cnvflg(i) .and. k < jmin(i))
then
2132 gamma = el2orc * qeso(i,k) / to(i,k)**2
2137 dz = zo(i,k) - zo(i,k+1)
2139 aa1(i) = aa1(i)+edto(i)*dz
2140 & *(grav/(cp*dt))*((dhh-dh)/(1.+dg))
2141 & *(1.+fv*cp*dg*dt/hvap)
2144 aa1(i) = aa1(i)+edto(i)*dz
2145 & *grav*fv*max(val,(qeso(i,k)-qo(i,k)))
2151 if(cnvflg(i) .and. aa1(i) <= 0.)
then
2158 totflg = totflg .and. (.not. cnvflg(i))
2163c--- what would the change be, that a cloud with unit mass
2164c--- will
do to the environment?
2169 if(cnvflg(i) .and. k <= kmax(i))
then
2177 if (.not.hwrf_samfdeep)
then
2181 if(cnvflg(i) .and. k <= kmax(i))
then
2190 dp = 1000. * del(i,1)
2191 tem = edto(i) * etad(i,1) * grav / dp
2192 dellah(i,1) = tem * (hcdo(i,1) - heo(i,1))
2193 dellaq(i,1) = tem * qrcdo(i,1)
2194 dellau(i,1) = tem * (ucdo(i,1) - uo(i,1))
2195 dellav(i,1) = tem * (vcdo(i,1) - vo(i,1))
2198 if (.not.hwrf_samfdeep)
then
2202 dp = 1000. * del(i,1)
2203 dellae(i,1,n) = edto(i) * etad(i,1) * ecdo(i,1,n)
2210c--- changed due to subsidence and entrainment
2214 if (cnvflg(i) .and. k < ktcon(i))
then
2216 if(k <= kb(i)) aup = 0.
2218 if(k > jmin(i)) adw = 0.
2219 dp = 1000. * del(i,k)
2220 dz = zi(i,k) - zi(i,k-1)
2223 dv2h = .5 * (heo(i,k) + heo(i,k-1))
2226 tem = 0.5 * (xlamue(i,k)+xlamue(i,k-1))
2227 tem1 = 0.5 * (xlamud(i,k)+xlamud(i,k-1))
2229 if(k <= kd94(i))
then
2231 ptem1 = xlamd(i)+xlamddt(i)
2239 dellah(i,k) = dellah(i,k) +
2240 & ((aup*eta(i,k)-adw*edto(i)*etad(i,k))*dv1h
2241 & - (aup*eta(i,k-1)-adw*edto(i)*etad(i,k-1))*dv3h
2242 & - (aup*tem*eta(i,k-1)+adw*edto(i)*ptem*etad(i,k))*dv2h*dz
2243 & + aup*tem1*eta(i,k-1)*.5*(hcko(i,k)+hcko(i,k-1))*dz
2244 & + adw*edto(i)*ptem1*etad(i,k)*.5*(hcdo(i,k)+hcdo(i,k-1))*dz
2247 tem1 = -eta(i,k) * qrcko(i,k)
2248 tem2 = -eta(i,k-1) * qcko(i,k-1)
2249 ptem1 = -etad(i,k) * qrcdo(i,k)
2250 ptem2 = -etad(i,k-1) * qcdo(i,k-1)
2251 dellaq(i,k) = dellaq(i,k) +
2252 & (aup*(tem1-tem2)-adw*edto(i)*(ptem1-ptem2))*factor
2254 tem1=eta(i,k)*(uo(i,k)-ucko(i,k))
2255 tem2=eta(i,k-1)*(uo(i,k-1)-ucko(i,k-1))
2256 ptem1=etad(i,k)*(uo(i,k)-ucdo(i,k))
2257 ptem2=etad(i,k-1)*(uo(i,k-1)-ucdo(i,k-1))
2258 dellau(i,k) = dellau(i,k) +
2259 & (aup*(tem1-tem2)-adw*edto(i)*(ptem1-ptem2))*factor
2261 tem1=eta(i,k)*(vo(i,k)-vcko(i,k))
2262 tem2=eta(i,k-1)*(vo(i,k-1)-vcko(i,k-1))
2263 ptem1=etad(i,k)*(vo(i,k)-vcdo(i,k))
2264 ptem2=etad(i,k-1)*(vo(i,k-1)-vcdo(i,k-1))
2265 dellav(i,k) = dellav(i,k) +
2266 & (aup*(tem1-tem2)-adw*edto(i)*(ptem1-ptem2))*factor
2271 if (.not.hwrf_samfdeep)
then
2275 if (cnvflg(i) .and. k < ktcon(i))
then
2277 if(k <= kb(i)) aup = 0.
2279 if(k > jmin(i)) adw = 0.
2280 dp = 1000. * del(i,k)
2282 tem1 = -eta(i,k) * ercko(i,k,n)
2283 tem2 = -eta(i,k-1) * ecko(i,k-1,n)
2284 ptem1 = -etad(i,k) * ecdo(i,k,n)
2285 ptem2 = -etad(i,k-1) * ecdo(i,k-1,n)
2286 dellae(i,k,n) = dellae(i,k,n) +
2287 & (aup*(tem1-tem2)-adw*edto(i)*(ptem1-ptem2))*grav/dp
2300 dp = 1000. * del(i,indx)
2301 tem = eta(i,indx-1) * grav / dp
2302 dellah(i,indx) = tem * (hcko(i,indx-1) - heo(i,indx-1))
2303 dellaq(i,indx) = tem * qcko(i,indx-1)
2304 dellau(i,indx) = tem * (ucko(i,indx-1) - uo(i,indx-1))
2305 dellav(i,indx) = tem * (vcko(i,indx-1) - vo(i,indx-1))
2309 dellal(i,indx) = tem * qlko_ktcon(i)
2312 if (.not.hwrf_samfdeep)
then
2317 dp = 1000. * del(i,indx)
2318 dellae(i,indx,n) = eta(i,indx-1) *
2319 & ecko(i,indx-1,n) * grav / dp
2332 if(cnvflg(i) .and. k <= ktcon(i))
then
2333 q_diff(i,k) = q1(i,k) - q1(i,k+1)
2339 if(q1(i,1) >= 0.)
then
2340 q_diff(i,0) = max(0.,2.*q1(i,1)-q1(i,2))-
2343 q_diff(i,0) = min(0.,2.*q1(i,1)-q1(i,2))-
2352 if(cnvflg(i) .and. k < ktcon(i))
then
2354 if(k >= kb(i)) tem = eta(i,k)
2355 if(k <= jmin(i))
then
2356 tem = tem - edto(i) * etad(i,k)
2360 if(abs(q_diff(i,k)) > 1.e-22)
2361 & rrkp = q_diff(i,k+1) / q_diff(i,k)
2362 phkp = (rrkp+abs(rrkp)) / (1.+abs(rrkp))
2364 & phkp*(qo(i,k)-q1(i,k+1))
2365 flxtvd(i,k) = tem * tem1
2366 elseif(tem < 0.)
then
2368 if(abs(q_diff(i,k)) > 1.e-22)
2369 & rrkp = q_diff(i,k-1) / q_diff(i,k)
2370 phkp = (rrkp+abs(rrkp)) / (1.+abs(rrkp))
2372 & phkp*(qo(i,k)-q1(i,k))
2373 flxtvd(i,k) = tem * tem1
2381 if(k == jmin(i))
then
2382 dp = 1000. * del(i,k+1)
2383 dellaq(i,k+1) = dellaq(i,k+1) -
2384 & edto(i) * etad(i,k) * tem1 * grav/dp
2387 dp = 1000. * del(i,k)
2388 dellaq(i,k) = dellaq(i,k) -
2389 & eta(i,k) * tem1 * grav/dp
2398 if(cnvflg(i) .and. k <= ktcon(i))
then
2399 dp = 1000. * del(i,k)
2400 dellaq(i,k) = dellaq(i,k) +
2401 & (flxtvd(i,k) - flxtvd(i,k-1)) * grav/dp
2408 if (.not.hwrf_samfdeep)
then
2413 if(cnvflg(i) .and. k <= ktcon(i))
then
2414 e_diff(i,k,n) = ctr(i,k,n) - ctr(i,k+1,n)
2420 if(ctr(i,1,n) >= 0.)
then
2421 e_diff(i,0,n) = max(0.,2.*ctr(i,1,n)-ctr(i,2,n))-
2424 e_diff(i,0,n) = min(0.,2.*ctr(i,1,n)-ctr(i,2,n))-
2436 if(cnvflg(i) .and. k < ktcon(i))
then
2438 if(k >= kb(i)) tem = eta(i,k)
2439 if(k <= jmin(i))
then
2440 tem = tem - edto(i) * etad(i,k)
2444 if(abs(e_diff(i,k,n)) > 1.e-22)
2445 & rrkp = e_diff(i,k+1,n) / e_diff(i,k,n)
2446 phkp = (rrkp+abs(rrkp)) / (1.+abs(rrkp))
2447 tem1 = ctr(i,k+1,n) +
2448 & phkp*(ctro(i,k,n)-ctr(i,k+1,n))
2449 flxtvd(i,k) = tem * tem1
2450 elseif(tem < 0.)
then
2452 if(abs(e_diff(i,k,n)) > 1.e-22)
2453 & rrkp = e_diff(i,k-1,n) / e_diff(i,k,n)
2454 phkp = (rrkp+abs(rrkp)) / (1.+abs(rrkp))
2456 & phkp*(ctro(i,k,n)-ctr(i,k,n))
2457 flxtvd(i,k) = tem * tem1
2465 if(k == jmin(i))
then
2466 dp = 1000. * del(i,k+1)
2467 dellae(i,k+1,n) = dellae(i,k+1,n) -
2468 & edto(i)*etad(i,k) * tem1 * grav/dp
2471 dp = 1000. * del(i,k)
2472 dellae(i,k,n) = dellae(i,k,n) -
2473 & eta(i,k) * tem1 * grav/dp
2482 if(cnvflg(i) .and. k <= ktcon(i))
then
2483 dp = 1000. * del(i,k)
2484 dellae(i,k,n) = dellae(i,k,n) +
2485 & (flxtvd(i,k) - flxtvd(i,k-1)) * grav/dp
2494c------- final changed variable per unit mass flux
2508 asqecflg(i) = cnvflg(i)
2509 if(asqecflg(i) .and. gdx(i) < dxcrtas)
then
2510 asqecflg(i) = .false.
2518 if (asqecflg(i) .and. k <= kmax(i))
then
2519 if(k > ktcon(i))
then
2523 if(k <= ktcon(i))
then
2524 qo(i,k) = dellaq(i,k) * mbdt(i) + q1(i,k)
2525 dellat = (dellah(i,k) - hvap * dellaq(i,k)) / cp
2526 to(i,k) = dellat * mbdt(i) + t1(i,k)
2528 qo(i,k) = max(qo(i,k), val )
2535c--- the above changed environment is now used to calulate the
2536c--- effect the arbitrary cloud(with unit mass flux)
2537c--- would have on the stability,
2538c--- which
then is used to calculate the real mass flux,
2539c--- necessary to keep this change in balance with the large-scale
2540c--- destabilization.
2542c--- environmental conditions again, first heights
2549 if(asqecflg(i) .and. k <= kmax(i))
then
2550 qeso(i,k) = 0.01 * fpvs(to(i,k))
2551 qeso(i,k) = eps * qeso(i,k) / (pfld(i,k)+epsm1*qeso(i,k))
2553 qeso(i,k) = max(qeso(i,k), val )
2564 if(asqecflg(i) .and. k <= kmax(i)-1)
then
2565 dz = .5 * (zo(i,k+1) - zo(i,k))
2566 dp = .5 * (pfld(i,k+1) - pfld(i,k))
2567 es = 0.01 * fpvs(to(i,k+1))
2568 pprime = pfld(i,k+1) + epsm1 * es
2569 qs = eps * es / pprime
2570 dqsdp = - qs / pprime
2571 desdt = es * (fact1 / to(i,k+1) + fact2 / (to(i,k+1)**2))
2572 dqsdt = qs * pfld(i,k+1) * desdt / (es * pprime)
2573 gamma = el2orc * qeso(i,k+1) / (to(i,k+1)**2)
2574 dt = (grav * dz + hvap * dqsdp * dp) / (cp * (1. + gamma))
2575 dq = dqsdt * dt + dqsdp * dp
2576 to(i,k) = to(i,k+1) + dt
2577 qo(i,k) = qo(i,k+1) + dq
2578 po(i,k) = .5 * (pfld(i,k) + pfld(i,k+1))
2584 if(asqecflg(i) .and. k <= kmax(i)-1)
then
2585 qeso(i,k) = 0.01 * fpvs(to(i,k))
2586 qeso(i,k) = eps * qeso(i,k) / (po(i,k) + epsm1 * qeso(i,k))
2588 qeso(i,k) = max(qeso(i,k), val1)
2590 qo(i,k) = max(qo(i,k), val2 )
2592 heo(i,k) = .5 * grav * (zo(i,k) + zo(i,k+1)) +
2593 & cp * to(i,k) + hvap * qo(i,k)
2594 heso(i,k) = .5 * grav * (zo(i,k) + zo(i,k+1)) +
2595 & cp * to(i,k) + hvap * qeso(i,k)
2600 if(asqecflg(i))
then
2602 heo(i,k) = grav * zo(i,k) + cp * to(i,k) + hvap * qo(i,k)
2603 heso(i,k) = grav * zo(i,k) + cp * to(i,k) + hvap * qeso(i,k)
2604c heo(i,k) = min(heo(i,k),heso(i,k))
2608c**************************** static control
2610c------- moisture and cloud work functions
2614 if(asqecflg(i))
then
2621 if(asqecflg(i))
then
2623 hcko(i,indx) = heo(i,indx)
2624 qcko(i,indx) = qo(i,indx)
2629 if (asqecflg(i))
then
2630 if(k > kb(i) .and. k <= ktcon(i))
then
2631 dz = zi(i,k) - zi(i,k-1)
2632 tem = 0.5 * (xlamue(i,k)+xlamue(i,k-1)) * dz
2633 tem1 = 0.25 * (xlamud(i,k)+xlamud(i,k-1)) * dz
2634 factor = 1. + tem - tem1
2635 hcko(i,k) = ((1.-tem1)*hcko(i,k-1)+tem*0.5*
2636 & (heo(i,k)+heo(i,k-1)))/factor
2643 if (asqecflg(i))
then
2644 if(k > kb(i) .and. k < ktcon(i))
then
2645 dz = zi(i,k) - zi(i,k-1)
2646 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
2647 xdby = hcko(i,k) - heso(i,k)
2649 & + gamma * xdby / (hvap * (1. + gamma))
2651 tem = 0.25 * (xlamue(i,k)+xlamue(i,k-1)) * dz
2654 qcko(i,k) = ((1.-tem)*qcko(i,k-1)+tem*
2655 & (qo(i,k)+qo(i,k-1)))/factor
2657 dq = eta(i,k) * (qcko(i,k) - xqrch)
2659 if(k >= kbcon(i) .and. dq > 0.)
then
2660 etah = .5 * (eta(i,k) + eta(i,k-1))
2661 if(ncloud > 0 .and. k > jmin(i))
then
2662 ptem = c0t(i,k) + c1
2663 qlk = dq / (eta(i,k) + etah * ptem * dz)
2665 qlk = dq / (eta(i,k) + etah * c0t(i,k) * dz)
2667 if(k < ktcon1(i))
then
2669 xaa0(i) = xaa0(i) - dz * grav * qlk
2671 qcko(i,k) = qlk + xqrch
2672 xpw = etah * c0t(i,k) * dz * qlk
2673 xpwav(i) = xpwav(i) + xpw
2676 if(k >= kbcon(i) .and. k < ktcon1(i))
then
2677 dz1 = zo(i,k+1) - zo(i,k)
2678 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
2679 rfact = 1. + fv * cp * gamma
2683 & + dz1 * (grav / (cp * to(i,k)))
2684 & * xdby / (1. + gamma)
2690 & max(val,(qeso(i,k) - qo(i,k)))
2696c------- downdraft calculations
2698c--- downdraft moisture properties
2702 if(asqecflg(i))
then
2704 hcdo(i,jmn) = heo(i,jmn)
2705 qcdo(i,jmn) = qo(i,jmn)
2706 qrcd(i,jmn) = qo(i,jmn)
2713 if (asqecflg(i) .and. k < jmin(i))
then
2714 dz = zi(i,k+1) - zi(i,k)
2715 if(k >= kd94(i))
then
2716 tem = xlamdet(i) * dz
2717 tem1 = 0.5 * xlamddt(i) * dz
2719 tem = xlamdet(i) * dz
2720 tem1 = 0.5 * (xlamd(i)+xlamddt(i)) * dz
2722 factor = 1. + tem - tem1
2723 hcdo(i,k) = ((1.-tem1)*hcdo(i,k+1)+tem*0.5*
2724 & (heo(i,k)+heo(i,k+1)))/factor
2731 if (asqecflg(i) .and. k < jmin(i))
then
2734 gamma = el2orc * dq / dt**2
2735 dh = hcdo(i,k) - heso(i,k)
2736 qrcd(i,k)=dq+(1./hvap)*(gamma/(1.+gamma))*dh
2739 dz = zi(i,k+1) - zi(i,k)
2740 tem = 0.5 * xlamdet(i) * dz
2743 qcdo(i,k) = ((1.-tem)*qrcd(i,k+1)+tem*
2744 & (qo(i,k)+qo(i,k+1)))/factor
2751 xpwd = etad(i,k) * (qcdo(i,k) - qrcd(i,k))
2752 xpwev(i) = xpwev(i) + xpwd
2759 if(islimsk(i) == 0) edtmax = edtmaxs
2760 if(asqecflg(i))
then
2761 if(xpwev(i) >= 0.)
then
2764 edtx(i) = -edtx(i) * xpwav(i) / xpwev(i)
2765 edtx(i) = min(edtx(i),edtmax)
2771c--- downdraft cloudwork functions
2776 if (asqecflg(i) .and. k < jmin(i))
then
2777 gamma = el2orc * qeso(i,k) / to(i,k)**2
2782 dz = zo(i,k) - zo(i,k+1)
2784 xaa0(i) = xaa0(i)+edtx(i)*dz
2785 & *(grav/(cp*dt))*((dhh-dh)/(1.+dg))
2786 & *(1.+fv*cp*dg*dt/hvap)
2789 xaa0(i) = xaa0(i)+edtx(i)*dz
2790 & *grav*fv*max(val,(qeso(i,k)-qo(i,k)))
2795c calculate critical cloud work function
2827c modify critical cloud workfunction by cloud base vertical velocity
2842c modify acrtfct(i) by colume mean rh
if rhbar(i) is greater than 80 percent
2844c
if(rhbar(i) >= .8)
then
2845c acrtfct(i) = acrtfct(i) * (.9 - min(rhbar(i),.9)) * 10.
2848c modify adjustment time scale by cloud base vertical velocity
2852c dtconv(i) = max(dtconv(i), dt2)
2853c dtconv(i) = 1800. * (pdot(i) - w2) / (w1 - w2)
2864 if(hwrf_samfdeep)
then
2867 tem = zi(i,ktcon1(i)) - zi(i,kbcon1(i))
2868 dtconv(i) = tem / wc(i)
2869 dtconv(i) = max(dtconv(i),dtmin)
2870 dtconv(i) = min(dtconv(i),dtmax)
2876 tem = zi(i,ktcon1(i)) - zi(i,kbcon1(i))
2877 dtconv(i) = tem / wc(i)
2878 tfac = 1. + gdx(i) / 75000.
2879 dtconv(i) = tfac * dtconv(i)
2880 dtconv(i) = max(dtconv(i),dtmin)
2881 dtconv(i) = min(dtconv(i),dtmax)
2896 if(k >= kbcon1(i) .and. k < ktcon1(i))
then
2897 dz = zi(i,k) - zi(i,k-1)
2898 tem = sqrt(u1(i,k)*u1(i,k)+v1(i,k)*v1(i,k))
2899 umean(i) = umean(i) + tem * dz
2900 sumx(i) = sumx(i) + dz
2907 umean(i) = umean(i) / sumx(i)
2908 umean(i) = max(umean(i), 1.)
2909 tauadv = gdx(i) / umean(i)
2910 advfac(i) = tauadv / dtconv(i)
2911 advfac(i) = min(advfac(i), 1.)
2919 if(first_time_step .and. .not.restart)
then
2928 qadv(i,k)=(q(i,k) - prevsq(i,k))*invdelt
2935 tmfq(i,k)=tmf(i,k,1)
2939 flag_shallow = .false.
2941 call progsigma_calc(im,km,first_time_step,restart,flag_shallow,
2942 & flag_mid,del,tmfq,qmicro,dbyo1,zdqca,omega_u,zeta,hvap,
2943 & delt,qadv,kbcon1,ktcon,cnvflg,betascu,betamcu,betadcu,
2944 & sigmind,sigminm,sigmins,sigmain,sigmaout,sigmab)
2951 if(cnvflg(i) .and. .not.asqecflg(i))
then
2953 rho = po(i,k)*100. / (rd*to(i,k))
2955 xmb(i) = advfac(i)*sigmab(i)*((-1.0*omegac(i))*gravinv)
2957 xmb(i) = advfac(i)*betaw*rho*wc(i)
2967 if(asqecflg(i))
then
2969 fld(i)=aa1(i)/dtconv(i)
2970 if(fld(i) <= 0.)
then
2971 asqecflg(i) = .false.
2980 if(asqecflg(i))
then
2981c xaa0(i) = max(xaa0(i),0.)
2982 xk(i) = (xaa0(i) - aa1(i)) / mbdt(i)
2983 if(xk(i) >= 0.)
then
2984 asqecflg(i) = .false.
2989c--- kernel, cloud base mass flux
2997 if(asqecflg(i))
then
2998 xmb(i) = -advfac(i) * fld(i) / xk(i)
3006 totflg = totflg .and. (.not. cnvflg(i))
3014 tem = min(max(xlamue(i,kbcon(i)), 7.e-5), 3.e-4)
3016 tem1 = 3.14 * tem * tem
3017 sigmagfm(i) = tem1 / garea(i)
3018 sigmagfm(i) = max(sigmagfm(i), 0.001)
3019 sigmagfm(i) = min(sigmagfm(i), 0.999)
3026 if (gdx(i) < dxcrtuf)
then
3028 scaldfunc(i)=(1.-sigmab(i))*(1.-sigmab(i))
3030 scaldfunc(i) = (1.-sigmagfm(i)) * (1.-sigmagfm(i))
3032 scaldfunc(i) = max(min(scaldfunc(i), 1.0), 0.)
3036 xmb(i) = xmb(i) * scaldfunc(i)
3037 xmb(i) = min(xmb(i),xmbmax(i))
3050c restore to,qo,uo,vo to t1,q1,u1,v1 in
case convection stops
3054 if (cnvflg(i) .and. k <= kmax(i))
then
3059 qeso(i,k) = 0.01 * fpvs(t1(i,k))
3060 qeso(i,k) = eps * qeso(i,k) / (pfld(i,k) + epsm1*qeso(i,k))
3062 qeso(i,k) = max(qeso(i,k), val )
3066 if (.not.hwrf_samfdeep)
then
3071 if (cnvflg(i) .and. k <= kmax(i))
then
3072 ctro(i,k,n) = qtr(i,k,kk)
3080c--- feedback: simply the changes from the cloud with unit mass flux
3081c--- multiplied by the mass flux necessary to keep the
3082c--- equilibrium with the larger-scale.
3096 if (.not.hwrf_samfdeep)
then
3105 if (cnvflg(i) .and. k <= kmax(i))
then
3106 if(k <= ktcon(i))
then
3108 dellat = (dellah(i,k) - hvap * dellaq(i,k)) / cp
3109 t1(i,k) = t1(i,k) + tem2 * dellat
3110 q1(i,k) = q1(i,k) + tem2 * dellaq(i,k)
3114 u1(i,k) = u1(i,k) + tem2 * dellau(i,k)
3115 v1(i,k) = v1(i,k) + tem2 * dellav(i,k)
3116 dp = 1000. * del(i,k)
3117 tem = xmb(i) * dp / grav
3118 delhbar(i) = delhbar(i) + tem * dellah(i,k)
3119 delqbar(i) = delqbar(i) + tem * dellaq(i,k)
3120 deltbar(i) = deltbar(i) + tem * dellat
3121 delubar(i) = delubar(i) + tem * dellau(i,k)
3122 delvbar(i) = delvbar(i) + tem * dellav(i,k)
3138 if(cnvflg(i) .and. k <= ktcon(i))
then
3139 tem = q1(i,k) * delp(i,k) / grav
3140 if(q1(i,k) < 0.) tsumn(i) = tsumn(i) + tem
3141 if(q1(i,k) > 0.) tsump(i) = tsump(i) + tem
3147 if(tsump(i) > 0. .and. tsumn(i) < 0.)
then
3148 if(tsump(i) > abs(tsumn(i)))
then
3149 rtnp(i) = tsumn(i) / tsump(i)
3151 rtnp(i) = tsump(i) / tsumn(i)
3158 if(cnvflg(i) .and. k <= ktcon(i))
then
3159 if(rtnp(i) < 0.)
then
3160 if(tsump(i) > abs(tsumn(i)))
then
3161 if(q1(i,k) < 0.) q1(i,k) = 0.
3162 if(q1(i,k) > 0.) q1(i,k) = (1.+rtnp(i))*q1(i,k)
3164 if(q1(i,k) < 0.) q1(i,k) = (1.+rtnp(i))*q1(i,k)
3165 if(q1(i,k) > 0.) q1(i,k) = 0.
3172 if (.not.hwrf_samfdeep)
then
3178 if (cnvflg(i) .and. k <= kmax(i))
then
3179 if(k <= ktcon(i))
then
3180 ctr(i,k,n) = ctr(i,k,n)+dellae(i,k,n)*xmb(i)*dt2
3181 dp = 1000. * del(i,k)
3182 delebar(i,n)=delebar(i,n)+dellae(i,k,n)*xmb(i)*dp/grav
3198 if(cnvflg(i) .and. k <= ktcon(i))
then
3201 dz = zi(i,k) - zi(i,k-1)
3205 tem = ctr(i,k,n) * dz
3207 tem = ctr(i,k,n) * delp(i,k) / grav
3209 if(ctr(i,k,n) < 0.) tsumn(i) = tsumn(i) + tem
3210 if(ctr(i,k,n) > 0.) tsump(i) = tsump(i) + tem
3216 if(tsump(i) > 0. .and. tsumn(i) < 0.)
then
3217 if(tsump(i) > abs(tsumn(i)))
then
3218 rtnp(i) = tsumn(i) / tsump(i)
3220 rtnp(i) = tsump(i) / tsumn(i)
3227 if(cnvflg(i) .and. k <= ktcon(i))
then
3228 if(rtnp(i) < 0.)
then
3229 if(tsump(i) > abs(tsumn(i)))
then
3230 if(ctr(i,k,n)<0.) ctr(i,k,n)=0.
3231 if(ctr(i,k,n)>0.) ctr(i,k,n)=(1.+rtnp(i))*ctr(i,k,n)
3233 if(ctr(i,k,n)<0.) ctr(i,k,n)=(1.+rtnp(i))*ctr(i,k,n)
3234 if(ctr(i,k,n)>0.) ctr(i,k,n)=0.
3244 if(cnvflg(i) .and. k <= ktcon(i))
then
3245 qtr(i,k,kk) = ctr(i,k,n)
3252 if (do_aerosols)
then
3260 if(k > kb(i) .and. k < ktcon(i))
then
3261 dp = 1000. * del(i,k)
3262 wet_dep(i,k,n) = chem_pw(i,k,n)*grav/dp
3263 wet_dep(i,k,n) = wet_dep(i,k,n)*xmb(i)*dt2*dp
3273 if(k > kb(i) .and. k < ktcon(i))
then
3274 dp = 1000. * del(i,k)
3275 if (qtr(i,k,kk) < 0.)
then
3277 tem = -qtr(i,k,kk)*dp
3278 if(wet_dep(i,k,n) >= tem)
then
3279 wet_dep(i,k,n) = wet_dep(i,k,n) - tem
3283 qtr(i,k,kk) = qtr(i,k,kk)+wet_dep(i,k,n)/dp
3300 if (cnvflg(i) .and. k <= kmax(i))
then
3301 if(k <= ktcon(i))
then
3302 qeso(i,k) = 0.01 * fpvs(t1(i,k))
3303 qeso(i,k) = eps * qeso(i,k)/(pfld(i,k) + epsm1*qeso(i,k))
3305 qeso(i,k) = max(qeso(i,k), val )
3320 if (cnvflg(i) .and. k <= kmax(i))
then
3321 if(k < ktcon(i))
then
3323 if(k <= kb(i)) aup = 0.
3325 if(k >= jmin(i)) adw = 0.
3326 rain = aup * pwo(i,k) + adw * edto(i) * pwdo(i,k)
3327 rntot(i) = rntot(i) + rain * xmb(i) * .001 * dt2
3337 if (k <= kmax(i))
then
3341 if(cnvflg(i) .and. k < ktcon(i))
then
3343 if(k <= kb(i)) aup = 0.
3345 if(k >= jmin(i)) adw = 0.
3346 rain = aup * pwo(i,k) + adw * edto(i) * pwdo(i,k)
3347 rn(i) = rn(i) + rain * xmb(i) * .001 * dt2
3349 if(flg(i) .and. k < ktcon(i))
then
3353 qcond(i) = evef * (q1(i,k) - qeso(i,k))
3354 & / (1. + el2orc * qeso(i,k) / t1(i,k)**2)
3355 dp = 1000. * del(i,k)
3358 if(rn(i) > 0. .and. qcond(i) < 0.)
then
3359 qevap(i) = -qcond(i) * (1.-exp(-.32*sqrt(dt2*rn(i))))
3360 qevap(i) = min(qevap(i), rn(i)*1000.*tem)
3361 delq2(i) = delqev(i) + .001 * qevap(i) * tem1
3363 if(rn(i) > 0. .and. qcond(i) < 0. .and.
3364 & delq2(i) > rntot(i))
then
3365 qevap(i) = 1000.* tem * (rntot(i) - delqev(i))
3368 if(rn(i) > 0. .and. qevap(i) > 0.)
then
3369 q1(i,k) = q1(i,k) + qevap(i)
3370 t1(i,k) = t1(i,k) - elocp * qevap(i)
3371 rn(i) = rn(i) - .001 * qevap(i) * tem1
3372 deltv(i) = - elocp*qevap(i)/dt2
3373 delq(i) = + qevap(i)/dt2
3374 delqev(i) = delqev(i) + .001 * qevap(i) * tem1
3376 delqbar(i) = delqbar(i) + delq(i) * tem1
3377 deltbar(i) = deltbar(i) + deltv(i) * tem1
3386 rainevap(i)=delqev(i)
3404c precipitation rate converted to actual precip
3405c in unit of m instead of kg
3410c in the event of upper level rain evaporation and lower level downdraft
3411c moistening, rn can become negative, in this
case, we back out of the
3412c heating and the moistening
3414 if(rn(i) < 0. .and. .not.flg(i)) rn(i) = 0.
3415 if(rn(i) <= 0.)
then
3426c convective cloud
water
3431 if (cnvflg(i) .and. rn(i) > 0.)
then
3432 if (k >= kbcon(i) .and. k < ktcon(i))
then
3433 cnvw(i,k) = cnvwt(i,k) * xmb(i) * dt2
3439c convective cloud cover
3444 if (cnvflg(i) .and. rn(i) > 0.)
then
3445 if (k >= kbcon(i) .and. k < ktcon(i))
then
3446 cnvc(i,k) = 0.04 * log(1. + 675. * eta(i,k) * xmb(i))
3447 cnvc(i,k) = min(cnvc(i,k), 0.6)
3448 cnvc(i,k) = max(cnvc(i,k), 0.0)
3457 if (ncloud > 0)
then
3461 if (cnvflg(i) .and. rn(i) > 0.)
then
3463 if (k >= kbcon(i) .and. k <= ktcon(i))
then
3464 tem = dellal(i,k) * xmb(i) * dt2
3465 tem1 = max(0.0, min(1.0, (tcr-t1(i,k))*tcrf))
3466 if (qtr(i,k,2) > -999.0)
then
3467 qtr(i,k,1) = qtr(i,k,1) + tem * tem1
3468 qtr(i,k,2) = qtr(i,k,2) + tem *(1.0-tem1)
3470 qtr(i,k,1) = qtr(i,k,1) + tem
3482 if(cnvflg(i) .and. rn(i) <= 0.)
then
3483 if (k <= kmax(i))
then
3492 if (.not.hwrf_samfdeep)
then
3497 if(cnvflg(i) .and. rn(i) <= 0.)
then
3498 if (k <= kmax(i))
then
3499 qtr(i,k,kk)= ctro(i,k,n)
3505 if (do_aerosols)
then
3509 if(cnvflg(i) .and. rn(i) <= 0.)
then
3510 if (k <= ktcon(i))
then
3540 if(cnvflg(i) .and. rn(i) > 0.)
then
3541 if(k >= kb(i) .and. k < ktop(i))
then
3542 ud_mf(i,k) = eta(i,k) * xmb(i) * dt2
3549 if(cnvflg(i) .and. rn(i) > 0.)
then
3551 dt_mf(i,k) = ud_mf(i,k)
3557 if(cnvflg(i) .and. rn(i) > 0.)
then
3558 if(k >= 1 .and. k <= jmin(i))
then
3559 dd_mf(i,k) = edto(i) * etad(i,k) * xmb(i) * dt2
3567 if (.not.hwrf_samfdeep)
then
3572 if(cnvflg(i) .and. rn(i) > 0.)
then
3573 if(k > kb(i) .and. k < ktop(i))
then
3574 tem = 0.5 * (eta(i,k-1) + eta(i,k)) * xmb(i)
3575 tem1 = pfld(i,k) * 100. / (rd * t1(i,k))
3579 tem2 = max(sigmagfm(i), betaw)
3581 ptem = tem / (tem2 * tem1)
3582 qtr(i,k,ntk)=qtr(i,k,ntk)+0.5*tem2*ptem*ptem
3590 if(cnvflg(i) .and. rn(i) > 0.)
then
3591 if(k > 1 .and. k <= jmin(i))
then
3592 tem = 0.5*edto(i)*(etad(i,k-1)+etad(i,k))*xmb(i)
3593 tem1 = pfld(i,k) * 100. / (rd * t1(i,k))
3597 tem2 = max(sigmagfm(i), betaw)
3599 ptem = tem / (tem2 * tem1)
3600 qtr(i,k,ntk)=qtr(i,k,ntk)+0.5*tem2*ptem*ptem
3608 if(mp_phys == mp_phys_mg)
then
3611 qlcn(i,k) = qtr(i,k,2) - qlcn(i,k)
3612 qicn(i,k) = qtr(i,k,1) - qicn(i,k)
3613 cf_upi(i,k) = cnvc(i,k)
3614 w_upi(i,k) = ud_mf(i,k)*t1(i,k)*rd /
3615 & (dt2*max(sigmagfm(i),1.e-12)*prslp(i,k))
3616 cnv_mfd(i,k) = ud_mf(i,k)/dt2
3617 clcn(i,k) = cnvc(i,k)
3618 cnv_fice(i,k) = qicn(i,k)
3619 & / max(1.e-10,qlcn(i,k)+qicn(i,k))