1 ! module cup_gf_sh will call shallow convection as described in Grell and
2 ! Freitas (2016). Input variables are:
3 ! zo Height at model levels
4 ! t,tn Temperature without and with forcing at model levels
5 ! q,qo mixing ratio without and with forcing at model levels
6 ! po pressure at model levels (mb)
7 ! psur surface pressure (mb)
9 ! dhdt forcing for boundary layer equilibrium
10 ! hfx,qfx in w/m2 (positive, if upward from sfc)
11 ! kpbl level of boundaty layer height
12 ! xland land mask (1. for land)
13 ! ichoice which closure to choose
18 ! tcrit parameter for water/ice conversion (258)
20 !!!!!!!!!!!! Variables that are diagnostic
22 ! zuo normalized mass flux profile
23 ! xmb_out base mass flux
24 ! kbcon convective cloud base
26 ! k22 level of updraft originating air
28 ! ierrc error description
30 !!!!!!!!!!!! Variables that are on output
31 ! outt temperature tendency (K/s)
32 ! outq mixing ratio tendency (kg/kg/s)
33 ! outqc cloud water/ice tendency (kg/kg/s)
34 ! pre precip rate (mm/s)
35 ! cupclw incloud mixing ratio of cloudwater/ice (for radiation)
36 ! this needs heavy tuning factors, since cloud fraction is
37 ! not included (kg/kg)
38 ! cnvwt required for GFS physics
40 ! itf,ktf,its,ite, kts,kte are dimensions
41 ! ztexec,zqexec excess temperature and moisture for updraft
42 MODULE module_cu_gf_sh
45 USE module_cu_gf_ctrans,only: ctrans_gf
48 real, parameter:: c1_shal=0.! .0005
49 real, parameter:: g =9.81
50 real, parameter:: cp =1004.
51 real, parameter:: xlv=2.5e6
52 real, parameter:: r_v=461.
53 real, parameter:: c0_shal=.001
54 real, parameter:: fluxtune=1.5
58 SUBROUTINE CUP_gf_sh ( &
59 ! input variables, must be supplied
60 zo,T,Q,Z1,TN,QO,PO,PSUR,dhdt,kpbl,rho, &
61 hfx,qfx,xland,ichoice,tcrit,dtime, &
62 ! input variables. Ierr should be initialized to zero or larger than zero for
63 ! turning off shallow convection for grid points
64 zuo,xmb_out,kbcon,ktop,k22,ierr,ierrc, &
66 OUTT,OUTQ,OUTQC,cnvwt,pre,cupclw, &
68 num_chem,chem2d,outchemt, &
69 num_tracer,tracer2d,outtracert, &
70 numgas,chemopt,traceropt, &
71 conv_tr_wetscav,conv_tr_aqchem, &
74 ! dimesnional variables
75 itf,ktf,its,ite, kts,kte,ipr)
77 ! this module needs some subroutines from gf_deep
79 use module_cu_gf_deep,only:cup_env,cup_env_clev,get_cloud_bc,cup_minimi, &
80 get_inversion_layers,rates_up_pdf,get_cloud_bc, &
81 cup_up_aa0,cup_kbcon,get_lateral_massflux
87 logical :: MAKE_CALC_FOR_XK = .true.
88 integer, intent (in ) :: &
93 ! outtem = output temp tendency (per s)
94 ! outq = output q tendency (per s)
95 ! outqc = output qc tendency (per s)
97 real, dimension (its:ite,kts:kte) &
99 cnvwt,OUTT,OUTQ,OUTQC,cupclw,zuo
100 real, dimension (its:ite) &
103 integer, dimension (its:ite) &
104 ,intent (inout ) :: &
106 integer, dimension (its:ite) &
109 integer, dimension (its:ite) &
113 ! basic environmental input includes a flag (ierr) to turn off
114 ! convection for this call only and at that particular gridpoint
116 real, dimension (its:ite,kts:kte) &
119 real, dimension (its:ite,kts:kte) &
122 real, dimension (its:ite) &
124 xland,Z1,PSUR,hfx,qfx
130 #if ( WRF_CHEM == 1 )
131 INTEGER,INTENT(IN ) :: &
132 num_chem,num_tracer,numgas,chemopt,traceropt, &
133 conv_tr_wetscav,conv_tr_aqchem,chem_conv_tr
134 REAL,DIMENSION(its:ite , kts:kte , num_chem),INTENT(IN):: &
136 REAL,DIMENSION(its:ite , kts:kte , num_chem),INTENT(IN):: &
138 REAL,DIMENSION(its:ite , kts:kte , num_tracer),INTENT(INOUT):: &
140 REAL,DIMENSION(its:ite , kts:kte , num_tracer),INTENT(INOUT):: &
143 real,dimension(its:ite,kts:kte) :: tempco
144 real,dimension(its:ite,kts:kte) :: &
145 zdo,clw_all,pwdo,dd_massentro,dd_massdetro
146 real,dimension(its:ite):: &
148 integer,dimension(its:ite):: &
153 !***************** the following are your basic environmental
154 ! variables. They carry a "_cup" if they are
155 ! on model cloud levels (staggered). They carry
156 ! an "o"-ending (z becomes zo), if they are the forced
159 ! z = heights of model levels
160 ! q = environmental mixing ratio
161 ! qes = environmental saturation mixing ratio
162 ! t = environmental temp
163 ! p = environmental pressure
164 ! he = environmental moist static energy
165 ! hes = environmental saturation moist static energy
166 ! z_cup = heights of model cloud levels
167 ! q_cup = environmental q on model cloud levels
168 ! qes_cup = saturation q on model cloud levels
169 ! t_cup = temperature (Kelvin) on model cloud levels
170 ! p_cup = environmental pressure
171 ! he_cup = moist static energy on model cloud levels
172 ! hes_cup = saturation moist static energy on model cloud levels
173 ! gamma_cup = gamma on model cloud levels
175 ! entr = entrainment rate
177 ! gamma_cup = gamma on model cloud levels
178 ! qrch = saturation q in cloud
179 ! pwev = total normalized integrated evaoprate (I2)
180 ! z1 = terrain elevation
181 ! psur = surface pressure
182 ! zu = updraft normalized mass flux
183 ! kbcon = LFC of parcel from k22
184 ! k22 = updraft originating level
185 ! ichoice = flag if only want one closure (usually set to zero!)
187 ! ktop = cloud top (output)
188 ! xmb = total base mass flux
189 ! hc = cloud moist static energy
190 ! hkb = moist static energy at originating level
192 real, dimension (its:ite,kts:kte) :: &
193 entr_rate_2d,he,hes,qes,z, &
195 xhe,xhes,xqes,xz,xt,xq, &
196 qes_cup,q_cup,he_cup,hes_cup,z_cup,p_cup,gamma_cup,t_cup, &
197 qeso_cup,qo_cup,heo_cup,heso_cup,zo_cup,po_cup,gammao_cup, &
199 xqes_cup,xq_cup,xhe_cup,xhes_cup,xz_cup, &
201 dbyo,qco,pwo,hco,qrco, &
204 ! cd = detrainment function for updraft
205 ! dellat = change of temperature per unit mass flux of cloud ensemble
206 ! dellaq = change of q per unit mass flux of cloud ensemble
207 ! dellaqc = change of qc per unit mass flux of cloud ensemble
209 cd,DELLAH,DELLAQ,DELLAT,DELLAQC
211 ! aa0 cloud work function for downdraft
212 ! aa0 = cloud work function without forcing effects
213 ! aa1 = cloud work function with forcing effects
214 ! xaa0 = cloud work function with cloud effects (ensemble dependent)
216 real, dimension (its:ite) :: &
217 zws,ztexec,zqexec,pre,AA1,AA0,XAA0,HKB, &
218 flux_tun,HKBO,XHKB, &
219 rand_vmas,xmbmax,XMB, &
222 integer, dimension (its:ite) :: &
223 kstabi,xland1,KBMAX,ktopx
229 cap_maxs,trash,trash2,frh
231 real buo_flux,pgeoh,dp,entup,detup,totmas
233 real xff_shal(3),blqe,xkshal
234 character*50 :: ierrc(its:ite)
235 real, dimension (its:ite,kts:kte) :: &
236 up_massentr,up_massdetr,up_massentro,up_massdetro
237 real :: C_up,x_add,qaver
238 real, dimension (its:ite,kts:kte) :: dtempdz
239 integer, dimension (its:ite,kts:kte) :: k_inv_layers
240 integer, dimension (its:ite) :: start_level
245 xland1(i)=int(xland(i)+.001) ! 1.
247 if(xland(i).gt.1.5 .or. xland(i).lt.0.5)then
253 cap_max_increment(i)=25.
255 entr_rate(i) = 9.e-5 ! 1.75e-3 ! 1.2e-3 ! .2/50.
258 !--- initial entrainment rate (these may be changed later on in the
263 !--- initial detrainmentrates
273 cd(i,k)=1.*entr_rate(i)
279 !--- max/min allowed value for epsilon (ratio downdraft base mass flux/updraft
281 !--- minimum depth (m), clouds must have
284 !--- maximum depth (mb) of capping
285 !--- inversion (larger cap = no convection)
300 !- buoyancy flux (H+LE)
301 buo_flux= (hfx(i)/cp+0.608*t(i,1)*qfx(i)/xlv)/rho(i,1)
303 !-convective-scale velocity w*
304 zws(i) = max(0.,flux_tun(i)*0.41*buo_flux*zo(i,2)*g/t(i,1))
305 if(zws(i) > TINY(pgeoh)) then
306 !-convective-scale velocity w*
307 zws(i) = 1.2*zws(i)**.3333
308 !- temperature excess
309 ztexec(i) = MAX(flux_tun(i)*hfx(i)/(rho(i,1)*zws(i)*cp),0.0)
311 zqexec(i) = MAX(flux_tun(i)*qfx(i)/xlv/(rho(i,1)*zws(i)),0.)
313 !- zws for shallow convection closure (Grant 2001)
315 zws(i) = max(0.,flux_tun(i)*0.41*buo_flux*zo(i,kpbl(i))*g/t(i,kpbl(i)))
316 zws(i) = 1.2*zws(i)**.3333
317 zws(i) = zws(i)*rho(i,kpbl(i)) !check if zrho is correct
322 !--- max height(m) above ground where updraft air can originate
326 !--- calculate moist static energy, heights, qes
328 call cup_env(z,qes,he,hes,t,q,po,z1, &
329 psur,ierr,tcrit,-1, &
332 call cup_env(zo,qeso,heo,heso,tn,qo,po,z1, &
333 psur,ierr,tcrit,-1, &
338 !--- environmental values on cloud levels
340 call cup_env_clev(t,qes,q,he,hes,z,po,qes_cup,q_cup,he_cup, &
341 hes_cup,z_cup,p_cup,gamma_cup,t_cup,psur, &
345 call cup_env_clev(tn,qeso,qo,heo,heso,zo,po,qeso_cup,qo_cup, &
346 heo_cup,heso_cup,zo_cup,po_cup,gammao_cup,tn_cup,psur, &
354 if(zo_cup(i,k).gt.zkbmax+z1(i))then
361 kbmax(i)=min(kbmax(i),ktf/2)
368 !------- DETERMINE LEVEL WITH HIGHEST MOIST STATIC ENERGY CONTENT - K22
371 if(kpbl(i).gt.3)cap_max(i)=po_cup(i,kpbl(i))
373 k22(i)=maxloc(HEO_CUP(i,2:kbmax(i)),1)
375 IF(K22(I).GT.KBMAX(i))then
377 ierrc(i)="could not find k22"
385 !--- DETERMINE THE LEVEL OF CONVECTIVE CLOUD BASE - KBCON
389 x_add = xlv*zqexec(i)+cp*ztexec(i)
390 call get_cloud_bc(kte,he_cup (i,1:kte),hkb (i),k22(i),x_add)
391 call get_cloud_bc(kte,heo_cup(i,1:kte),hkbo(i),k22(i),x_add)
395 !JOE-Georg and Saulo's new idea:
398 dbyo(i,k)= 0. !hkbo(i)-heso_cup(i,k)
402 call cup_kbcon(ierrc,cap_max_increment,5,k22,kbcon,heo_cup,heso_cup, &
403 hkbo,ierr,kbmax,po_cup,cap_max, &
407 z_cup,entr_rate,heo,0)
408 !--- get inversion layers for cloud tops
409 call cup_minimi(HEso_cup,Kbcon,kbmax,kstabi,ierr, &
413 call get_inversion_layers(ierr,p_cup,t_cup,z_cup,q_cup,qes_cup,k_inv_layers,&
414 kbcon,kstabi,dtempdz,itf,ktf,its,ite, kts,kte)
418 entr_rate_2d(i,:)=entr_rate(i)
420 start_level(i)=k22(i)
421 x_add = xlv*zqexec(i)+cp*ztexec(i)
422 call get_cloud_bc(kte,he_cup (i,1:kte),hkb (i),k22(i),x_add)
423 if(kbcon(i).gt.ktf-4)then
427 frh = 2.*min(qo_cup(i,k)/qeso_cup(i,k),1.)
428 entr_rate_2d(i,k)=entr_rate(i)*(2.3-frh)
429 cd(i,k)=entr_rate_2d(i,k)
432 ! first estimate for shallow convection
435 ! if(k_inv_layers(i,1).gt.0)then
436 !! ktop(i)=min(k_inv_layers(i,1),k_inv_layers(i,2))
437 if(k_inv_layers(i,1).gt.0 .and. &
438 (po_cup(i,kbcon(i))-po_cup(i,k_inv_layers(i,1))).lt.200.)then
439 ktop(i)=k_inv_layers(i,1)
442 if((po_cup(i,kbcon(i))-po_cup(i,k)).gt.200.)then
450 ! get normalized mass flux profile
451 call rates_up_pdf(rand_vmas,ipr,'shallow',ktop,ierr,po_cup,entr_rate_2d,hkbo,heo,heso_cup,zo_cup, &
452 xland1,kstabi,k22,kbcon,its,ite,itf,kts,kte,ktf,zuo,kpbl,ktopx,ktopx,kbcon)
455 ! do k=maxloc(zuo(i,:),1),1,-1 ! ktop(i)-1,1,-1
456 ! if(zuo(i,k).lt.1.e-6)then
458 ! start_level(i)=k22(i)
469 do k=maxloc(zuo(i,:),1),ktop(i)
470 if(zuo(i,k).lt.1.e-6)then
488 ! calculate mass entrainment and detrainment
490 CALL get_lateral_massflux(itf,ktf, its,ite, kts,kte &
491 ,ierr,ktop,zo_cup,zuo,cd,entr_rate_2d &
492 ,up_massentro, up_massdetro ,up_massentr, up_massdetr &
493 ,'shallow',kbcon,k22)
506 IF(ierr(I) /= 0) cycle
507 do k=1,start_level(i)-1
509 hco(i,k)=heo_cup(i,k)
519 IF(ierr(I) /= 0) cycle
520 do k=start_level(i)+1,ktop(i)
521 hc(i,k)=(hc(i,k-1)*zu(i,k-1)-.5*up_massdetr(i,k-1)*hc(i,k-1)+ &
522 up_massentr(i,k-1)*he(i,k-1)) / &
523 (zu(i,k-1)-.5*up_massdetr(i,k-1)+up_massentr(i,k-1))
524 dby(i,k)=max(0.,hc(i,k)-hes_cup(i,k))
525 hco(i,k)=(hco(i,k-1)*zuo(i,k-1)-.5*up_massdetro(i,k-1)*hco(i,k-1)+ &
526 up_massentro(i,k-1)*heo(i,k-1)) / &
527 (zuo(i,k-1)-.5*up_massdetro(i,k-1)+up_massentro(i,k-1))
528 dbyo(i,k)=hco(i,k)-heso_cup(i,k)
529 DZ=Zo_cup(i,K+1)-Zo_cup(i,K)
530 dbyt(i,k)=dbyt(i,k-1)+dbyo(i,k)*dz
532 ki=maxloc(dbyt(i,:),1)
533 if(ktop(i).gt.ki+1)then
535 zuo(i,ktop(i)+1:ktf)=0.
536 zu(i,ktop(i)+1:ktf)=0.
537 cd(i,ktop(i)+1:ktf)=0.
538 up_massdetro(i,ktop(i))=zuo(i,ktop(i))
539 ! up_massentro(i,ktop(i))=0.
540 up_massentro(i,ktop(i):ktf)=0.
541 up_massdetro(i,ktop(i)+1:ktf)=0.
542 entr_rate_2d(i,ktop(i)+1:ktf)=0.
547 if(ktop(i).lt.kbcon(i)+1)then
549 ierrc(i)='ktop is less than kbcon+1'
552 if(ktop(i).gt.ktf-2)then
554 ierrc(i)="ktop is larger than ktf-2"
558 call get_cloud_bc(kte,qo_cup (i,1:kte),qaver,k22(i))
559 qaver = qaver + zqexec(i)
560 do k=1,start_level(i)-1
561 qco (i,k)= qo_cup(i,k)
566 do k=start_level(i)+1,ktop(i)
567 trash=QESo_cup(I,K)+(1./XLV)*(GAMMAo_cup(i,k) &
568 /(1.+GAMMAo_cup(i,k)))*DBYo(I,K)
569 !- total water liq+vapour
570 trash2 = qco(i,k-1) ! +qrco(i,k-1)
571 qco (i,k)= (trash2* ( zuo(i,k-1)-0.5*up_massdetr(i,k-1)) + &
572 up_massentr(i,k-1)*qo(i,k-1)) / &
573 (zuo(i,k-1)-.5*up_massdetr(i,k-1)+up_massentr(i,k-1))
575 if(qco(i,k)>=trash ) then
576 DZ=Z_cup(i,K)-Z_cup(i,K-1)
578 qrco(i,k)= (qco(i,k)-trash)/(1.+(c0_shal+c1_shal)*dz)
579 ! qrco(i,k)= (qco(i,k)-trash)/(1.+c0_shal*dz)
580 pwo(i,k)=c0_shal*dz*qrco(i,k)*zuo(i,k)
582 qco (i,k)= trash+qrco(i,k)
587 cupclw(i,k)=qrco(i,k)
591 do k=k22(i)+1,ktop(i)
592 dp=100.*(po_cup(i,k)-po_cup(i,k+1))
593 cnvwt(i,k)=zuo(i,k)*cupclw(i,k)*g/dp
594 trash2=trash2+entr_rate_2d(i,k)
595 qco(i,k)=qco(i,k)-qrco(i,k)
597 do k=k22(i)+1,max(kbcon(i),k22(i)+1)
598 trash=trash+entr_rate_2d(i,k)
601 hc (i,k)=hes_cup (i,k)
602 hco (i,k)=heso_cup(i,k)
603 qco (i,k)=qeso_cup(i,k)
613 !--- calculate workfunctions for updrafts
615 IF(MAKE_CALC_FOR_XK) THEN
616 call cup_up_aa0(aa0,z,zu,dby,GAMMA_CUP,t_cup, &
618 itf,ktf, its,ite, kts,kte)
619 call cup_up_aa0(aa1,zo,zuo,dbyo,GAMMAo_CUP,tn_cup, &
621 itf,ktf, its,ite, kts,kte)
626 ierrc(i)="cloud work function zero"
631 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
632 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
635 !--- change per unit mass that a model cloud would modify the environment
637 !--- 1. in bottom layer
646 !---------------------------------------------- cloud level ktop
648 !- - - - - - - - - - - - - - - - - - - - - - - - model level ktop-1
656 !---------------------------------------------- cloud level k+2
658 !- - - - - - - - - - - - - - - - - - - - - - - - model level k+1
660 !---------------------------------------------- cloud level k+1
662 !- - - - - - - - - - - - - - - - - - - - - - - - model level k
664 !---------------------------------------------- cloud level k
677 !---------------------------------------------- cloud level 3
679 !- - - - - - - - - - - - - - - - - - - - - - - - model level 2
681 !---------------------------------------------- cloud level 2
683 !- - - - - - - - - - - - - - - - - - - - - - - - model level 1
688 ! entrainment/detrainment for updraft
689 entup=up_massentro(i,k)
690 detup=up_massdetro(i,k)
691 totmas=detup-entup+zuo(i,k+1)-zuo(i,k)
692 if(abs(totmas).gt.1.e-6)then
693 write(0,*)'*********************',i,k,totmas
694 write(0,*)k22(i),kbcon(i),ktop(i)
696 dp=100.*(po_cup(i,k)-po_cup(i,k+1))
697 dellah(i,k) =-(zuo(i,k+1)*(hco(i,k+1)-heo_cup(i,k+1) )- &
698 zuo(i,k )*(hco(i,k )-heo_cup(i,k ) ))*g/dp
700 !-- take out cloud liquid water for detrainment
701 dz=zo_cup(i,k+1)-zo_cup(i,k)
703 dellaqc(i,k)= zuo(i,k)*c1_shal*qrco(i,k)*dz/dp*g ! detup*0.5*(qrco(i,k+1)+qrco(i,k)) *g/dp
705 dellaqc(i,k)= detup*qrco(i,k) *g/dp
708 !-- condensation source term = detrained + flux divergence of
709 !-- cloud liquid water (qrco)
710 C_up = dellaqc(i,k)+(zuo(i,k+1)* qrco(i,k+1) - &
711 zuo(i,k )* qrco(i,k ) )*g/dp
712 ! C_up = dellaqc(i,k)
713 !-- water vapor budget (flux divergence of Q_up-Q_env - condensation
715 dellaq(i,k) =-(zuo(i,k+1)*(qco(i,k+1)-qo_cup(i,k+1) ) - &
716 zuo(i,k )*(qco(i,k )-qo_cup(i,k ) ) )*g/dp &
717 - C_up - 0.5*(pwo (i,k)+pwo (i,k+1))*g/dp
723 !--- using dellas, calculate changed environmental profiles
731 xhe(i,k)=dellah(i,k)*mbdt+heo(i,k)
732 xq (i,k)=max(1.e-16,(dellaq(i,k)+dellaqc(i,k))*mbdt+qo(i,k))
733 dellat(i,k)=(1./cp)*(dellah(i,k)-xlv*(dellaq(i,k)))
734 xt (i,k)= (-dellaqc(i,k)*xlv/cp+dellat(i,k))*mbdt+tn(i,k)
735 xt (i,k)= max(190.,xt(i,k))
741 ! xhkb(i)=hkbo(i)+(dellah(i,k22(i)))*mbdt
742 xhe(i,ktf)=heo(i,ktf)
749 IF(MAKE_CALC_FOR_XK) THEN
751 !--- calculate moist static energy, heights, qes
753 call cup_env(xz,xqes,xhe,xhes,xt,xq,po,z1, &
754 psur,ierr,tcrit,-1, &
758 !--- environmental values on cloud levels
760 call cup_env_clev(xt,xqes,xq,xhe,xhes,xz,po,xqes_cup,xq_cup, &
761 xhe_cup,xhes_cup,xz_cup,po_cup,gamma_cup,xt_cup,psur, &
767 !**************************** static control
776 x_add = xlv*zqexec(i)+cp*ztexec(i)
777 call get_cloud_bc(kte,xhe_cup (i,1:kte),xhkb (i),k22(i),x_add)
778 do k=1,start_level(i)-1
779 xhc(i,k)=xhe_cup(i,k)
789 xzu(i,1:ktf)=zuo(i,1:ktf)
790 do k=start_level(i)+1,ktop(i)
791 xhc(i,k)=(xhc(i,k-1)*xzu(i,k-1)-.5*up_massdetro(i,k-1)*xhc(i,k-1)+ &
792 up_massentro(i,k-1)*xhe(i,k-1)) / &
793 (xzu(i,k-1)-.5*up_massdetro(i,k-1)+up_massentro(i,k-1))
794 xdby(i,k)=xhc(i,k)-xhes_cup(i,k)
797 xHC (i,K)=xhes_cup(i,k)
805 !--- workfunctions for updraft
807 call cup_up_aa0(xaa0,xz,xzu,xdby,GAMMA_CUP,xt_cup, &
815 ! now for shallow forcing
822 ! xmbmax(i)=100.*(p(i,kbcon(i))-p(i,kbcon(i)+1))/(g*dtime)
824 !-stabilization closure
825 xkshal=(xaa0(i)-aa1(i))/mbdt
826 if(xkshal.le.0.and.xkshal.gt.-.01*mbdt) &
828 if(xkshal.gt.0.and.xkshal.lt.1.e-2) &
831 xff_shal(1)=max(0.,-(aa1(i)-aa0(i))/(xkshal*dtime))
833 !- closure from Grant (2001)
834 xff_shal(2)=.03*zws(i)
835 !- boundary layer QE closure
839 blqe=blqe+100.*dhdt(i,k)*(po_cup(i,k)-po_cup(i,k+1))/g
841 trash=max((hc(i,kbcon(i))-he_cup(i,kbcon(i))),1.e1)
842 xff_shal(3)=max(0.,blqe/trash)
843 xff_shal(3)=min(xmbmax(i),xff_shal(3))
845 xmb(i)=(xff_shal(1)+xff_shal(2)+xff_shal(3))/3.
846 xmb(i)=min(xmbmax(i),xmb(i))
847 if(ichoice > 0)xmb(i)=min(xmbmax(i),xff_shal(ichoice))
861 else if(ierr(i).eq.0)then
868 outt (i,k)= dellat (i,k)*xmb(i)
869 outq (i,k)= dellaq (i,k)*xmb(i)
870 outqc(i,k)= dellaqc(i,k)*xmb(i)
871 pre (i) = pre(i)+pwo(i,k)*xmb(i)
876 #if ( WRF_CHEM == 1 )
877 !--- calculate in-cloud/updraft air temperature
881 tempco(i,k)=(1./cp)*(hco(i,k)-g*zo_cup(i,k)-xlv*qco(i,k))
885 tempco(i,k)=tn_cup(i,k)
903 if ((chem_conv_tr>0).and.(chemopt>0)) then
904 call ctrans_gf(numgas,num_chem,chem2d,chemopt,0 &
905 ,outchemt,conv_tr_wetscav,conv_tr_aqchem &
907 ,zuo,zdo,pwo,pwdo,pwevo,pwavo &
908 ,up_massentro,up_massdetro &
909 ,dd_massentro,dd_massdetro &
911 ,ktop,k22,kbcon,jmin &
913 ,itf,ktf,its,ite,kts,kte &
916 if ((chem_conv_tr>0).and.(traceropt>0)) then
917 call ctrans_gf(0,num_tracer,tracer2d,0,traceropt &
920 ,zuo,zdo,pwo,pwdo,pwevo,pwavo &
921 ,up_massentro,up_massdetro &
922 ,dd_massentro,dd_massdetro &
924 ,ktop,k22,kbcon,jmin &
926 ,itf,ktf,its,ite,kts,kte &
932 !--------------------------done------------------------------
935 END SUBROUTINE CUP_gf_sh
936 END MODULE module_cu_gf_sh