54 & eps,epsm1,fv,grav,hvap,rd,rv, &
55 & t0c,delt,ntk,ntr,delp,first_time_step,restart, &
56 & tmf,qmicro,progsigma, &
57 & prslp,psp,phil,qtr,prevsq,q,q1,t1,u1,v1,fscav, &
58 & rn,kbot,ktop,kcnv,islimsk,garea, &
59 & dot,ncloud,hpbl,ud_mf,dt_mf,cnvw,cnvc, &
60 & clam,c0s,c1,evef,pgcon,asolfac,hwrf_samfshal, &
61 & sigmain,sigmaout,betadcu,betamcu,betascu,errmsg,errflg)
63 use machine ,
only : kind_phys
64 use funcphys ,
only : fpvs
68 integer,
intent(in) :: im, km, itc, ntc, ntk, ntr, ncloud
69 integer,
intent(in) :: islimsk(:)
70 real(kind=kind_phys),
intent(in) :: cliq, cp, cvap, &
71 & eps, epsm1, fv, grav, hvap, rd, rv, t0c, betascu, betadcu, &
73 real(kind=kind_phys),
intent(in) :: delt
74 real(kind=kind_phys),
intent(in) :: psp(:), delp(:,:), &
75 & prslp(:,:), garea(:), hpbl(:), dot(:,:), phil(:,:), &
77 real(kind=kind_phys),
intent(in),
optional :: qmicro(:,:), &
79 real(kind=kind_phys),
intent(in),
optional :: sigmain(:,:)
81 real(kind=kind_phys),
dimension(:),
intent(in) :: fscav
82 integer,
intent(inout) :: kcnv(:)
84 real(kind=kind_phys),
intent(inout) :: qtr(:,:,:), &
85 & q1(:,:), t1(:,:), u1(:,:), v1(:,:)
87 integer,
intent(out) :: kbot(:), ktop(:)
88 real(kind=kind_phys),
intent(out) :: rn(:), &
89 & cnvw(:,:), cnvc(:,:), dt_mf(:,:)
91 real(kind=kind_phys),
intent(out),
optional :: ud_mf(:,:), &
93 real(kind=kind_phys),
intent(in) :: clam, c0s, c1, &
94 & asolfac, evef, pgcon
95 logical,
intent(in) :: hwrf_samfshal,first_time_step, &
97 character(len=*),
intent(out) :: errmsg
98 integer,
intent(out) :: errflg
101 integer i,j,indx, k, kk, km1, n
104 real(kind=kind_phys) clamd, tkemx, tkemn, dtke
106 real(kind=kind_phys) dellat,
109 & dq, dqsdp, dqsdt, dt,
114 & el2orc, elocp, aafac,
116 & es, etah, h1, shevf,
118 & fact1, fact2, factor,
119 & cthk, cthkmn, dthk,
120 & gamma, pprime, betaw, tauadv,
122 & rfact, shear, tfac,
127 & rho, tem, tem1, tem2,
130 integer kb(im), kb1(im), kbcon(im), kbcon1(im),
131 & ktcon(im), ktcon1(im),
134 real(kind=kind_phys) aa1(im), cina(im),
135 & tkemean(im), clamt(im),
136 & ps(im), del(im,km), prsl(im,km),
137 & umean(im), advfac(im), gdx(im),
138 & delhbar(im), delq(im), delq2(im),
139 & delqbar(im), delqev(im), deltbar(im),
141 & deltv(im), dtconv(im),
142 & pdot(im), po(im,km),
143 & qcond(im), qevap(im), hmax(im),
146 & xlamud(im), xmb(im), xmbmax(im),
148 & delubar(im), delvbar(im)
150 real(kind=kind_phys) c0(im), sfcpbl(im)
152 real(kind=kind_phys) crtlame, crtlamd
154 real(kind=kind_phys) cinpcr, cinpcrmx, cinpcrmn,
155 & cinacr, cinacrmx, cinacrmn,
160 real(kind=kind_phys) bb1, bb2, csmf, wucb
164 real(kind=kind_phys) omega_u(im,km),zdqca(im,km),tmfq(im,km),
165 & omegac(im),zeta(im,km),dbyo1(im,km),
166 & sigmab(im),qadv(im,km)
167 real(kind=kind_phys) gravinv,dxcrtas,invdelt,sigmind,sigmins,
169 logical flag_shallow,flag_mid
187 parameter(cm=1.0,cq=1.0)
189 parameter(clamd=0.1,tkemx=0.65,tkemn=0.05)
190 parameter(dtke=tkemx-tkemn)
191 parameter(cthk=200.,cthkmn=0.,dthk=25.)
192 parameter(sfclfac=0.2,rhcrt=0.75)
193 parameter(cinpcrmx=180.,cinpcrmn=120.)
195 parameter(cinacrmx=-120.,shevf=2.0)
196 parameter(dtmax=10800.,dtmin=600.)
197 parameter(bb1=4.0,bb2=0.8,csmf=0.2)
198 parameter(tkcrt=2.,cmxfac=10.)
200 parameter(betaw=.03,dxcrtc0=9.e3)
201 parameter(h1=0.33333333)
203 parameter(dxcrtas=30.e3,sigmind=0.01,sigmins=0.03,sigminm=0.01)
204c local variables and arrays
205 real(kind=kind_phys) pfld(im,km), to(im,km), qo(im,km),
206 & uo(im,km), vo(im,km), qeso(im,km),
207 & ctr(im,km,ntr), ctro(im,km,ntr)
210c variables for tracer wet deposition,
211 real(kind=kind_phys),
dimension(im,km,ntc) :: chem_c, chem_pw,
213 real(kind=kind_phys),
parameter :: escav = 0.8
216 real(kind=kind_phys) wu2(im,km), buo(im,km), drag(im,km),
217 & wush(im,km), wc(im)
220 real(kind=kind_phys) scaldfunc(im), sigmagfm(im)
224 real(kind=kind_phys) qlko_ktcon(im), dellal(im,km),
225 & dbyo(im,km), zo(im,km), xlamue(im,km),
227 & heo(im,km), heso(im,km),
228 & dellah(im,km), dellaq(im,km),
230 & dellau(im,km), dellav(im,km), hcko(im,km),
231 & ucko(im,km), vcko(im,km), qcko(im,km),
232 & qrcko(im,km), ecko(im,km,ntr),
233 & ercko(im,km,ntr), eta(im,km),
234 & zi(im,km), pwo(im,km), c0t(im,km),
235 & sumx(im), tx1(im), cnvwt(im,km)
241 real(kind=kind_phys) q_diff(im,0:km-1), e_diff(im,0:km-1,ntr),
243 real(kind=kind_phys) rrkp, phkp
244 real(kind=kind_phys) tsumn(im), tsump(im), rtnp(im)
246 logical do_aerosols, totflg, cnvflg(im), flg(im)
248 real(kind=kind_phys) tf, tcr, tcrf
249 parameter(tf=233.16, tcr=263.16, tcrf=1.0/(tcr-tf))
252c-----------------------------------------------------------------------
262 el2orc = hvap*hvap/(rv*cp)
264 fact1 = (cvap-cliq)/rv
265 fact2 = hvap/rv-fact1*t0c
267 if (.not.hwrf_samfshal)
then
277c-----------------------------------------------------------------------
278 if (.not.hwrf_samfshal)
then
280 do_aerosols = (itc > 0) .and. (ntc > 0) .and. (ntr > 0)
281 if (do_aerosols) do_aerosols = (ntr >= itc + ntc - 3)
303 if(hwrf_samfshal)
then
306 if(kcnv(i) == 1) cnvflg(i) = .false.
311 sfcpbl(i) = sfclfac * hpbl(i)
323 gdx(i) = sqrt(garea(i))
332 if(kcnv(i) == 1) cnvflg(i) = .false.
337 sfcpbl(i) = sfclfac * hpbl(i)
348 gdx(i) = sqrt(garea(i))
357 totflg = totflg .and. (.not. cnvflg(i))
363 if(islimsk(i) == 1)
then
372 if(gdx(i) < dxcrtc0)
then
373 tem = gdx(i) / dxcrtc0
382 if(t1(i,k) > 273.16)
then
385 tem = d0 * (t1(i,k) - 273.16)
387 c0t(i,k) = c0(i) * tem1
410c model tunable parameters are all here
427c define top layer for search of the downdraft originating layer
428c and the maximum thetae for updraft
439 if (prsl(i,k)*tx1(i) > 0.70) kbm(i) = k + 1
440 if (prsl(i,k)*tx1(i) > 0.60) kmax(i) = k + 1
444 kbm(i) = min(kbm(i),kmax(i))
447c hydrostatic height assume zero terr and compute
448c updraft entrainment rate as an inverse
function of height
453 zo(i,k) = phil(i,k) / grav
457 if(hwrf_samfshal)
then
460 zi(i,k) = 0.5*(zo(i,k)+zo(i,k+1))
461 xlamue(i,k) = clam / zi(i,k)
465 xlamue(i,km) = xlamue(i,km1)
470 zi(i,k) = 0.5*(zo(i,k)+zo(i,k+1))
484 if (flg(i) .and. zo(i,k) <= hpbl(i))
then
492 kpbl(i)= min(kpbl(i),kbm(i))
496c convert surface pressure to mb from cb
501 if (cnvflg(i) .and. k <= kmax(i))
then
502 pfld(i,k) = prsl(i,k) * 10.0
543 if (.not.hwrf_samfshal)
then
548 if (cnvflg(i) .and. k <= kmax(i))
then
549 ctr(i,k,kk) = qtr(i,k,n)
550 ctro(i,k,kk) = qtr(i,k,n)
561 if (cnvflg(i) .and. k <= kmax(i))
then
562 qeso(i,k) = 0.01 * fpvs(to(i,k))
563 qeso(i,k) = eps * qeso(i,k) / (pfld(i,k) + epsm1*qeso(i,k))
565 qeso(i,k) = max(qeso(i,k), val1)
567 qo(i,k) = max(qo(i,k), val2 )
574c compute moist static
energy
579 if (cnvflg(i) .and. k <= kmax(i))
then
581 tem = phil(i,k) + cp * to(i,k)
582 heo(i,k) = tem + hvap * qo(i,k)
583 heso(i,k) = tem + hvap * qeso(i,k)
584c heo(i,k) = min(heo(i,k),heso(i,k))
589c determine level with largest moist static
energy within pbl
590c this is the level
where updraft starts
600 if (flg(i) .and. zo(i,k) <= sfcpbl(i))
then
608 kb1(i) = min(kb1(i),kpbl(i))
614 hmax(i) = heo(i,kb1(i))
620 if(cnvflg(i) .and. (k > kb1(i) .and. k <= kpbl(i)))
then
621 if(heo(i,k) > hmax(i))
then
632 if (cnvflg(i) .and. k <= kmax(i)-1)
then
633 dz = .5 * (zo(i,k+1) - zo(i,k))
634 dp = .5 * (pfld(i,k+1) - pfld(i,k))
635 es = 0.01 * fpvs(to(i,k+1))
636 pprime = pfld(i,k+1) + epsm1 * es
637 qs = eps * es / pprime
638 dqsdp = - qs / pprime
639 desdt = es * (fact1 / to(i,k+1) + fact2 / (to(i,k+1)**2))
640 dqsdt = qs * pfld(i,k+1) * desdt / (es * pprime)
641 gamma = el2orc * qeso(i,k+1) / (to(i,k+1)**2)
642 dt = (grav*dz + hvap*dqsdp*dp) / (cp*(1. + gamma))
643 dq = dqsdt * dt + dqsdp * dp
644 to(i,k) = to(i,k+1) + dt
645 qo(i,k) = qo(i,k+1) + dq
646 po(i,k) = .5 * (pfld(i,k) + pfld(i,k+1))
654 if (cnvflg(i) .and. k <= kmax(i)-1)
then
655 qeso(i,k) = 0.01 * fpvs(to(i,k))
656 qeso(i,k) = eps * qeso(i,k) / (po(i,k) + epsm1*qeso(i,k))
658 qeso(i,k) = max(qeso(i,k), val1)
660 qo(i,k) = max(qo(i,k), val2 )
662 rh(i,k) = min(qo(i,k)/qeso(i,k), 1.)
663 heo(i,k) = .5 * grav * (zo(i,k) + zo(i,k+1)) +
664 & cp * to(i,k) + hvap * qo(i,k)
665 heso(i,k) = .5 * grav * (zo(i,k) + zo(i,k+1)) +
666 & cp * to(i,k) + hvap * qeso(i,k)
667 uo(i,k) = .5 * (uo(i,k) + uo(i,k+1))
668 vo(i,k) = .5 * (vo(i,k) + vo(i,k+1))
673 if (.not.hwrf_samfshal)
then
677 if (cnvflg(i) .and. k <= kmax(i)-1)
then
678 ctro(i,k,n) = .5 * (ctro(i,k,n) + ctro(i,k+1,n))
685c look for the level of free convection as cloud base
690 if(flg(i)) kbcon(i) = kmax(i)
694 if (flg(i) .and. k < kbm(i))
then
695 if(k > kb(i) .and. heo(i,kb(i)) > heso(i,k))
then
705 if(kbcon(i) == kmax(i)) cnvflg(i) = .false.
712 totflg = totflg .and. (.not. cnvflg(i))
720 pdot(i) = 0.01 * dot(i,kbcon(i))
724c turn off convection
if pressure depth between parcel source level
725c and cloud base is larger than a critical
value, cinpcr
729 if(islimsk(i) == 1)
then
740 if(pdot(i) <= w4)
then
741 tem = (pdot(i) - w4) / (w3 - w4)
742 elseif(pdot(i) >= -w4)
then
743 tem = - (pdot(i) + w4) / (w4 - w3)
752 ptem1= .5*(cinpcrmx-cinpcrmn)
753 cinpcr = cinpcrmx - ptem * ptem1
754 tem1 = pfld(i,kb(i)) - pfld(i,kbcon(i))
756 if(tem1 > cinpcr .and.
757 & zi(i,kbcon(i)) > hpbl(i))
then
765 totflg = totflg .and. (.not. cnvflg(i))
779 if (cnvflg(i) .and. k <= kpbl(i))
then
780 if(heo(i,k) > hmax(i))
then
790 if(flg(i)) kbcon(i) = kmax(i)
794 if (flg(i) .and. k < kbm(i))
then
795 if(k > kb(i) .and. heo(i,kb(i)) > heso(i,k))
then
805 if(kbcon(i) == kmax(i)) cnvflg(i) = .false.
811 totflg = totflg .and. (.not. cnvflg(i))
818 pdot(i) = 0.01 * dot(i,kbcon(i))
831 if(k >= kb(i) .and. k < kbcon(i))
then
832 dz = zo(i,k+1) - zo(i,k)
833 rhbar(i) = rhbar(i) + rh(i,k) * dz
834 sumx(i) = sumx(i) + dz
841 rhbar(i) = rhbar(i) / sumx(i)
842 if(rhbar(i) < rhcrt)
then
850 totflg = totflg .and. (.not. cnvflg(i))
861 if (hwrf_samfshal)
then
864 xlamud(i) = xlamue(i,kbcon(i))
880 if(k >= kb(i) .and. k < kbcon(i))
then
881 dz = zo(i,k+1) - zo(i,k)
882 tem = 0.5 * (qtr(i,k,ntk)+qtr(i,k+1,ntk))
883 tkemean(i) = tkemean(i) + tem * dz
884 sumx(i) = sumx(i) + dz
892 tkemean(i) = tkemean(i) / sumx(i)
893 if(tkemean(i) > tkemx)
then
894 clamt(i) = clam + clamd
895 else if(tkemean(i) < tkemn)
then
896 clamt(i) = clam - clamd
898 tem = tkemx - tkemean(i)
899 tem1 = 1. - 2. * tem / dtke
900 clamt(i) = clam + clamd * tem1
907 if(tkemean(i) > tkcrt)
then
908 tem = 1. + tkemean(i)/tkcrt
909 tem1 = min(tem, cmxfac)
910 clamt(i) = tem1 * clam
932 dz = zo(i,k+1) - zo(i,k)
933 xlamue(i,k) = clamt(i) / (zi(i,k) + dz)
934 xlamue(i,k) = max(xlamue(i,k), crtlame)
940 xlamue(i,km) = xlamue(i,km1)
944c specify the detrainment rate for the updrafts
953 xlamud(i) = 0.001 * clamt(i)
958c determine updraft mass flux for the subcloud layers
968 if(k < kbcon(i) .and. k >= kb(i))
then
969 dz = zi(i,k+1) - zi(i,k)
970 ptem = 0.5*(xlamue(i,k)+xlamue(i,k+1))-xlamud(i)
971 eta(i,k) = eta(i,k+1) / (1. + ptem * dz)
977c compute mass flux above cloud base
985 if(k > kbcon(i) .and. k < kmax(i))
then
986 dz = zi(i,k) - zi(i,k-1)
987 ptem = 0.5*(xlamue(i,k)+xlamue(i,k-1))-xlamud(i)
988 eta(i,k) = eta(i,k-1) * (1 + ptem * dz)
989 if(eta(i,k) <= 0.)
then
991 kbm(i) = min(kbm(i),kmax(i))
999c compute updraft cloud property
1005 hcko(i,indx) = heo(i,indx)
1006 ucko(i,indx) = uo(i,indx)
1007 vcko(i,indx) = vo(i,indx)
1011 if (.not. hwrf_samfshal)
then
1016 ecko(i,indx,n) = ctro(i,indx,n)
1017 ercko(i,indx,n) = ctro(i,indx,n)
1029 if(k > kb(i) .and. k < kmax(i))
then
1030 dz = zi(i,k) - zi(i,k-1)
1031 tem = 0.5 * (xlamue(i,k)+xlamue(i,k-1)) * dz
1032 tem1 = 0.5 * xlamud(i) * dz
1033 factor = 1. + tem - tem1
1034 hcko(i,k) = ((1.-tem1)*hcko(i,k-1)+tem*0.5*
1035 & (heo(i,k)+heo(i,k-1)))/factor
1036 dbyo(i,k) = hcko(i,k) - heso(i,k)
1038 tem = 0.5 * cm * tem
1042 ucko(i,k) = ((1.-tem)*ucko(i,k-1)+ptem*uo(i,k)
1043 & +ptem1*uo(i,k-1))/factor
1044 vcko(i,k) = ((1.-tem)*vcko(i,k-1)+ptem*vo(i,k)
1045 & +ptem1*vo(i,k-1))/factor
1051 if (.not.hwrf_samfshal)
then
1052 if (do_aerosols)
then
1061 if(k > kb(i) .and. k < kmax(i))
then
1062 dz = zi(i,k) - zi(i,k-1)
1063 tem = 0.25 * (xlamue(i,k)+xlamue(i,k-1)) * dz
1066 ecko(i,k,n) = ((1.-tem)*ecko(i,k-1,n)+tem*
1067 & (ctro(i,k,n)+ctro(i,k-1,n)))/factor
1068 ercko(i,k,n) = ecko(i,k,n)
1074 if (do_aerosols)
then
1080 if(k > kb(i) .and. k < kmax(i))
then
1081 dz = zi(i,k) - zi(i,k-1)
1082 tem = 0.25 * (xlamue(i,k)+xlamue(i,k-1)) * dz
1085 ecko(i,k,kk) = ((1. - tem) * ecko(i,k-1,kk) + tem *
1086 & (ctro(i,k,kk) + ctro(i,k-1,kk))) / factor
1087 ercko(i,k,kk) = ecko(i,k,kk)
1088 chem_c(i,k,n) = escav * fscav(n) * ecko(i,k,kk)
1089 tem = chem_c(i,k,n) / (1. + c0t(i,k) * dz)
1090 chem_pw(i,k,n) = c0t(i,k) * dz * tem * eta(i,k-1)
1091 ecko(i,k,kk) = tem + ecko(i,k,kk) - chem_c(i,k,n)
1100c taking account into convection inhibition due to existence of
1101c dry layers below cloud base
1110 if (flg(i) .and. k < kbm(i))
then
1111 if(k >= kbcon(i) .and. dbyo(i,k) > 0.)
then
1120 if(kbcon1(i) == kmax(i)) cnvflg(i) = .false.
1125 tem = pfld(i,kbcon(i)) - pfld(i,kbcon1(i))
1134 totflg = totflg .and. (.not. cnvflg(i))
1139c calculate convective inhibition
1145 if(k > kb(i) .and. k < kbcon1(i))
then
1146 dz1 = zo(i,k+1) - zo(i,k)
1147 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
1148 rfact = 1. + fv * cp * gamma
1152 & dz1 * (grav / (cp * to(i,k)))
1153 & * dbyo(i,k) / (1. + gamma)
1159 & max(val,(qeso(i,k) - qo(i,k)))
1166 if (hwrf_samfshal)
then
1170 if(cina(i) < cinacr) cnvflg(i) = .false.
1176 if(islimsk(i) == 1)
then
1187 if(pdot(i) <= w4)
then
1188 tem = (pdot(i) - w4) / (w3 - w4)
1189 elseif(pdot(i) >= -w4)
then
1190 tem = - (pdot(i) + w4) / (w4 - w3)
1200 tem1= .5*(cinacrmx-cinacrmn)
1201 cinacr = cinacrmx - tem * tem1
1202 if(cina(i) < cinacr) cnvflg(i) = .false.
1209 totflg = totflg .and. (.not. cnvflg(i))
1214c determine first guess cloud top as the level of zero buoyancy
1215c limited to the level of p/ps=0.7
1220 if(flg(i)) ktcon(i) = 1
1224 if (flg(i) .and. k < kbm(i))
then
1225 if(k > kbcon1(i) .and. dbyo(i,k) < 0.)
then
1233c turn off shallow convection
if cloud depth is larger than cthk or less than cthkmn
1237 tem = pfld(i,kbcon(i))-pfld(i,ktcon(i))
1238 if(tem > cthk .or. tem < cthkmn)
then
1245c specify upper limit of mass flux at cloud base
1251 dp = 1000. * del(i,k)
1252 xmbmax(i) = dp / (grav * dt2)
1256c compute cloud moisture property and precipitation
1262 qcko(i,kb(i)) = qo(i,kb(i))
1263 qrcko(i,kb(i)) = qo(i,kb(i))
1270 if(k > kb(i) .and. k < ktcon(i))
then
1271 dz = zi(i,k) - zi(i,k-1)
1272 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
1274 & + gamma * dbyo(i,k) / (hvap * (1. + gamma))
1276 tem = 0.25 * (xlamue(i,k)+xlamue(i,k-1)) * dz
1279 qcko(i,k) = ((1.-tem)*qcko(i,k-1)+tem*
1280 & (qo(i,k)+qo(i,k-1)))/factor
1281 qrcko(i,k) = qcko(i,k)
1283 dq = eta(i,k) * (qcko(i,k) - qrch)
1287c below lfc check
if there is excess moisture to release latent heat
1289 if(k >= kbcon(i) .and. dq > 0.)
then
1290 etah = .5 * (eta(i,k) + eta(i,k-1))
1291 dp = 1000. * del(i,k)
1293 ptem = c0t(i,k) + c1
1294 qlk = dq / (eta(i,k) + etah * ptem * dz)
1295 dellal(i,k) = etah * c1 * dz * qlk * grav / dp
1297 qlk = dq / (eta(i,k) + etah * c0t(i,k) * dz)
1299 buo(i,k) = buo(i,k) - grav * qlk
1300 qcko(i,k)= qlk + qrch
1301 pwo(i,k) = etah * c0t(i,k) * dz * qlk
1302 cnvwt(i,k) = etah * qlk * grav / dp
1303 zdqca(i,k)=dq/eta(i,k)
1308 if(k >= kbcon(i))
then
1309 rfact = 1. + fv * cp * gamma
1311 buo(i,k) = buo(i,k) + (grav / (cp * to(i,k)))
1312 & * dbyo(i,k) / (1. + gamma)
1315 buo(i,k) = buo(i,k) + grav * fv *
1316 & max(val,(qeso(i,k) - qo(i,k)))
1317 drag(i,k) = max(xlamue(i,k),xlamud(i))
1319 tem = ((uo(i,k)-uo(i,k-1))/dz)**2
1320 tem = tem+((vo(i,k)-vo(i,k-1))/dz)**2
1321 wush(i,k) = csmf * sqrt(tem)
1330c calculate cloud work function
1373 if(k >= kbcon(i) .and. k < ktcon(i))
then
1374 dz1 = zo(i,k+1) - zo(i,k)
1375 aa1(i) = aa1(i) + buo(i,k) * dz1
1376 dbyo1(i,k) = hcko(i,k) - heso(i,k)
1382 if(cnvflg(i) .and. aa1(i) <= 0.) cnvflg(i) = .false.
1388 totflg = totflg .and. (.not. cnvflg(i))
1393c estimate the onvective overshooting as the level
1394c
where the [aafac * cloud work function] becomes zero,
1395c which is the final cloud top
1396c limited to the level of p/ps=0.7
1401 aa1(i) = aafac * aa1(i)
1412 if(k >= ktcon(i) .and. k < kbm(i))
then
1413 dz1 = zo(i,k+1) - zo(i,k)
1414 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
1415 rfact = 1. + fv * cp * gamma
1419 & dz1 * (grav / (cp * to(i,k)))
1420 & * dbyo(i,k) / (1. + gamma)
1427 if(aa1(i) < 0.)
then
1436c compute cloud moisture property, detraining cloud
water
1437c and precipitation in overshooting layers
1443 if(k >= ktcon(i) .and. k < ktcon1(i))
then
1444 dz = zi(i,k) - zi(i,k-1)
1445 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
1447 & + gamma * dbyo(i,k) / (hvap * (1. + gamma))
1449 tem = 0.25 * (xlamue(i,k)+xlamue(i,k-1)) * dz
1452 qcko(i,k) = ((1.-tem)*qcko(i,k-1)+tem*
1453 & (qo(i,k)+qo(i,k-1)))/factor
1454 qrcko(i,k) = qcko(i,k)
1456 dq = eta(i,k) * (qcko(i,k) - qrch)
1458c check
if there is excess moisture to release latent heat
1461 etah = .5 * (eta(i,k) + eta(i,k-1))
1462 dp = 1000. * del(i,k)
1464 ptem = c0t(i,k) + c1
1465 qlk = dq / (eta(i,k) + etah * ptem * dz)
1466 dellal(i,k) = etah * c1 * dz * qlk * grav / dp
1468 qlk = dq / (eta(i,k) + etah * c0t(i,k) * dz)
1470 qcko(i,k) = qlk + qrch
1471 pwo(i,k) = etah * c0t(i,k) * dz * qlk
1472 cnvwt(i,k) = etah * qlk * grav / dp
1473 zdqca(i,k)=dq/eta(i,k)
1483 if (hwrf_samfshal)
then
1487 tem = po(i,k) / (rd * to(i,k))
1488 wucb = -0.01 * dot(i,k) / (tem * grav)
1490 wu2(i,k) = wucb * wucb
1500 if(k > kbcon1(i) .and. k < ktcon(i))
then
1501 dz = zi(i,k) - zi(i,k-1)
1502 tem = 0.25 * bb1 * (drag(i,k-1)+drag(i,k)) * dz
1503 tem1 = 0.5 * bb2 * (buo(i,k-1)+buo(i,k))
1504 tem2 = wush(i,k) * sqrt(wu2(i,k-1))
1505 tem2 = (tem1 - tem2) * dz
1506 ptem = (1. - tem) * wu2(i,k-1)
1508 wu2(i,k) = (ptem + tem2) / ptem1
1509 wu2(i,k) = max(wu2(i,k), 0.)
1519 if(k > kbcon1(i) .and. k < ktcon(i))
then
1520 rho = po(i,k)*100. / (rd * to(i,k))
1521 omega_u(i,k)=-1.0*sqrt(wu2(i,k))*rho*grav
1522 omega_u(i,k)=max(omega_u(i,k),-80.)
1539 if(k > kbcon1(i) .and. k < ktcon(i))
then
1540 dz = zi(i,k) - zi(i,k-1)
1541 tem = 0.5 * (sqrt(wu2(i,k)) + sqrt(wu2(i,k-1)))
1542 wc(i) = wc(i) + tem * dz
1543 sumx(i) = sumx(i) + dz
1550 if(sumx(i) == 0.)
then
1553 wc(i) = wc(i) / sumx(i)
1556 if (wc(i) < val) cnvflg(i)=.false.
1569 if(k > kbcon1(i) .and. k < ktcon(i))
then
1570 dp = 1000. * del(i,k)
1571 tem = 0.5 * (omega_u(i,k) + omega_u(i,k-1))
1572 omegac(i) = omegac(i) + tem * dp
1573 sumx(i) = sumx(i) + dp
1580 if(sumx(i) == 0.)
then
1583 omegac(i) = omegac(i) / sumx(i)
1586 if (omegac(i) > val) cnvflg(i)=.false.
1594 if(k > kbcon1(i) .and. k < ktcon(i))
then
1595 if(omega_u(i,k) .ne. 0.)
then
1596 zeta(i,k)=eta(i,k)*(omegac(i)/omega_u(i,k))
1600 zeta(i,k)=max(0.,zeta(i,k))
1601 zeta(i,k)=min(1.,zeta(i,k))
1608c exchange ktcon with ktcon1
1613 ktcon(i) = ktcon1(i)
1618c this section is ready for cloud
water
1622c compute liquid and vapor separation at cloud top
1628 gamma = el2orc * qeso(i,k) / (to(i,k)**2)
1630 & + gamma * dbyo(i,k) / (hvap * (1. + gamma))
1631 dq = qcko(i,k) - qrch
1633c check
if there is excess moisture to release latent heat
1645c--- compute precipitation efficiency in terms of windshear
1681c--- what would the change be, that a cloud with unit mass
1682c--- will
do to the environment?
1688 if(cnvflg(i) .and. k <= kmax(i))
then
1696 if (.not.hwrf_samfshal)
then
1700 if(cnvflg(i) .and. k <= kmax(i))
then
1708c--- changed due to subsidence and entrainment
1713 if(k > kb(i) .and. k < ktcon(i))
then
1714 dp = 1000. * del(i,k)
1715 dz = zi(i,k) - zi(i,k-1)
1718 dv2h = .5 * (heo(i,k) + heo(i,k-1))
1721 tem = 0.5 * (xlamue(i,k)+xlamue(i,k-1))
1726 dellah(i,k) = dellah(i,k) +
1727 & ( eta(i,k)*dv1h - eta(i,k-1)*dv3h
1728 & - tem*eta(i,k-1)*dv2h*dz
1729 & + tem1*eta(i,k-1)*.5*(hcko(i,k)+hcko(i,k-1))*dz
1732 tem1 = -eta(i,k) * qrcko(i,k)
1733 tem2 = -eta(i,k-1) * qcko(i,k-1)
1734 dellaq(i,k) = dellaq(i,k) + (tem1-tem2) * factor
1736 tem1=eta(i,k)*(uo(i,k)-ucko(i,k))
1737 tem2=eta(i,k-1)*(uo(i,k-1)-ucko(i,k-1))
1738 dellau(i,k) = dellau(i,k) + (tem1-tem2) * factor
1740 tem1=eta(i,k)*(vo(i,k)-vcko(i,k))
1741 tem2=eta(i,k-1)*(vo(i,k-1)-vcko(i,k-1))
1742 dellav(i,k) = dellav(i,k) + (tem1-tem2) * factor
1748 if(.not.hwrf_samfshal)
then
1753 if(k > kb(i) .and. k < ktcon(i))
then
1754 dp = 1000. * del(i,k)
1756 tem1 = -eta(i,k) * ercko(i,k,n)
1757 tem2 = -eta(i,k-1) * ecko(i,k-1,n)
1758 dellae(i,k,n) = dellae(i,k,n) + (tem1-tem2) * grav/dp
1772 dp = 1000. * del(i,indx)
1773 tem = eta(i,indx-1) * grav / dp
1774 dellah(i,indx) = tem * (hcko(i,indx-1) - heo(i,indx-1))
1775 dellaq(i,indx) = tem * qcko(i,indx-1)
1776 dellau(i,indx) = tem * (ucko(i,indx-1) - uo(i,indx-1))
1777 dellav(i,indx) = tem * (vcko(i,indx-1) - vo(i,indx-1))
1781 dellal(i,indx) = tem * qlko_ktcon(i)
1784 if (.not.hwrf_samfshal)
then
1789 dp = 1000. * del(i,indx)
1790 dellae(i,indx,n) = eta(i,indx-1) *
1791 & ecko(i,indx-1,n) * grav / dp
1804 if(cnvflg(i) .and. k <= ktcon(i))
then
1805 q_diff(i,k) = q1(i,k) - q1(i,k+1)
1811 if(q1(i,1) >= 0.)
then
1812 q_diff(i,0) = max(0.,2.*q1(i,1)-q1(i,2))-
1815 q_diff(i,0) = min(0.,2.*q1(i,1)-q1(i,2))-
1825 & (k >= kb(i) .and. k < ktcon(i)))
then
1826 if(eta(i,k) > 0.)
then
1828 if(abs(q_diff(i,k)) > 1.e-22)
1829 & rrkp = q_diff(i,k+1) / q_diff(i,k)
1830 phkp = (rrkp+abs(rrkp)) / (1.+abs(rrkp))
1832 & phkp*(qo(i,k)-q1(i,k+1))
1833 flxtvd(i,k) = eta(i,k) * tem1
1842 & (k > kb(i) .and. k <= ktcon(i)))
then
1843 dp = 1000. * del(i,k)
1844 dellaq(i,k) = dellaq(i,k) +
1845 & (flxtvd(i,k) - flxtvd(i,k-1)) * grav/dp
1852 if (.not.hwrf_samfshal)
then
1857 if(cnvflg(i) .and. k <= ktcon(i))
then
1858 e_diff(i,k,n) = ctr(i,k,n) - ctr(i,k+1,n)
1864 if(ctr(i,1,n) >= 0.)
then
1865 e_diff(i,0,n) = max(0.,2.*ctr(i,1,n)-ctr(i,2,n))-
1868 e_diff(i,0,n) = min(0.,2.*ctr(i,1,n)-ctr(i,2,n))-
1881 & (k >= kb(i) .and. k < ktcon(i)))
then
1882 if(eta(i,k) > 0.)
then
1884 if(abs(e_diff(i,k,n)) > 1.e-22)
1885 & rrkp = e_diff(i,k+1,n) / e_diff(i,k,n)
1886 phkp = (rrkp+abs(rrkp)) / (1.+abs(rrkp))
1887 tem1 = ctr(i,k+1,n) +
1888 & phkp*(ctro(i,k,n)-ctr(i,k+1,n))
1889 flxtvd(i,k) = eta(i,k) * tem1
1898 & (k > kb(i) .and. k <= ktcon(i)))
then
1899 dp = 1000. * del(i,k)
1900 dellae(i,k,n) = dellae(i,k,n) +
1901 & (flxtvd(i,k) - flxtvd(i,k-1)) * grav/dp
1915 tem = zi(i,ktcon1(i)) - zi(i,kbcon1(i))
1916 dtconv(i) = tem / wc(i)
1917 if (.not.hwrf_samfshal)
then
1918 tfac = 1. + gdx(i) / 75000.
1919 dtconv(i) = tfac * dtconv(i)
1921 dtconv(i) = max(dtconv(i),dtmin)
1922 dtconv(i) = max(dtconv(i),dt2)
1923 dtconv(i) = min(dtconv(i),dtmax)
1937 if(k >= kbcon1(i) .and. k < ktcon1(i))
then
1938 dz = zi(i,k) - zi(i,k-1)
1939 tem = sqrt(u1(i,k)*u1(i,k)+v1(i,k)*v1(i,k))
1940 umean(i) = umean(i) + tem * dz
1941 sumx(i) = sumx(i) + dz
1948 umean(i) = umean(i) / sumx(i)
1949 umean(i) = max(umean(i), 1.)
1950 tauadv = gdx(i) / umean(i)
1951 advfac(i) = tauadv / dtconv(i)
1952 advfac(i) = min(advfac(i), 1.)
1956c compute cloud base mass flux as a
function of the mean
1962 if(first_time_step .and. .not.restart)
then
1971 qadv(i,k)=(q(i,k) - prevsq(i,k))*invdelt
1978 tmfq(i,k)=tmf(i,k,1)
1982 flag_shallow = .true.
1984 call progsigma_calc(im,km,first_time_step,restart,flag_shallow,
1985 & flag_mid,del,tmfq,qmicro,dbyo1,zdqca,omega_u,zeta,hvap,
1986 & delt,qadv,kbcon1,ktcon,cnvflg,betascu,betamcu,betadcu,
1987 & sigmind,sigminm,sigmins,sigmain,sigmaout,sigmab)
1996 rho = po(i,k)*100. / (rd*to(i,k))
1997 if(
progsigma .and. gdx(i) < dxcrtas)
then
1998 xmb(i) = advfac(i)*sigmab(i)*((-1.0*omegac(i))*gravinv)
2000 xmb(i) = advfac(i)*betaw*rho*wc(i)
2008 tem = min(max(xlamue(i,kbcon(i)), 2.e-4), 6.e-4)
2010 tem1 = 3.14 * tem * tem
2011 sigmagfm(i) = tem1 / garea(i)
2012 sigmagfm(i) = max(sigmagfm(i), 0.001)
2013 sigmagfm(i) = min(sigmagfm(i), 0.999)
2020 if (gdx(i) < dxcrt)
then
2022 scaldfunc(i)=(1.-sigmab(i))*(1.-sigmab(i))
2024 scaldfunc(i) = (1.-sigmagfm(i)) * (1.-sigmagfm(i))
2026 scaldfunc(i) = max(min(scaldfunc(i), 1.0), 0.)
2030 xmb(i) = xmb(i) * scaldfunc(i)
2031 xmb(i) = min(xmb(i),xmbmax(i))
2054 if (cnvflg(i) .and. k <= kmax(i))
then
2055 qeso(i,k) = 0.01 * fpvs(t1(i,k))
2056 qeso(i,k) = eps * qeso(i,k) / (pfld(i,k) + epsm1*qeso(i,k))
2058 qeso(i,k) = max(qeso(i,k), val )
2075 if (.not. hwrf_samfshal)
then
2085 if(k > kb(i) .and. k <= ktcon(i))
then
2086 dellat = (dellah(i,k) - hvap * dellaq(i,k)) / cp
2087 t1(i,k) = t1(i,k) + dellat * xmb(i) * dt2
2088 q1(i,k) = q1(i,k) + dellaq(i,k) * xmb(i) * dt2
2092 u1(i,k) = u1(i,k) + dellau(i,k) * xmb(i) * dt2
2093 v1(i,k) = v1(i,k) + dellav(i,k) * xmb(i) * dt2
2094 dp = 1000. * del(i,k)
2095 tem = xmb(i) * dp / grav
2096 delhbar(i) = delhbar(i) + tem * dellah(i,k)
2097 delqbar(i) = delqbar(i) + tem * dellaq(i,k)
2098 deltbar(i) = deltbar(i) + tem * dellat
2099 delubar(i) = delubar(i) + tem * dellau(i,k)
2100 delvbar(i) = delvbar(i) + tem * dellav(i,k)
2117 if(k > kb(i) .and. k <= ktcon(i))
then
2118 tem = q1(i,k) * delp(i,k) / grav
2119 if(q1(i,k) < 0.) tsumn(i) = tsumn(i) + tem
2120 if(q1(i,k) > 0.) tsump(i) = tsump(i) + tem
2127 if(tsump(i) > 0. .and. tsumn(i) < 0.)
then
2128 if(tsump(i) > abs(tsumn(i)))
then
2129 rtnp(i) = tsumn(i) / tsump(i)
2131 rtnp(i) = tsump(i) / tsumn(i)
2139 if(k > kb(i) .and. k <= ktcon(i))
then
2140 if(rtnp(i) < 0.)
then
2141 if(tsump(i) > abs(tsumn(i)))
then
2142 if(q1(i,k) < 0.) q1(i,k)= 0.
2143 if(q1(i,k) > 0.) q1(i,k)=(1.+rtnp(i))*q1(i,k)
2145 if(q1(i,k) < 0.) q1(i,k)=(1.+rtnp(i))*q1(i,k)
2146 if(q1(i,k) > 0.) q1(i,k)=0.
2154 if (.not.hwrf_samfshal)
then
2162 if(k > kb(i) .and. k <= ktcon(i))
then
2163 ctr(i,k,n) = ctr(i,k,n)+dellae(i,k,n)*xmb(i)*dt2
2164 dp = 1000. * del(i,k)
2165 delebar(i,n)=delebar(i,n)+dellae(i,k,n)*xmb(i)*dp/grav
2182 if(k > kb(i) .and. k <= ktcon(i))
then
2185 dz = zi(i,k) - zi(i,k-1)
2189 tem = ctr(i,k,n) * dz
2191 tem = ctr(i,k,n) * delp(i,k) / grav
2193 if(ctr(i,k,n) < 0.) tsumn(i) = tsumn(i) + tem
2194 if(ctr(i,k,n) > 0.) tsump(i) = tsump(i) + tem
2201 if(tsump(i) > 0. .and. tsumn(i) < 0.)
then
2202 if(tsump(i) > abs(tsumn(i)))
then
2203 rtnp(i) = tsumn(i) / tsump(i)
2205 rtnp(i) = tsump(i) / tsumn(i)
2213 if(k > kb(i) .and. k <= ktcon(i))
then
2214 if(rtnp(i) < 0.)
then
2215 if(tsump(i) > abs(tsumn(i)))
then
2216 if(ctr(i,k,n)<0.) ctr(i,k,n)=0.
2217 if(ctr(i,k,n)>0.) ctr(i,k,n)=(1.+rtnp(i))*ctr(i,k,n)
2219 if(ctr(i,k,n)<0.) ctr(i,k,n)=(1.+rtnp(i))*ctr(i,k,n)
2220 if(ctr(i,k,n)>0.) ctr(i,k,n)=0.
2232 if(k > kb(i) .and. k <= ktcon(i))
then
2233 qtr(i,k,kk) = ctr(i,k,n)
2241 if (do_aerosols)
then
2249 if(k > kb(i) .and. k < ktcon(i))
then
2250 dp = 1000. * del(i,k)
2251 wet_dep(i,k,n) = chem_pw(i,k,n)*grav/dp
2252 wet_dep(i,k,n) = wet_dep(i,k,n)*xmb(i)*dt2*dp
2262 if(k > kb(i) .and. k < ktcon(i))
then
2263 dp = 1000. * del(i,k)
2264 if (qtr(i,k,kk) < 0.)
then
2266 tem = -qtr(i,k,kk)*dp
2267 if(wet_dep(i,k,n) >= tem)
then
2268 wet_dep(i,k,n) = wet_dep(i,k,n) - tem
2272 qtr(i,k,kk) = qtr(i,k,kk)+wet_dep(i,k,n)/dp
2290 if(k > kb(i) .and. k <= ktcon(i))
then
2291 qeso(i,k) = 0.01 * fpvs(t1(i,k))
2292 qeso(i,k) = eps * qeso(i,k)/(pfld(i,k) + epsm1*qeso(i,k))
2294 qeso(i,k) = max(qeso(i,k), val )
2310 if(k < ktcon(i) .and. k > kb(i))
then
2311 rntot(i) = rntot(i) + pwo(i,k) * xmb(i) * .001 * dt2
2324 if (k <= kmax(i))
then
2329 if(k < ktcon(i) .and. k > kb(i))
then
2330 rn(i) = rn(i) + pwo(i,k) * xmb(i) * .001 * dt2
2333 if(flg(i) .and. k < ktcon(i))
then
2337 qcond(i) = shevf * evef * (q1(i,k) - qeso(i,k))
2338 & / (1. + el2orc * qeso(i,k) / t1(i,k)**2)
2339 dp = 1000. * del(i,k)
2341 if(rn(i) > 0. .and. qcond(i) < 0.)
then
2342 qevap(i) = -qcond(i) * (1.-exp(-.32*sqrt(dt2*rn(i))))
2343 qevap(i) = min(qevap(i), rn(i)*1000.*grav/dp)
2344 delq2(i) = delqev(i) + .001 * qevap(i) * factor
2346 if(rn(i) > 0. .and. qcond(i) < 0. .and.
2347 & delq2(i) > rntot(i))
then
2348 qevap(i) = 1000.* grav * (rntot(i) - delqev(i)) / dp
2351 if(rn(i) > 0. .and. qevap(i) > 0.)
then
2353 tem1 = qevap(i) * tem
2354 if(tem1 > rn(i))
then
2355 qevap(i) = rn(i) / tem
2358 rn(i) = rn(i) - tem1
2360 q1(i,k) = q1(i,k) + qevap(i)
2361 t1(i,k) = t1(i,k) - elocp * qevap(i)
2362 deltv(i) = - elocp*qevap(i)/dt2
2363 delq(i) = + qevap(i)/dt2
2364 delqev(i) = delqev(i) + tem * qevap(i)
2366 delqbar(i) = delqbar(i) + delq(i) * factor
2367 deltbar(i) = deltbar(i) + deltv(i) * factor
2394 if(rn(i) < 0. .or. .not.flg(i)) rn(i) = 0.
2401c convective cloud
water
2407 if (k >= kbcon(i) .and. k < ktcon(i))
then
2408 cnvw(i,k) = cnvwt(i,k) * xmb(i) * dt2
2415c convective cloud cover
2421 if (k >= kbcon(i) .and. k < ktcon(i))
then
2422 cnvc(i,k) = 0.04 * log(1. + 675. * eta(i,k) * xmb(i))
2423 cnvc(i,k) = min(cnvc(i,k), 0.2)
2424 cnvc(i,k) = max(cnvc(i,k), 0.0)
2433 if (ncloud > 0)
then
2439 if (k >= kbcon(i) .and. k <= ktcon(i))
then
2440 tem = dellal(i,k) * xmb(i) * dt2
2441 tem1 = max(0.0, min(1.0, (tcr-t1(i,k))*tcrf))
2442 if (qtr(i,k,2) > -999.0)
then
2443 qtr(i,k,1) = qtr(i,k,1) + tem * tem1
2444 qtr(i,k,2) = qtr(i,k,2) + tem *(1.0-tem1)
2446 qtr(i,k,1) = qtr(i,k,1) + tem
2478 if(k >= kb(i) .and. k < ktop(i))
then
2479 ud_mf(i,k) = eta(i,k) * xmb(i) * dt2
2488 dt_mf(i,k) = ud_mf(i,k)
2494 if (.not.hwrf_samfshal)
then
2500 if(k > kb(i) .and. k < ktop(i))
then
2501 tem = 0.5 * (eta(i,k-1) + eta(i,k)) * xmb(i)
2502 tem1 = pfld(i,k) * 100. / (rd * t1(i,k))
2506 tem2 = max(sigmagfm(i), betaw)
2508 ptem = tem / (tem2 * tem1)
2509 qtr(i,k,ntk)=qtr(i,k,ntk)+0.5*tem2*ptem*ptem