1 !WRF:MODEL_LAYER:PHYSICS
8 !-------------------------------------------------------------
13 ,dz8w,p8w,XLV,CP,G,r_v &
15 ,CU_ACT_FLAG,warm_rain &
16 ,APR_GR,APR_W,APR_MC,APR_ST,APR_AS &
17 ,APR_CAPMA,APR_CAPME,APR_CAPMI &
18 ,MASS_FLUX,XF_ENS,PR_ENS,HT,XLAND,gsw,edt_out &
19 ,GDC,GDC2 ,kpbl,k22_shallow,kbcon_shallow &
20 ,ktop_shallow,xmb_shallow,ktop_deep &
21 ,cugd_tten,cugd_qvten ,cugd_qcten &
22 ,cugd_ttens,cugd_qvtens,cugd_avedx,imomentum &
23 ,ensdim,maxiens,maxens,maxens2,maxens3,ichoice &
24 ,ishallow_g3,ids,ide, jds,jde, kds,kde &
25 ,ims,ime, jms,jme, kms,kme &
26 ,ips,ipe, jps,jpe, kps,kpe &
27 ,its,ite, jts,jte, kts,kte &
28 ,periodic_x,periodic_y &
29 ,RQVCUTEN,RQCCUTEN,RQICUTEN &
30 ,RQVFTEN,RTHFTEN,RTHCUTEN &
32 ,F_QV ,F_QC ,F_QR ,F_QI ,F_QS &
33 #if ( WRF_DFI_RADAR == 1 )
34 ! Optional CAP suppress option
35 ,do_capsuppress,cap_suppress_loc &
38 !-------------------------------------------------------------
40 !-------------------------------------------------------------
41 INTEGER, INTENT(IN ) :: &
42 ids,ide, jds,jde, kds,kde, &
43 ims,ime, jms,jme, kms,kme, &
44 ips,ipe, jps,jpe, kps,kpe, &
45 its,ite, jts,jte, kts,kte
46 LOGICAL periodic_x,periodic_y
47 integer, parameter :: ens4_spread = 3 ! max(3,cugd_avedx)
48 integer, parameter :: ens4=ens4_spread*ens4_spread
50 integer, intent (in ) :: &
51 ensdim,maxiens,maxens,maxens2,maxens3,ichoice
53 INTEGER, INTENT(IN ) :: ITIMESTEP,cugd_avedx, &
55 LOGICAL, INTENT(IN ) :: warm_rain
57 REAL, INTENT(IN ) :: XLV, R_v
58 REAL, INTENT(IN ) :: CP,G
60 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ) , &
72 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ) , &
77 REAL, DIMENSION( ims:ime , jms:jme ),INTENT(IN) :: GSW,HT,XLAND
78 INTEGER, DIMENSION( ims:ime , jms:jme ),INTENT(IN) :: KPBL
79 INTEGER, DIMENSION( ims:ime , jms:jme ),INTENT(INOUT) :: k22_shallow, &
80 kbcon_shallow,ktop_shallow
81 INTEGER, DIMENSION( ims:ime , jms:jme ),INTENT( OUT) :: ktop_deep
83 REAL, INTENT(IN ) :: DT, DX
86 REAL, DIMENSION( ims:ime , jms:jme ), &
87 INTENT(INOUT) :: pratec,RAINCV, MASS_FLUX, &
88 APR_GR,APR_W,APR_MC,APR_ST,APR_AS, &
89 edt_out,APR_CAPMA,APR_CAPME,APR_CAPMI, &
92 ! REAL, DIMENSION( ims:ime , jms:jme ) :: & !, INTENT(INOUT) :: &
93 ! HTOP, &! highest model layer penetrated by cumulus since last reset in radiation_driver
94 ! HBOT ! lowest model layer penetrated by cumulus since last reset in radiation_driver
95 ! ! HBOT>HTOP follow physics leveling convention
97 LOGICAL, DIMENSION( ims:ime , jms:jme ), &
98 INTENT(INOUT) :: CU_ACT_FLAG
103 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), &
105 INTENT(INOUT) :: RTHFTEN, &
106 cugd_tten,cugd_qvten,cugd_qcten, &
107 cugd_ttens,cugd_qvtens, &
110 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), &
120 ! Flags relating to the optional tendency arrays declared above
121 ! Models that carry the optional tendencies will provdide the
122 ! optional arguments at compile time; these flags all the model
123 ! to determine at run-time whether a particular tracer is in
126 LOGICAL, OPTIONAL :: &
134 #if ( WRF_DFI_RADAR == 1 )
136 ! option of cap suppress:
137 ! do_capsuppress = 1 do
138 ! do_capsuppress = other don't
141 INTEGER, INTENT(IN ) ,OPTIONAL :: do_capsuppress
142 REAL, DIMENSION( ims:ime, jms:jme ),INTENT(IN ),OPTIONAL :: cap_suppress_loc
143 REAL, DIMENSION( its:ite ) :: cap_suppress_j
148 real, dimension(ims:ime,jms:jme,1:ensdim),intent(inout) :: &
150 real, dimension ( its:ite , jts:jte , 1:ensdim) :: &
151 massflni,xfi_ens,pri_ens
152 REAL, DIMENSION( its:ite , jts:jte ) :: MASSI_FLX, &
153 APRi_GR,APRi_W,APRi_MC,APRi_ST,APRi_AS, &
154 edti_out,APRi_CAPMA,APRi_CAPME,APRi_CAPMI,gswi
155 real, dimension (its:ite,kts:kte) :: &
156 SUBT,SUBQ,OUTT,OUTQ,OUTQC,phh,subm,cupclw,dhdt, &
158 real, dimension (its:ite) :: &
159 pret, ter11, aa0, fp,xlandi
161 integer, dimension (its:ite) :: &
162 kbcon, ktop,kpbli,k22s,kbcons,ktops
164 integer, dimension (its:ite,jts:jte) :: &
166 integer :: iens,ibeg,iend,jbeg,jend,n,nn,ens4n
167 integer :: ibegh,iendh,jbegh,jendh
168 integer :: ibegc,iendc,jbegc,jendc
171 ! basic environmental input includes moisture convergence (mconv)
172 ! omega (omeg), windspeed (us,vs), and a flag (aaeq) to turn off
173 ! convection for this call only and at that particular gridpoint
175 real, dimension (its:ite,kts:kte) :: &
176 T2d,q2d,PO,P2d,US,VS,tn,qo,tshall,qshall
177 real, dimension (ips-2:ipe+2,kps:kpe,jps-2:jpe+2) :: &
179 real, dimension (its:ite,kts:kte,1:ens4) :: &
181 real, dimension (its:ite) :: &
182 Z1,PSUR,AAEQ,direction,cuten,umean,vmean,pmean,xmbs
183 real, dimension (its:ite,1:ens4) :: &
186 INTEGER :: i,j,k,ICLDCK,ipr,jpr
187 REAL :: tcrit,tscl_KF,dp,dq,sub_spread,subcenter
188 INTEGER :: itf,jtf,ktf,iss,jss,nbegin,nend
189 INTEGER :: high_resolution
190 REAL :: rkbcon,rktop !-lxz
192 real, dimension (its:ite) :: tkm
194 ! A. Betts for shallow convection: suggestion for the KF timescale < DELTAX / 25 m/s
197 ! write(0,*)'ishallow = ',ishallow_g3
199 if(cugd_avedx.gt.1) high_resolution=1
201 ! subcenter=1./float(cugd_avedx)
202 sub_spread=max(1.,float(cugd_avedx*cugd_avedx-1))
203 sub_spread=(1.-subcenter)/sub_spread
209 ! if(itimestep.eq.8)then
213 IF ( periodic_x ) THEN
224 IF ( periodic_y ) THEN
253 if(high_resolution.eq.1)then
255 ! calculate these on the halo...the incominh tendencies have been exchanged on a 24pt halo
256 ! only neede for high resolution run
262 if(its.eq.ips)ibegh=max(its-1,ids)
263 if(jts.eq.jps)jbegh=max(jts-1,jds)
264 if(jte.eq.jpe)jendh=min(jte+1,jde-1)
265 if(ite.eq.ipe)iendh=min(ite+1,ide-1)
269 ave_f_t(i,k,j)=(rthften(i-1,k,j-1)+rthften(i-1,k,j) + rthften(i-1,k,j+1)+ &
270 rthften(i,k,j-1) +rthften(i,k,j) +rthften(i,k,j+1)+ &
271 rthften(i+1,k,j-1) +rthften(i+1,k,j) +rthften(i+1,k,j+1))/9.
272 ave_f_q(i,k,j)=(rqvften(i-1,k,j-1)+rqvften(i-1,k,j) + rqvften(i-1,k,j+1)+ &
273 rqvften(i,k,j-1) +rqvften(i,k,j) +rqvften(i,k,j+1)+ &
274 rqvften(i+1,k,j-1) +rqvften(i+1,k,j) +rqvften(i+1,k,j+1))/9.
275 ! ave_f_t(i,k,j)=rthften(i,k,j)
276 ! ave_f_q(i,k,j)=rqvften(i,k,j)
287 ! xfi_ens(i,j,n)=xf_ens(i,j,n)
288 ! pri_ens(i,j,n)=pr_ens(i,j,n)
306 APRi_GR(i,j)=apr_gr(i,j)
307 APRi_w(i,j)=apr_w(i,j)
308 APRi_mc(i,j)=apr_mc(i,j)
309 APRi_st(i,j)=apr_st(i,j)
310 APRi_as(i,j)=apr_as(i,j)
311 APRi_capma(i,j)=apr_capma(i,j)
312 APRi_capme(i,j)=apr_capme(i,j)
313 APRi_capmi(i,j)=apr_capmi(i,j)
314 CU_ACT_FLAG(i,j) = .true.
321 cugd_qvtens(i,k,j)=0.
342 ! put hydrostatic pressure on half levels
350 PSUR(I)=p8w(I,1,J)*.01
351 ! PSUR(I)=p(I,1,J)*.01
361 ! if(j.eq.jpr)write(0,*)'psur(ipr),ter11(ipr),kpbli(ipr)'
362 ! if(j.eq.jpr)write(0,*)psur(ipr),ter11(ipr),kpbli(ipr),r_v
372 IF(Q2d(I,K).LT.1.E-08)Q2d(I,K)=1.E-08
380 TN(I,K)=t2d(i,k)+RTHFTEN(i,k,j)*dt
381 QO(I,K)=q2d(i,k)+RQVFTEN(i,k,j)*dt
382 TSHALL(I,K)=t2d(i,k)+RTHBLTEN(i,k,j)*pi(i,k,j)*dt
383 DHDT(I,K)=cp*RTHBLTEN(i,k,j)*pi(i,k,j)+ XLV*RQVBLTEN(i,k,j)
384 QSHALL(I,K)=q2d(i,k)+RQVBLTEN(i,k,j)*dt
385 if(high_resolution.eq.1)then
386 TN(I,K)=t2d(i,k)+ave_f_t(i,k,j)*dt
387 QO(I,K)=q2d(i,k)+ave_f_q(i,k,j)*dt
389 IF(TN(I,K).LT.200.)TN(I,K)=T2d(I,K)
390 IF(QO(I,K).LT.1.E-08)QO(I,K)=1.E-08
391 ! if(i.eq.ipr.and.j.eq.jpr)then
392 ! write(0,123)k,p2d(i,k),t2d(i,k),tn(i,k),q2d(i,k),QO(i,k),RTHBLTEN(i,k,j),RQVBLTEN(i,k,j)
396 123 format(1x,i2,f8.0,1x,2(1x,f8.3),4(1x,e12.4))
400 if(ens4_spread.gt.1)then
401 nbegin=-ens4_spread/2
413 omeg(I,K,ens4n)= -g*rho(i,k,j)*w(iss,k,jss)
414 ! omeg(I,K,ens4n)= -g*rho(i,k,j)*w(i,k,j)
415 Tx(I,K,ens4n)=t2d(i,k)+RTHFTEN(iss,k,jss)*dt
416 ! Tx(I,K,ens4n)=t2d(i,k)+RTHFTEN(i,k,j)*dt
417 if(high_resolution.eq.1)Tx(I,K,ens4n)=t2d(i,k)+ave_f_t(iss,k,jss)*dt
418 IF(Tx(I,K,ens4n).LT.200.)Tx(I,K,ens4n)=T2d(I,K)
419 Qx(I,K,ens4n)=q2d(i,k)+RQVFTEN(iss,k,jss)*dt
420 Qx(I,K,ens4n)=q2d(i,k)+RQVFTEN(i,k,j)*dt
421 if(high_resolution.eq.1)qx(I,K,ens4n)=q2d(i,k)+ave_f_q(iss,k,jss)*dt
422 IF(Qx(I,K,ens4n).LT.1.E-08)Qx(I,K,ens4n)=1.E-08
429 if((p2d(i,1)-p2d(i,k)).gt.150.and.p2d(i,k).gt.300)then
430 dp=-.5*(p2d(i,k+1)-p2d(i,k-1))
431 umean(i)=umean(i)+us(i,k)*dp
432 vmean(i)=vmean(i)+vs(i,k)*dp
438 umean(i)=umean(i)/pmean(i)
439 vmean(i)=vmean(i)/pmean(i)
440 direction(i)=(atan2(umean(i),vmean(i))+3.1415926)*57.29578
441 if(direction(i).gt.360.)direction(i)=direction(i)-360.
446 dq=(q2d(i,k+1)-q2d(i,k))
447 mconv(i,n)=mconv(i,n)+omeg(i,k,n)*dq/g
453 if(mconv(i,n).lt.0.)mconv(i,n)=0.
457 !---- CALL CUMULUS PARAMETERIZATION
459 #if ( WRF_DFI_RADAR == 1 )
460 if(do_capsuppress == 1 ) then
462 cap_suppress_j(i)=cap_suppress_loc(i,j)
466 CALL CUP_enss_3d(outqc,j,AAEQ,T2d,Q2d,TER11,subm,TN,QO,PO,PRET,&
467 P2d,OUTT,OUTQ,DT,itimestep,tkm,PSUR,US,VS,tcrit,iens,tx,qx, &
468 tshall,qshall,kpbli,DHDT,outts,outqs,tscl_kf, &
469 k22s,kbcons,ktops,xmbs, &
470 mconv,massflni,iact_old_gr,omeg,direction,MASSi_FLX, &
471 maxiens,maxens,maxens2,maxens3,ensdim, &
472 APRi_GR,APRi_W,APRi_MC,APRi_ST,APRi_AS, &
473 APRi_CAPMA,APRi_CAPME,APRi_CAPMI,kbcon,ktop,cupclw, &
474 xfi_ens,pri_ens,XLANDi,gswi,edti_out,subt,subq, &
475 ! ruc lv_p,rv_p,cpd_p,g0_p,ichoice,ipr,jpr, &
476 xlv,r_v,cp,g,ichoice,ipr,jpr,ens4,high_resolution, &
477 ishallow_g3,itf,jtf,ktf, &
478 its,ite, jts,jte, kts,kte &
479 #if ( WRF_DFI_RADAR == 1 )
480 ,do_capsuppress,cap_suppress_j &
485 if(j.lt.jbegc.or.j.gt.jendc)go to 100
487 xmb_shallow(i,j)=xmbs(i)
488 k22_shallow(i,j)=k22s(i)
489 kbcon_shallow(i,j)=kbcons(i)
490 ktop_shallow(i,j)=ktops(i)
491 ktop_deep(i,j)=ktop(i)
493 if(pret(i).gt.0.)then
495 ! raincv(i,j)=pret(i)*dt
498 ! if(j.eq.jpr)write(0,*)'precip,ktop,kbcon = ',pret(ipr),ktop(ipr),kbcon(ipr)
501 cugd_ttens(I,K,J)=subt(i,k)*cuten(i)*sub_spread
502 cugd_qvtens(I,K,J)=subq(i,k)*cuten(i)*sub_spread
503 ! cugd_tten(I,K,J)=outt(i,k)*cuten(i)
504 ! cugd_qvten(I,K,J)=outq(i,k)*cuten(i)
505 cugd_tten(I,K,J)=outts(i,k)+outt(i,k)*cuten(i)
506 cugd_qvten(I,K,J)=outqs(i,k)+outq(i,k)*cuten(i)
507 cugd_qcten(I,K,J)=outqc(i,k)*cuten(i)
508 ! if(i.eq.ipr.and.j.eq.jpr)then
509 ! write(0,*)subt(i,k)+outt(i,k),subq(i,k)+outq(i,k),outts(i,k),outqs(i,k)
514 if(pret(i).gt.0.)then
515 raincv(i,j)=pret(i)*dt
517 rkbcon = kte+kts - kbcon(i)
518 rktop = kte+kts - ktop(i)
519 if (ktop(i) > HTOP(i,j)) HTOP(i,j) = ktop(i)+.001
520 if (kbcon(i) < HBOT(i,j)) HBOT(i,j) = kbcon(i)+.001
525 xf_ens(i,j,n)=xfi_ens(i,j,n)
526 pr_ens(i,j,n)=pri_ens(i,j,n)
530 APR_GR(i,j)=apri_gr(i,j)
531 APR_w(i,j)=apri_w(i,j)
532 APR_mc(i,j)=apri_mc(i,j)
533 APR_st(i,j)=apri_st(i,j)
534 APR_as(i,j)=apri_as(i,j)
535 APR_capma(i,j)=apri_capma(i,j)
536 APR_capme(i,j)=apri_capme(i,j)
537 APR_capmi(i,j)=apri_capmi(i,j)
538 mass_flux(i,j)=massi_flx(i,j)
539 edt_out(i,j)=edti_out(i,j)
541 IF(PRESENT(RQCCUTEN)) THEN
545 RQCCUTEN(I,K,J)=outqc(I,K)*cuten(i)
546 IF ( PRESENT( GDC ) ) GDC(I,K,J)=CUPCLW(I,K)*cuten(i)
547 IF ( PRESENT( GDC2 ) ) GDC2(I,K,J)=0.
553 !...... QSTEN STORES GRAUPEL TENDENCY IF IT EXISTS, OTHERISE SNOW (V2)
555 IF(PRESENT(RQICUTEN).AND.PRESENT(RQCCUTEN))THEN
559 if(t2d(i,k).lt.258.)then
560 RQICUTEN(I,K,J)=outqc(I,K)*cuten(i)
563 IF ( PRESENT( GDC2 ) ) GDC2(I,K,J)=CUPCLW(I,K)*cuten(i)
566 RQCCUTEN(I,K,J)=outqc(I,K)*cuten(i)
567 IF ( PRESENT( GDC ) ) GDC(I,K,J)=CUPCLW(I,K)*cuten(i)
578 SUBROUTINE CUP_enss_3d(OUTQC,J,AAEQ,T,Q,Z1,sub_mas, &
579 TN,QO,PO,PRE,P,OUTT,OUTQ,DTIME,ktau,tkmax,PSUR,US,VS, &
581 tshall,qshall,kpbl,dhdt,outts,outqs,tscl_kf, &
582 k23,kbcon3,ktop3,xmb3, &
583 mconv,massfln,iact, &
584 omeg,direction,massflx,maxiens, &
585 maxens,maxens2,maxens3,ensdim, &
586 APR_GR,APR_W,APR_MC,APR_ST,APR_AS, &
587 APR_CAPMA,APR_CAPME,APR_CAPMI,kbcon,ktop,cupclw, & !-lxz
588 xf_ens,pr_ens,xland,gsw,edt_out,subt,subq, &
589 xl,rv,cp,g,ichoice,ipr,jpr,ens4,high_resolution, &
590 ishallow_g3,itf,jtf,ktf, &
591 its,ite, jts,jte, kts,kte &
592 #if ( WRF_DFI_RADAR == 1 )
593 ! Optional CAP suppress option
594 ,do_capsuppress,cap_suppress_j &
603 its,ite, jts,jte, kts,kte,ipr,jpr,ens4,high_resolution
604 integer, intent (in ) :: &
605 j,ensdim,maxiens,ishallow_g3,maxens,maxens2,maxens3,ichoice,iens
609 real, dimension (its:ite,jts:jte,1:ensdim) &
611 massfln,xf_ens,pr_ens
612 real, dimension (its:ite,jts:jte) &
613 ,intent (inout ) :: &
614 APR_GR,APR_W,APR_MC,APR_ST,APR_AS,APR_CAPMA, &
615 APR_CAPME,APR_CAPMI,massflx,edt_out
616 real, dimension (its:ite,jts:jte) &
619 integer, dimension (its:ite,jts:jte) &
622 ! outtem = output temp tendency (per s)
623 ! outq = output q tendency (per s)
624 ! outqc = output qc tendency (per s)
625 ! pre = output precip
626 real, dimension (its:ite,kts:kte) &
627 ,intent (inout ) :: &
628 DHDT,OUTT,OUTQ,OUTQC,subt,subq,sub_mas,cupclw,outts,outqs
629 real, dimension (its:ite) &
632 integer, dimension (its:ite) &
634 kbcon,ktop,k23,kbcon3,ktop3
635 integer, dimension (its:ite) &
639 ! basic environmental input includes moisture convergence (mconv)
640 ! omega (omeg), windspeed (us,vs), and a flag (aaeq) to turn off
641 ! convection for this call only and at that particular gridpoint
643 real, dimension (its:ite,kts:kte) &
645 T,PO,P,US,VS,tn,tshall,qshall
646 real, dimension (its:ite,kts:kte,1:ens4) &
647 ,intent (inout ) :: &
649 real, dimension (its:ite,kts:kte) &
652 real, dimension (its:ite) &
654 Z1,PSUR,AAEQ,direction,tkmax,xland
655 real, dimension (its:ite,1:ens4) &
662 dtime,tcrit,xl,cp,rv,g,tscl_kf
664 #if ( WRF_DFI_RADAR == 1 )
666 ! option of cap suppress:
667 ! do_capsuppress = 1 do
668 ! do_capsuppress = other don't
671 INTEGER, INTENT(IN ) ,OPTIONAL :: do_capsuppress
672 REAL, DIMENSION( its:ite ),INTENT(IN ) ,OPTIONAL :: cap_suppress_j
676 ! local ensemble dependent variables in this routine
678 real, dimension (its:ite,1:maxens) :: &
680 real, dimension (1:maxens) :: &
682 real, dimension (1:maxens2) :: &
684 real, dimension (its:ite,1:maxens2) :: &
686 real, dimension (its:ite,kts:kte,1:maxens2) :: &
687 dellat_ens,dellaqc_ens,dellaq_ens,pwo_ens,subt_ens,subq_ens
691 !***************** the following are your basic environmental
692 ! variables. They carry a "_cup" if they are
693 ! on model cloud levels (staggered). They carry
694 ! an "o"-ending (z becomes zo), if they are the forced
695 ! variables. They are preceded by x (z becomes xz)
696 ! to indicate modification by some typ of cloud
698 ! z = heights of model levels
699 ! q = environmental mixing ratio
700 ! qes = environmental saturation mixing ratio
701 ! t = environmental temp
702 ! p = environmental pressure
703 ! he = environmental moist static energy
704 ! hes = environmental saturation moist static energy
705 ! z_cup = heights of model cloud levels
706 ! q_cup = environmental q on model cloud levels
707 ! qes_cup = saturation q on model cloud levels
708 ! t_cup = temperature (Kelvin) on model cloud levels
709 ! p_cup = environmental pressure
710 ! he_cup = moist static energy on model cloud levels
711 ! hes_cup = saturation moist static energy on model cloud levels
712 ! gamma_cup = gamma on model cloud levels
715 ! hcd = moist static energy in downdraft
716 ! zd normalized downdraft mass flux
718 ! entr = entrainment rate
719 ! zd = downdraft normalized mass flux
720 ! entr= entrainment rate
721 ! hcd = h in model cloud
723 ! zd = normalized downdraft mass flux
724 ! gamma_cup = gamma on model cloud levels
725 ! mentr_rate = entrainment rate
726 ! qcd = cloud q (including liquid water) after entrainment
727 ! qrch = saturation q in cloud
728 ! pwd = evaporate at that level
729 ! pwev = total normalized integrated evaoprate (I2)
730 ! entr= entrainment rate
731 ! z1 = terrain elevation
732 ! entr = downdraft entrainment rate
733 ! jmin = downdraft originating level
734 ! kdet = level above ground where downdraft start detraining
735 ! psur = surface pressure
736 ! z1 = terrain elevation
737 ! pr_ens = precipitation ensemble
738 ! xf_ens = mass flux ensembles
739 ! massfln = downdraft mass flux ensembles used in next timestep
740 ! omeg = omega from large scale model
741 ! mconv = moisture convergence from large scale model
742 ! zd = downdraft normalized mass flux
743 ! zu = updraft normalized mass flux
744 ! dir = "storm motion"
745 ! mbdt = arbitrary numerical parameter
746 ! dtime = dt over which forcing is applied
747 ! iact_gr_old = flag to tell where convection was active
748 ! kbcon = LFC of parcel from k22
749 ! k22 = updraft originating level
750 ! icoic = flag if only want one closure (usually set to zero!)
752 ! ktop = cloud top (output)
753 ! xmb = total base mass flux
754 ! hc = cloud moist static energy
755 ! hkb = moist static energy at originating level
756 ! mentr_rate = entrainment rate
757 real, dimension (its:ite,kts:kte) :: &
758 he3,hes3,qes3,z3,zdo3,zu3_0,hc3_0,dby3_0, &
759 qes3_cup,q3_cup,he3_cup,hes3_cup,z3_cup,gamma3_cup,t3_cup, &
760 xhe3,xhes3,xqes3,xz3,xt3,xq3, &
761 xqes3_cup,xq3_cup,xhe3_cup,xhes3_cup,xz3_cup,xgamma3_cup, &
763 xdby3,xqc3,xhc3,xqrc3,xzu3, &
764 dby3,qc3,pw3,hc3,qrc3,zu3,cd3,DELLAH3,DELLAQ3, &
765 dsubt3,dsubq3,DELLAT3,DELLAQC3
767 real, dimension (its:ite,kts:kte) :: &
770 xhe,xhes,xqes,xz,xt,xq, &
772 qes_cup,q_cup,he_cup,hes_cup,z_cup,p_cup,gamma_cup,t_cup, &
773 qeso_cup,qo_cup,heo_cup,heso_cup,zo_cup,po_cup,gammao_cup, &
775 xqes_cup,xq_cup,xhe_cup,xhes_cup,xz_cup,xp_cup,xgamma_cup, &
778 dby,qc,qrcd,pwd,pw,hcd,qcd,dbyd,hc,qrc,zu,zd,clw_all, &
779 dbyo,qco,qrcdo,pwdo,pwo,hcdo,qcdo,dbydo,hco,qrco,zuo,zdo, &
780 xdby,xqc,xqrcd,xpwd,xpw,xhcd,xqcd,xhc,xqrc,xzu,xzd, &
782 ! cd = detrainment function for updraft
783 ! cdd = detrainment function for downdraft
784 ! dellat = change of temperature per unit mass flux of cloud ensemble
785 ! dellaq = change of q per unit mass flux of cloud ensemble
786 ! dellaqc = change of qc per unit mass flux of cloud ensemble
788 cd,cdd,scr1,DELLAH,DELLAQ,DELLAT,DELLAQC,dsubt,dsubq
790 ! aa0 cloud work function for downdraft
792 ! aa0 = cloud work function without forcing effects
793 ! aa1 = cloud work function with forcing effects
794 ! xaa0 = cloud work function with cloud effects (ensemble dependent)
797 real, dimension (its:ite) :: &
798 aa3_0,aa3,hkb3,qkb3,pwav3,bu3,xaa3,xhkb3, &
799 hkb3_0,edt,edto,edtx,AA1,AA0,XAA0,HKB, &
800 HKBO,aad,XHKB,QKB,QKBO,edt3, &
801 XMB,XPWAV,XPWEV,PWAV,PWEV,PWAVO, &
802 PWEVO,BU,BUO,cap_max,xland1, &
803 cap_max_increment,closure_n,cap_max3
804 real, dimension (its:ite,1:ens4) :: &
806 integer, dimension (its:ite) :: &
807 kzdown,KDET,K22,KB,JMIN,kstabi,kstabm,K22x,jmin3,kdet3, & !-lxz
808 KBCONx,KBx,KTOPx,ierr,ierr2,ierr3,KBMAX,ierr5,ierr5_0
811 nall,iedt,nens,nens3,ki,I,K,KK,iresult
813 day,dz,mbdt,mbdt_s,entr_rate,radius,entrd_rate,mentr_rate,mentrd_rate, &
814 zcutdown,edtmax,edtmin,depth_min,zkbmax,z_detr,zktop, &
815 massfld,dh,cap_maxs,trash,entr_rate3,mentr_rate3
818 logical :: keep_going
819 real xff_shal(9),blqe,xkshal
828 if(xland(i).gt.1.5)xland1(i)=0.
829 ! cap_max_increment(i)=50.
830 cap_max_increment(i)=25.
833 !--- specify entrainmentrate and detrainmentrate
836 radius=14000.-float(iens)*2000.
841 !--- gross entrainment rate (these may be changed later on in the
842 !--- program, depending what your detrainment is!!)
847 !--- entrainment of mass
851 mentr_rate3=entr_rate3
853 !--- initial detrainmentrates
858 cd(i,k)=0.01*entr_rate
868 !--- max/min allowed value for epsilon (ratio downdraft base mass flux/updraft
874 !--- minimum depth (m), clouds must have
878 !--- maximum depth (mb) of capping
879 !--- inversion (larger cap = no convection)
902 !--- first check for upstream convection
904 #if ( WRF_DFI_RADAR == 1 )
905 if(do_capsuppress == 1) then
909 if(gsw(i,j).lt.1.or.high_resolution.eq.1)cap_max(i)=25.
910 if (abs(cap_suppress_j(i) - 1.0 ) < 0.1 ) then
911 cap_max(i)=cap_maxs+75.
912 elseif (abs(cap_suppress_j(i) - 0.0 ) < 0.1 ) then
921 if(gsw(i,j).lt.1.or.high_resolution.eq.1)cap_max(i)=25.
927 edt_out(i,j)=cap_max(i)
933 if(gsw(i,j).lt.1.or.high_resolution.eq.1)cap_max(i)=25.
939 !--- max height(m) above ground where updraft air can originate
943 !--- height(m) above which no downdrafts are allowed to originate
947 !--- depth(m) over which downdraft detrains all its mass
952 mbdt_ens(nens)=(float(nens)-3.)*dtime*1.e-3+dtime*5.E-03
955 edt_ens(nens)=.95-float(nens)*.01
958 !--- environmental conditions, FIRST HEIGHTS
961 if(ierr(i).ne.20)then
962 do k=1,maxens*maxens2*maxens3
963 xf_ens(i,j,(iens-1)*maxens*maxens2*maxens3+k)=0.
964 pr_ens(i,j,(iens-1)*maxens*maxens2*maxens3+k)=0.
969 !--- calculate moist static energy, heights, qes
971 call cup_env(z,qes,he,hes,t,q,p,z1, &
972 psur,ierr,tcrit,0,xl,cp, &
974 its,ite, jts,jte, kts,kte)
975 call cup_env(zo,qeso,heo,heso,tn,qo,po,z1, &
976 psur,ierr,tcrit,0,xl,cp, &
978 its,ite, jts,jte, kts,kte)
980 !--- environmental values on cloud levels
982 call cup_env_clev(t,qes,q,he,hes,z,p,qes_cup,q_cup,he_cup, &
983 hes_cup,z_cup,p_cup,gamma_cup,t_cup,psur, &
986 its,ite, jts,jte, kts,kte)
987 call cup_env_clev(tn,qeso,qo,heo,heso,zo,po,qeso_cup,qo_cup, &
988 heo_cup,heso_cup,zo_cup,po_cup,gammao_cup,tn_cup,psur, &
991 its,ite, jts,jte, kts,kte)
993 if(aaeq(i).lt.-0.1)then
996 ! if(ierr(i).eq.0)then
999 if(zo_cup(i,k).gt.zkbmax+z1(i))then
1006 !--- level where detrainment for downdraft starts
1009 if(zo_cup(i,k).gt.z_detr+z1(i))then
1021 !------- DETERMINE LEVEL WITH HIGHEST MOIST STATIC ENERGY CONTENT - K22
1023 CALL cup_MAXIMI(HEO_CUP,3,KBMAX,K22,ierr, &
1025 its,ite, jts,jte, kts,kte)
1027 IF(ierr(I).eq.0.)THEN
1028 IF(K22(I).GE.KBMAX(i))ierr(i)=2
1032 !--- DETERMINE THE LEVEL OF CONVECTIVE CLOUD BASE - KBCON
1034 call cup_kbcon(cap_max_increment,1,k22,kbcon,heo_cup,heso_cup, &
1035 ierr,kbmax,po_cup,cap_max, &
1037 its,ite, jts,jte, kts,kte)
1039 !--- increase detrainment in stable layers
1041 CALL cup_minimi(HEso_cup,Kbcon,kstabm,kstabi,ierr, &
1043 its,ite, jts,jte, kts,kte)
1045 IF(ierr(I).eq.0.)THEN
1046 if(kstabm(i)-1.gt.kstabi(i))then
1047 do k=kstabi(i),kstabm(i)-1
1048 cd(i,k)=cd(i,k-1)+.15*entr_rate
1049 if(cd(i,k).gt.1.0*entr_rate)cd(i,k)=1.0*entr_rate
1055 !--- calculate incloud moist static energy
1057 call cup_up_he(k22,hkb,z_cup,cd,mentr_rate,he_cup,hc, &
1058 kbcon,ierr,dby,he,hes_cup,'deep', &
1060 its,ite, jts,jte, kts,kte)
1061 call cup_up_he(k22,hkbo,zo_cup,cd,mentr_rate,heo_cup,hco, &
1062 kbcon,ierr,dbyo,heo,heso_cup,'deep', &
1064 its,ite, jts,jte, kts,kte)
1066 !--- DETERMINE CLOUD TOP - KTOP
1068 call cup_ktop(1,dbyo,kbcon,ktop,ierr, &
1070 its,ite, jts,jte, kts,kte)
1073 if(ierr(i).eq.0)then
1074 zktop=(zo_cup(i,ktop(i))-z1(i))*.6
1075 zktop=min(zktop+z1(i),zcutdown+z1(i))
1077 if(zo_cup(i,k).gt.zktop)then
1085 !--- DOWNDRAFT ORIGINATING LEVEL - JMIN
1087 call cup_minimi(HEso_cup,K22,kzdown,JMIN,ierr, &
1089 its,ite, jts,jte, kts,kte)
1091 IF(ierr(I).eq.0.)THEN
1093 !--- check whether it would have buoyancy, if there where
1094 !--- no entrainment/detrainment
1098 do while ( keep_going )
1099 keep_going = .FALSE.
1100 if ( jmini - 1 .lt. kdet(i) ) kdet(i) = jmini-1
1101 if ( jmini .ge. ktop(i)-1 ) jmini = ktop(i) - 2
1103 hcdo(i,ki)=heso_cup(i,ki)
1104 DZ=Zo_cup(i,Ki+1)-Zo_cup(i,Ki)
1107 hcdo(i,k)=heso_cup(i,jmini)
1108 DZ=Zo_cup(i,K+1)-Zo_cup(i,K)
1109 dh=dh+dz*(HCDo(i,K)-heso_cup(i,k))
1112 if ( jmini .gt. 3 ) then
1122 if ( jmini .le. 3 ) then
1128 ! - Must have at least depth_min m between cloud convective base
1132 IF(ierr(I).eq.0.)THEN
1133 IF(-zo_cup(I,KBCON(I))+zo_cup(I,KTOP(I)).LT.depth_min)then
1140 !c--- normalized updraft mass flux profile
1142 call cup_up_nms(zu,z_cup,mentr_rate,cd,kbcon,ktop,ierr,k22, &
1144 its,ite, jts,jte, kts,kte)
1145 call cup_up_nms(zuo,zo_cup,mentr_rate,cd,kbcon,ktop,ierr,k22, &
1147 its,ite, jts,jte, kts,kte)
1149 !c--- normalized downdraft mass flux profile,also work on bottom detrainment
1150 !--- in this routine
1152 call cup_dd_nms(zd,z_cup,cdd,mentrd_rate,jmin,ierr, &
1155 its,ite, jts,jte, kts,kte)
1156 call cup_dd_nms(zdo,zo_cup,cdd,mentrd_rate,jmin,ierr, &
1159 its,ite, jts,jte, kts,kte)
1161 !--- downdraft moist static energy
1163 call cup_dd_he(hes_cup,zd,hcd,z_cup,cdd,mentrd_rate, &
1164 jmin,ierr,he,dbyd,he_cup, &
1166 its,ite, jts,jte, kts,kte)
1167 call cup_dd_he(heso_cup,zdo,hcdo,zo_cup,cdd,mentrd_rate, &
1168 jmin,ierr,heo,dbydo,he_cup,&
1170 its,ite, jts,jte, kts,kte)
1172 !--- calculate moisture properties of downdraft
1174 call cup_dd_moisture_3d(zd,hcd,hes_cup,qcd,qes_cup, &
1175 pwd,q_cup,z_cup,cdd,mentrd_rate,jmin,ierr,gamma_cup, &
1176 pwev,bu,qrcd,q,he,t_cup,2,xl,high_resolution, &
1178 its,ite, jts,jte, kts,kte)
1179 call cup_dd_moisture_3d(zdo,hcdo,heso_cup,qcdo,qeso_cup, &
1180 pwdo,qo_cup,zo_cup,cdd,mentrd_rate,jmin,ierr,gammao_cup, &
1181 pwevo,bu,qrcdo,qo,heo,tn_cup,1,xl,high_resolution, &
1183 its,ite, jts,jte, kts,kte)
1185 !--- calculate moisture properties of updraft
1187 call cup_up_moisture('deep',ierr,z_cup,qc,qrc,pw,pwav, &
1188 kbcon,ktop,cd,dby,mentr_rate,clw_all, &
1189 q,GAMMA_cup,zu,qes_cup,k22,q_cup,xl, &
1191 its,ite, jts,jte, kts,kte)
1194 cupclw(i,k)=qrc(i,k)
1197 call cup_up_moisture('deep',ierr,zo_cup,qco,qrco,pwo,pwavo, &
1198 kbcon,ktop,cd,dbyo,mentr_rate,clw_all, &
1199 qo,GAMMAo_cup,zuo,qeso_cup,k22,qo_cup,xl,&
1201 its,ite, jts,jte, kts,kte)
1203 !--- calculate workfunctions for updrafts
1205 call cup_up_aa0(aa0,z,zu,dby,GAMMA_CUP,t_cup, &
1208 its,ite, jts,jte, kts,kte)
1209 call cup_up_aa0(aa1,zo,zuo,dbyo,GAMMAo_CUP,tn_cup, &
1212 its,ite, jts,jte, kts,kte)
1214 if(ierr(i).eq.0)then
1215 if(aa1(i).eq.0.)then
1220 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1221 ! NEXT section for shallow convection
1223 if(ishallow_g3.eq.1)then
1224 ! write(0,*)'now do shallow for j = ',j
1225 call cup_env(z3,qes3,he3,hes3,tshall,qshall,po,z1, &
1226 psur,ierr5,tcrit,0,xl,cp, &
1228 its,ite, jts,jte, kts,kte)
1229 call cup_env_clev(tshall,qes3,qshall,he3,hes3,z3,po,qes3_cup,q3_cup, &
1230 he3_cup,hes3_cup,z3_cup,po_cup,gamma3_cup,t3_cup,psur, &
1231 ierr5,z1,xl,rv,cp, &
1233 its,ite, jts,jte, kts,kte)
1234 CALL cup_MAXIMI(HE3_CUP,1,kbmax,K23,ierr5, &
1236 its,ite, jts,jte, kts,kte)
1238 if(kpbl(i).gt.5)cap_max3(i)=po_cup(i,kpbl(i))
1239 IF(ierr5(I).eq.0.)THEN
1240 IF(K23(I).Gt.Kbmax(i))ierr5(i)=2
1241 if(kpbl(i).gt.5)k23(i)=kpbl(i)
1245 call cup_kbcon(cap_max_increment,5,k23,kbcon3,he3_cup,hes3_cup, &
1246 ierr5,kbmax,po_cup,cap_max3, &
1247 ! ierr5,kpbl,po_cup,cap_max3, &
1249 its,ite, jts,jte, kts,kte)
1250 call cup_up_he(k23,hkb3,z3_cup,cd3,mentr_rate3,he3_cup,hc3, &
1251 kbcon3,ierr5,dby3,he3,hes3_cup,'shallow', &
1253 its,ite, jts,jte, kts,kte)
1254 call cup_up_he(k23,hkb3_0,z_cup,cd3,mentr_rate3,he_cup,hc3_0, &
1255 kbcon3,ierr5,dby3_0,he,hes_cup,'shallow', &
1257 its,ite, jts,jte, kts,kte)
1258 call cup_ktop(1,dby3,kbcon3,ktop3,ierr5, &
1260 its,ite, jts,jte, kts,kte)
1261 call cup_up_nms(zu3,z3_cup,mentr_rate3,cd3,kbcon3,ktop3, &
1264 its,ite, jts,jte, kts,kte)
1265 call cup_up_nms(zu3_0,z_cup,mentr_rate3,cd3,kbcon3,ktop3, &
1268 its,ite, jts,jte, kts,kte)
1270 ! first calculate aa3_0_cup
1272 call cup_up_aa0(aa3_0,z,zu3_0,dby3_0,GAMMA3_CUP,t_cup, &
1273 kbcon3,ktop3,ierr5, &
1275 its,ite, jts,jte, kts,kte)
1277 ! now what is necessary for aa3 and feedbacks
1279 call cup_up_moisture('shallow',ierr5,z3_cup,qc3,qrc3,pw3,pwav3, &
1280 kbcon3,ktop3,cd3,dby3,mentr_rate3,clw_all, &
1281 qshall,GAMMA3_cup,zu3,qes3_cup,k23,q3_cup,xl,&
1283 its,ite, jts,jte, kts,kte)
1284 call cup_up_aa0(aa3,z3,zu3,dby3,GAMMA3_CUP,t3_cup, &
1285 kbcon3,ktop3,ierr5, &
1287 its,ite, jts,jte, kts,kte)
1289 ! if(ierr5(i).eq.0)then
1290 ! if(aa3(i).eq.0.)then
1295 ! call cup_dellabot('shallow',ipr,jpr,q3_cup,ierr5,z3_cup,po,qrcdo,edto, &
1296 ! zdo,cdd,q3,dellaq3,dsubq,j,mentrd_rate,z3,g,&
1298 ! its,ite, jts,jte, kts,kte)
1299 call cup_dellas_3d(ierr5,z3_cup,po_cup,hcdo,edt3,zdo3,cdd, &
1300 he3,dellah3,dsubt3,j,mentrd_rate,zu3,g, &
1301 cd3,hc3,ktop3,k23,kbcon3,mentr_rate3,jmin,he3_cup,kdet, &
1302 k23,ipr,jpr,'shallow',0, &
1304 its,ite, jts,jte, kts,kte)
1305 call cup_dellas_3d(ierr5,z3_cup,po_cup,qrcdo,edt3,zdo3,cdd, &
1306 qshall,dellaq3,dsubq3,j,mentrd_rate,zu3,g, &
1307 cd3,qc3,ktop3,k23,kbcon3,mentr_rate3,jmin,q3_cup,kdet, &
1308 k23,ipr,jpr,'shallow',0, &
1310 its,ite, jts,jte, kts,kte )
1311 mbdt_s=1.e-1*mbdt_ens(1)
1315 if(ierr5(i).eq.0)then
1317 XHE3(I,K)=(dsubt3(i,k)+DELLAH3(I,K))*MBDT_S+HE3(I,K)
1318 XQ3(I,K)=(dsubq3(i,k)+DELLAQ3(I,K))*MBDT_S+QSHALL(I,K)
1319 DELLAT3(I,K)=(1./cp)*(DELLAH3(I,K)-xl*DELLAQ3(I,K))
1320 dSUBT3(I,K)=(1./cp)*(dsubt3(i,k)-xl*dsubq3(i,k))
1321 XT3(I,K)= (DELLAT3(I,K)+dsubt3(i,k))*MBDT_S+TSHALL(I,K)
1322 IF(XQ3(I,K).LE.0.)XQ3(I,K)=1.E-08
1323 ! if(i.eq.ipr.and.j.eq.jpr)then
1324 ! write(0,*)k,trash,DELLAQ3(I,K),dsubq3(I,K),dsubt3(i,k)
1330 if(ierr5(i).eq.0)then
1331 XHE3(I,ktf)=HE3(I,ktf)
1332 XQ3(I,ktf)=QSHALL(I,ktf)
1333 XT3(I,ktf)=TSHALL(I,ktf)
1334 IF(XQ3(I,ktf).LE.0.)XQ3(I,ktf)=1.E-08
1338 !--- calculate moist static energy, heights, qes
1340 call cup_env(xz3,xqes3,xhe3,xhes3,xt3,xq3,po,z1, &
1341 psur,ierr5,tcrit,2,xl,cp, &
1343 its,ite, jts,jte, kts,kte)
1345 !--- environmental values on cloud levels
1347 call cup_env_clev(xt3,xqes3,xq3,xhe3,xhes3,xz3,po,xqes3_cup,xq3_cup, &
1348 xhe3_cup,xhes3_cup,xz3_cup,po_cup,gamma3_cup,xt3_cup,psur, &
1349 ierr5,z1,xl,rv,cp, &
1351 its,ite, jts,jte, kts,kte)
1354 !**************************** static control
1356 !--- moist static energy inside cloud
1359 if(ierr5(i).eq.0)then
1360 xhkb3(i)=xhe3(i,k23(i))
1363 call cup_up_he(k23,xhkb3,xz3_cup,cd3,mentr_rate3,xhe3_cup,xhc3, &
1364 kbcon3,ierr5,xdby3,xhe3,xhes3_cup,'shallow', &
1366 its,ite, jts,jte, kts,kte)
1368 !c--- normalized mass flux profile and CWF
1370 call cup_up_nms(xzu3,xz3_cup,mentr_rate3,cd3,kbcon3,ktop3,ierr5,k23, &
1372 its,ite, jts,jte, kts,kte)
1373 call cup_up_aa0(xaa3,xz3,xzu3,xdby3,GAMMA3_CUP,xt3_cup, &
1374 kbcon3,ktop3,ierr5, &
1376 its,ite, jts,jte, kts,kte)
1378 ! now for shallow forcing
1383 if(ierr5(i).eq.0)then
1384 xkshal=(xaa3(i)-aa3(i))/mbdt_s
1385 if(xkshal.ge.0.)xkshal=+1.e6
1386 if(xkshal.gt.-1.e-4 .and. xkshal.lt.0.)xkshal=-1.e-4
1387 xff_shal(1)=max(0.,-(aa3(i)-aa3_0(i))/(xkshal*dtime))
1388 xff_shal(2)=max(0.,-(aa3(i)-aa3_0(i))/(xkshal*dtime))
1389 xff_shal(3)=max(0.,-(aa3(i)-aa3_0(i))/(xkshal*dtime))
1390 if(aa3_0(i).le.0)then
1395 if(aa3(i)-aa3_0(i).le.0.)then
1400 ! boundary layer QE (from Saulo Freitas)
1403 if(k23(i).lt.kpbl(i)+1)then
1405 blqe=blqe+100.*dhdt(i,k)*(p_cup(i,k)-p_cup(i,k+1))/g
1407 trash=max((hc3(i,kbcon3(i))-he_cup(i,kbcon3(i))),1.e1)
1408 xff_shal(7)=max(0.,blqe/trash)
1409 xff_shal(7)=min(0.1,xff_shal(7))
1413 if((xkshal.lt.-1.1e-04) .and. &
1414 ((aa3(i)-aa3_0(i).gt.0.) .or. (xff_shal(7).gt.0)))then
1415 xff_shal(4)=max(0.,-aa3(i)/(xkshal*tscl_KF))
1416 xff_shal(4)=min(0.1,xff_shal(4))
1417 xff_shal(5)=xff_shal(4)
1418 xff_shal(6)=xff_shal(4)
1424 ! write(0,888)'i0=',i,j,kpbl(i),blqe,xff_shal(7)
1425 888 format(a3,3(1x,i3),2e12.4)
1426 xff_shal(8)= xff_shal(7)
1427 xff_shal(9)= xff_shal(7)
1429 xmb3(i)=xmb3(i)+xff_shal(k)
1431 xmb3(i)=min(.1,xmb3(i)/9.)
1432 ! if(xmb3(i).eq.10.1 )then
1433 ! write(0,*)'i0,xmb3,blqe,xkshal = ',i,j,xmb3(i),blqe,xkshal
1434 ! if(xff_shal(7).ge.0.1)then
1435 ! write(0,*)'i1,blqe,trash = ',blqe,trash
1437 ! if(xff_shal(7).eq.0 .and. xff_shal(1).ge.0.1)then
1438 ! write(0,*)'i2,aa3_0(i),aa3(i),xaa3(i) = ',aa3_0(i),aa3(i),xaa3(i)
1440 ! if(xff_shal(5).ge.0.1)then
1441 ! write(0,*)'i3,aa3(i),a0,xkshal= ',aa3(i),aa3_0(i),xkshal
1443 ! write(0,*)'i0, xff_shallow = ',xff_shal
1445 !! if(xff_shal(7).eq.0 .and. xff_shal(4).gt.0 .and. xmb3(i).eq.0.5)then
1446 !! write(0,*)'i4,xmb3 = ',i,j,xmb3(i),xkshal
1447 !! write(0,*)'xff_shallow = ',xff_shal
1448 !! write(0,*)aa3(i),xaa3(i),blqe
1450 if(xmb3(i).eq.0.)ierr5(i)=22
1451 if(xmb3(i).lt.0.)then
1453 ! write(0,*)'neg xmb,i,j,xmb3 for shallow = ',i,j,k23(i),ktop3(i),kbcon3(i),kpbl(i)
1456 ! if(ierr5(i).eq.0)write(0,*)'i,j,xmb3 for shallow = ',i,j,xmb3(i),k23(i),ktop3(i)
1457 ! if(ierr5(i).eq.0.and.i.eq.12.and.j.eq.25)write(0,*)'i,j,xmb3 for shallow = ',k23(i),ktop3(i),kbcon3(i),kpbl(i)
1458 ! if(ierr5(i).eq.0)write(0,*)'i,j,xmb3 for shallow = ',i,j,k23(i),ktop3(i),kbcon3(i),kpbl(i)
1459 if(ierr5(i).ne.0)then
1468 else if(ierr5(i).eq.0)then
1470 ! got the mass flux, sanity check, first for heating rates
1474 trash=max(trash,86400.*(dsubt3(i,k)+dellat3(i,k))*xmb3(i))
1476 if(trash.gt.150.)xmb3(i)=xmb3(i)*150./trash
1478 ! sanity check on moisture tendencies: do not allow anything that may allow neg tendencies
1481 trash=q(i,k)+(dsubq3(i,k)+dellaq3(i,k))*xmb3(i)*dtime
1482 if(trash.lt.1.e-12)then
1483 ! max allowable tendency over tendency that would lead to too small mix ratios
1485 trash=((1.e-12-q(i,k))/dtime) &
1486 /((dsubq3(i,k)+dellaq3(i,k))*xmb3(i))
1489 xmb3(i)=trash*xmb3(i)
1496 outts(i,k)=(dsubt3(i,k)+dellat3(i,k))*xmb3(i)
1497 outqs(i,k)=(dsubq3(i,k)+dellaq3(i,k))*xmb3(i)
1502 !! write(0,*)'!!!!!!!! j = ',j,' !!!!!!!!!!!!!!!!!!!!'
1504 ! write(0,*)k23(i),kbcon3(i),ktop3(i)
1505 ! write(0,*)kpbl(i),ierr5(i),ierr(i)
1506 ! write(0,*)xmb3(i),xff_shal(1:9)
1507 ! write(0,*)xaa3(i),aa1(i),aa0(i),aa3(i)
1509 ! write(0,*)po(i,k),he3(i,k),hes3(i,k),dellah3(i,k)
1512 ! write(0,*)zu3(i,k),hc3(i,k),dsubt3(i,k),dellat3(i,k)
1515 ! blqe=cp*outts(i,k)+xl*outqs(i,k)
1516 ! write(0,*)outts(i,k),outqs(i,k),blqe
1521 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1523 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1526 call cup_axx(tcrit,kbmax,z1,p,psur,xl,rv,cp,tx,qx,axx,ierr, &
1527 cap_max,cap_max_increment,entr_rate,mentr_rate,&
1529 its,ite, jts,jte, kts,kte,ens4)
1532 !--- DETERMINE DOWNDRAFT STRENGTH IN TERMS OF WINDSHEAR
1534 call cup_dd_edt(ierr,us,vs,zo,ktop,kbcon,edt,po,pwavo, &
1535 pwevo,edtmax,edtmin,maxens2,edtc, &
1537 its,ite, jts,jte, kts,kte)
1538 do 250 iedt=1,maxens2
1540 if(ierr(i).eq.0)then
1542 edto(i)=edtc(i,iedt)
1543 edtx(i)=edtc(i,iedt)
1544 edt_out(i,j)=edtc(i,2)
1545 if(high_resolution.eq.1)then
1549 edt_out(i,j)=edtc(i,3)
1555 subt_ens(i,k,iedt)=0.
1556 subq_ens(i,k,iedt)=0.
1557 dellat_ens(i,k,iedt)=0.
1558 dellaq_ens(i,k,iedt)=0.
1559 dellaqc_ens(i,k,iedt)=0.
1560 pwo_ens(i,k,iedt)=0.
1564 ! if(j.eq.jpr.and.iedt.eq.1.and.ipr.gt.its.and.ipr.lt.ite)then
1567 !! write(0,*)'in 250 loop ',iedt,edt(ipr),ierr(ipr)
1568 !! if(ierr(i).eq.0.or.ierr(i).eq.3)then
1569 ! write(0,*)'250',k22(I),kbcon(i),ktop(i),jmin(i)
1570 ! write(0,*)edt(i),aa0(i),aa1(i)
1572 ! write(0,*)k,z(i,k),he(i,k),hes(i,k)
1574 ! write(0,*)'end 250 loop ',iedt,edt(ipr),ierr(ipr)
1576 ! write(0,*)zu(i,k),zd(i,k),pw(i,k),pwd(i,k)
1584 !--- change per unit mass that a model cloud would modify the environment
1586 !--- 1. in bottom layer
1588 call cup_dellabot('deep',ipr,jpr,heo_cup,ierr,zo_cup,po,hcdo,edto, &
1589 zdo,cdd,heo,dellah,dsubt,j,mentrd_rate,zo,g, &
1591 its,ite, jts,jte, kts,kte)
1592 call cup_dellabot('deep',ipr,jpr,qo_cup,ierr,zo_cup,po,qrcdo,edto, &
1593 zdo,cdd,qo,dellaq,dsubq,j,mentrd_rate,zo,g,&
1595 its,ite, jts,jte, kts,kte)
1597 !--- 2. everywhere else
1599 call cup_dellas_3d(ierr,zo_cup,po_cup,hcdo,edto,zdo,cdd, &
1600 heo,dellah,dsubt,j,mentrd_rate,zuo,g, &
1601 cd,hco,ktop,k22,kbcon,mentr_rate,jmin,heo_cup,kdet, &
1602 k22,ipr,jpr,'deep',high_resolution, &
1604 its,ite, jts,jte, kts,kte)
1606 !-- take out cloud liquid water for detrainment
1613 if(ierr(i).eq.0)then
1614 scr1(i,k)=qco(i,k)-qrco(i,k)
1615 if(k.eq.ktop(i)-0)dellaqc(i,k)= &
1616 .01*zuo(i,ktop(i))*qrco(i,ktop(i))* &
1617 9.81/(po_cup(i,k)-po_cup(i,k+1))
1618 if(k.lt.ktop(i).and.k.gt.kbcon(i))then
1619 dz=zo_cup(i,k+1)-zo_cup(i,k)
1620 dellaqc(i,k)=.01*9.81*cd(i,k)*dz*zuo(i,k) &
1621 *.5*(qrco(i,k)+qrco(i,k+1))/ &
1622 (po_cup(i,k)-po_cup(i,k+1))
1627 call cup_dellas_3d(ierr,zo_cup,po_cup,qrcdo,edto,zdo,cdd, &
1628 qo,dellaq,dsubq,j,mentrd_rate,zuo,g, &
1629 cd,qco,ktop,k22,kbcon,mentr_rate,jmin,qo_cup,kdet, &
1630 k22,ipr,jpr,'deep',high_resolution, &
1632 its,ite, jts,jte, kts,kte )
1634 !--- using dellas, calculate changed environmental profiles
1636 ! do 200 nens=1,maxens
1645 ! write(0,*)'xt',xl,'DELLAH(I,K),DELLAQ(I,K),dsubq(I,K),dsubt(i,k)'
1650 if(ierr(i).eq.0)then
1652 XHE(I,K)=(dsubt(i,k)+DELLAH(I,K))*MBDT+HEO(I,K)
1653 XQ(I,K)=(dsubq(i,k)+DELLAQ(I,K))*MBDT+QO(I,K)
1654 DELLAT(I,K)=(1./cp)*(DELLAH(I,K)-xl*DELLAQ(I,K))
1655 dSUBT(I,K)=(1./cp)*(dsubt(i,k)-xl*dsubq(i,k))
1656 XT(I,K)= (DELLAT(I,K)+dsubt(i,k))*MBDT+TN(I,K)
1657 IF(XQ(I,K).LE.0.)XQ(I,K)=1.E-08
1658 ! if(i.eq.ipr.and.j.eq.jpr)then
1659 ! write(0,*)k,trash,DELLAQ(I,K),dsubq(I,K),dsubt(i,k)
1665 if(ierr(i).eq.0)then
1666 XHE(I,ktf)=HEO(I,ktf)
1669 IF(XQ(I,ktf).LE.0.)XQ(I,ktf)=1.E-08
1673 !--- calculate moist static energy, heights, qes
1675 call cup_env(xz,xqes,xhe,xhes,xt,xq,po,z1, &
1676 psur,ierr,tcrit,2,xl,cp, &
1678 its,ite, jts,jte, kts,kte)
1680 !--- environmental values on cloud levels
1682 call cup_env_clev(xt,xqes,xq,xhe,xhes,xz,po,xqes_cup,xq_cup, &
1683 xhe_cup,xhes_cup,xz_cup,po_cup,gamma_cup,xt_cup,psur, &
1686 its,ite, jts,jte, kts,kte)
1689 !**************************** static control
1691 !--- moist static energy inside cloud
1694 if(ierr(i).eq.0)then
1695 xhkb(i)=xhe(i,k22(i))
1698 call cup_up_he(k22,xhkb,xz_cup,cd,mentr_rate,xhe_cup,xhc, &
1699 kbcon,ierr,xdby,xhe,xhes_cup,'deep', &
1701 its,ite, jts,jte, kts,kte)
1703 !c--- normalized mass flux profile
1705 call cup_up_nms(xzu,xz_cup,mentr_rate,cd,kbcon,ktop,ierr,k22, &
1707 its,ite, jts,jte, kts,kte)
1709 !--- moisture downdraft
1711 call cup_dd_nms(xzd,xz_cup,cdd,mentrd_rate,jmin,ierr, &
1714 its,ite, jts,jte, kts,kte)
1715 call cup_dd_he(xhes_cup,xzd,xhcd,xz_cup,cdd,mentrd_rate, &
1716 jmin,ierr,xhe,dbyd,xhe_cup,&
1718 its,ite, jts,jte, kts,kte)
1719 call cup_dd_moisture_3d(xzd,xhcd,xhes_cup,xqcd,xqes_cup, &
1720 xpwd,xq_cup,xz_cup,cdd,mentrd_rate,jmin,ierr,gamma_cup, &
1721 xpwev,bu,xqrcd,xq,xhe,xt_cup,3,xl,high_resolution, &
1723 its,ite, jts,jte, kts,kte)
1726 !------- MOISTURE updraft
1728 call cup_up_moisture('deep',ierr,xz_cup,xqc,xqrc,xpw,xpwav, &
1729 kbcon,ktop,cd,xdby,mentr_rate,clw_all, &
1730 xq,GAMMA_cup,xzu,xqes_cup,k22,xq_cup,xl, &
1732 its,ite, jts,jte, kts,kte)
1734 !--- workfunctions for updraft
1736 call cup_up_aa0(xaa0,xz,xzu,xdby,GAMMA_CUP,xt_cup, &
1739 its,ite, jts,jte, kts,kte)
1740 do 200 nens=1,maxens
1742 if(ierr(i).eq.0)then
1743 xaa0_ens(i,nens)=xaa0(i)
1744 nall=(iens-1)*maxens3*maxens*maxens2 &
1745 +(iedt-1)*maxens*maxens3 &
1748 if(k.le.ktop(i))then
1752 pr_ens(i,j,nall+nens3)=pr_ens(i,j,nall+nens3) &
1753 +edto(i)*pwdo(i,k) &
1756 else if(nens3.eq.8)then
1757 pr_ens(i,j,nall+nens3)=pr_ens(i,j,nall+nens3)+ &
1760 else if(nens3.eq.9)then
1761 pr_ens(i,j,nall+nens3)=pr_ens(i,j,nall+nens3) &
1762 +.5*edto(i)*pwdo(i,k) &
1765 pr_ens(i,j,nall+nens3)=pr_ens(i,j,nall+nens3)+ &
1766 pwo(i,k)+edto(i)*pwdo(i,k)
1771 if(pr_ens(i,j,nall+7).lt.1.e-6)then
1774 pr_ens(i,j,nall+nens3)=0.
1778 if(pr_ens(i,j,nall+nens3).lt.1.e-4)then
1779 pr_ens(i,j,nall+nens3)=0.
1786 !--- LARGE SCALE FORCING
1789 !------- CHECK wether aa0 should have been zero
1792 CALL cup_MAXIMI(HEO_CUP,3,KBMAX,K22x,ierr, &
1794 its,ite, jts,jte, kts,kte)
1799 call cup_kbcon(cap_max_increment,2,k22x,kbconx,heo_cup, &
1800 heso_cup,ierr2,kbmax,po_cup,cap_max, &
1802 its,ite, jts,jte, kts,kte)
1803 call cup_kbcon(cap_max_increment,3,k22x,kbconx,heo_cup, &
1804 heso_cup,ierr3,kbmax,po_cup,cap_max, &
1806 its,ite, jts,jte, kts,kte)
1808 !--- DETERMINE THE LEVEL OF CONVECTIVE CLOUD BASE - KBCON
1811 call cup_forcing_ens_3d(closure_n,xland1,aa0,aa1,xaa0_ens,mbdt_ens,dtime, &
1812 ierr,ierr2,ierr3,xf_ens,j,'deeps',axx, &
1813 maxens,iens,iedt,maxens2,maxens3,mconv, &
1814 po_cup,ktop,omeg,zdo,k22,zuo,pr_ens,edto,kbcon, &
1815 massflx,iact,direction,ensdim,massfln,ichoice,edt_out, &
1816 high_resolution,itf,jtf,ktf, &
1817 its,ite, jts,jte, kts,kte,ens4,ktau)
1821 if(ierr(i).eq.0)then
1822 subt_ens(i,k,iedt)=dsubt(i,k)
1823 subq_ens(i,k,iedt)=dsubq(i,k)
1824 dellat_ens(i,k,iedt)=dellat(i,k)
1825 dellaq_ens(i,k,iedt)=dellaq(i,k)
1826 dellaqc_ens(i,k,iedt)=dellaqc(i,k)
1827 pwo_ens(i,k,iedt)=pwo(i,k)+edt(i)*pwdo(i,k)
1829 subt_ens(i,k,iedt)=0.
1830 subq_ens(i,k,iedt)=0.
1831 dellat_ens(i,k,iedt)=0.
1832 dellaq_ens(i,k,iedt)=0.
1833 dellaqc_ens(i,k,iedt)=0.
1834 pwo_ens(i,k,iedt)=0.
1836 ! if(i.eq.ipr.and.j.eq.jpr)then
1837 ! write(0,*)'1',iens,iedt,dellat(i,k),dellat_ens(i,k,iedt), &
1838 ! dellaq(i,k), dellaqc(i,k)
1839 ! write(0,*)'2',k,subt_ens(i,k,iedt),subq_ens(i,k,iedt)
1847 call cup_output_ens_3d(xf_ens,ierr,dellat_ens,dellaq_ens, &
1848 dellaqc_ens,subt_ens,subq_ens,subt,subq,outt, &
1849 outq,outqc,zuo,sub_mas,pre,pwo_ens,xmb,ktop, &
1850 j,'deep',maxens2,maxens,iens,ierr2,ierr3, &
1851 pr_ens,maxens3,ensdim,massfln, &
1852 APR_GR,APR_W,APR_MC,APR_ST,APR_AS, &
1853 APR_CAPMA,APR_CAPME,APR_CAPMI,closure_n,xland1, &
1855 its,ite, jts,jte, kts,kte)
1858 if(ierr(i).eq.0.and.ierr5(i).eq.0.and.kbcon(i).lt.ktop3(i)+1)then
1859 ! write(0,*)'both ier and ier5=0 at i,j=',i,j,kbcon(i),ktop3(i)
1860 if(high_resolution.eq.1)then
1864 elseif (ierr5(i).eq.0)then
1865 ! write(0,*)'ier5=0 at i,j=',i,j,k23(i),ktop3(i)
1868 PRE(I)=MAX(PRE(I),0.)
1869 ! if(i.eq.ipr.and.j.eq.jpr)then
1870 ! write(0,*)'i,j,pre(i),aa0(i),aa1(i)'
1871 ! write(0,*)i,j,pre(i),aa0(i)
1875 !---------------------------done------------------------------
1878 ! if(ierr(i).eq.0)then
1879 ! if(i.eq.ipr.and.j.eq.jpr)then
1880 ! write(0,*)'on output, pre =',pre(i),its,itf,kts,ktf
1882 ! write(0,*)z(i,k),outt(i,k)*86400.,subt(i,k)*86400.
1884 ! write(0,*)i,j,(axx(i,k),k=1,ens4)
1888 ! print *,'ierr(i) = ',ierr(i),pre(i)
1890 END SUBROUTINE CUP_enss_3d
1893 SUBROUTINE cup_dd_aa0(edt,ierr,aa0,jmin,gamma_cup,t_cup, &
1896 its,ite, jts,jte, kts,kte )
1903 ! only local wrf dimensions are need as of now in this routine
1908 its,ite, jts,jte, kts,kte
1909 ! aa0 cloud work function for downdraft
1910 ! gamma_cup = gamma on model cloud levels
1911 ! t_cup = temperature (Kelvin) on model cloud levels
1912 ! hes_cup = saturation moist static energy on model cloud levels
1913 ! hcd = moist static energy in downdraft
1915 ! zd normalized downdraft mass flux
1916 ! z = heights of model levels
1917 ! ierr error value, maybe modified in this routine
1919 real, dimension (its:ite,kts:kte) &
1921 z,zd,gamma_cup,t_cup,hes_cup,hcd
1922 real, dimension (its:ite) &
1925 integer, dimension (its:ite) &
1933 integer, dimension (its:ite) &
1934 ,intent (inout) :: &
1936 real, dimension (its:ite) &
1940 ! local variables in this routine
1955 IF(ierr(I).eq.0.and.k.lt.jmin(i))then
1960 DZ=(Z(I,KK)-Z(I,KK+1))
1961 AA0(I)=AA0(I)+zd(i,kk)*EDT(I)*DZ*(9.81/(1004.*T_cup(I,KK))) &
1962 *((hcd(i,kk)-hes_cup(i,kk))/(1.+GAMMA_cup(i,kk)))
1967 END SUBROUTINE CUP_dd_aa0
1970 SUBROUTINE cup_dd_edt(ierr,us,vs,z,ktop,kbcon,edt,p,pwav, &
1971 pwev,edtmax,edtmin,maxens2,edtc, &
1973 its,ite, jts,jte, kts,kte )
1980 its,ite, jts,jte, kts,kte
1981 integer, intent (in ) :: &
1984 ! ierr error value, maybe modified in this routine
1986 real, dimension (its:ite,kts:kte) &
1989 real, dimension (its:ite,1:maxens2) &
1992 real, dimension (its:ite) &
1995 real, dimension (its:ite) &
2001 integer, dimension (its:ite) &
2004 integer, dimension (its:ite) &
2005 ,intent (inout) :: &
2008 ! local variables in this routine
2012 real einc,pef,pefb,prezk,zkbc
2013 real, dimension (its:ite) :: &
2017 !--- DETERMINE DOWNDRAFT STRENGTH IN TERMS OF WINDSHEAR
2019 ! */ calculate an average wind shear over the depth of the cloud
2034 IF(ierr(i).ne.0)GO TO 62
2035 if (kk .le. min0(ktop(i),ktf) .and. kk .ge. kbcon(i)) then
2037 (abs((us(i,kk+1)-us(i,kk))/(z(i,kk+1)-z(i,kk))) &
2038 + abs((vs(i,kk+1)-vs(i,kk))/(z(i,kk+1)-z(i,kk)))) * &
2039 (p(i,kk) - p(i,kk+1))
2040 sdp(i) = sdp(i) + p(i,kk) - p(i,kk+1)
2042 if (kk .eq. ktf-1)vshear(i) = 1.e3 * vws(i) / sdp(i)
2046 IF(ierr(i).eq.0)then
2047 pef=(1.591-.639*VSHEAR(I)+.0953*(VSHEAR(I)**2) &
2048 -.00496*(VSHEAR(I)**3))
2052 !--- cloud base precip efficiency
2054 zkbc=z(i,kbcon(i))*3.281e-3
2057 prezk=.96729352+zkbc*(-.70034167+zkbc*(.162179896+zkbc &
2058 *(- 1.2569798E-2+zkbc*(4.2772E-4-zkbc*5.44E-6))))
2064 if(pefb.gt.1.)pefb=1.
2065 if(pefb.lt.0.)pefb=0.
2066 EDT(I)=1.-.5*(pefb+pef)
2067 !--- edt here is 1-precipeff!
2070 edtc(i,k)=edt(i)+float(k-2)*einc
2075 IF(ierr(i).eq.0)then
2077 EDTC(I,K)=-EDTC(I,K)*PWAV(I)/PWEV(I)
2078 IF(EDTC(I,K).GT.edtmax)EDTC(I,K)=edtmax
2079 IF(EDTC(I,K).LT.edtmin)EDTC(I,K)=edtmin
2084 END SUBROUTINE cup_dd_edt
2087 SUBROUTINE cup_dd_he(hes_cup,zd,hcd,z_cup,cdd,entr, &
2088 jmin,ierr,he,dby,he_cup, &
2090 its,ite, jts,jte, kts,kte )
2097 ! only local wrf dimensions are need as of now in this routine
2102 its,ite, jts,jte, kts,kte
2103 ! hcd = downdraft moist static energy
2104 ! he = moist static energy on model levels
2105 ! he_cup = moist static energy on model cloud levels
2106 ! hes_cup = saturation moist static energy on model cloud levels
2107 ! dby = buoancy term
2108 ! cdd= detrainment function
2109 ! z_cup = heights of model cloud levels
2110 ! entr = entrainment rate
2111 ! zd = downdraft normalized mass flux
2113 real, dimension (its:ite,kts:kte) &
2115 he,he_cup,hes_cup,z_cup,cdd,zd
2116 ! entr= entrainment rate
2120 integer, dimension (its:ite) &
2127 ! ierr error value, maybe modified in this routine
2129 integer, dimension (its:ite) &
2130 ,intent (inout) :: &
2133 real, dimension (its:ite,kts:kte) &
2137 ! local variables in this routine
2149 IF(ierr(I).eq.0)then
2150 hcd(i,k)=hes_cup(i,k)
2156 IF(ierr(I).eq.0)then
2158 hcd(i,k)=hes_cup(i,k)
2159 dby(i,k)=hcd(i,jmin(i))-hes_cup(i,k)
2161 do ki=jmin(i)-1,1,-1
2162 DZ=Z_cup(i,Ki+1)-Z_cup(i,Ki)
2163 HCD(i,Ki)=(HCD(i,Ki+1)*(1.-.5*CDD(i,Ki)*DZ) &
2165 )/(1.+entr*DZ-.5*CDD(i,Ki)*DZ)
2166 dby(i,ki)=HCD(i,Ki)-hes_cup(i,ki)
2170 !--- end loop over i
2174 END SUBROUTINE cup_dd_he
2177 SUBROUTINE cup_dd_moisture_3d(zd,hcd,hes_cup,qcd,qes_cup, &
2178 pwd,q_cup,z_cup,cdd,entr,jmin,ierr, &
2179 gamma_cup,pwev,bu,qrcd, &
2180 q,he,t_cup,iloop,xl,high_resolution, &
2182 its,ite, jts,jte, kts,kte )
2189 its,ite, jts,jte, kts,kte,high_resolution
2190 ! cdd= detrainment function
2191 ! q = environmental q on model levels
2192 ! q_cup = environmental q on model cloud levels
2193 ! qes_cup = saturation q on model cloud levels
2194 ! hes_cup = saturation h on model cloud levels
2195 ! hcd = h in model cloud
2197 ! zd = normalized downdraft mass flux
2198 ! gamma_cup = gamma on model cloud levels
2199 ! mentr_rate = entrainment rate
2200 ! qcd = cloud q (including liquid water) after entrainment
2201 ! qrch = saturation q in cloud
2202 ! pwd = evaporate at that level
2203 ! pwev = total normalized integrated evaoprate (I2)
2204 ! entr= entrainment rate
2206 real, dimension (its:ite,kts:kte) &
2208 zd,t_cup,hes_cup,hcd,qes_cup,q_cup,z_cup,cdd,gamma_cup,q,he
2215 integer, dimension (its:ite) &
2218 integer, dimension (its:ite) &
2219 ,intent (inout) :: &
2221 real, dimension (its:ite,kts:kte) &
2224 real, dimension (its:ite) &
2228 ! local variables in this routine
2251 IF(ierr(I).eq.0)then
2253 DZ=Z_cup(i,K+1)-Z_cup(i,K)
2255 if(high_resolution.eq.1)qcd(i,k)=.5*(qes_cup(i,k)+q_cup(i,k))
2256 qrcd(i,k)=qes_cup(i,k)
2257 pwd(i,jmin(i))=min(0.,qcd(i,k)-qrcd(i,k))
2258 pwev(i)=pwev(i)+pwd(i,jmin(i))
2259 qcd(i,k)=qes_cup(i,k)
2261 DH=HCD(I,k)-HES_cup(I,K)
2263 do ki=jmin(i)-1,1,-1
2264 DZ=Z_cup(i,Ki+1)-Z_cup(i,Ki)
2265 QCD(i,Ki)=(qCD(i,Ki+1)*(1.-.5*CDD(i,Ki)*DZ) &
2267 )/(1.+entr*DZ-.5*CDD(i,Ki)*DZ)
2269 !--- to be negatively buoyant, hcd should be smaller than hes!
2271 DH=HCD(I,ki)-HES_cup(I,Ki)
2273 QRCD(I,Ki)=qes_cup(i,ki)+(1./XL)*(GAMMA_cup(i,ki) &
2274 /(1.+GAMMA_cup(i,ki)))*DH
2275 dqeva=qcd(i,ki)-qrcd(i,ki)
2276 if(dqeva.gt.0.)dqeva=0.
2277 pwd(i,ki)=zd(i,ki)*dqeva
2278 qcd(i,ki)=qrcd(i,ki)
2279 pwev(i)=pwev(i)+pwd(i,ki)
2280 ! if(iloop.eq.1.and.i.eq.102.and.j.eq.62)then
2281 ! print *,'in cup_dd_moi ', hcd(i,ki),HES_cup(I,Ki),dh,dqeva
2285 !--- end loop over i
2286 if(pwev(I).eq.0.and.iloop.eq.1)then
2287 ! print *,'problem with buoy in cup_dd_moisture',i
2290 if(BU(I).GE.0.and.iloop.eq.1)then
2291 ! print *,'problem with buoy in cup_dd_moisture',i
2297 END SUBROUTINE cup_dd_moisture_3d
2300 SUBROUTINE cup_dd_nms(zd,z_cup,cdd,entr,jmin,ierr, &
2303 its,ite, jts,jte, kts,kte )
2310 ! only local wrf dimensions are need as of now in this routine
2315 its,ite, jts,jte, kts,kte
2316 ! z_cup = height of cloud model level
2317 ! z1 = terrain elevation
2318 ! entr = downdraft entrainment rate
2319 ! jmin = downdraft originating level
2320 ! kdet = level above ground where downdraft start detraining
2321 ! itest = flag to whether to calculate cdd
2323 real, dimension (its:ite,kts:kte) &
2326 real, dimension (its:ite) &
2332 integer, dimension (its:ite) &
2342 ! ierr error value, maybe modified in this routine
2344 integer, dimension (its:ite) &
2345 ,intent (inout) :: &
2347 ! zd is the normalized downdraft mass flux
2348 ! cdd is the downdraft detrainmen function
2350 real, dimension (its:ite,kts:kte) &
2353 real, dimension (its:ite,kts:kte) &
2354 ,intent (inout) :: &
2357 ! local variables in this routine
2366 !--- perc is the percentage of mass left when hitting the ground
2373 if(itest.eq.0)cdd(i,k)=0.
2381 IF(ierr(I).eq.0)then
2384 !--- integrate downward, specify detrainment(cdd)!
2386 do ki=jmin(i)-1,1,-1
2387 DZ=Z_cup(i,Ki+1)-Z_cup(i,Ki)
2388 if(ki.le.kdet(i).and.itest.eq.0)then
2389 cdd(i,ki)=entr+(1.- (a*(z_cup(i,ki)-z1(i)) &
2390 +perc*(z_cup(i,kdet(i))-z1(i)) ) &
2391 /(a*(z_cup(i,ki+1)-z1(i)) &
2392 +perc*(z_cup(i,kdet(i))-z1(i))))/dz
2394 zd(i,ki)=zd(i,ki+1)*(1.+(entr-cdd(i,ki))*dz)
2398 !--- end loop over i
2401 END SUBROUTINE cup_dd_nms
2404 SUBROUTINE cup_dellabot(name,ipr,jpr,he_cup,ierr,z_cup,p_cup, &
2405 hcd,edt,zd,cdd,he,della,subs,j,mentrd_rate,z,g, &
2407 its,ite, jts,jte, kts,kte )
2414 its,ite, jts,jte, kts,kte
2415 integer, intent (in ) :: &
2417 character *(*), intent (in) :: &
2420 ! ierr error value, maybe modified in this routine
2422 real, dimension (its:ite,kts:kte) &
2425 real, dimension (its:ite,kts:kte) &
2427 z_cup,p_cup,hcd,zd,cdd,he,z,he_cup
2428 real, dimension (its:ite) &
2434 integer, dimension (its:ite) &
2435 ,intent (inout) :: &
2438 ! local variables in this routine
2442 real detdo,detdo1,detdo2,entdo,dp,dz,subin, &
2446 ! if(name.eq.'shallow')then
2453 if(ierr(i).ne.0)go to 100
2454 dz=z_cup(i,2)-z_cup(i,1)
2455 DP=100.*(p_cup(i,1)-P_cup(i,2))
2456 detdo1=edt(i)*zd(i,2)*CDD(i,1)*DZ
2457 detdo2=edt(i)*zd(i,1)
2458 entdo=edt(i)*zd(i,2)*mentrd_rate*dz
2459 subin=-EDT(I)*zd(i,2)
2460 detdo=detdo1+detdo2-entdo+subin
2461 DELLA(I,1)=(detdo1*.5*(HCD(i,1)+HCD(i,2)) &
2463 +subin*he_cup(i,2) &
2464 -entdo*he(i,1))*g/dp
2466 ! if(i.eq.ipr.and.j.eq.jpr)then
2467 ! write(0,*)'db1',della(i,1),subs(i,1),subin,entdo
2468 ! write(0,*)'db2',detdo1,detdo2,detdo1+detdo2-entdo+subin
2472 END SUBROUTINE cup_dellabot
2475 SUBROUTINE cup_dellas_3d(ierr,z_cup,p_cup,hcd,edt,zd,cdd, &
2476 he,della,subs,j,mentrd_rate,zu,g, &
2477 cd,hc,ktop,k22,kbcon,mentr_rate,jmin,he_cup,kdet,kpbl, &
2478 ipr,jpr,name,high_res, &
2480 its,ite, jts,jte, kts,kte )
2487 its,ite, jts,jte, kts,kte
2488 integer, intent (in ) :: &
2491 ! ierr error value, maybe modified in this routine
2493 real, dimension (its:ite,kts:kte) &
2496 real, dimension (its:ite,kts:kte) &
2498 z_cup,p_cup,hcd,zd,cdd,he,hc,cd,zu,he_cup
2499 real, dimension (its:ite) &
2504 g,mentrd_rate,mentr_rate
2505 integer, dimension (its:ite) &
2507 kbcon,ktop,k22,jmin,kdet,kpbl
2508 integer, dimension (its:ite) &
2509 ,intent (inout) :: &
2511 character *(*), intent (in) :: &
2514 ! local variables in this routine
2518 real detdo1,detdo2,entdo,dp,dz,subin,detdo,entup, &
2519 detup,subdown,entdoj,entupk,detupk,totmas
2523 if(name.eq.'shallow')kstart=kts
2531 ! no downdrafts for shallow convection
2533 DO 100 k=kts+1,ktf-1
2535 IF(ierr(i).ne.0)GO TO 100
2536 IF(K.Gt.KTOP(I))GO TO 100
2537 if(k.lt.k22(i)-1.and.name.eq.'shallow')GO TO 100
2539 !--- SPECIFY DETRAINMENT OF DOWNDRAFT, HAS TO BE CONSISTENT
2540 !--- WITH ZD CALCULATIONS IN SOUNDD.
2542 DZ=Z_cup(I,K+1)-Z_cup(I,K)
2543 detdo=edt(i)*CDD(i,K)*DZ*ZD(i,k+1)
2544 entdo=edt(i)*mentrd_rate*dz*zd(i,k+1)
2545 !3d subin=zu(i,k+1)-zd(i,k+1)*edt(i)
2546 subin=-zd(i,k+1)*edt(i)
2549 if(k.ge.kbcon(i).and.k.lt.ktop(i))then
2550 entup=mentr_rate*dz*zu(i,k)
2551 detup=CD(i,K+1)*DZ*ZU(i,k)
2553 !3d subdown=(zu(i,k)-zd(i,k)*edt(i))
2554 subdown=-zd(i,k)*edt(i)
2559 if(k.eq.jmin(i))then
2560 entdoj=edt(i)*zd(i,k)
2563 if(k.eq.k22(i)-1)then
2564 entupk=zu(i,kpbl(i))
2565 subin=zu(i,k+1)-zd(i,k+1)*edt(i)
2566 if(high_res.eq.1)subin=-zd(i,k+1)*edt(i)
2567 ! subin=-zd(i,k+1)*edt(i)
2570 if(k.gt.kdet(i))then
2574 if(k.eq.ktop(i)-0)then
2575 detupk=zu(i,ktop(i))
2578 ! this subsidene for ktop now in subs term!
2582 if(k.lt.kbcon(i))then
2586 !C--- CHANGED DUE TO SUBSIDENCE AND ENTRAINMENT
2588 totmas=subin-subdown+detup-entup-entdo+ &
2589 detdo-entupk-entdoj+detupk
2590 ! if(j.eq.jpr.and.i.eq.ipr)print *,'k,totmas,sui,sud = ',k,
2591 ! 1 totmas,subin,subdown
2592 ! if(j.eq.jpr.and.i.eq.ipr)print *,'updr stuff = ',detup,
2593 ! 1 entup,entupk,detupk
2594 ! if(j.eq.jpr.and.i.eq.ipr)print *,'dddr stuff = ',entdo,
2596 if(abs(totmas).gt.1.e-6)then
2597 ! print *,'*********************',i,j,k,totmas,name
2598 ! print *,kpbl(i),k22(i),kbcon(i),ktop(i)
2599 !c print *,'updr stuff = ',subin,
2600 !c 1 subdown,detup,entup,entupk,detupk
2601 !c print *,'dddr stuff = ',entdo,
2603 ! call wrf_error_fatal ( 'totmas .gt.1.e-6' )
2605 dp=100.*(p_cup(i,k-1)-p_cup(i,k))
2606 della(i,k)=(detup*.5*(HC(i,K+1)+HC(i,K)) &
2607 +detdo*.5*(HCD(i,K+1)+HCD(i,K)) &
2610 +subin*he_cup(i,k+1) &
2611 -subdown*he_cup(i,k) &
2612 +detupk*(hc(i,ktop(i))-he_cup(i,ktop(i))) &
2613 -entupk*he_cup(i,k22(i)) &
2614 -entdoj*he_cup(i,jmin(i)) &
2616 if(high_res.eq.1)then
2617 ! the first term includes entr and detr into/from updraft as well as (entup-detup)*he(i,k) from
2618 ! neighbouring point, to make things mass consistent....
2619 ! if(k.ge.k22(i))then
2621 detup*.5*(HC(i,K+1)+HC(i,K))-entup*he(i,k)+(entup-detup)*he(i,k) &
2622 +detdo*.5*(HCD(i,K+1)+HCD(i,K)) &
2624 +subin*he_cup(i,k+1) &
2625 -subdown*he_cup(i,k) &
2626 +detupk*(hc(i,ktop(i))-he(i,ktop(i))) &
2627 -entdoj*he_cup(i,jmin(i)) &
2628 -entupk*he_cup(i,k22(i))+entupk*he(i,k) &
2630 ! else if(k.eq.k22(i)-1)then
2631 ! della(i,k)=(-entupk*he_cup(i,k22(i))+entupk*he(i,k))*g/dp
2633 !3d subin=zu(i,k+1)-zd(i,k+1)*edt(i)
2635 ! updraft subsidence only
2637 if(k.ge.k22(i).and.k.lt.ktop(i))then
2638 subs(i,k)=(zu(i,k+1)*he_cup(i,k+1) &
2639 -zu(i,k)*he_cup(i,k))*g/dp
2640 ! else if(k.eq.ktop(i))then
2641 ! subs(i,k)=-detupk*he_cup(i,k)*g/dp
2644 ! in igh res case, subsidence terms are for meighbouring points only. This has to be
2645 ! done mass consistent with the della term
2646 if(high_res.eq.1)then
2647 if(k.ge.k22(i).and.k.lt.ktop(i))then
2648 subs(i,k)=(zu(i,k+1)*he_cup(i,k+1)-zu(i,k)*he_cup(i,k)-(entup-detup)*he(i,k))*g/dp
2649 else if(k.eq.ktop(i))then
2650 subs(i,k)=detupk*(he(i,ktop(i))-he_cup(i,ktop(i)))*g/dp
2651 else if(k.eq.k22(i)-1)then
2652 subs(i,k)=(entupk*he(i,k)-entupk*he_cup(i,k))*g/dp
2655 ! if(i.eq.ipr.and.j.eq.jpr)then
2656 ! write(0,*)'d',k,della(i,k),subs(i,k),subin,subdown
2657 !! write(0,*)'d',detup,entup,entdo,entupk,entdoj
2658 !! print *,k,della(i,k),subin*he_cup(i,k+1),subdown*he_cup(i,k),
2659 !! 1 detdo*.5*(HCD(i,K+1)+HCD(i,K))
2660 !! print *,k,detup*.5*(HC(i,K+1)+HC(i,K)),detupk*hc(i,ktop(i)),
2661 !! 1 entup*he(i,k),entdo*he(i,k)
2662 !! print *,k,he_cup(i,k+1),he_cup(i,k),entupk*he_cup(i,k)
2667 END SUBROUTINE cup_dellas_3d
2670 SUBROUTINE cup_direction2(i,j,dir,id,massflx, &
2671 iresult,imass,massfld, &
2673 its,ite, jts,jte, kts,kte )
2680 its,ite, jts,jte, kts,kte
2681 integer, intent (in ) :: &
2683 integer, intent (out ) :: &
2686 ! ierr error value, maybe modified in this routine
2688 integer, dimension (its:ite,jts:jte) &
2691 real, dimension (its:ite,jts:jte) &
2694 real, dimension (its:ite) &
2695 ,intent (inout) :: &
2701 ! local variables in this routine
2704 integer k,ia,ja,ib,jb
2710 massfld=massflx(i,j)
2715 if(dir(i).lt.22.5)dir(i)=360.+dir(i)
2716 if(id(i,j).eq.1)iresult=1
2725 if(dir(i).gt.90.-diff.and.dir(i).le.90.+diff)then
2726 !--- steering flow from the east
2727 if(id(ib,j).eq.1)then
2730 massfld=max(massflx(ib,j),massflx(i,j))
2734 else if(dir(i).gt.135.-diff.and.dir(i).le.135.+diff)then
2735 !--- steering flow from the south-east
2736 if(id(ib,ja).eq.1)then
2739 massfld=max(massflx(ib,ja),massflx(i,j))
2743 !--- steering flow from the south
2744 else if(dir(i).gt.180.-diff.and.dir(i).le.180.+diff)then
2745 if(id(i,ja).eq.1)then
2748 massfld=max(massflx(i,ja),massflx(i,j))
2752 !--- steering flow from the south west
2753 else if(dir(i).gt.225.-diff.and.dir(i).le.225.+diff)then
2754 if(id(ia,ja).eq.1)then
2757 massfld=max(massflx(ia,ja),massflx(i,j))
2761 !--- steering flow from the west
2762 else if(dir(i).gt.270.-diff.and.dir(i).le.270.+diff)then
2763 if(id(ia,j).eq.1)then
2766 massfld=max(massflx(ia,j),massflx(i,j))
2770 !--- steering flow from the north-west
2771 else if(dir(i).gt.305.-diff.and.dir(i).le.305.+diff)then
2772 if(id(ia,jb).eq.1)then
2775 massfld=max(massflx(ia,jb),massflx(i,j))
2779 !--- steering flow from the north
2780 else if(dir(i).gt.360.-diff.and.dir(i).le.360.+diff)then
2781 if(id(i,jb).eq.1)then
2784 massfld=max(massflx(i,jb),massflx(i,j))
2788 !--- steering flow from the north-east
2789 else if(dir(i).gt.45.-diff.and.dir(i).le.45.+diff)then
2790 if(id(ib,jb).eq.1)then
2793 massfld=max(massflx(ib,jb),massflx(i,j))
2799 END SUBROUTINE cup_direction2
2802 SUBROUTINE cup_env(z,qes,he,hes,t,q,p,z1, &
2803 psur,ierr,tcrit,itest,xl,cp, &
2805 its,ite, jts,jte, kts,kte )
2812 its,ite, jts,jte, kts,kte
2814 ! ierr error value, maybe modified in this routine
2815 ! q = environmental mixing ratio
2816 ! qes = environmental saturation mixing ratio
2817 ! t = environmental temp
2818 ! tv = environmental virtual temp
2819 ! p = environmental pressure
2820 ! z = environmental heights
2821 ! he = environmental moist static energy
2822 ! hes = environmental saturation moist static energy
2823 ! psur = surface pressure
2824 ! z1 = terrain elevation
2827 real, dimension (its:ite,kts:kte) &
2830 real, dimension (its:ite,kts:kte) &
2833 real, dimension (its:ite,kts:kte) &
2834 ,intent (inout) :: &
2836 real, dimension (its:ite) &
2842 integer, dimension (its:ite) &
2843 ,intent (inout) :: &
2849 ! local variables in this routine
2854 real, dimension (1:2) :: AE,BE,HT
2855 real, dimension (its:ite,kts:kte) :: tv
2856 real :: tcrit,e,tvbar
2861 BE(1)=.622*HT(1)/.286
2862 AE(1)=BE(1)/273.+ALOG(610.71)
2863 BE(2)=.622*HT(2)/.286
2864 AE(2)=BE(2)/273.+ALOG(610.71)
2865 ! print *, 'TCRIT = ', tcrit,its,ite
2868 if(ierr(i).eq.0)then
2869 !Csgb - IPH is for phase, dependent on TCRIT (water or ice)
2871 IF(T(I,K).LE.TCRIT)IPH=2
2872 ! print *, 'AE(IPH),BE(IPH) = ',AE(IPH),BE(IPH),AE(IPH)-BE(IPH),T(i,k),i,k
2873 E=EXP(AE(IPH)-BE(IPH)/T(I,K))
2874 ! print *, 'P, E = ', P(I,K), E
2875 QES(I,K)=.622*E/(100.*P(I,K)-E)
2876 IF(QES(I,K).LE.1.E-08)QES(I,K)=1.E-08
2877 IF(QES(I,K).LT.Q(I,K))QES(I,K)=Q(I,K)
2878 ! IF(Q(I,K).GT.QES(I,K))Q(I,K)=QES(I,K)
2879 TV(I,K)=T(I,K)+.608*Q(I,K)*T(I,K)
2884 !--- z's are calculated with changed h's and q's and t's
2889 if(ierr(i).eq.0)then
2890 Z(I,1)=max(0.,Z1(I))-(ALOG(P(I,1))- &
2891 ALOG(PSUR(I)))*287.*TV(I,1)/9.81
2895 ! --- calculate heights
2898 if(ierr(i).eq.0)then
2899 TVBAR=.5*TV(I,K)+.5*TV(I,K-1)
2900 Z(I,K)=Z(I,K-1)-(ALOG(P(I,K))- &
2901 ALOG(P(I,K-1)))*287.*TVBAR/9.81
2908 if(ierr(i).eq.0)then
2909 z(i,k)=(he(i,k)-1004.*t(i,k)-2.5e6*q(i,k))/9.81
2910 z(i,k)=max(1.e-3,z(i,k))
2916 !--- calculate moist static energy - HE
2917 ! saturated moist static energy - HES
2921 if(ierr(i).eq.0)then
2922 if(itest.eq.0)HE(I,K)=9.81*Z(I,K)+1004.*T(I,K)+2.5E06*Q(I,K)
2923 HES(I,K)=9.81*Z(I,K)+1004.*T(I,K)+2.5E06*QES(I,K)
2924 IF(HE(I,K).GE.HES(I,K))HE(I,K)=HES(I,K)
2929 END SUBROUTINE cup_env
2932 SUBROUTINE cup_env_clev(t,qes,q,he,hes,z,p,qes_cup,q_cup, &
2933 he_cup,hes_cup,z_cup,p_cup,gamma_cup,t_cup,psur, &
2936 its,ite, jts,jte, kts,kte )
2943 its,ite, jts,jte, kts,kte
2945 ! ierr error value, maybe modified in this routine
2946 ! q = environmental mixing ratio
2947 ! q_cup = environmental mixing ratio on cloud levels
2948 ! qes = environmental saturation mixing ratio
2949 ! qes_cup = environmental saturation mixing ratio on cloud levels
2950 ! t = environmental temp
2951 ! t_cup = environmental temp on cloud levels
2952 ! p = environmental pressure
2953 ! p_cup = environmental pressure on cloud levels
2954 ! z = environmental heights
2955 ! z_cup = environmental heights on cloud levels
2956 ! he = environmental moist static energy
2957 ! he_cup = environmental moist static energy on cloud levels
2958 ! hes = environmental saturation moist static energy
2959 ! hes_cup = environmental saturation moist static energy on cloud levels
2960 ! gamma_cup = gamma on cloud levels
2961 ! psur = surface pressure
2962 ! z1 = terrain elevation
2965 real, dimension (its:ite,kts:kte) &
2968 real, dimension (its:ite,kts:kte) &
2970 qes_cup,q_cup,he_cup,hes_cup,z_cup,p_cup,gamma_cup,t_cup
2971 real, dimension (its:ite) &
2977 integer, dimension (its:ite) &
2978 ,intent (inout) :: &
2981 ! local variables in this routine
2990 if(ierr(i).eq.0)then
2991 qes_cup(i,k)=.5*(qes(i,k-1)+qes(i,k))
2992 q_cup(i,k)=.5*(q(i,k-1)+q(i,k))
2993 hes_cup(i,k)=.5*(hes(i,k-1)+hes(i,k))
2994 he_cup(i,k)=.5*(he(i,k-1)+he(i,k))
2995 if(he_cup(i,k).gt.hes_cup(i,k))he_cup(i,k)=hes_cup(i,k)
2996 z_cup(i,k)=.5*(z(i,k-1)+z(i,k))
2997 p_cup(i,k)=.5*(p(i,k-1)+p(i,k))
2998 t_cup(i,k)=.5*(t(i,k-1)+t(i,k))
2999 gamma_cup(i,k)=(xl/cp)*(xl/(rv*t_cup(i,k) &
3000 *t_cup(i,k)))*qes_cup(i,k)
3005 if(ierr(i).eq.0)then
3006 qes_cup(i,1)=qes(i,1)
3008 hes_cup(i,1)=hes(i,1)
3010 z_cup(i,1)=.5*(z(i,1)+z1(i))
3011 p_cup(i,1)=.5*(p(i,1)+psur(i))
3013 gamma_cup(i,1)=xl/cp*(xl/(rv*t_cup(i,1) &
3014 *t_cup(i,1)))*qes_cup(i,1)
3018 END SUBROUTINE cup_env_clev
3021 SUBROUTINE cup_forcing_ens_3d(closure_n,xland,aa0,aa1,xaa0,mbdt,dtime,ierr,ierr2,ierr3,&
3022 xf_ens,j,name,axx,maxens,iens,iedt,maxens2,maxens3,mconv, &
3023 p_cup,ktop,omeg,zd,k22,zu,pr_ens,edt,kbcon,massflx, &
3024 iact_old_gr,dir,ensdim,massfln,icoic,edt_out, &
3025 high_resolution,itf,jtf,ktf, &
3026 its,ite, jts,jte, kts,kte,ens4,ktau )
3033 its,ite, jts,jte, kts,kte,ens4,high_resolution,ktau
3034 integer, intent (in ) :: &
3035 j,ensdim,maxens,iens,iedt,maxens2,maxens3
3037 ! ierr error value, maybe modified in this routine
3038 ! pr_ens = precipitation ensemble
3039 ! xf_ens = mass flux ensembles
3040 ! massfln = downdraft mass flux ensembles used in next timestep
3041 ! omeg = omega from large scale model
3042 ! mconv = moisture convergence from large scale model
3043 ! zd = downdraft normalized mass flux
3044 ! zu = updraft normalized mass flux
3045 ! aa0 = cloud work function without forcing effects
3046 ! aa1 = cloud work function with forcing effects
3047 ! xaa0 = cloud work function with cloud effects (ensemble dependent)
3049 ! dir = "storm motion"
3050 ! mbdt = arbitrary numerical parameter
3051 ! dtime = dt over which forcing is applied
3052 ! iact_gr_old = flag to tell where convection was active
3053 ! kbcon = LFC of parcel from k22
3054 ! k22 = updraft originating level
3055 ! icoic = flag if only want one closure (usually set to zero!)
3056 ! name = deep or shallow convection flag
3058 real, dimension (its:ite,jts:jte,1:ensdim) &
3059 ,intent (inout) :: &
3061 real, dimension (its:ite,jts:jte,1:ensdim) &
3064 real, dimension (its:ite,jts:jte) &
3065 ,intent (inout ) :: &
3067 real, dimension (its:ite,jts:jte) &
3070 real, dimension (its:ite,kts:kte) &
3073 real, dimension (its:ite,kts:kte,1:ens4) &
3076 real, dimension (its:ite,1:maxens) &
3079 real, dimension (its:ite) &
3082 real, dimension (its:ite,1:ens4) &
3085 real, dimension (its:ite) &
3086 ,intent (inout) :: &
3088 real, dimension (1:maxens) &
3094 integer, dimension (its:ite,jts:jte) &
3097 integer, dimension (its:ite) &
3100 integer, dimension (its:ite) &
3101 ,intent (inout) :: &
3106 character *(*), intent (in) :: &
3109 ! local variables in this routine
3112 real, dimension (1:maxens3) :: &
3114 real, dimension (1:maxens) :: &
3117 i,k,nall,n,ne,nens,nens3,iresult,iresultd,iresulte,mkxcrt,kclim
3118 parameter (mkxcrt=15)
3120 fens4,a1,massfld,a_ave,xff0,xff00,xxx,xomg,aclim1,aclim2,aclim3,aclim4
3121 real, dimension(1:mkxcrt) :: &
3124 integer :: nall2,ixxx,irandom
3125 integer, allocatable :: seed(:)
3126 integer :: seed_size
3129 DATA PCRIT/850.,800.,750.,700.,650.,600.,550.,500.,450.,400., &
3130 350.,300.,250.,200.,150./
3131 DATA ACRIT/.0633,.0445,.0553,.0664,.075,.1082,.1521,.2216, &
3132 .3151,.3677,.41,.5255,.7663,1.1686,1.6851/
3133 ! GDAS DERIVED ACRIT
3134 DATA ACRITT/.203,.515,.521,.566,.625,.665,.659,.688, &
3135 .743,.813,.886,.947,1.138,1.377,1.896/
3137 call random_seed(size=seed_size) ! Get size of seed array.
3138 allocate(seed(1:seed_size)) ! Allocate according to returned size
3141 if(seed_size .ge. 2) seed(2)=j
3142 if(seed_size .ge. 3) seed(3)=ktau
3145 if(high_resolution.eq.1)irandom=0
3149 !--- LARGE SCALE FORCING
3152 if(name.eq.'deeps'.and.ierr(i).gt.995)then
3156 IF(ierr(i).eq.0)then
3160 if(name.eq.'deeps')then
3164 a_ave=a_ave+axx(i,ne)
3166 a_ave=max(0.,a_ave/fens4)
3167 a_ave=min(a_ave,aa1(i))
3172 xff0= (AA1(I)-AA0(I))/DTIME
3173 if(high_resolution.eq.1)xff0= (a_ave-AA0(I))/DTIME
3174 xff_ens3(1)=(AA1(I)-AA0(I))/dtime
3175 xff_ens3(2)=(a_ave-AA0(I))/dtime
3176 if(irandom.eq.1)then
3178 call random_seed (PUT=seed)
3179 call random_number (xxx)
3180 ixxx=min(ens4,max(1,int(fens4*xxx+1.e-8)))
3181 xff_ens3(3)=(axx(i,ixxx)-AA0(I))/dtime
3182 call random_number (xxx)
3183 ixxx=min(ens4,max(1,int(fens4*xxx+1.e-8)))
3184 xff_ens3(13)=(axx(i,ixxx)-AA0(I))/dtime
3186 xff_ens3(3)=(AA1(I)-AA0(I))/dtime
3187 xff_ens3(13)=(AA1(I)-AA0(I))/dtime
3189 if(high_resolution.eq.1)then
3190 xff_ens3(1)=(a_ave-AA0(I))/dtime
3191 xff_ens3(2)=(a_ave-AA0(I))/dtime
3192 xff_ens3(3)=(a_ave-AA0(I))/dtime
3193 xff_ens3(13)=(a_ave-AA0(I))/dtime
3196 !--- more original Arakawa-Schubert (climatologic value of aa0)
3199 !--- omeg is in bar/s, mconv done with omeg in Pa/s
3200 ! more like Brown (1979), or Frank-Cohen (199?)
3204 xff_ens3(14)=xff_ens3(14)-omeg(i,k22(i),ne)/(fens4*9.81)
3206 if(xff_ens3(14).lt.0.)xff_ens3(14)=0.
3209 xff_ens3(5)=xff_ens3(5)-omeg(i,kbcon(i),ne)/(fens4*9.81)
3211 if(xff_ens3(5).lt.0.)xff_ens3(5)=0.
3213 ! minimum below kbcon
3215 if(high_resolution.eq.0)then
3216 xff_ens3(4)=-omeg(i,2,1)/9.81
3219 xomg=-omeg(i,k,ne)/9.81
3220 if(xomg.lt.xff_ens3(4))xff_ens3(4)=xomg
3223 if(xff_ens3(4).lt.0.)xff_ens3(4)=0.
3226 xff_ens3(6)=-omeg(i,2,1)/9.81
3229 xomg=-omeg(i,k,ne)/9.81
3230 if(xomg.gt.xff_ens3(6))xff_ens3(6)=xomg
3233 if(xff_ens3(6).lt.0.)xff_ens3(6)=0.
3235 if(high_resolution.eq.1)then
3236 xff_ens3(5)=min(xff_ens3(5),xff_ens3(14))
3237 xff_ens3(4)=xff_ens3(5)
3238 xff_ens3(6)=xff_ens3(5)
3241 !--- more like Krishnamurti et al.; pick max and average values
3243 xff_ens3(7)=mconv(i,1)
3244 xff_ens3(8)=mconv(i,1)
3245 xff_ens3(9)=mconv(i,1)
3248 if (mconv(i,ne).gt.xff_ens3(7))xff_ens3(7)=mconv(i,ne)
3251 if (mconv(i,ne).lt.xff_ens3(8))xff_ens3(8)=mconv(i,ne)
3254 xff_ens3(9)=xff_ens3(9)+mconv(i,ne)
3256 xff_ens3(9)=xff_ens3(9)/fens4
3258 if(high_resolution.eq.1)then
3259 xff_ens3(7)=xff_ens3(9)
3260 xff_ens3(8)=xff_ens3(9)
3261 xff_ens3(15)=xff_ens3(9)
3264 if(high_resolution.eq.0)then
3265 if(irandom.eq.1)then
3267 call random_seed (PUT=seed)
3268 call random_number (xxx)
3269 ixxx=min(ens4,max(1,int(fens4*xxx+1.e-8)))
3270 xff_ens3(15)=mconv(i,ixxx)
3272 xff_ens3(15)=mconv(i,1)
3276 !--- more like Fritsch Chappel or Kain Fritsch (plus triggers)
3278 xff_ens3(10)=A_AVE/(60.*40.)
3279 xff_ens3(11)=AA1(I)/(60.*40.)
3280 if(irandom.eq.1)then
3282 call random_seed (PUT=seed)
3283 call random_number (xxx)
3284 ixxx=min(ens4,max(1,int(fens4*xxx+1.e-8)))
3285 xff_ens3(12)=AXX(I,ixxx)/(60.*40.)
3287 xff_ens3(12)=AA1(I)/(60.*40.)
3289 if(high_resolution.eq.1)then
3290 xff_ens3(11)=xff_ens3(10)
3291 xff_ens3(12)=xff_ens3(10)
3294 !--- more original Arakawa-Schubert (climatologic value of aa0)
3312 XK(nens)=(XAA0(I,nens)-AA1(I))/MBDT(2)
3313 if(xk(nens).le.0.and.xk(nens).gt.-1.e-6) &
3315 if(xk(nens).gt.0.and.xk(nens).lt.1.e-6) &
3319 !--- add up all ensembles
3323 !--- for every xk, we have maxens3 xffs
3324 !--- iens is from outermost ensemble (most expensive!
3326 !--- iedt (maxens2 belongs to it)
3327 !--- is from second, next outermost, not so expensive
3329 !--- so, for every outermost loop, we have maxens*maxens2*3
3330 !--- ensembles!!! nall would be 0, if everything is on first
3331 !--- loop index, then ne would start counting, then iedt, then iens....
3336 nall=(iens-1)*maxens3*maxens*maxens2 &
3337 +(iedt-1)*maxens*maxens3 &
3340 ! over water, enfor!e small cap for some of the closures
3342 if(xland(i).lt.0.1)then
3343 if(ierr2(i).gt.0.or.ierr3(i).gt.0)then
3345 massfln(i,j,nall+1)=0.
3347 massfln(i,j,nall+2)=0.
3349 massfln(i,j,nall+3)=0.
3351 massfln(i,j,nall+10)=0.
3353 massfln(i,j,nall+11)=0.
3355 massfln(i,j,nall+12)=0.
3357 massfln(i,j,nall+7)=0.
3359 massfln(i,j,nall+8)=0.
3361 massfln(i,j,nall+9)=0.
3363 massfln(i,j,nall+13)=0.
3365 massfln(i,j,nall+15)=0.
3369 ! end water treatment
3372 !--- check for upwind convection
3376 ! call cup_direction2(i,j,dir,iact_old_gr, &
3377 ! massflx,iresult,1, &
3380 ! ims,ime, jms,jme, kms,kme, &
3381 ! its,ite, jts,jte, kts,kte )
3382 ! if(i.eq.ipr.and.j.eq.jpr.and.iedt.eq.1.and.ne.eq.1)then
3383 ! if(iedt.eq.1.and.ne.eq.1)then
3384 ! print *,massfld,ne,iedt,iens
3385 ! print *,xk(ne),xff_ens3(1),xff_ens3(2),xff_ens3(3)
3387 ! print *,i,j,massfld,aa0(i),aa1(i)
3388 IF(XK(ne).lt.0.and.xff0.gt.0.)iresultd=1
3389 iresulte=max(iresult,iresultd)
3391 if(iresulte.eq.1)then
3393 !--- special treatment for stability closures
3397 xf_ens(i,j,nall+1)=massfld
3398 xf_ens(i,j,nall+2)=massfld
3399 xf_ens(i,j,nall+3)=massfld
3400 xf_ens(i,j,nall+13)=massfld
3401 if(xff_ens3(1).gt.0)xf_ens(i,j,nall+1)=max(0.,-xff_ens3(1)/xk(ne)) &
3403 if(xff_ens3(2).gt.0)xf_ens(i,j,nall+2)=max(0.,-xff_ens3(2)/xk(ne)) &
3405 if(xff_ens3(3).gt.0)xf_ens(i,j,nall+3)=max(0.,-xff_ens3(3)/xk(ne)) &
3407 if(xff_ens3(13).gt.0)xf_ens(i,j,nall+13)=max(0.,-xff_ens3(13)/xk(ne)) &
3411 xf_ens(i,j,nall+1)=massfld
3412 xf_ens(i,j,nall+2)=massfld
3413 xf_ens(i,j,nall+3)=massfld
3414 xf_ens(i,j,nall+13)=massfld
3417 !--- if iresult.eq.1, following independent of xff0
3419 xf_ens(i,j,nall+4)=max(0.,xff_ens3(4) &
3421 xf_ens(i,j,nall+5)=max(0.,xff_ens3(5) &
3423 xf_ens(i,j,nall+6)=max(0.,xff_ens3(6) &
3425 xf_ens(i,j,nall+14)=max(0.,xff_ens3(14) &
3427 a1=max(1.e-3,pr_ens(i,j,nall+7))
3428 xf_ens(i,j,nall+7)=max(0.,xff_ens3(7) &
3430 a1=max(1.e-3,pr_ens(i,j,nall+8))
3431 xf_ens(i,j,nall+8)=max(0.,xff_ens3(8) &
3433 a1=max(1.e-3,pr_ens(i,j,nall+9))
3434 xf_ens(i,j,nall+9)=max(0.,xff_ens3(9) &
3436 a1=max(1.e-3,pr_ens(i,j,nall+15))
3437 xf_ens(i,j,nall+15)=max(0.,xff_ens3(15) &
3439 if(XK(ne).lt.0.)then
3440 xf_ens(i,j,nall+10)=max(0., &
3441 -xff_ens3(10)/xk(ne)) &
3443 xf_ens(i,j,nall+11)=max(0., &
3444 -xff_ens3(11)/xk(ne)) &
3446 xf_ens(i,j,nall+12)=max(0., &
3447 -xff_ens3(12)/xk(ne)) &
3450 xf_ens(i,j,nall+10)=massfld
3451 xf_ens(i,j,nall+11)=massfld
3452 xf_ens(i,j,nall+12)=massfld
3456 xf_ens(i,j,nall+1)=xf_ens(i,j,nall+icoic)
3457 xf_ens(i,j,nall+2)=xf_ens(i,j,nall+icoic)
3458 xf_ens(i,j,nall+3)=xf_ens(i,j,nall+icoic)
3459 xf_ens(i,j,nall+4)=xf_ens(i,j,nall+icoic)
3460 xf_ens(i,j,nall+5)=xf_ens(i,j,nall+icoic)
3461 xf_ens(i,j,nall+6)=xf_ens(i,j,nall+icoic)
3462 xf_ens(i,j,nall+7)=xf_ens(i,j,nall+icoic)
3463 xf_ens(i,j,nall+8)=xf_ens(i,j,nall+icoic)
3464 xf_ens(i,j,nall+9)=xf_ens(i,j,nall+icoic)
3465 xf_ens(i,j,nall+10)=xf_ens(i,j,nall+icoic)
3466 xf_ens(i,j,nall+11)=xf_ens(i,j,nall+icoic)
3467 xf_ens(i,j,nall+12)=xf_ens(i,j,nall+icoic)
3468 xf_ens(i,j,nall+13)=xf_ens(i,j,nall+icoic)
3469 xf_ens(i,j,nall+14)=xf_ens(i,j,nall+icoic)
3470 xf_ens(i,j,nall+15)=xf_ens(i,j,nall+icoic)
3471 xf_ens(i,j,nall+16)=xf_ens(i,j,nall+icoic)
3474 ! 16 is a randon pick from the oher 15
3476 if(irandom.eq.1)then
3477 call random_number (xxx)
3478 ixxx=min(15,max(1,int(15.*xxx+1.e-8)))
3479 xf_ens(i,j,nall+16)=xf_ens(i,j,nall+ixxx)
3481 xf_ens(i,j,nall+16)=xf_ens(i,j,nall+1)
3485 !--- store new for next time step
3488 massfln(i,j,nall+nens3)=edt(i) &
3489 *xf_ens(i,j,nall+nens3)
3490 massfln(i,j,nall+nens3)=max(0., &
3491 massfln(i,j,nall+nens3))
3495 !--- do some more on the caps!!! ne=1 for 175, ne=2 for 100,....
3497 ! do not care for caps here for closure groups 1 and 5,
3498 ! they are fine, do not turn them off here
3501 if(ne.eq.2.and.ierr2(i).gt.0)then
3502 xf_ens(i,j,nall+1) =0.
3503 xf_ens(i,j,nall+2) =0.
3504 xf_ens(i,j,nall+3) =0.
3505 xf_ens(i,j,nall+4) =0.
3506 xf_ens(i,j,nall+5) =0.
3507 xf_ens(i,j,nall+6) =0.
3508 xf_ens(i,j,nall+7) =0.
3509 xf_ens(i,j,nall+8) =0.
3510 xf_ens(i,j,nall+9) =0.
3511 xf_ens(i,j,nall+10)=0.
3512 xf_ens(i,j,nall+11)=0.
3513 xf_ens(i,j,nall+12)=0.
3514 xf_ens(i,j,nall+13)=0.
3515 xf_ens(i,j,nall+14)=0.
3516 xf_ens(i,j,nall+15)=0.
3517 xf_ens(i,j,nall+16)=0.
3518 massfln(i,j,nall+1)=0.
3519 massfln(i,j,nall+2)=0.
3520 massfln(i,j,nall+3)=0.
3521 massfln(i,j,nall+4)=0.
3522 massfln(i,j,nall+5)=0.
3523 massfln(i,j,nall+6)=0.
3524 massfln(i,j,nall+7)=0.
3525 massfln(i,j,nall+8)=0.
3526 massfln(i,j,nall+9)=0.
3527 massfln(i,j,nall+10)=0.
3528 massfln(i,j,nall+11)=0.
3529 massfln(i,j,nall+12)=0.
3530 massfln(i,j,nall+13)=0.
3531 massfln(i,j,nall+14)=0.
3532 massfln(i,j,nall+15)=0.
3533 massfln(i,j,nall+16)=0.
3535 if(ne.eq.3.and.ierr3(i).gt.0)then
3536 xf_ens(i,j,nall+1) =0.
3537 xf_ens(i,j,nall+2) =0.
3538 xf_ens(i,j,nall+3) =0.
3539 xf_ens(i,j,nall+4) =0.
3540 xf_ens(i,j,nall+5) =0.
3541 xf_ens(i,j,nall+6) =0.
3542 xf_ens(i,j,nall+7) =0.
3543 xf_ens(i,j,nall+8) =0.
3544 xf_ens(i,j,nall+9) =0.
3545 xf_ens(i,j,nall+10)=0.
3546 xf_ens(i,j,nall+11)=0.
3547 xf_ens(i,j,nall+12)=0.
3548 xf_ens(i,j,nall+13)=0.
3549 xf_ens(i,j,nall+14)=0.
3550 xf_ens(i,j,nall+15)=0.
3551 xf_ens(i,j,nall+16)=0.
3552 massfln(i,j,nall+1)=0.
3553 massfln(i,j,nall+2)=0.
3554 massfln(i,j,nall+3)=0.
3555 massfln(i,j,nall+4)=0.
3556 massfln(i,j,nall+5)=0.
3557 massfln(i,j,nall+6)=0.
3558 massfln(i,j,nall+7)=0.
3559 massfln(i,j,nall+8)=0.
3560 massfln(i,j,nall+9)=0.
3561 massfln(i,j,nall+10)=0.
3562 massfln(i,j,nall+11)=0.
3563 massfln(i,j,nall+12)=0.
3564 massfln(i,j,nall+13)=0.
3565 massfln(i,j,nall+14)=0.
3566 massfln(i,j,nall+15)=0.
3567 massfln(i,j,nall+16)=0.
3574 nall=(iens-1)*maxens3*maxens*maxens2 &
3575 +(iedt-1)*maxens*maxens3
3578 nall2=(iens-1)*maxens3*maxens*maxens2 &
3579 +(iedt-1)*maxens*maxens3 &
3581 xf_ens(i,j,nall+4) = xf_ens(i,j,nall2+4)
3582 xf_ens(i,j,nall+5) =xf_ens(i,j,nall2+5)
3583 xf_ens(i,j,nall+6) =xf_ens(i,j,nall2+6)
3584 xf_ens(i,j,nall+14) =xf_ens(i,j,nall2+14)
3585 xf_ens(i,j,nall+7) =xf_ens(i,j,nall2+7)
3586 xf_ens(i,j,nall+8) =xf_ens(i,j,nall2+8)
3587 xf_ens(i,j,nall+9) =xf_ens(i,j,nall2+9)
3588 xf_ens(i,j,nall+15) =xf_ens(i,j,nall2+15)
3589 xf_ens(i,j,nall+10)=xf_ens(i,j,nall2+10)
3590 xf_ens(i,j,nall+11)=xf_ens(i,j,nall2+11)
3591 xf_ens(i,j,nall+12)=xf_ens(i,j,nall2+12)
3594 elseif(ierr(i).ne.20.and.ierr(i).ne.0)then
3602 END SUBROUTINE cup_forcing_ens_3d
3605 SUBROUTINE cup_kbcon(cap_inc,iloop,k22,kbcon,he_cup,hes_cup, &
3606 ierr,kbmax,p_cup,cap_max, &
3608 its,ite, jts,jte, kts,kte )
3613 ! only local wrf dimensions are need as of now in this routine
3618 its,ite, jts,jte, kts,kte
3622 ! ierr error value, maybe modified in this routine
3624 real, dimension (its:ite,kts:kte) &
3626 he_cup,hes_cup,p_cup
3627 real, dimension (its:ite) &
3630 integer, dimension (its:ite) &
3633 integer, dimension (its:ite) &
3634 ,intent (inout) :: &
3640 ! local variables in this routine
3648 !--- DETERMINE THE LEVEL OF CONVECTIVE CLOUD BASE - KBCON
3652 IF(ierr(I).ne.0)GO TO 27
3657 IF(KBCON(I).GT.KBMAX(i)+2)THEN
3658 if(iloop.ne.4)ierr(i)=3
3659 ! if(iloop.lt.4)ierr(i)=997
3663 hetest=HE_cup(I,K22(I))
3666 hetest=max(hetest,he_cup(i,k))
3669 IF(HETEST.LT.HES_cup(I,KBCON(I)))GO TO 31
3671 ! cloud base pressure and max moist static energy pressure
3672 ! i.e., the depth (in mb) of the layer of negative buoyancy
3673 if(KBCON(I)-K22(I).eq.1)go to 27
3674 if(iloop.eq.5 .and. (KBCON(I)-K22(I)).eq.0)go to 27
3675 PBCDIF=-P_cup(I,KBCON(I))+P_cup(I,K22(I))
3676 plus=max(25.,cap_max(i)-float(iloop-1)*cap_inc(i))
3677 if(iloop.eq.4)plus=cap_max(i)
3679 ! for shallow convection, if cap_max is greater than 25, it is the pressure at pbltop
3680 if(iloop.eq.5)plus=25.
3681 if(iloop.eq.5.and.cap_max(i).gt.25)pbcdif=-P_cup(I,KBCON(I))+cap_max(i)
3682 IF(PBCDIF.GT.plus)THEN
3689 END SUBROUTINE cup_kbcon
3692 SUBROUTINE cup_ktop(ilo,dby,kbcon,ktop,ierr, &
3694 its,ite, jts,jte, kts,kte )
3701 ! only local wrf dimensions are need as of now in this routine
3706 its,ite, jts,jte, kts,kte
3707 ! dby = buoancy term
3708 ! ktop = cloud top (output)
3710 ! ierr error value, maybe modified in this routine
3712 real, dimension (its:ite,kts:kte) &
3713 ,intent (inout) :: &
3715 integer, dimension (its:ite) &
3721 integer, dimension (its:ite) &
3724 integer, dimension (its:ite) &
3725 ,intent (inout) :: &
3728 ! local variables in this routine
3736 IF(ierr(I).EQ.0)then
3737 DO 40 K=KBCON(I)+1,ktf-1
3738 IF(DBY(I,K).LE.0.)THEN
3743 if(ilo.eq.1)ierr(i)=5
3744 ! if(ilo.eq.2)ierr(i)=998
3750 if(kbcon(i).eq.ktop(i))then
3756 END SUBROUTINE cup_ktop
3759 SUBROUTINE cup_MAXIMI(ARRAY,KS,KE,MAXX,ierr, &
3761 its,ite, jts,jte, kts,kte )
3768 ! only local wrf dimensions are need as of now in this routine
3773 its,ite, jts,jte, kts,kte
3775 ! x output array with return values
3776 ! kt output array of levels
3777 ! ks,kend check-range
3778 real, dimension (its:ite,kts:kte) &
3781 integer, dimension (its:ite) &
3787 integer, dimension (its:ite) &
3790 real, dimension (its:ite) :: &
3799 if(ierr(i).eq.0)then
3804 IF(XAR.GE.X(I)) THEN
3812 END SUBROUTINE cup_MAXIMI
3815 SUBROUTINE cup_minimi(ARRAY,KS,KEND,KT,ierr, &
3817 its,ite, jts,jte, kts,kte )
3824 ! only local wrf dimensions are need as of now in this routine
3829 its,ite, jts,jte, kts,kte
3831 ! x output array with return values
3832 ! kt output array of levels
3833 ! ks,kend check-range
3834 real, dimension (its:ite,kts:kte) &
3837 integer, dimension (its:ite) &
3840 integer, dimension (its:ite) &
3843 real, dimension (its:ite) :: &
3850 if(ierr(i).eq.0)then
3852 KSTOP=MAX(KS(I)+1,KEND(I))
3854 DO 100 K=KS(I)+1,KSTOP
3855 IF(ARRAY(I,K).LT.X(I)) THEN
3863 END SUBROUTINE cup_MINIMI
3866 SUBROUTINE cup_output_ens_3d(xf_ens,ierr,dellat,dellaq,dellaqc, &
3867 subt_ens,subq_ens,subt,subq,outtem,outq,outqc, &
3868 zu,sub_mas,pre,pw,xmb,ktop, &
3869 j,name,nx,nx2,iens,ierr2,ierr3,pr_ens, &
3870 maxens3,ensdim,massfln, &
3871 APR_GR,APR_W,APR_MC,APR_ST,APR_AS, &
3872 APR_CAPMA,APR_CAPME,APR_CAPMI,closure_n,xland1, &
3874 its,ite, jts,jte, kts,kte)
3881 ! only local wrf dimensions are need as of now in this routine
3886 its,ite, jts,jte, kts,kte
3887 integer, intent (in ) :: &
3888 j,ensdim,nx,nx2,iens,maxens3
3889 ! xf_ens = ensemble mass fluxes
3890 ! pr_ens = precipitation ensembles
3891 ! dellat = change of temperature per unit mass flux of cloud ensemble
3892 ! dellaq = change of q per unit mass flux of cloud ensemble
3893 ! dellaqc = change of qc per unit mass flux of cloud ensemble
3894 ! outtem = output temp tendency (per s)
3895 ! outq = output q tendency (per s)
3896 ! outqc = output qc tendency (per s)
3897 ! pre = output precip
3898 ! xmb = total base mass flux
3899 ! xfac1 = correction factor
3900 ! pw = pw -epsilon*pd (ensemble dependent)
3901 ! ierr error value, maybe modified in this routine
3903 real, dimension (its:ite,jts:jte,1:ensdim) &
3904 ,intent (inout) :: &
3905 xf_ens,pr_ens,massfln
3906 real, dimension (its:ite,jts:jte) &
3907 ,intent (inout) :: &
3908 APR_GR,APR_W,APR_MC,APR_ST,APR_AS,APR_CAPMA, &
3911 real, dimension (its:ite,kts:kte) &
3913 outtem,outq,outqc,subt,subq,sub_mas
3914 real, dimension (its:ite,kts:kte) &
3917 real, dimension (its:ite) &
3920 real, dimension (its:ite) &
3921 ,intent (inout ) :: &
3923 real, dimension (its:ite,kts:kte,1:nx) &
3925 subt_ens,subq_ens,dellat,dellaqc,dellaq,pw
3926 integer, dimension (its:ite) &
3929 integer, dimension (its:ite) &
3930 ,intent (inout) :: &
3933 ! local variables in this routine
3939 outtes,ddtes,dtt,dtq,dtqc,dtpw,tuning,prerate,clos_wei,xmbhelp
3942 real, dimension (its:ite) :: &
3944 real, dimension (its:ite):: &
3945 xmb_ske,xmb_ave,xmb_std,xmb_cur,xmbweight
3946 real, dimension (its:ite):: &
3947 pr_ske,pr_ave,pr_std,pr_cur
3948 real, dimension (its:ite,jts:jte):: &
3949 pr_gr,pr_w,pr_mc,pr_st,pr_as,pr_capma, &
3951 real, dimension (5) :: weight,wm,wm1,wm2,wm3
3952 real, dimension (its:ite,5) :: xmb_w
3955 character *(*), intent (in) :: &
3958 weight(1) = -999. !this will turn off weights
3982 IF(ierr(i).eq.0)then
3983 do n=(iens-1)*nx*nx2*maxens3+1,iens*nx*nx2*maxens3
3984 if(pr_ens(i,j,n).le.0.)then
3991 !--- calculate ensemble average mass fluxes
3993 call massflx_stats(xf_ens,ensdim,nx2,nx,maxens3, &
3994 xmb_ave,xmb_std,xmb_cur,xmb_ske,j,ierr,1, &
3995 APR_GR,APR_W,APR_MC,APR_ST,APR_AS, &
3996 APR_CAPMA,APR_CAPME,APR_CAPMI, &
3997 pr_gr,pr_w,pr_mc,pr_st,pr_as, &
3998 pr_capma,pr_capme,pr_capmi, &
4000 its,ite, jts,jte, kts,kte )
4002 call massflx_stats(pr_ens,ensdim,nx2,nx,maxens3, &
4003 pr_ave,pr_std,pr_cur,pr_ske,j,ierr,2, &
4004 APR_GR,APR_W,APR_MC,APR_ST,APR_AS, &
4005 APR_CAPMA,APR_CAPME,APR_CAPMI, &
4006 pr_gr,pr_w,pr_mc,pr_st,pr_as, &
4007 pr_capma,pr_capme,pr_capmi, &
4009 its,ite, jts,jte, kts,kte )
4015 if(ierr(i).eq.0)then
4016 if(xmb_ave(i).le.0.)then
4020 xmb(i)=max(.1*xmb_ave(i),xmb_ave(i)-tuning*xmb_std(i))
4021 ! --- Now use proper count of how many closures were actually
4022 ! used in cup_forcing_ens (including screening of some
4023 ! closures over water) to properly normalize xmb
4024 clos_wei=16./max(1.,closure_n(i))
4025 if (xland1(i).lt.0.5)xmb(i)=xmb(i)*clos_wei
4026 if(xmb(i).eq.0.)then
4029 if(xmb(i).gt.100.)then
4036 ! if(weight(1).lt.-100.)xfac1(i)=xmb_ave(i)
4037 ! if(weight(1).lt.-100.)xfac2(i)=xmb_ave(i)
4047 IF(ierr(i).eq.0.and.k.le.ktop(i))then
4049 dtt=dtt+dellat(i,k,n)
4050 dtts=dtts+subt_ens(i,k,n)
4051 dtq=dtq+dellaq(i,k,n)
4052 dtqs=dtqs+subq_ens(i,k,n)
4053 dtqc=dtqc+dellaqc(i,k,n)
4056 OUTTEM(I,K)=XMB(I)*dtt/float(nx)
4057 SUBT(I,K)=XMB(I)*dtts/float(nx)
4058 OUTQ(I,K)=XMB(I)*dtq/float(nx)
4059 SUBQ(I,K)=XMB(I)*dtqs/float(nx)
4060 OUTQC(I,K)=XMB(I)*dtqc/float(nx)
4061 PRE(I)=PRE(I)+XMB(I)*dtpw/float(nx)
4062 sub_mas(i,k)=zu(i,k)*xmb(i)
4068 if(ierr(i).eq.0)then
4069 do k=(iens-1)*nx*nx2*maxens3+1,iens*nx*nx2*maxens3
4070 massfln(i,j,k)=massfln(i,j,k)*xfac1(i)
4071 xf_ens(i,j,k)=xf_ens(i,j,k)*xfac1(i)
4076 END SUBROUTINE cup_output_ens_3d
4079 SUBROUTINE cup_up_aa0(aa0,z,zu,dby,GAMMA_CUP,t_cup, &
4082 its,ite, jts,jte, kts,kte )
4089 ! only local wrf dimensions are need as of now in this routine
4094 its,ite, jts,jte, kts,kte
4095 ! aa0 cloud work function
4096 ! gamma_cup = gamma on model cloud levels
4097 ! t_cup = temperature (Kelvin) on model cloud levels
4098 ! dby = buoancy term
4099 ! zu= normalized updraft mass flux
4100 ! z = heights of model levels
4101 ! ierr error value, maybe modified in this routine
4103 real, dimension (its:ite,kts:kte) &
4105 z,zu,gamma_cup,t_cup,dby
4106 integer, dimension (its:ite) &
4114 integer, dimension (its:ite) &
4115 ,intent (inout) :: &
4117 real, dimension (its:ite) &
4121 ! local variables in this routine
4134 IF(ierr(i).ne.0)GO TO 100
4135 IF(K.LE.KBCON(I))GO TO 100
4136 IF(K.Gt.KTOP(I))GO TO 100
4138 da=zu(i,k)*DZ*(9.81/(1004.*( &
4139 (T_cup(I,K)))))*DBY(I,K-1)/ &
4141 IF(K.eq.KTOP(I).and.da.le.0.)go to 100
4143 if(aa0(i).lt.0.)aa0(i)=0.
4146 END SUBROUTINE cup_up_aa0
4149 SUBROUTINE cup_up_he(k22,hkb,z_cup,cd,entr,he_cup,hc, &
4150 kbcon,ierr,dby,he,hes_cup,name, &
4152 its,ite, jts,jte, kts,kte )
4159 ! only local wrf dimensions are need as of now in this routine
4164 its,ite, jts,jte, kts,kte
4165 character *(*), intent (in) :: &
4167 ! hc = cloud moist static energy
4168 ! hkb = moist static energy at originating level
4169 ! he = moist static energy on model levels
4170 ! he_cup = moist static energy on model cloud levels
4171 ! hes_cup = saturation moist static energy on model cloud levels
4172 ! dby = buoancy term
4173 ! cd= detrainment function
4174 ! z_cup = heights of model cloud levels
4175 ! entr = entrainment rate
4177 real, dimension (its:ite,kts:kte) &
4179 he,he_cup,hes_cup,z_cup,cd
4180 ! entr= entrainment rate
4184 integer, dimension (its:ite) &
4191 ! ierr error value, maybe modified in this routine
4193 integer, dimension (its:ite) &
4194 ,intent (inout) :: &
4197 real, dimension (its:ite,kts:kte) &
4200 real, dimension (its:ite) &
4204 ! local variables in this routine
4212 !--- moist static energy inside cloud
4224 if(ierr(i).eq.0.)then
4225 hkb(i)=he_cup(i,k22(i))
4226 if(name.eq.'shallow')then
4228 hkb(i)=max(hkb(i),he_cup(i,k))
4234 do k=k22(i),kbcon(i)-1
4239 DBY(I,Kbcon(i))=Hkb(I)-HES_cup(I,K)
4244 if(k.gt.kbcon(i).and.ierr(i).eq.0.)then
4245 DZ=Z_cup(i,K)-Z_cup(i,K-1)
4246 HC(i,K)=(HC(i,K-1)*(1.-.5*CD(i,K)*DZ)+entr* &
4247 DZ*HE(i,K-1))/(1.+entr*DZ-.5*cd(i,k)*dz)
4248 DBY(I,K)=HC(I,K)-HES_cup(I,K)
4254 END SUBROUTINE cup_up_he
4257 SUBROUTINE cup_up_moisture(name,ierr,z_cup,qc,qrc,pw,pwav, &
4258 kbcon,ktop,cd,dby,mentr_rate,clw_all, &
4259 q,GAMMA_cup,zu,qes_cup,k22,qe_cup,xl, &
4261 its,ite, jts,jte, kts,kte )
4268 ! only local wrf dimensions are need as of now in this routine
4273 its,ite, jts,jte, kts,kte
4274 ! cd= detrainment function
4275 ! q = environmental q on model levels
4276 ! qe_cup = environmental q on model cloud levels
4277 ! qes_cup = saturation q on model cloud levels
4278 ! dby = buoancy term
4279 ! cd= detrainment function
4280 ! zu = normalized updraft mass flux
4281 ! gamma_cup = gamma on model cloud levels
4282 ! mentr_rate = entrainment rate
4284 real, dimension (its:ite,kts:kte) &
4286 q,zu,gamma_cup,qe_cup,dby,qes_cup,z_cup,cd
4287 ! entr= entrainment rate
4291 integer, dimension (its:ite) &
4298 ! ierr error value, maybe modified in this routine
4300 integer, dimension (its:ite) &
4301 ,intent (inout) :: &
4303 character *(*), intent (in) :: &
4305 ! qc = cloud q (including liquid water) after entrainment
4306 ! qrch = saturation q in cloud
4307 ! qrc = liquid water content in cloud after rainout
4308 ! pw = condensate that will fall out at that level
4309 ! pwav = totan normalized integrated condensate (I1)
4310 ! c0 = conversion rate (cloud to rain)
4312 real, dimension (its:ite,kts:kte) &
4315 real, dimension (its:ite) &
4319 ! local variables in this routine
4325 dh,qrch,c0,dz,radius
4330 !--- no precip for small clouds
4332 if(name.eq.'shallow')c0=0.
4340 if(ierr(i).eq.0)qc(i,k)=qes_cup(i,k)
4346 if(ierr(i).eq.0.)then
4347 do k=k22(i),kbcon(i)-1
4348 qc(i,k)=qe_cup(i,k22(i))
4355 IF(ierr(i).ne.0)GO TO 100
4356 IF(K.Lt.KBCON(I))GO TO 100
4357 IF(K.Gt.KTOP(I))GO TO 100
4358 DZ=Z_cup(i,K)-Z_cup(i,K-1)
4360 !------ 1. steady state plume equation, for what could
4361 !------ be in cloud without condensation
4364 QC(i,K)=(QC(i,K-1)*(1.-.5*CD(i,K)*DZ)+mentr_rate* &
4365 DZ*Q(i,K-1))/(1.+mentr_rate*DZ-.5*cd(i,k)*dz)
4367 !--- saturation in cloud, this is what is allowed to be in it
4369 QRCH=QES_cup(I,K)+(1./XL)*(GAMMA_cup(i,k) &
4370 /(1.+GAMMA_cup(i,k)))*DBY(I,K)
4372 !------- LIQUID WATER CONTENT IN cloud after rainout
4374 clw_all(i,k)=QC(I,K)-QRCH
4375 QRC(I,K)=(QC(I,K)-QRCH)/(1.+C0*DZ*zu(i,k))
4376 if(qrc(i,k).lt.0.)then
4380 !------- 3.Condensation
4382 PW(i,k)=c0*dz*QRC(I,K)*zu(i,k)
4385 pw(i,k)=(QC(I,K)-QRCH)*zu(i,k)
4386 if(pw(i,k).lt.0.)pw(i,k)=0.
4389 !----- set next level
4391 QC(I,K)=QRC(I,K)+qrch
4393 !--- integrated normalized ondensate
4395 PWAV(I)=PWAV(I)+PW(I,K)
4398 END SUBROUTINE cup_up_moisture
4401 SUBROUTINE cup_up_nms(zu,z_cup,entr,cd,kbcon,ktop,ierr,k22, &
4403 its,ite, jts,jte, kts,kte )
4411 ! only local wrf dimensions are need as of now in this routine
4416 its,ite, jts,jte, kts,kte
4417 ! cd= detrainment function
4418 real, dimension (its:ite,kts:kte) &
4421 ! entr= entrainment rate
4425 integer, dimension (its:ite) &
4432 ! ierr error value, maybe modified in this routine
4434 integer, dimension (its:ite) &
4435 ,intent (inout) :: &
4437 ! zu is the normalized mass flux
4439 real, dimension (its:ite,kts:kte) &
4443 ! local variables in this routine
4451 ! initialize for this go around
4459 ! do normalized mass budget
4462 IF(ierr(I).eq.0)then
4463 do k=k22(i),kbcon(i)
4466 DO K=KBcon(i)+1,KTOP(i)
4467 DZ=Z_cup(i,K)-Z_cup(i,K-1)
4468 ZU(i,K)=ZU(i,K-1)*(1.+(entr-cd(i,k))*DZ)
4473 END SUBROUTINE cup_up_nms
4475 !====================================================================
4476 SUBROUTINE g3init(RTHCUTEN,RQVCUTEN,RQCCUTEN,RQICUTEN, &
4477 MASS_FLUX,cp,restart, &
4478 P_QC,P_QI,P_FIRST_SCALAR, &
4480 APR_GR,APR_W,APR_MC,APR_ST,APR_AS, &
4481 APR_CAPMA,APR_CAPME,APR_CAPMI, &
4482 cugd_tten,cugd_ttens,cugd_qvten, &
4483 cugd_qvtens,cugd_qcten, &
4485 ids, ide, jds, jde, kds, kde, &
4486 ims, ime, jms, jme, kms, kme, &
4487 its, ite, jts, jte, kts, kte )
4488 !--------------------------------------------------------------------
4490 !--------------------------------------------------------------------
4491 LOGICAL , INTENT(IN) :: restart,allowed_to_read
4492 INTEGER , INTENT(IN) :: ids, ide, jds, jde, kds, kde, &
4493 ims, ime, jms, jme, kms, kme, &
4494 its, ite, jts, jte, kts, kte
4495 INTEGER , INTENT(IN) :: P_FIRST_SCALAR, P_QI, P_QC
4496 REAL, INTENT(IN) :: cp
4498 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ) , INTENT(OUT) :: &
4504 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ) , INTENT(OUT) :: &
4510 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ) , INTENT(OUT) :: &
4514 REAL, DIMENSION( ims:ime , jms:jme ) , INTENT(OUT) :: &
4515 APR_GR,APR_W,APR_MC,APR_ST,APR_AS, &
4516 APR_CAPMA,APR_CAPME,APR_CAPMI, &
4519 INTEGER :: i, j, k, itf, jtf, ktf
4525 IF(.not.restart)THEN
4538 cugd_ttens(i,k,j)=0.
4539 cugd_qvten(i,k,j)=0.
4540 cugd_qvtens(i,k,j)=0.
4554 IF (P_QC .ge. P_FIRST_SCALAR) THEN
4559 cugd_qcten(i,k,j)=0.
4565 IF (P_QI .ge. P_FIRST_SCALAR) THEN
4596 END SUBROUTINE g3init
4599 SUBROUTINE massflx_stats(xf_ens,ensdim,maxens,maxens2,maxens3, &
4600 xt_ave,xt_std,xt_cur,xt_ske,j,ierr,itest, &
4601 APR_GR,APR_W,APR_MC,APR_ST,APR_AS, &
4602 APR_CAPMA,APR_CAPME,APR_CAPMI, &
4603 pr_gr,pr_w,pr_mc,pr_st,pr_as, &
4604 pr_capma,pr_capme,pr_capmi, &
4606 its,ite, jts,jte, kts,kte)
4610 integer, intent (in ) :: &
4611 j,ensdim,maxens3,maxens,maxens2,itest
4612 INTEGER, INTENT(IN ) :: &
4614 its,ite, jts,jte, kts,kte
4617 real, dimension (its:ite) &
4618 , intent(inout) :: &
4619 xt_ave,xt_cur,xt_std,xt_ske
4620 integer, dimension (its:ite), intent (in) :: &
4622 real, dimension (its:ite,jts:jte,1:ensdim) &
4625 real, dimension (its:ite,jts:jte) &
4626 , intent(inout) :: &
4627 APR_GR,APR_W,APR_MC,APR_ST,APR_AS, &
4628 APR_CAPMA,APR_CAPME,APR_CAPMI
4629 real, dimension (its:ite,jts:jte) &
4630 , intent(inout) :: &
4631 pr_gr,pr_w,pr_mc,pr_st,pr_as, &
4632 pr_capma,pr_capme,pr_capmi
4637 real, dimension (its:ite , 1:maxens3 ) :: &
4638 x_ave,x_cur,x_std,x_ske
4639 real, dimension (its:ite , 1:maxens ) :: &
4643 integer, dimension (1:maxens3) :: nc1
4645 integer :: num,kk,num2,iedt
4685 if(ierr(i).eq.0)then
4686 x_ave(i,k)=x_ave(i,k)+xf_ens(i,j,maxens3*(kk-1)+k)
4695 if(ierr(i).eq.0)then
4696 x_ave_cap(i,k)=x_ave_cap(i,k) &
4697 +xf_ens(i,j,maxens3*(k-1)+(iedt-1)*maxens*maxens3+kk)
4705 if(ierr(i).eq.0)then
4706 x_ave_cap(i,k)=x_ave_cap(i,k)/float(num2)
4713 if(ierr(i).eq.0)then
4714 x_ave(i,k)=x_ave(i,k)/float(num)
4720 if(ierr(i).eq.0)then
4721 xt_ave(i)=xt_ave(i)+x_ave(i,k)
4726 if(ierr(i).eq.0)then
4727 xt_ave(i)=xt_ave(i)/float(maxens3)
4731 !--- now do std, skewness,curtosis
4736 if(ierr(i).eq.0.and.x_ave(i,k).gt.0.)then
4737 ! print *,i,j,k,kk,x_std(i,k),xf_ens(i,j,maxens3*(kk-1)+k),x_ave(i,k)
4738 x_std(i,k)=x_std(i,k)+(xf_ens(i,j,maxens3*(kk-1)+k)-x_ave(i,k))**2
4739 x_ske(i,k)=x_ske(i,k)+(xf_ens(i,j,maxens3*(kk-1)+k)-x_ave(i,k))**3
4740 x_cur(i,k)=x_cur(i,k)+(xf_ens(i,j,maxens3*(kk-1)+k)-x_ave(i,k))**4
4747 if(ierr(i).eq.0.and.xt_ave(i).gt.0.)then
4748 xt_std(i)=xt_std(i)+(x_ave(i,k)-xt_ave(i))**2
4749 xt_ske(i)=xt_ske(i)+(x_ave(i,k)-xt_ave(i))**3
4750 xt_cur(i)=xt_cur(i)+(x_ave(i,k)-xt_ave(i))**4
4756 if(ierr(i).eq.0.and.x_std(i,k).gt.0.)then
4757 x_std(i,k)=x_std(i,k)/float(num)
4758 a3=max(1.e-6,x_std(i,k))
4760 a3=max(1.e-6,x_std(i,k)**3)
4761 a4=max(1.e-6,x_std(i,k)**4)
4762 x_ske(i,k)=x_ske(i,k)/float(num)/a3
4763 x_cur(i,k)=x_cur(i,k)/float(num)/a4
4766 ! print*,'Some statistics at gridpoint i,j, ierr',i,j,ierr(i)
4767 ! print*,'statistics for closure number ',k
4768 ! print*,'Average= ',x_ave(i,k),' Std= ',x_std(i,k)
4769 ! print*,'Skewness= ',x_ske(i,k),' Curtosis= ',x_cur(i,k)
4775 if(ierr(i).eq.0.and.xt_std(i).gt.0.)then
4776 xt_std(i)=xt_std(i)/float(maxens3)
4777 a3=max(1.e-6,xt_std(i))
4779 a3=max(1.e-6,xt_std(i)**3)
4780 a4=max(1.e-6,xt_std(i)**4)
4781 xt_ske(i)=xt_ske(i)/float(maxens3)/a3
4782 xt_cur(i)=xt_cur(i)/float(maxens3)/a4
4784 ! print*,'Total ensemble independent statistics at i =',i
4785 ! print*,'Average= ',xt_ave(i),' Std= ',xt_std(i)
4786 ! print*,'Skewness= ',xt_ske(i),' Curtosis= ',xt_cur(i)
4789 ! first go around: store massflx for different closures/caps
4792 pr_gr(i,j) = .25*(x_ave(i,1)+x_ave(i,2)+x_ave(i,3)+x_ave(i,13))
4793 pr_w(i,j) = .25*(x_ave(i,4)+x_ave(i,5)+x_ave(i,6)+x_ave(i,14))
4794 pr_mc(i,j) = .25*(x_ave(i,7)+x_ave(i,8)+x_ave(i,9)+x_ave(i,15))
4795 pr_st(i,j) = .333*(x_ave(i,10)+x_ave(i,11)+x_ave(i,12))
4796 pr_as(i,j) = x_ave(i,16)
4797 pr_capma(i,j) = x_ave_cap(i,1)
4798 pr_capme(i,j) = x_ave_cap(i,2)
4799 pr_capmi(i,j) = x_ave_cap(i,3)
4801 ! second go around: store preciprates (mm/hour) for different closures/caps
4803 else if (itest.eq.2)then
4804 APR_GR(i,j)=.25*(x_ave(i,1)+x_ave(i,2)+x_ave(i,3)+x_ave(i,13))* &
4805 3600.*pr_gr(i,j) +APR_GR(i,j)
4806 APR_W(i,j)=.25*(x_ave(i,4)+x_ave(i,5)+x_ave(i,6)+x_ave(i,14))* &
4807 3600.*pr_w(i,j) +APR_W(i,j)
4808 APR_MC(i,j)=.25*(x_ave(i,7)+x_ave(i,8)+x_ave(i,9)+x_ave(i,15))* &
4809 3600.*pr_mc(i,j) +APR_MC(i,j)
4810 APR_ST(i,j)=.333*(x_ave(i,10)+x_ave(i,11)+x_ave(i,12))* &
4811 3600.*pr_st(i,j) +APR_ST(i,j)
4812 APR_AS(i,j)=x_ave(i,16)* &
4813 3600.*pr_as(i,j) +APR_AS(i,j)
4814 APR_CAPMA(i,j) = x_ave_cap(i,1)* &
4815 3600.*pr_capma(i,j) +APR_CAPMA(i,j)
4816 APR_CAPME(i,j) = x_ave_cap(i,2)* &
4817 3600.*pr_capme(i,j) +APR_CAPME(i,j)
4818 APR_CAPMI(i,j) = x_ave_cap(i,3)* &
4819 3600.*pr_capmi(i,j) +APR_CAPMI(i,j)
4824 END SUBROUTINE massflx_stats
4826 SUBROUTINE cup_axx(tcrit,kbmax,z1,p,psur,xl,rv,cp,tx,qx,axx,ierr, &
4827 cap_max,cap_max_increment,entr_rate,mentr_rate,&
4829 its,ite, jts,jte, kts,kte,ens4)
4831 INTEGER, INTENT(IN ) :: &
4833 its,ite, jts,jte, kts,kte,ens4
4834 real, dimension (its:ite,kts:kte,1:ens4) &
4835 , intent(inout) :: &
4837 real, dimension (its:ite,kts:kte) &
4840 real, dimension (its:ite) &
4842 z1,psur,cap_max,cap_max_increment
4843 real, intent(in) :: &
4844 tcrit,xl,rv,cp,mentr_rate,entr_rate
4845 real, dimension (its:ite,1:ens4) &
4848 integer, dimension (its:ite), intent (in) :: &
4850 integer, dimension (its:ite) :: &
4851 ierrxx,k22xx,kbconxx,ktopxx,kstabm,kstabi
4852 real, dimension (1:2) :: AE,BE,HT
4853 real, dimension (its:ite,kts:kte) :: tv
4856 real, dimension (its:ite,kts:kte) :: &
4858 qes_cup,q_cup,he_cup,hes_cup,z_cup,p_cup,gamma_cup,t_cup, &
4860 dby,qc,qrcd,pwd,pw,hcd,qcd,dbyd,hc,qrc,zu,zd,cd
4862 real, dimension (its:ite) :: &
4872 BE(1)=.622*HT(1)/.286
4873 AE(1)=BE(1)/273.+ALOG(610.71)
4874 BE(2)=.622*HT(2)/.286
4875 AE(2)=BE(2)/273.+ALOG(610.71)
4882 cd(i,k)=0.1*entr_rate
4896 if(ierrxx(i).eq.0)then
4898 IF(Tx(I,K,n).LE.TCRIT)IPH=2
4899 E=EXP(AE(IPH)-BE(IPH)/TX(I,K,N))
4900 QES(I,K)=.622*E/(100.*P(I,K)-E)
4901 IF(QES(I,K).LE.1.E-08)QES(I,K)=1.E-08
4902 IF(Qx(I,K,N).GT.QES(I,K))Qx(I,K,N)=QES(I,K)
4903 TV(I,K)=Tx(I,K,N)+.608*Qx(I,K,N)*Tx(I,K,N)
4909 if(ierrxx(i).eq.0)then
4910 Z(I,KTS)=max(0.,Z1(I))-(ALOG(P(I,KTS))- &
4911 ALOG(PSUR(I)))*287.*TV(I,KTS)/9.81
4915 ! --- calculate heights
4918 if(ierrxx(i).eq.0)then
4919 TVBAR=.5*TV(I,K)+.5*TV(I,K-1)
4920 Z(I,K)=Z(I,K-1)-(ALOG(P(I,K))- &
4921 ALOG(P(I,K-1)))*287.*TVBAR/9.81
4926 !--- calculate moist static energy - HE
4927 ! saturated moist static energy - HES
4931 if(ierrxx(i).eq.0)then
4932 HE(I,K)=9.81*Z(I,K)+1004.*Tx(I,K,n)+2.5E06*Qx(I,K,n)
4933 HES(I,K)=9.81*Z(I,K)+1004.*Tx(I,K,n)+2.5E06*QES(I,K)
4934 IF(HE(I,K).GE.HES(I,K))HE(I,K)=HES(I,K)
4943 if(ierrxx(i).eq.0)then
4944 qes_cup(i,k)=.5*(qes(i,k-1)+qes(i,k))
4945 q_cup(i,k)=.5*(qx(i,k-1,n)+qx(i,k,n))
4946 hes_cup(i,k)=.5*(hes(i,k-1)+hes(i,k))
4947 he_cup(i,k)=.5*(he(i,k-1)+he(i,k))
4948 if(he_cup(i,k).gt.hes_cup(i,k))he_cup(i,k)=hes_cup(i,k)
4949 z_cup(i,k)=.5*(z(i,k-1)+z(i,k))
4950 p_cup(i,k)=.5*(p(i,k-1)+p(i,k))
4951 t_cup(i,k)=.5*(tx(i,k-1,n)+tx(i,k,n))
4952 gamma_cup(i,k)=(xl/cp)*(xl/(rv*t_cup(i,k) &
4953 *t_cup(i,k)))*qes_cup(i,k)
4958 if(ierrxx(i).eq.0)then
4959 qes_cup(i,1)=qes(i,1)
4960 q_cup(i,1)=qx(i,1,n)
4961 hes_cup(i,1)=hes(i,1)
4963 z_cup(i,1)=.5*(z(i,1)+z1(i))
4964 p_cup(i,1)=.5*(p(i,1)+psur(i))
4965 t_cup(i,1)=tx(i,1,n)
4966 gamma_cup(i,1)=xl/cp*(xl/(rv*t_cup(i,1) &
4967 *t_cup(i,1)))*qes_cup(i,1)
4972 !------- DETERMINE LEVEL WITH HIGHEST MOIST STATIC ENERGY CONTENT - K22
4974 CALL cup_MAXIMI(HE_CUP,3,KBMAX,K22XX,ierrxx, &
4976 its,ite, jts,jte, kts,kte)
4978 IF(ierrxx(I).eq.0.)THEN
4979 IF(K22xx(I).GE.KBMAX(i))ierrxx(i)=2
4983 !--- DETERMINE THE LEVEL OF CONVECTIVE CLOUD BASE - KBCON
4985 call cup_kbcon(cap_max_increment,1,k22xx,kbconxx,he_cup,hes_cup, &
4986 ierrxx,kbmax,p_cup,cap_max, &
4988 its,ite, jts,jte, kts,kte)
4990 !--- increase detrainment in stable layers
4992 CALL cup_minimi(HEs_cup,Kbconxx,kstabm,kstabi,ierrxx, &
4994 its,ite, jts,jte, kts,kte)
4996 IF(ierrxx(I).eq.0.)THEN
4997 if(kstabm(i)-1.gt.kstabi(i))then
4998 do k=kstabi(i),kstabm(i)-1
4999 cd(i,k)=cd(i,k-1)+1.5*entr_rate
5000 if(cd(i,k).gt.10.0*entr_rate)cd(i,k)=10.0*entr_rate
5006 !--- calculate incloud moist static energy
5008 call cup_up_he(k22xx,hkb,z_cup,cd,mentr_rate,he_cup,hc, &
5009 kbconxx,ierrxx,dby,he,hes_cup,'deep', &
5011 its,ite, jts,jte, kts,kte)
5013 !--- DETERMINE CLOUD TOP - KTOP
5015 call cup_ktop(1,dby,kbconxx,ktopxx,ierrxx, &
5017 its,ite, jts,jte, kts,kte)
5019 !c--- normalized updraft mass flux profile
5021 call cup_up_nms(zu,z_cup,mentr_rate,cd,kbconxx,ktopxx,ierrxx,k22xx, &
5023 its,ite, jts,jte, kts,kte)
5025 !--- calculate workfunctions for updrafts
5027 call cup_up_aa0(aa0,z,zu,dby,GAMMA_CUP,t_cup, &
5028 kbconxx,ktopxx,ierrxx, &
5030 its,ite, jts,jte, kts,kte)
5032 if(ierrxx(i).eq.0)axx(i,n)=aa0(i)
5035 END SUBROUTINE cup_axx
5037 SUBROUTINE conv_grell_spread3d(rthcuten,rqvcuten,rqccuten,raincv, &
5038 & cugd_avedx,cugd_tten,cugd_qvten,rqicuten,cugd_ttens, &
5039 & cugd_qvtens,cugd_qcten,pi_phy,moist_qv,pratec,dt,num_tiles,&
5040 & imomentum,F_QV ,F_QC ,F_QR ,F_QI ,F_QS, &
5041 & ids, ide, jds, jde, kds, kde, &
5042 & ips, ipe, jps, jpe, kps, kpe, &
5043 & ims, ime, jms, jme, kms, kme, &
5044 & its, ite, jts, jte, kts, kte )
5048 INTEGER, INTENT(IN ) :: num_tiles,imomentum
5049 INTEGER, INTENT(IN ) :: ids, ide, jds, jde, kds, kde,&
5050 ims,ime, jms,jme, kms,kme, &
5051 ips,ipe, jps,jpe, kps,kpe, &
5052 its,ite, jts,jte, kts,kte, &
5054 REAL, DIMENSION (ims:ime,kms:kme,jms:jme), optional,INTENT (INOUT) :: &
5055 & rthcuten,rqvcuten,rqccuten,rqicuten
5056 REAL, DIMENSION (ims:ime,kms:kme,jms:jme), optional,INTENT (IN ) :: &
5057 & cugd_tten,cugd_qvten,cugd_ttens,cugd_qvtens,cugd_qcten
5058 REAL, DIMENSION (ims:ime,kms:kme,jms:jme),INTENT (IN) :: &
5060 REAL, DIMENSION (ims:ime,kms:kme,jms:jme), INTENT (IN) :: &
5062 REAL, DIMENSION (ims:ime,jms:jme), INTENT (INOUT) :: &
5064 REAL, INTENT(IN) :: dt
5065 INTEGER :: ikk1,ikk2,ikk11,i,j,k,kk,nn,smoothh,smoothv
5066 INTEGER :: ifs,ife,jfs,jfe,ido,jdo,cugd_spread
5069 ! Flags relating to the optional tendency arrays declared above
5070 ! Models that carry the optional tendencies will provdide the
5071 ! optional arguments at compile time; these flags all the model
5072 ! to determine at run-time whether a particular tracer is in
5075 LOGICAL, OPTIONAL :: &
5081 REAL, DIMENSION (its-2:ite+2,kts:kte,jts-2:jte+2) :: &
5083 real, dimension (its-2:ite+2,jts-2:jte+2) :: Qmem
5084 real, dimension (its-1:ite+1,jts-1:jte+1) :: smTT,smTQ
5085 real, dimension (kts:kte) :: conv_TRASHT,conv_TRASHQ
5086 REAL :: Qmem1,Qmem2,Qmemf,Thresh
5090 cugd_spread=cugd_avedx/2
5128 ! prelims finished, now go real for every grid point
5130 if(cugd_spread.gt.0.or.smoothh.eq.1)then
5131 !if(its.eq.ips)ifs=max(its-1,ids)
5132 !if(ite.eq.ipe)ife=min(ite+1,ide-1)
5133 !if(jts.eq.jps)jfs=max(jts-1,jds)
5134 !if(jte.eq.jpe)jfe=min(jte+1,jde-1)
5136 ife=min(ite+1,ide-1)
5138 jfe=min(jte+1,jde-1)
5141 ! *** jm note -- for smoothing this goes out one row/column beyond tile in i and j
5146 RTHcutent(i,k,j)=cugd_tten(i,k,j)
5147 RQVcutent(i,k,j)=cugd_qvten(i,k,j)
5150 ! for high res run, spread the subsidence
5151 ! this is tricky......only consider grid points where there was no rain,
5152 ! so cugd_tten and such are zero!
5154 if(cugd_spread.gt.0)then
5162 RTHcutent(i,k,j)=RTHcutent(i,k,j) &
5163 +Qmem(ido,jdo)*cugd_ttens(ido,k,jdo)
5164 RQVcutent(i,k,j)=RQVcutent(i,k,j) &
5165 +Qmem(ido,jdo)*cugd_qvtens(ido,k,jdo)
5173 if(cugd_spread.eq.0)then
5175 RTHcutent(i,k,j)=RTHcutent(i,k,j)+cugd_ttens(i,k,j)
5176 RQVcutent(i,k,j)=RQVcutent(i,k,j)+cugd_qvtens(i,k,j)
5184 if(smoothh.eq.0)then
5191 rthcuten(i,k,j)=RTHcutent(i,k,j)
5192 rqvcuten(i,k,j)=RQVcutent(i,k,j)
5195 else if(smoothh.eq.1)then ! smooth
5200 ! we need an extra row for j (halo comp)
5201 !if(jts.eq.jps)jfs=max(jts-1,jds)
5202 !if(jte.eq.jpe)jfe=min(jte+1,jde-1)
5204 jfe=min(jte+1,jde-1)
5207 smTT(i,j)=.25*(RTHcutent(i-1,k,j)+2.*RTHcutent(i,k,j)+RTHcutent(i+1,k,j))
5208 smTQ(i,j)=.25*(RQVcutent(i-1,k,j)+2.*RQVcutent(i,k,j)+RQVcutent(i+1,k,j))
5217 rthcuten(i,k,j)=.25*(smTT(i,j-1)+2.*smTT(i,j)+smTT(i,j+1))
5218 rqvcuten(i,k,j)=.25*(smTQ(i,j-1)+2.*smTQ(i,j)+smTQ(i,j+1))
5224 ! check moistening rates
5235 if(rqvcuten(i,k,j).lt.0.)then
5236 Qmem1=moist_qv(i,k,j)+rqvcuten(i,k,j)*dt
5237 if(Qmem1.lt.Thresh)then
5238 Qmem1=rqvcuten(i,k,j)
5239 Qmem2=(Thresh-moist_qv(i,k,j))/dt
5240 Qmemf=min(Qmemf,Qmem2/Qmem1)
5247 rqvcuten(i,k,j)=rqvcuten(i,k,j)*Qmemf
5248 rthcuten(i,k,j)=rthcuten(i,k,j)*Qmemf
5250 if(present(rqccuten))then
5253 rqccuten(i,k,j)=rqccuten(i,k,j)*Qmemf
5257 if(present(rqicuten))then
5260 rqicuten(i,k,j)=rqicuten(i,k,j)*Qmemf
5264 raincv(I,J)=raincv(I,J)*Qmemf
5265 pratec(I,J)=pratec(I,J)*Qmemf
5267 ! check heating rates
5274 Qmem1=abs(rthcuten(i,k,j))*86400.
5276 if(Qmem1.gt.Thresh)then
5278 Qmemf=min(Qmemf,Qmem2)
5283 raincv(i,j)=raincv(i,j)*Qmemf
5284 pratec(i,j)=pratec(i,j)*Qmemf
5286 rqvcuten(i,k,j)=rqvcuten(i,k,j)*Qmemf
5287 rthcuten(i,k,j)=rthcuten(i,k,j)*Qmemf
5289 if(present(rqccuten))then
5292 rqccuten(i,k,j)=rqccuten(i,k,j)*Qmemf
5296 if(present(rqicuten))then
5299 rqicuten(i,k,j)=rqicuten(i,k,j)*Qmemf
5303 if(smoothv.eq.1)then
5308 conv_TRASHT(k)= .25*(rthcuten(i,k-1,j)+2.*rthcuten(i,k,j)+rthcuten(i,k+1,j))
5309 conv_TRASHQ(k)= .25*(rqvcuten(i,k-1,j)+2.*rqvcuten(i,k,j)+rqvcuten(i,k+1,j))
5312 rthcuten(i,k,j)=conv_TRASHT(k)
5313 rqvcuten(i,k,j)=conv_TRASHQ(k)
5317 rthcuten(i,k,j)=rthcuten(i,k,j)/pi_phy(i,k,j)
5322 END SUBROUTINE CONV_GRELL_SPREAD3D
5323 !-------------------------------------------------------
5324 END MODULE module_cu_g3