2 !#define DENG_SHCU1D_subsidence
3 MODULE module_shcu_deng
7 REAL , PARAMETER :: TO = 263.15
8 ! Lookup table variables:
9 INTEGER, PARAMETER :: KFNT=250,KFNP=220
10 REAL, DIMENSION(KFNT,KFNP),PRIVATE, SAVE :: TTAB,QSTAB
11 REAL, DIMENSION(KFNP),PRIVATE, SAVE :: THE0K
12 REAL, DIMENSION(200),PRIVATE, SAVE :: ALU
13 REAL, PRIVATE, SAVE :: RDPR,RDTHK,PLUTOP
17 SUBROUTINE deng_shcu_driver( &
18 ids,ide, jds,jde, kds,kde &
19 ,ims,ime, jms,jme, kms,kme &
20 ,its,ite, jts,jte, kts,kte &
21 ,DT,KTAU,DX, xtime, gmt &
22 ,XLV, XLS,XLV0,XLV1,XLS0,XLS1,CP,R,G & ! Constants
23 ,SVP1,SVP2,SVP3,SVPT0 & ! Constants
24 ,ADAPT_STEP_FLAG, DSIGMA & ! in
25 ,XLONG, ht, PBLH & ! in 2D
26 ,U,V,w,TH,T,QV,QC,QR,dz8w,PCPS,rho,z_at_w,pi & ! in 3D
28 ,ten_radl, ten_rads & ! in 3D
29 ,rainsh, rainshv, rainshvb, pblmax, capesave & ! inout 2D
30 ,xtime1, radsave, clddpthb, cldtopb, MAVAIL, PBLHAVG & ! inout 2D
31 ,ainckfsa, ltopb, kdcldtop, kdcldbas & ! inout 2D
32 ,W0AVG, TKEAVG, cldareaa, cldareab & ! inout 3D
33 ,cldliqa, cldliqb, cldfra_sh, ca_rad, cw_rad, wub & ! inout 3D
34 ,RUSHTEN, RVSHTEN, RTHSHTEN, RQVSHTEN, RQCSHTEN & ! inout 3D
35 ,RQRSHTEN, RDCASHTEN, RQCDCSHTEN & ! inout 3D
37 !-------------------------------------------------------------
39 ! ------------ IN ---------------------------------------------
40 INTEGER, INTENT(IN ) :: ids,ide, jds,jde, kds,kde, &
41 ims,ime, jms,jme, kms,kme, &
42 its,ite, jts,jte, kts,kte
43 REAL, INTENT(IN ) :: DT, DX, xtime, gmt
44 INTEGER, INTENT(IN ) :: KTAU
45 REAL, INTENT(IN ) :: XLV, XLS,XLV0,XLV1,XLS0,XLS1,CP,R,G, &
47 LOGICAL , INTENT(IN ) :: adapt_step_flag
48 REAL, DIMENSION( kms:kme ), INTENT(IN ) :: dsigma
50 REAL, DIMENSION( ims:ime , jms:jme ), &
51 INTENT(IN ) :: xlong, ht, pblh
52 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ) , &
53 INTENT(IN ) :: U, V, W, TH, T, QV, QR, dz8w, Pcps, &
54 rho, z_at_w, pi, tke, &
55 kth, bbls, ten_radl, ten_rads
56 ! ------------ INOUT ------------------------------------------
57 REAL, DIMENSION( ims:ime , jms:jme ), &
58 INTENT(INOUT) :: RAINSHV, RAINSH, pblmax, cldtopb, clddpthb, &
59 rainshvb, capesave, xtime1, radsave, &
62 REAL, DIMENSION( ims:ime , 1:100, jms:jme ), &
63 INTENT(INOUT) :: ainckfsa
64 INTEGER, DIMENSION( ims:ime , jms:jme ), &
65 INTENT(INOUT) :: ltopb, kdcldtop, kdcldbas
66 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ) , &
67 INTENT(INOUT) :: W0AVG, TKEAVG, &
68 cldareaa, cldareab, cldliqa, cldliqb, wub
69 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ) , &
71 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ) , &
72 INTENT( OUT) :: ca_rad, cw_rad, cldfra_sh
73 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), &
74 INTENT(INOUT) :: RUSHTEN, RVSHTEN, RTHSHTEN, RQVSHTEN, RQCSHTEN, &
75 RQRSHTEN, RDCASHTEN, RQCDCSHTEN
79 REAL, DIMENSION( its:ite , jts:jte ) :: CAPEI, RADIUSC, AINCKFI
80 REAL, DIMENSION( kts:kte ) :: U1D, V1D, TH1D, T1D, DZ1D, QV1D, &
81 QC1D, RH1D, QR1D, P1D, z1d, RHO1D, W0AVG1D, &
82 kth1D, tke1d, bbls1D, &
86 ten_radl1d, ten_rads1d
87 REAL, DIMENSION( kts:kte+1 ) :: z_at_w1d
88 REAL, DIMENSION( kts:kte ) :: QVTEN, QCTEN, QRTEN, TTEN, DCATEN, QCDCTEN
89 REAL, DIMENSION( its:ite , jts:jte ) :: pblh_tile, pblhavg_tile
90 REAL, DIMENSION( its:ite , kts:kte , jts:jte ) :: w_at_half, w_at_half_mean
91 REAL, DIMENSION( its:ite , kts:kte , jts:jte ) :: tke_tile, tkeavg_tile
92 REAL, DIMENSION( its:ite , kts:kte , jts:jte ) :: cldareac, cldliqc, rh
95 INTEGER :: i, j, k, ii, ntst, kk
96 REAL :: AMOIS, time_period_avg_min ! time window to perform a running mean value
97 INTEGER :: if_avg_w=1, if_avg_pbl=0, if_avg_tke=0
99 REAL :: es, qes, alf1, alf2, alf3, c1, c2, cs, qctot
100 #ifdef DENG_SHCU1D_subsidence
101 REAL, DIMENSION(100) :: P_P, WSUBS_P
102 REAL, DIMENSION(kte) :: P_SIGMA, WSUBSID, WSUBSID_td, thten_sub
103 REAL, DIMENSION(kte+1) :: th_full
105 INTEGER :: kx, kxp1, kl
115 ! print*, ids, ide, jds, jde, kds, kde
116 ! print*, ims, ime, jms, jme, kms, kme
117 ! print*, its, ite, jts, jte, kts, kte
120 write(301,*) xtime/60.,pblh(1,1)
121 #ifdef DENG_SHCU1D_subsidence
122 OPEN(3,FILE='input03.dat',STATUS='old')
125 READ(3,*) P_P(K),WSUBS_P(K) ! SUBSIDENCE IN CM/SEC. (from Betts 1994)
131 ! Time averaging w on the half levels
133 IF( if_avg_w == 1 ) THEN
134 time_period_avg_min = 10.0
138 w_at_half(i,k,j) = 0.5* ( w(i,k,j) + w(i,k+1,j) )
139 w_at_half_mean(i,k,j) = w0avg(i,k,j)
143 CALL time_avg_3d( dt, ADAPT_STEP_FLAG, time_period_avg_min &
144 ,w_at_half, w_at_half_mean &
145 ,its,ite, jts,jte, kts,kte &
150 w0avg(i,k,j) = w_at_half_mean(i,k,j)
158 w_at_half(i,k,j) = 0.5* ( w(i,k,j) + w(i,k+1,j) )
159 w0avg(i,k,j) = w_at_half(i,k,j)
165 ! Time averaging PBLH
167 IF( if_avg_pbl == 1 ) THEN
168 time_period_avg_min = 120.0
171 pblh_tile(i,j) = pblh(i,j)
172 pblhavg_tile(i,j) = pblhavg(i,j)
175 CALL time_avg_2d( dt, ADAPT_STEP_FLAG, time_period_avg_min &
176 ,pblh_tile, pblhavg_tile &
181 pblhavg(i,j) = pblhavg_tile(i,j)
187 pblh_tile(i,j) = pblh(i,j)
188 pblhavg(i,j) = pblh_tile(i,j)
193 write(302,*) xtime/60.,PBLHAVG(1,1)
198 IF( if_avg_tke == 1 ) THEN
199 time_period_avg_min = 30.0
203 tke_tile(i,k,j) = tke(i,k,j)
204 tkeavg_tile(i,k,j) = tkeavg(i,k,j)
208 CALL time_avg_3d( dt, ADAPT_STEP_FLAG, time_period_avg_min &
209 ,tke_tile, tkeavg_tile &
210 ,its,ite, jts,jte, kts,kte &
215 tkeavg(i,k,j) = tkeavg_tile(i,k,j)
223 tke_tile(i,k,j) = tke(i,k,j)
224 tkeavg(i,k,j) = tke_tile(i,k,j)
230 ! Calculate the RH-based cloud fraction, CS, based on Xu and Randall (1996, JAS)
231 ! As shown in Deng et al. 2003a, the virtual cloud fraction CAREA is a wighted average
232 ! of Deng scheme-predicted cloud fraction, CLDLIQA and CS. This effective cloud
233 ! fraction is used in the radiation calculation.
238 IF( T(i,k,j) .GE. TO ) THEN
239 ES=1.E3*SVP1*EXP(SVP2*(T(i,k,j)-SVPT0)/(T(i,k,j)-SVP3))
241 ES=611.0*EXP(22.514-6.15E3/T(i,k,j))
243 QES = 0.622*ES/(PCPS(i,k,j)-ES)
244 RH(i,k,j)=AMAX1(QV(i,k,j)/QES,1.0E-25)
249 IF( RH(I,K,J) .LT. 0.999) THEN
250 C1=(1.0-RH(I,K,J))*QES**alf2
251 QCTOT=CLDLIQA(I,K,J)*CLDAREAA(I,K,J)+QC(I,K,J)
253 CS=RH(I,K,J)**alf1*(1.0-EXP(C2))
258 CA_RAD(I,K,J)=(1.0-CLDAREAA(I,K,J))*CS+CLDAREAA(I,K,J)
259 CLDFRA_SH(I,K,J)= CA_RAD(I,K,J)
260 CW_RAD(I,K,J)=CLDLIQA(I,K,J)*CLDAREAA(I,K,J)
283 W0AVG1D(k) = W0AVG(i,k,j)
284 tke1d(k) = tkeavg(i,k,j)
286 QV1D(K)=MAX(QV(I,K,J),1.E-12)
289 ca_rad1d(k) = ca_rad(i,k,j)
295 kth1d(k) = kth(i,k,j)
296 bbls1d(k) = bbls(i,k,j)
297 ten_radl1d(k) = ten_radl(i,k,j)
298 ten_rads1d(k) = ten_rads(i,k,j)
302 z_at_w1d(k) = z_at_w(I,K,J)
305 #ifdef DENG_SHCU1D_subsidence
308 P_SIGMA(K) = p1d(kk)/100.0
310 CALL INTERP1D( P_SIGMA, P_P, WSUBS_P, WSUBSID_td, KX, 35 )
313 WSUBSID(K) = WSUBSID_td(KK)/100.0 ! convert to m/s (READ IN INPUT2.F)
316 th_full(K) = 0.5*( th1d(k)+th1d(k-1) )
319 thten_sub(K) = - WSUBSID(K) * ( th_full(K+1)-th_full(K) ) / dz1d(k)
324 CALL deng_shcu(I, J, &
325 ids,ide, jds,jde, kds,kde, &
326 ims,ime, jms,jme, kms,kme, &
327 its,ite, jts,jte, kts,kte, &
328 XLV,XLS,XLV0,XLV1,XLS0,XLS1,CP,R,G, &
329 SVP1,SVP2,SVP3,SVPT0, &
330 DT, ktau, dt2, DX, DXSQ, xtime, gmt, &
331 PBLHAVG(i,j), ht(i,j), xlong, capesave, radsave, ainckfsa, &
332 U1D,V1D,T1D,QV1D,rh1d,QC1D,QR1D,p1d,RHO1D,z_at_w1d,DZ1D,W0AVG1D, &
334 ca_rad1d, & ! for 1d printing only
336 tke1d, kth1d, bbls1d, ten_radl1d, ten_rads1d, dsigma, &
337 RAINSHV, RAINSH, pblmax, CLDTOPB, CLDDPTHB, &
338 ltopb, kdcldtop, kdcldbas, &
339 cldareab, cldliqb, wub, &
340 CAPEI, RADIUSC, AINCKFI, &
341 QVTEN,QCTEN,QRTEN,TTEN,DCATEN,QCDCTEN &
347 RTHSHTEN(i,k,j) = TTEN(k)/pi(I,K,J) * 1.0
348 #ifdef DENG_SHCU1D_subsidence
349 RTHSHTEN(i,k,j) = RTHSHTEN(i,k,j) + thten_sub(k)
351 RQVSHTEN(i,k,j) = QVTEN(k) * 1.0
352 RQCSHTEN(i,k,j) = QCTEN(k) * 1.0
353 RQRSHTEN(i,k,j) = QRTEN(k) * 1.0
354 RDCASHTEN(i,k,j) = DCATEN(K) * 1.0
355 RQCDCSHTEN(i,k,j) = QCDCTEN(K) * 1.0
358 ! IF THERE IS CONVECTIVE PRECIPITATION, UPDATE THE SURFACE MOISTURE
359 ! AVAILABILITY THAT THE SURFACE IS WET FOR THE FOLLOWING HOUR
361 IF(RAINSHV(I,J) .EQ. 0.0 .AND. RAINSHVB(I,J) .NE. 0.0) THEN
362 XTIME1(I,J)=XTIME+60.
366 IF(RAINSHV(I,J) .NE. 0.0 .OR. XTIME .LE. XTIME1(I,J)) THEN
367 MAVAIL(I,J)=AMOIS+0.67*(1.0-AMOIS)
372 RAINSHVB(I,J)=RAINSHV(I,J)
374 AINCKFSA(i,ii,j) = AINCKFSA(i,ii-1,j)
376 RADSAVE(I,J)=RADIUSC(i,j)
377 AINCKFSA(i,1,j) = AINCKFI(i,j)
378 CAPESAVE(i,j) = CAPEI(i,j)
383 ! NBC prediction using the MM5 leapfog method
388 CLDAREAC(I,K,J) = CLDAREAB(I,K,J) + RDCASHTEN(I,K,J) * DT
389 CLDLIQC(I,K,J) = CLDLIQB(I,K,J) + RQCDCSHTEN(I,K,J) * DT
390 CLDAREAC(I,K,J) = AMAX1(0.0,CLDAREAC(I,K,J))
391 CLDLIQC(I,K,J) = AMAX1(0.0,CLDLIQC(I,K,J))
392 IF( CLDAREAC(I,K,J) .GT. 0.99999 ) THEN
393 CLDLIQC(I,K,J) = CLDLIQC(I,K,J)*CLDAREAC(I,K,J)
394 CLDAREAC(I,K,J) = 1.0
396 IF( CLDAREAC(I,K,J) .LE. 1.0e-17 .OR. CLDLIQC(I,K,J) .LE. 1.0e-17 ) THEN
397 CLDAREAC(I,K,J) = 0.0
407 CLDAREAB(I,K,J)=OMUHF*CLDAREAA(I,K,J)+GNUHF*(CLDAREAB(I,K,J)+CLDAREAC(I,K,J))
408 CLDLIQB(I,K,J)=OMUHF*CLDLIQA(I,K,J) +GNUHF*(CLDLIQB(I,K,J)+CLDLIQC(I,K,J))
409 CLDAREAA(I,K,J)=CLDAREAC(I,K,J)
410 CLDLIQA(I,K,J)= CLDLIQC(I,K,J)
412 IF( CLDAREAA(I,K,J) .LE. 1.0e-17 .OR. CLDLIQA(I,K,J) .LE. 1.0e-17 ) THEN
413 CLDAREAA(I,K,J) = 0.0
417 IF(CLDDPTHB(I,J) .LE. 0.0) THEN ! No active updraft
418 RQCSHTEN(I,K,J)=RQCSHTEN(I,K,J)+CLDAREAB(I,K,J)*CLDLIQB(I,K,J)/DT
419 CLDAREAB(I,K,J) = 0.0
426 END SUBROUTINE deng_shcu_driver
429 SUBROUTINE deng_shcu(I,J, & ! in
430 ids,ide, jds,jde, kds,kde, & ! in
431 ims,ime, jms,jme, kms,kme, & ! in
432 its,ite, jts,jte, kts,kte, & ! in
433 XLV,XLS,XLV0,XLV1,XLS0,XLS1,CP,R,G, & ! in
434 SVP1,SVP2,SVP3,SVPT0, & ! in
435 DT, ktau, dt2, DX, DXSQ, xtime, gmt, zpbl, ht, & ! in
436 xlong, capesave, radsave, ainckfsa, & ! in 2D
437 U0,V0,T0,Q0,RH0, QC0_expl,QR0,P0, & ! in 3D
438 RHOE,z_at_w0, DZQ,W0AVG0, & ! in 1D
440 ca_rad0, & ! for 1d printing only
442 tke0, kth0, bbls0, ten_radl0, ten_rads0, dsigma, & ! in 1D
443 RAINSHV, RAINSH, pblmax, CLDTOPB, CLDDPTHB, & ! inout 2D
444 ltopb, kdcldtop, kdcldbas, & ! inout 2D
445 cldareab, cldliqb, wub, & ! inout 3D
446 CAPEI,RADIUSC, AINCKFI, & ! out 2D
447 QVTEN,QCTEN,QRTEN,TTEN,DCATEN,QCDCTEN & ! out 1D (output tendencie)
449 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
451 ! ----------- IN -------------------------------------------
452 INTEGER, INTENT(IN ) :: i, j, &
453 ids,ide, jds,jde, kds,kde, &
454 ims,ime, jms,jme, kms,kme, &
455 its,ite, jts,jte, kts,kte
456 REAL, INTENT(IN ) :: XLV,XLS,XLV0,XLV1,XLS0,XLS1, &
457 CP,R,G,SVP1,SVP2,SVP3,SVPT0
458 REAL, INTENT(IN ) :: DT, dt2, DX, DXSQ, xtime, gmt
459 INTEGER, INTENT(IN ) :: KTAU
460 REAL, INTENT(IN ) :: zpbl, ht
461 REAL, DIMENSION( ims:ime , jms:jme ), &
462 INTENT(IN ) :: xlong, capesave, radsave
463 REAL, DIMENSION( ims:ime , 1:100, jms:jme ), &
464 INTENT(IN ) :: ainckfsa
465 REAL, DIMENSION( kts:kte ), &
466 INTENT(IN ) :: U0, V0, T0, QR0, RH0, P0, rhoe, DZQ, W0AVG0, &
467 TKE0, KTH0, BBLS0, ten_radl0, ten_rads0
468 REAL, DIMENSION( kms:kme ), &
469 INTENT(IN ) :: dsigma
470 REAL, DIMENSION( kts:kte+1 ), &
471 INTENT(IN ) :: z_at_w0
472 ! ------------ INOUT ---------------------------------------------
473 REAL, DIMENSION( kts:kte ), &
474 INTENT(INOUT) :: Q0, QC0_expl
475 REAL, DIMENSION( ims:ime, jms:jme ), &
476 INTENT(INOUT) :: RAINSHV, RAINSH, pblmax, cldtopb, clddpthb
477 INTEGER, DIMENSION( ims:ime , jms:jme ), &
478 INTENT(INOUT) :: ltopb, kdcldtop, kdcldbas
479 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ) , &
480 INTENT(INOUT) :: cldareab, cldliqb, wub
481 REAL, DIMENSION( kts:kte ), &
482 INTENT(INOUT) :: QVTEN, QCTEN, QRTEN, TTEN, DCATEN, QCDCTEN
483 ! ----------- OUT ------------------------------------------------
484 REAL, DIMENSION( its:ite, jts:jte ), &
485 INTENT( OUT) :: CAPEI, RADIUSC, AINCKFI
490 REAL, DIMENSION( kts:kte ) :: DTDT, DQDT, DQRDT, DQLDT, DDCADT, DQCDCDT
492 REAL , PARAMETER :: PIE = 3.141592654
493 REAL , PARAMETER :: TTFRZ = 268.16
494 REAL , PARAMETER :: TBFRZ = 248.16
495 REAL , PARAMETER :: RHBC = 0.90
496 REAL , PARAMETER :: P00 = 100000.0
497 REAL , PARAMETER :: T00 = 273.16
498 REAL , PARAMETER :: RLF = 3.339E5
499 REAL , PARAMETER :: AVTS = 11.72
500 REAL , PARAMETER :: BVTS = 0.41
501 REAL , PARAMETER :: N0R = 8.E6
502 ! REAL , PARAMETER :: TO = 263.15
503 REAL , PARAMETER :: XN0 = 1.E-2
504 REAL , PARAMETER :: XMMAX = 9.4E-10 ! from MM5 param.F for autoconvertion of qc to qs
505 REAL , PARAMETER :: N0S = 2.E7
506 REAL , PARAMETER :: ESI = 0.1
507 REAL , PARAMETER :: QCTH = 0.5E-3 ! from MM5 param.F for autoconvertion of qc to qr
508 REAL , PARAMETER :: QCK1 = 1.0E-3 ! from MM5 param.F for autoconvertion of qc to qr
509 REAL , PARAMETER :: AVT = 841.99667
510 REAL , PARAMETER :: BVT = 0.8
511 REAL , PARAMETER :: RHCRIT = 0.999
513 REAL, DIMENSION( kts:kte ) :: SCR3
515 REAL :: nupdraft, ZLCL,ZLFC, TRPPT, CLDTOP, CLDDPTH, & ! nupdraft is for sure a real number
516 TTLCL, PPLCL, ainc, ainc2, ainc3, ainc4, tenv, qenv, tven, tvbar, &
517 AINCM1, AINCM2, AINCMX, timeunv, timeloc, wbar, wtke, wpbltp, wnh
519 INTEGER :: LLC, KPBL, KKPBL,KLCL,KDCB,KDCT,LTOP, LTOP1, LTOPM1, LTOP2, &
520 kpblmax, kl, klm, kx, kxp1, kp1, LCL, LET, LFS, L, n
522 REAL, DIMENSION( kts:kte ) :: z0, prc, pra, tlong,tshort, &
523 QU,TU,TVU,UMF,UER,TZ,QD,TV0, &
524 WD,TVD,DMF,DER,TG,QQG,TVG, &
525 EMS,EMSD,THETEU,THETED,THETEE,THTAU, &
526 THTAD,THTA0,RLIQ,RICE,QLQOUT,QICOUT, &
527 PPTLIQ,PPTICE,DETLQ,DETIC,UMF2,DMF2, &
528 DETLQ2,DETIC2,UDR,UDR2,DDR,UER2, &
529 DER2,RATIO2,DOMGDP,EXN, &
530 DZA,TVQU,DP,DMS,EQFRC,WSPD,QDT,FXM, &
531 THTES,THTESG,THTAG,DDR2,THPA,QPA, &
532 THFXIN,THFXOUT,QFXIN,QFXOUT,DTFM, &
533 QC0,QCG,QCPA,QCFXIN,QCFXOUT, &
534 DCA,DCAFXIN,DCAFXOUT,DCA0, &
537 REAL, DIMENSION( kts:kte+1 ) :: OMG, KV,KR, LFLUX, LFLUX1, LFLUX2
539 REAL :: zagl_bot, zagl_top, &
540 tmix, thmix, qmix, zmix, pmix, dpthmx, &
541 qmix1, zmix1, dpthmx1, &
542 tmix2, thmix2, qmix2, pmix2, emix, emix2, &
543 c1, c2, c3, AREA, AREA1, AREA2, CLQ, CLQ1, CLQ2, &
544 emax, zval, TLCL, PLCL, TVLCL, ES, QS, TVAVG, QESE, WTW, RHOLCL, &
545 sum, val, val0, val1, val2, ff, h, b, rad, &
546 PPBL, TENVPBL, QENVPBL, TVENPBL, TPBL, TVPBL, RHOPBL, ROCPQ, &
547 RHO_INI, T_INI, TV_INI, TVEN_INI, Z_INI, P_INI, &
548 DPTH, PPLSDP, AU0, VMFPBLCL, VMFLCL, UPOLD, UPNEW, &
549 abe, THTUDL, TUDL, TTEMP, RATE, FRC, FRC1, QNEWLQ, QNEWIC, RL, &
550 QNWFRZ, EFFQ, BE, BOTERM, ENTERM, DZZ, WSQ, &
551 WABS, UDLBE, ee, ee1, ee2, ud1, ud2, rei, ttmp, f1, f2, THTTMP, &
552 RTMP, TMPLIQ, TMPICE, TU95, TU10, EQMAX, EQMIN, CTP1, CTP2, WUMAX, &
553 DPTT, DUMFDP, TSAT, THTA, P165, PPTMLT, PPTML2, CLVF, USR, VCONV, &
554 TIMEC, TADVEC, TCMIN, TCMAX, SHSIGN, VWS, PEF, PEFMX, PEFMN, &
555 CBH, RCBH, PEFCBH, CBHMX, PEFF, TDER, TDER2, THTMIN, DTMLTD, &
556 DPT, DPDD, a1, rdd, DQSSDT, DTMP, QSRH, PPTFLX, PPTFL2, CPR, CNDTNF, &
557 UPDINC, DMFMIN, DEVDMF, PPR, RCED, DPPTDF, DMFLFS, &
558 DDINC, FABE, STAB, TKEMAX, DSOURCE, TIMECS, &
559 DTT, DTT1, GD, CPM, GM, DTEMPDT, DTHETADT, &
560 TMA, TMB, TMM, BCOEFF, ACOEFF, TOPOMG, DTMLTE, TDP, &
561 DQ, QMIN, TLOG, TDPT, CPORQ, DLP, ZLCL1, ABEG, THATA, &
562 THTFC, DABE, AINCMIN, RF, UPDIN2, &
563 DR, UDFRC, UEFRC, DDFRC, DEFRC, TUC, TDC, QGS, RH_0, RHG, &
564 QINIT, QFNL, QCFINL, ERR2, RELERR, &
565 DIFFK, RLC, E2, EOVLC, RCP, RLOVCP, &
566 RHCR, AREADIFF, FX, FX1, FX2, &
567 EFOLD, EX, DEPTHMAX, HIN, HOUT, DELTH, QIN, QOUT, &
568 DELTQ, RKAPA, DELTA, RATIO, RATIOMIN, RATIOMAX, &
569 GAMA, BEITA, SIGMMA, WFUN, BVT3, BVTS3, PPI, G3PB, G3PBS, PRAC, PRACS, &
570 TOUT, SC2, SC3, SC7, RHOS, PPIS, XNC, &
571 RHO2, VT2C, FALTNDC, gdry, p300, factor1, &
572 z1, p1, t1, w1, z2, p2, t2, w2, r1, &
575 INTEGER :: ii, k, ks, k1, k2, kk, k0, ndk, nj, nm, nk, nk1, &
576 kval, kval1, kval2, iflag, kflag, nic, &
577 KMIN, KSTART, ND, NT, ND1, LDB, LDT, LMAX, NCOUNT, ISTOP, &
578 k100, k1000, KAMAX, KLCMAX, dbg_level, i0, j0, KRADLMAX, &
579 NTC, NSTEP, ML, L5, LLFC, LM, LM1, LM2, LC, lvf, kradsmax
581 REAL :: ALIQ, BLIQ, CLIQ, DLIQ
583 LOGICAL, EXTERNAL :: wrf_dm_on_monitor
585 ! REAL :: tpdd ! Function declaration
586 ! REAL :: GAMMA ! Function declaration
588 CHARACTER*1024 message
591 REAL, DIMENSION( its:ite , jts:jte ) :: &
592 TPBLG,PPBLG,TLCLG,PLCLG, & ! used to be 1-d mm5 graphics
593 CLDHGTG,TCLDTPG,PCLDTPG,TLFSG,PLFSG,TLDTG,PLDTG, &
594 TLDBG,PLDBG,TLLCG,PLLCG
596 REAL, DIMENSION( its:ite , jts:jte ) :: &
598 nca_ctr1,nca_ctr2,nca_ctr3,nca_ctr4, &
601 REAL, DIMENSION( kts:kte ) :: tt4, tt6, tt7, wsubsub, wutemp, cldaten0, cldaten, &
602 cldlctn0, cldlctn1, cldlctn2, cldlctn3, cldlctn4, &
603 cldlctn5, thtetmp, thtatmp, cldua, tug, wsp_plot, &
604 wdr_plot, td_plot, ca_rad0
606 REAL :: PLET,TLET, aa=60.0*60.0, bb=60.0*60.0*1000.0, qqq, ees, &
609 INTEGER :: KTAU1HUR, KCBASE
611 !******************************************************************************
613 CALL get_wrf_debug_level( dbg_level )
635 KTAU1HUR = 3600/INT(DT)
636 IF( i == 1 .AND. j == 1 ) write(31,*) xtime/60.,zpbl
683 !...INPUT A VERTICAL SOUNDING ... NOTE THAT MODEL LAYERS ARE NUMBERED FROM THE
684 !...BOTTOM-UP IN THE SHALLOW CONVECTION SCHEME...
694 !...IF Q0 IS ABOVE SATURATION VALUE, REDUCE IT TO SATURATION LEVEL...
696 ! ES=ALIQ*EXP((BLIQ*T0(K)-CLIQ)/(T0(K)-DLIQ))
697 IF( T0(K) .GT. TO ) THEN
698 ES=1.E3*SVP1*EXP(SVP2*(T0(K)-SVPT0)/(T0(K)-SVP3))
700 ES=611.0*EXP(22.514-6.15E3/T0(K))
702 QES(K)=0.622*ES/(P0(K)-ES)
703 Q0(K)=AMIN1(QES(K),Q0(K))
704 IF(Q0(K).GT.QES(K))Q0(K)=QES(K)
706 TV0(K)=T0(K)*(1.+.608*Q0(K))
707 ! RHOE(K)=P0(K)/(R*TV0(K))
709 !...DZQ IS DZ BETWEEN SIGMA SURFACES, DZA IS DZ BETWEEN MODEL HALF LEVELS,
710 ! DP IS THE PRESSURE INTERVAL BETWEEN FULL SIGMA LEVELS...
712 DP(K)=rhoe(k)*g*DZQ(k)
713 IF(P0(K).GE.500E2) L5=K
714 IF(P0(K).GE.P300) LLFC=K
715 IF(T0(K).GT.T00) ML=K
720 Z0(K) = Z0(K-1)+.5*(DZQ(K)+DZQ(K-1))
721 DZA(K-1) = Z0(K)-Z0(K-1)
732 !...FIND CONVECTIVE SOURCE LAYER WHERE THE INITIAL PARCEL CHARACTERISTICS
733 ! ARE DEFINED. IT IS THE MAXIMUM OF 20% OF PBL AND 2 (IF PBL IS AT LEAST
734 ! 4 LATERS DEEP. DEFINE THE PARCEL PURTERBATION PROPERTITES FROM THE
735 ! SOURCE LAYER (THMIX,QMIX,ZMIX,PMIX)
738 FACTOR1 = 0.20 ! 20% of PBL
740 IF( (Z0(NK)+0.5*DZQ(NK)) .LT. FACTOR1*ZPBL ) THEN
749 loop_ku: DO k = 1, kl
750 zagl_bot = z_at_w0(k)-ht
751 zagl_top = z_at_w0(k+1)-ht
752 IF( zpbl >= zagl_bot .AND. zpbl < zagl_top ) THEN
759 IF( KPBL .GE. 4 ) LM2=2
769 ROCPQ=0.2854*(1.-0.28*Q0(NK))
770 THMIX=THMIX+DP(NK)*T0(NK)*(P00/P0(NK))**ROCPQ
771 QMIX=QMIX+DP(NK)*Q0(NK)
772 ZMIX=ZMIX+DP(NK)*Z0(NK)
773 PMIX=PMIX+DP(NK)*P0(NK)
780 ! FIND THE LCL (TLCL,TVLCL,PLCL,KLCL)
782 ROCPQ=0.2854*(1.-0.28*QMIX)
783 TMIX=THMIX*(PMIX/P00)**ROCPQ
784 EMIX=QMIX*PMIX/(0.622+QMIX)
785 ! TLOG=ALOG(EMIX/ALIQ)
786 ! TDPT=(CLIQ-DLIQ*TLOG)/(BLIQ-TLOG)
787 TLOG=ALOG(EMIX/SVP1/1000.)
788 TDPT=(SVP2*SVPT0-SVP3*TLOG)/(SVP2-TLOG)
789 TLCL=TDPT-(.212+1.571E-3*(TDPT-T00)-4.36E-4*(TMIX-T00))* &
791 TLCL=AMIN1(TLCL,TMIX)
792 TVLCL=TLCL*(1.+0.608*QMIX)
794 PLCL=P00*(TLCL/THMIX)**CPORQ
798 IF( PLCL >= P0(NK) ) GO TO 35
804 IF(KLCL .EQ. 1 ) THEN
806 write(*,*) 'KL layer is saturated and skip over active con.'
822 IF(ZPBL .LE. Z0(1)) THEN
825 loop12: DO KK=1, KL-1
826 IF(ZPBL .GE. Z0(KK) .AND. ZPBL .LT. Z0(KK+1)) THEN
832 C1=(ZPBL-Z0(K0))/(Z0(K0+1)-Z0(K0))
833 PPBL=P0(K0)*EXP(C1*(ALOG(P0(K0+1))-ALOG(P0(K0))))
835 TPBL=TLCL*(PPBL/PLCL)**ROCPQ
841 nca_ctr1(i,j)=nca_ctr1(i,j)+1
849 DLP=LOG(PLCL/P0(K))/LOG(P0(KLCL)/P0(K))
851 !...ESTIMATE ENVIRONMENTAL TEMPERATURE AND MIXING RATIO AT THE LCL...
853 TENV=T0(K)+(T0(KLCL)-T0(K))*DLP
854 QENV=Q0(K)+(Q0(KLCL)-Q0(K))*DLP
855 TVEN=TENV*(1.+0.608*QENV)
856 TVBAR=0.5*(TV0(K)+TVEN)
857 ZLCL=Z0(K)+(Z0(KLCL)-Z0(K))*DLP
859 ! DETERMINE PURTERBATION VERTICAL VELOCITIES FOR INITIATING PARCEL,
860 ! WPBLTP=WBAR+WTKE+WNH, WHERE WBAR IS THE RESOLVABLE-SCALE MEAN VERTICAL
861 ! MOTION, WTKE IS THE CONTRIBUTION FROM THE PBL TKE AND WNH IS THE NON-HYDROSTAIC
864 IF( zpbl .GT. PBLMAX(I,J) ) THEN
869 ! CALCULATE LOCAL TIME USING UTC (DATE) AND THE LONGITUDE.
871 TIMEUNV = gmt + XTIME/60.
872 IF( TIMEUNV .GE. 24.0 ) TIMEUNV = TIMEUNV - 24.0
873 TIMELOC = TIMEUNV + XLONG(I,J)/15.0
874 IF( TIMELOC .LT. 0.0 ) TIMELOC = TIMELOC + 24.0
875 IF( TIMELOC .GE.24.0 ) TIMELOC = TIMELOC - 24.0
877 IF( ABS(TIMELOC-6.0) .LT. 0.01 ) THEN
878 PBLMAX(I,J) = 0.0 ! SET PBLMAX=0 IF LOCAL TIME=6AM
881 KVAL=MIN(KLCL,KPBLMAX)
884 loop154: DO nk = 1, KVAL
886 IF( val.LT.EMAX ) CYCLE loop154
890 KVAL=MIN(KLCL-1,KPBL)
893 WTKE=SQRT(2.0*EMAX/3.0)
898 IF( CLDDPTHB(I,J) .GT. 4.0E3 ) THEN
901 IF( ABS(Z0(NK)-ZVAL) .LT. DZQ(NK)/2.0 ) KVAL = NK
903 IF( WUB(I,KVAL,J) .GT. WPBLTP ) THEN
904 WNH=0.25*(WUB(I,KVAL,J)-WPBLTP)
912 IF( i == 1 .AND. j == 1 ) write(45,*) xtime/60.,WBAR,WTKE,WNH,WPBLTP
915 !...THE PARCEL IS BUOYANT; COMPUTE EQUIVALENT POTENTIAL TEMPERATURE (THETEU)
916 !...AND VERTICAL VELOCITY OF THE RISING PARCEL AT THE LCL...USE BOLTONS (1980)
917 !...FORMULA FOR THETE...
919 THETEU(K)=TMIX*(1.E5/PMIX)**(0.2854*(1.-0.28*QMIX))* &
920 EXP((3374.6525/TLCL-2.5403)*QMIX*(1.+0.81*QMIX))
921 ES=1.E3*SVP1*EXP(SVP2*(TENV-SVPT0)/(TENV-SVP3))
922 TVAVG=0.5*(TV0(KLCL)+TENV*(1.+0.608*QENV))
923 QESE=0.622*ES/(PLCL-ES)
924 THTES(K)=TENV*(1.E5/PLCL)**(0.2854*(1.-0.28*QESE))* &
925 EXP((3374.6525/TENV-2.5403)*QESE*(1.+0.81*QESE))
927 TVLCL=TLCL*(1.+0.608*QMIX)
928 RHOLCL=PLCL/(R*TVLCL)
932 ! DEFINE THE UPDRAFT RADIUS, RAD, AS A FUNCTION OF DEPTHS OF THE PBL
933 ! AND UPDRAFT AT THE PREVIOUS TIME STEP. RAD IS IN THE RANGE OF 150
938 IF(VAL/1000.0 .GT. 3.9) THEN
942 FF=12.0*VAL/(4.0-VAL/1000.)/1000.
944 B=-0.5*(7.0+2.0*H/1000.)
945 RAD=0.5*(-B-SQRT(B*B-12.0*H/1000.0))
947 IF(RAD .LT. 150.0) RAD=150.0
948 IF(RAD .GT.1500.0) RAD=1500.0
950 ! write(*,'(i7, 2i3, 4f10.3)') ktau, i, j, xtime/60.0, rad, zpbl, CLDDPTHB(I,J)
952 ! Averaging the radius between current and the previous time value
954 IF(CAPESAVE(I,J) .LT. 100.0) RAD=(RAD+RADSAVE(I,J))/2.0
958 ! FIND PBL PROPERTIES
960 IF( ZPBL .LE. Z0(1) ) THEN
967 loop13: DO KK = 1, KL-1
968 IF( ZPBL .GE. Z0(KK) .AND. ZPBL .LT. Z0(KK+1) ) THEN
974 C1 = ( ZPBL-Z0(K) )/( Z0(K+1)-Z0(K) )
975 PPBL = P0(K)*EXP( C1 * ( ALOG(P0(K+1))-ALOG(P0(K)) ) )
976 TENVPBL = C1* (T0(K+1)-T0(K)) + T0(K)
977 QENVPBL = C1* (Q0(K+1)-Q0(K)) + Q0(K)
978 TVENPBL = C1* (TV0(K+1)-TV0(K)) + TV0(K)
981 TPBL=TLCL*(PPBL/PLCL)**ROCPQ
982 TVPBL = TPBL*(1.+0.608*QMIX)
983 RHOPBL=PPBL/(R*TVPBL)
985 ! THE LOWER OF LCL AND PBL IS DETERMINED AS THE PARCEL RELEASING POINT
986 ! WHERE K,RHO_INI, T_INI, TV_INI, TVEN_IN, Z_INI AND P_INI ARE DEFINED
988 IF( PPBL .GE. PLCL ) THEN
989 THETEU(K)=TMIX*(1.E5/PMIX)**(0.2854*(1.-0.28*QMIX))* &
990 EXP((3374.6525/TLCL-2.5403)*QMIX*(1.+0.81*QMIX))
991 ES=1.E3*SVP1*EXP(SVP2*(TENVPBL-SVPT0)/(TENVPBL-SVP3))
992 QESE=0.622*ES/(PPBL-ES)
993 THTES(K)=TENVPBL*(1.E5/PPBL)**(0.2854*(1.-0.28*QESE))* &
994 EXP((3374.6525/TENVPBL-2.5403)*QESE*(1.+0.81*QESE))
1012 ! DETERMIN THE DEPTH OF SOURCE LAYER WHERE THE MASS IS IS REMOVED AS A RESULTS OF
1013 ! CONVECTION. THE DEPTH IS DEFINED AS A FUNCTION OF CLOUD RADIUS AND IS IN THE
1014 ! RANGE OF 10 MB TO 60 MB
1018 DPTHMX1 = DPTHMX1 + DP(NK)
1024 DPTH = 100.0*(RAD-150.0)/27.0 + 1000.0
1025 IF( DPTH .GE. DPTHMX1 ) THEN
1029 PPLSDP = P0(K+1) + DP(K+1)/2.0 + DPTH
1032 IF( ABS(PPLSDP-P0(NK)) .LE. ABS(PPLSDP-P0(NK+1)) ) LLC = NK
1039 IF( i == 1 .AND. j == 1 ) write(300,*) xtime/60.,K, RHO_INI, T_INI, TV_INI, TVEN_INI, Z_INI, P_INI
1042 !&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
1043 ! BEGINING OF UPDRAFT CACULATION
1044 !&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
1046 ! COMPUTE INITIAL UPDRAFT MASS FLUX UMF(K)
1050 UMF(K)=RHO_INI*AU0*WPBLTP
1057 !...UER IS THE ENVIR ENTRAINMENT RATE, ABE IS AVAILABLE BUOYANT ENERGY,
1058 ! TRPPT IS THE TOTAL RATE OF PRECIPITATION PRODUCTION...
1078 !...THE AMOUNT OF CONV AVAIL POT ENERGY (CAPE) IS CALCULATED WITH RESPECT TO
1079 !...UNDILUTE PARCEL ASCENT; EQ POT TEMP OF UNDILT PARCEL IS THTUDL, UNDILT
1080 ! TEMP IS GIVEN BY TUDL...
1085 !...TTEMP IS USED DURING CALCULATION OF THE LINEAR GLACIATION PROCESS; IT IS
1086 ! INITIALLY SET TO THE TEMPERATURE AT WHICH FREEZING IS SPECIFIED TO BEGIN;
1087 ! WITHIN THE GLACIATION INTERVAL, IT IS SET EQUAL TO THE UPDR TEMP AT THE
1088 ! PREVIOUS MODEL LEVEL...
1092 ! FOR SHALLOW CONVECTION, SET RATE=0 SO NO LIQUID FALLS OUT
1094 IF( CLDDPTHB(I,J) .LT. 4.E3) THEN
1095 RATE = 0.0 ! TURN OFF DOWNDRAFT ALSO
1100 !...ENTER THE LOOP FOR UPDRAFT CALCULATIONS...CALCULATE UPDRAFT TEMP, MIXING
1101 ! RATIO, VERTICAL MASS FLUX, LATERAL DETRAINMENT OF MASS AND MOISTURE, AND
1102 ! PRECIPITATION RATES AT EACH MODEL LEVEL...
1109 RATIO2(NK1)=RATIO2(NK)
1111 !...UPDATE UPDRAFT PROPERTIES AT THE NEXT MODEL LVL TO REFLECT ENTRAINMNT OF
1112 ! ENVIRONMENTAL AIR...
1116 THETEU(NK1)=THETEU(NK)
1120 CALL TPMIX(P0(NK1),THETEU(NK1),TU(NK1),QU(NK1),RLIQ(NK1), &
1121 RICE(NK1),QNEWLQ,QNEWIC,RATIO2(NK1),RL,XLV0,XLV1,XLS0,XLS1, &
1122 SVP1,SVP2,SVPT0,SVP3)
1123 ! CALL TPMIXBG(P0(NK1),THETEU(NK1),TU(NK1),QU(NK1),RLIQ(NK1), &
1124 ! RICE(NK1),QNEWLQ,QNEWIC,RATIO2(NK1),RL,XLV0,XLV1,XLS0,XLS1, &
1125 ! SVP1,SVP2,SVPT0,SVP3)
1127 ! CALL TPMIX2(P0(NK1),THETEU(NK1),TU(NK1),QU(NK1),RLIQ(NK1), &
1128 ! RICE(NK1),QNEWLQ,QNEWIC,XLV1,XLV0,ktau,i,j,nk1, 1)
1129 TVU(NK1)=TU(NK1)*(1.+0.608*QU(NK1))
1131 ! CHECK TO SEE IF UPDRAFT TEMP IS WITHIN THE FREEZING INTERVAL, IF IT IS,
1132 ! CALCULATE THE FRACTIONAL CONVERSION TO GLACIATION AND ADJUST QNEWLQ TO
1133 ! REFLECT THE GRADUAL CHANGE IN THETAU SINCE THE LAST MODEL LEVEL...THE
1134 ! GLACIATION EFFECTS WILL BE DETERMINED AFTER THE AMOUNT OF CONDENSATE
1135 ! AVAILABLE AFTER PRECIP FALLOUT IS DETERMINED...TTFRZ IS THE TEMP AT WHICH
1136 ! GLACIATION BEGINS, TBFRZ THE TEMP AT WHICH IT ENDS...
1138 IF(TU(NK1).LE.TTFRZ.AND.IFLAG.LT.1)THEN
1139 IF(TU(NK1).GT.TBFRZ)THEN
1140 IF(TTEMP.GT.TTFRZ)TTEMP=TTFRZ
1141 FRC1=(TTEMP-TU(NK1))/(TTFRZ-TBFRZ)
1142 R1=(TTEMP-TU(NK1))/(TTEMP-TBFRZ)
1144 FRC1=(TTEMP-TBFRZ)/(TTFRZ-TBFRZ)
1149 QNEWIC=QNEWIC+QNEWLQ*R1*0.5
1150 QNEWLQ=QNEWLQ-QNEWLQ*R1*0.5
1151 IF( ABS(TTEMP-TBFRZ) < 1.E-3 ) THEN
1154 EFFQ=(TTFRZ-TBFRZ)/(TTEMP-TBFRZ)
1159 ! CALCULATE UPDRAFT VERTICAL VELOCITY AND PRECIPITATION FALLOUT...
1162 BE=(TV_INI+TVU(NK1))/(TVEN_INI+TV0(NK1))-1.
1163 BOTERM=2.*(Z0(NK1)-Z_INI)*G*BE/1.5
1167 BE=(TVU(NK)+TVU(NK1))/(TV0(NK)+TV0(NK1))-1.
1168 BOTERM=2.*DZA(NK)*G*BE/1.5
1169 ENTERM=2.*UER(NK)*WTW/UPOLD
1173 CALL CONDLOAD(RLIQ(NK1),RICE(NK1),WTW,DZZ,BOTERM,ENTERM, &
1174 RATE,QNEWLQ,QNEWIC,QLQOUT(NK1),QICOUT(NK1), G)
1175 IF(WTW < 1.E-3) THEN
1181 !...IF VERT VELOCITY IS LESS THAN ZERO, EXIT THE UPDRAFT LOOP AND, IF CLOUD
1182 ! IS TALL ENOUGH, FINALIZE UPDRAFT CALCULATIONS...
1184 ! IF(WU(NK1).LT.0.) EXIT loop60
1186 ! UPDATE THE ABE FOR UNDILUTE ASCENT...
1188 THTES(NK1)=T0(NK1)*(1.E5/P0(NK1))**(0.2854*(1.-0.28*QES(NK1)))* &
1189 EXP((3374.6525/T0(NK1)-2.5403)*QES(NK1)*(1.+0.81*QES(NK1)))
1190 UDLBE=((2.*THTUDL)/(THTES(NK)+THTES(NK1))-1.)*DZZ
1191 IF(UDLBE.GT.0.)ABE=ABE+UDLBE*G
1193 ! DETERMINE THE EFFECTS OF CLOUD GLACIATION IF WITHIN THE SPECIFIED
1196 IF(FRC1.GT.1.E-6)THEN
1197 CALL DTFRZNEW(TU(NK1),P0(NK1),THETEU(NK1),QU(NK1),RLIQ(NK1), &
1198 RICE(NK1),RATIO2(NK1),QNWFRZ,RL,FRC1,EFFQ, &
1199 IFLAG,XLV0,XLV1,XLS0,XLS1, &
1200 SVP1,SVP2,SVPT0,SVP3)
1203 ! CALL SUBROUTINE TO CALCULATE ENVIRONMENTAL EQUIVALENT POTENTIAL TEMP...
1204 ! WITHIN GLACIATION INTERVAL, THETAE MUST BE CALCULATED WITH RESPECT TO THE
1205 ! SAME DEGREE OF GLACIATION FOR ALL ENTRAINING AIR...
1207 CALL ENVIRTHT(P0(NK1),T0(NK1),Q0(NK1), &
1208 THETEE(NK1),RATIO2(NK1),RL, &
1209 SVP1,SVP2,SVPT0,SVP3,I,J)
1210 ! CALL ENVIRTHT2(P0(NK1),T0(NK1),Q0(NK1), &
1211 ! THETEE(NK1),ALIQ,BLIQ,CLIQ,DLIQ)
1213 !...REI IS THE RATE OF ENVIRONMENTAL INFLOW...
1215 REI=VMFPBLCL*DP(NK1)*0.03/RAD
1217 !...TVQU IS THE PARCEL TEMP INCLUDING WATER LOADING...
1218 !...IF IT BECOMES GREATER THAN TV0, THEN YOU ARE PAST LFC...
1220 TVQU(NK1)=TU(NK1)*(1.+0.608*QU(NK1)-RLIQ(NK1)-RICE(NK1))
1222 !...IF CLOUD PARCELS ARE VIRTUALLY COLDER THAN THE ENVIRONMENT, NO
1223 ! ENTRAINMENT IS ALLOWED AT THIS LEVEL...
1225 IF(TVQU(NK1).LE.TV0(NK1))THEN
1236 !...DETERMINE THE CRITICAL MIXED FRACTION OF UPDRAFT AND ENVIRONMENTAL AIR...
1240 THTTMP=F1*THETEE(NK1)+F2*THETEU(NK1)
1241 RTMP=F1*Q0(NK1)+F2*QU(NK1)
1244 CALL TPMIX(P0(NK1),THTTMP,TTMP,RTMP,TMPLIQ,TMPICE,QNEWLQ, &
1245 QNEWIC,RATIO2(NK1),RL,XLV0,XLV1,XLS0,XLS1, &
1246 SVP1,SVP2,SVPT0,SVP3)
1247 ! CALL TPMIX2(P0(NK1),THTTMP,TTMP,RTMP,TMPLIQ,TMPICE,QNEWLQ, &
1248 ! QNEWIC,XLV1,XLV0,ktau,i,j,nk1,2)
1249 ! CALL TPMIXBG(P0(NK1),THTTMP,TTMP,RTMP,TMPLIQ,TMPICE,QNEWLQ, &
1250 ! QNEWIC,RATIO2(NK1),RL,XLV0,XLV1,XLS0,XLS1, &
1251 ! SVP1,SVP2,SVPT0,SVP3)
1252 TU95=TTMP*(1.+0.608*RTMP-TMPLIQ-TMPICE)
1253 IF(TU95.GT.TV0(NK1))THEN
1261 THTTMP=F1*THETEE(NK1)+F2*THETEU(NK1)
1262 RTMP=F1*Q0(NK1)+F2*QU(NK1)
1265 CALL TPMIX(P0(NK1),THTTMP,TTMP,RTMP,TMPLIQ,TMPICE,QNEWLQ, &
1266 QNEWIC,RATIO2(NK1),RL,XLV0,XLV1,XLS0,XLS1, &
1267 SVP1,SVP2,SVPT0,SVP3)
1268 ! CALL TPMIX2(P0(NK1),THTTMP,TTMP,RTMP,TMPLIQ,TMPICE,QNEWLQ, &
1269 ! QNEWIC,XLV1,XLV0,ktau,i,j,nk1,3)
1270 ! CALL TPMIXBG(P0(NK1),THTTMP,TTMP,RTMP,TMPLIQ,TMPICE,QNEWLQ, &
1271 ! QNEWIC,RATIO2(NK1),RL,XLV0,XLV1,XLS0,XLS1, &
1272 ! SVP1,SVP2,SVPT0,SVP3)
1273 TU10=TTMP*(1.+0.608*RTMP-TMPLIQ-TMPICE)
1274 IF( ABS(TU10-TVQU(NK1)) < 1.E-3) THEN
1277 EQFRC(NK1)=(TV0(NK1)-TVQU(NK1))*F1/(TU10-TVQU(NK1)+1.E-20)
1281 EQFRC(NK1)=MAX(EQMIN,EQFRC(NK1))
1282 EQFRC(NK1)=MIN(EQMAX,EQFRC(NK1))
1283 IF(EQFRC(NK1).EQ.1)THEN
1287 ELSEIF(EQFRC(NK1).EQ.0.)THEN
1293 !...SUBROUTINE PROF5 INTEGRATES OVER THE GAUSSIAN DIST TO DETERMINE THE
1294 ! FRACTIONAL ENTRAINMENT AND DETRAINMENT RATES...
1296 CALL PROF5(EQFRC(NK1),EE2,UD2)
1301 ! IF( NK .EQ. K) THEN
1306 !...NET ENTRAINMENT AND DETRAINMENT RATES ARE GIVEN BY THE AVERAGE FRACTIONAL
1307 ! VALUES IN THE LAYER...
1309 UER(NK1)=0.5*REI*(EE1+EE2)
1310 UDR(NK1)=0.5*REI*(UD1+UD2)
1312 !...IF THE CALCULATED UPDRAFT DETRAINMENT RATE IS GREATER THAN THE TOTAL
1313 ! UPDRAFT MASS FLUX, ALL CLOUD MASS DETRAINS, EXIT UPDRAFT CALCULATIONS...
1317 IF(UMF(NK)-UDR(NK1).LT.10.)THEN
1319 !...IF THE CALCULATED DETRAINED MASS FLUX IS GREATER THAN THE TOTAL UPD MASS
1320 ! FLUX, IMPOSE TOTAL DETRAINMENT OF UPDRAFT MASS AT THE PREVIOUS MODEL LVL..
1322 IF(UDLBE.GT.0.)ABE=ABE-UDLBE*G
1329 UPOLD=UMF(NK)-UDR(NK1)
1330 UPNEW=UPOLD+UER(NK1)
1333 !...DETLQ AND DETIC ARE THE RATES OF DETRAINMENT OF LIQUID AND ICE IN THE
1334 ! DETRAINING UPDRAFT MASS...
1336 DETLQ(NK1)=RLIQ(NK1)*UDR(NK1)
1337 DETIC(NK1)=RICE(NK1)*UDR(NK1)
1339 QU(NK1)=(UPOLD*QU(NK1)+UER(NK1)*Q0(NK1))/UPNEW
1340 THETEU(NK1)=(THETEU(NK1)*UPOLD+THETEE(NK1)*UER(NK1))/UPNEW
1341 RLIQ(NK1)=RLIQ(NK1)*UPOLD/UPNEW
1342 RICE(NK1)=RICE(NK1)*UPOLD/UPNEW
1344 !...KFRZ IS THE HIGHEST MODEL LEVEL AT WHICH LIQUID CONDENSATE IS GENERATED...
1345 ! PPTLIQ IS THE RATE OF GENERATION (FALLOUT) OF LIQUID PRECIP AT A GIVEN
1346 ! MODEL LVL, PPTICE THE SAME FOR ICE, TRPPT IS THE TOTAL RATE OF PRODUCTION
1347 ! OF PRECIP UP TO THE CURRENT MODEL LEVEL...
1349 ! IF(ABS(RATIO2(NK1)-1.).GT.1.E-6)KFRZ=NK1
1350 PPTLIQ(NK1)=QLQOUT(NK1)*UMF(NK)
1351 PPTICE(NK1)=QICOUT(NK1)*UMF(NK)
1352 TRPPT=TRPPT+PPTLIQ(NK1)+PPTICE(NK1)
1357 IF( i == 1 .AND. j == 1 ) write(88,*) xtime/60.,ABE
1360 ! UPDRAFT TOP IS DEFINED AS THE LAGER VALUE OF LTOP1 (CTP1) AND LTOP1 (CTP2)
1361 ! WHERE LTOP1 IS THE KAIN-FRITSCH UPDRAFT TOP AND LTOP2 IS THE HEIGHT CALCULATED
1362 ! USING THE EQUATION: CTP2=CLDTOPB(I,J)+0.2*WUMAX*DT2/2.0
1369 IF(WU(NK) .GT. WUMAX) WUMAX=WU(NK)
1372 IF(LTOPB(I,J) .LE. 1) GOTO 666
1373 CTP2=CLDTOPB(I,J)+0.2*WUMAX*DT2/2.0
1375 IF(CTP2 .GE. (Z0(KL)+DZQ(KL)/2.0)) THEN
1380 IF(CTP2 .LT. (Z0(NK)+DZQ(NK)/2.0) .AND. &
1381 CTP2 .GE. (Z0(NK)-DZQ(NK)/2.0)) LTOP2 = NK
1384 LTOP2=MAX(LTOP2,KLCL)
1387 CLDTOP=MIN(CTP1,CTP2)
1388 LTOP=MIN(LTOP1,LTOP2)
1395 IF( i == 1 .AND. j == 1 ) write(89,'(8f10.3,i3)') xtime/60.,CLDTOPB(I,J),CTP1,CTP2, &
1396 CLDTOP,ZLCL,WUMAX,ABE, LTOPB(I,J)
1399 ! MODIFY TRPPT CONSIDERING ACTUAL CLOUD TOP WHICH IS
1400 ! LOWER IN MOST CASES
1402 IF(LTOP .EQ. LTOP2 .AND. LTOP1 .GT. LTOP2) THEN
1404 TRPPT=TRPPT-PPTLIQ(NK)-PPTICE(NK)
1408 IF(CLDDPTH .LE. 0.0) CLDDPTH=0.0
1410 CLDHGTG(I,J)=CLDDPTH ! Graphics
1411 PCLDTPG(I,J)=P0(LTOP) ! Graphics
1412 TCLDTPG(I,J)=TU(LTOP) ! Graphics
1415 ! FIND LEVEL OF FREE CONVECTION. WHEN THE PARCCEL IS WARMER THAN THE ENVIRONMENT
1416 ! AT ITS LCL, IT NEED AT LEAST 400 M TO SAY THAT LFC IF AT LCL
1419 IF(CLDDPTH .LE. 0.0) THEN
1422 ELSE IF(TVQU(KLCL) .GE. TV0(KLCL)) THEN
1424 KVAL=MAX(KLCL,KKPBL)
1425 loop61: DO KS=KVAL,LTOP1
1426 IF(TVQU(KS).GT.TV0(KS)) THEN
1433 IF(SUM .GE. 300.) THEN
1440 loop66: DO KK =KVAL,LTOP1-1
1441 IF(TVQU(KK) .LT. TV0(KK) .AND. TVQU(KK+1).GT.TV0(KK+1)) THEN
1444 ! VAL0=TVQU(K2)-TV0(K2)+TV0(K1)-TVQU(K1)
1445 ! IF( ABS(VAL0) < 0.001 ) then
1446 ! if( dbg_level > 100 ) then
1447 ! write(message,*) kval, k1, k2, TVQU(K2), TV0(K2), TVQU(K1), TV0(K1), TVQU(K2)-TV0(K2)+TV0(K1)-TVQU(K1)
1448 ! call wrf_message( message )
1452 ! VAL1=(TVQU(K2)-TV0(K2))/VAL0
1453 ! VAL2=(TV0(K1)-TVQU(K1))/VAL0
1454 ! VAL=VAL1*Z0(K1)+VAL2*Z0(K2)
1458 loop62: DO KS=K2,LTOP1
1459 IF(TVQU(KS).GT.TV0(KS)) THEN
1466 IF(SUM .GE. 300.) THEN
1481 !=================================================================
1484 TUG(NK)=TLCL*(P0(NK)/PLCL)**ROCPQ
1491 IF( CLDTOP .LE. ZLCL .OR. LTOP .LT. KLCL) THEN
1494 TLET = TLCL*(PLET/PLCL)**ROVCP
1496 TLFSG(I,J) = TLCL*(PLFSG(I,J)/PLCL)**ROVCP
1498 TLDTG(I,J) = TLCL*(PLDTG(I,J)/PLCL)**ROVCP
1500 TLDBG(I,J) = TLCL*(PLDBG(I,J)/PLCL)**ROVCP
1506 IF( LET .GT. LTOP ) LET = LTOP
1508 !...IF THE LET AND LTOP ARE THE SAME, DETRAIN ALL OF THE UPDRAFT MASS FLUX AT
1512 UPOLD=UMF(LTOP-1)-UDR(LTOP)
1513 UPNEW=UPOLD+UER(LTOP)
1514 UDR(LTOP)=UMF(LTOP)+UDR(LTOP)-UER(LTOP)
1515 IF( ABS(UPOLD) < 0.001 ) STOP 907
1516 DETLQ(LTOP)=RLIQ(LTOP)*UDR(LTOP)*UPNEW/UPOLD
1517 DETIC(LTOP)=RICE(LTOP)*UDR(LTOP)*UPNEW/UPOLD
1523 ! BEGIN TOTAL DETRAINMENT AT THE LEVEL ABOVE THE LET...
1529 DUMFDP=UMF(LET)/DPTT
1531 !...ADJUST MASS FLUX PROFILES, DETRAINMENT RATES, AND PRECIPITATION FALLOUT
1532 ! RATES TO REFLECT THE LINEAR DECREASE IN MASS FLX BETWEEN THE LET AND LTOP
1535 UDR(NK)=DP(NK)*DUMFDP
1536 UMF(NK)=UMF(NK-1)-UDR(NK)
1537 DETLQ(NK)=RLIQ(NK)*UDR(NK)
1538 DETIC(NK)=RICE(NK)*UDR(NK)
1540 TRPPT=TRPPT-PPTLIQ(NK)-PPTICE(NK)
1541 PPTLIQ(NK)=UMF(NK-1)*QLQOUT(NK)
1542 PPTICE(NK)=UMF(NK-1)*QICOUT(NK)
1543 TRPPT=TRPPT+PPTLIQ(NK)+PPTICE(NK)
1549 !...EXTEND THE UPDRAFT MASS FLUX PROFILE DOWN TO THE SOURCE LAYER FOR THE
1550 ! UPDRAFT AIR...ALSO, DEFINE THETAE FOR LEVELS BELOW THE LCL...
1556 DPTHMX1 = DPTHMX1 + DP(NK)
1557 QMIX1 = QMIX1 + DP(NK)*Q0(NK)
1558 ZMIX1 = ZMIX1 + DP(NK)*Z0(NK)
1560 QMIX1 = QMIX1 / DPTHMX1
1561 ZMIX1 = ZMIX1 / DPTHMX1
1566 UMF(NK)=VMFPBLCL*DP(NK)/DPTHMX1
1567 UER(NK)=VMFPBLCL*DP(NK)/DPTHMX1
1568 ELSEIF(NK .LE. K)THEN
1569 UER(NK)=VMFPBLCL*DP(NK)/DPTHMX1
1570 UMF(NK)=UMF(NK-1)+UER(NK)
1576 TU(NK)=TLCL+(Z0(NK)-ZLCL)*GDRY
1596 EE=Q0(NK)*P0(NK)/(0.622+Q0(NK))
1597 TLOG=ALOG(EE/SVP1/1000.)
1598 TDPT=(SVP2*SVPT0-SVP3*TLOG)/(SVP2-TLOG)
1599 TSAT=TDPT-(.212+1.571E-3*(TDPT-T00)-4.36E-4*(T0(NK)-T00))*(T0(NK)-TDPT)
1600 THTA=T0(NK)*(1.E5/P0(NK))**(0.2854*(1.-0.28*Q0(NK)))
1601 THETEE(NK)=THTA*EXP((3374.6525/TSAT-2.5403)*Q0(NK)*(1.+0.81*Q0(NK)))
1602 THTES(NK)=THTA*EXP((3374.6525/T0(NK)-2.5403)*QES(NK)*(1.+0.81*QES(NK)))
1609 !...DEFINE VARIABLES ABOVE CLOUD TOP...
1631 EMS(NK)=DP(NK)*DXSQ/G
1653 P165=P0(KLCL)-1.65E4
1656 EMS(NK)=DP(NK)*DXSQ/G
1660 !...INITIALIZE SOME VARIABLES TO BE USED LATER IN THE VERT ADVECTION SCHEME.
1662 EXN(NK)=(P00/P0(NK))**(0.2854*(1.-0.28*QDT(NK)))
1663 THTAU(NK)=TU(NK)*EXN(NK)
1664 EXN(NK)=(P00/P0(NK))**(0.2854*(1.-0.28*Q0(NK)))
1665 THTA0(NK)=T0(NK)*EXN(NK)
1667 IF(P0(NK).GT.P165) LVF=NK
1668 PPTMLT=PPTMLT+PPTICE(NK)
1675 CLVF=CLVF+PPTLIQ(NK)+PPTICE(NK)
1677 USR=UMF(LVF+1)*QU(LVF+1)+CLVF
1679 ! WRITE(28,1025)KLCL,ZLCL,LTOP,P0(LTOP),IFLAG, &
1680 ! TMIX-T00,PMIX,QMIX,ABE
1681 ! WRITE(28,1030)P0(LET)/100.,P0(LTOP)/100.,VMFPBLCL,XTIME/60. &
1682 ! ,PLCL/100.,WPBLTP,CLDDPTH
1683 !1025 FORMAT(5X,' KLCL=',I2,' ZLCL=',F7.1,'M', &
1684 ! ' LTOP=',I2,' P0(LTOP)=',-2PF5.1,'MB FRZ LV=', &
1685 ! I2,' TMIX=',0PF4.1,1X,'PMIX=',-2PF6.1,' QMIX=',3PF5.1, &
1687 !1030 FORMAT(' ',' P0(LET) = ',F6.1,' P0(LTOP) = ',F6.1,' VMFLCL =', &
1688 ! E12.3,' XTIME =',F10.3,' PLCL =',F6.1,' WLCL =',F6.3,' CLDHGT =', &
1691 !...COMPUTE CONVECTIVE TIME SCALE(TIMEC). THE MEAN WIND AT THE LCL
1692 !...AND MIDTROPOSPHERE IS USED.
1694 WSPD(KLCL)=SQRT(U0(KLCL)*U0(KLCL)+V0(KLCL)*V0(KLCL))
1695 WSPD(L5)=SQRT(U0(L5)*U0(L5)+V0(L5)*V0(L5))
1696 WSPD(LTOP)=SQRT(U0(LTOP)*U0(LTOP)+V0(LTOP)*V0(LTOP))
1697 VCONV = .5*(WSPD(KLCL)+WSPD(L5))
1702 TIMEC = MAX(TCMIN,TIMEC)
1703 TIMEC = MIN(TCMAX,TIMEC)
1704 NIC = NINT(TIMEC/(.5*DT2))
1705 TIMEC = FLOAT(NIC)*.5*DT2
1707 !...COMPUTE WIND SHEAR AND PRECIPITATION EFFICIENCY.
1709 IF(WSPD(LTOP).GT.WSPD(KLCL))THEN
1714 VWS=(U0(LTOP)-U0(KLCL))*(U0(LTOP)-U0(KLCL))+(V0(LTOP)-V0(KLCL))*(V0(LTOP)-V0(KLCL))
1715 IF(LTOP .LE. LCL) GO TO 425
1716 VWS=1.E3*SHSIGN*SQRT(VWS)/(Z0(LTOP)-Z0(LCL))
1717 PEF=1.591+VWS*(-.639+VWS*(9.53E-2-VWS*4.96E-3))
1723 !...PRECIPITATION EFFICIENCY IS A FUNCTION OF THE HEIGHT OF CLOUD BASE.
1725 CBH=(ZLCL-Z0(1))*3.281E-3
1729 RCBH=.96729352+CBH*(-.70034167+CBH*(.162179896+CBH*(- &
1730 1.2569798E-2+CBH*(4.2772E-4-CBH*5.44E-6))))
1732 IF (CBH.GT.25) RCBH=2.4
1735 PEFCBH=MIN(PEFCBH,CBHMX)
1737 !... MEAN PEF. IS USED TO COMPUTE RAINFALL.
1738 ! DOWNDRAFT IS TURNED OFF BY RATE=0.0
1740 PEFF=.5*(PEF+PEFCBH)
1741 IF(CLDDPTHB(I,J) .LT. 4.E3) THEN
1745 ! IF ( wrf_dm_on_monitor()) THEN
1746 ! CALL get_wrf_debug_level( dbg_level )
1747 ! IF( dbg_level >= 10 .AND. i == i0 .AND. j == j0 ) THEN
1748 ! WRITE(message,1035)PEF,PEFCBH,LC,LET,VWS
1749 !1035 FORMAT(1X,'PEF(WS)=',F4.2,'(CB)=',F4.2,'LC,LET=',2I3,'VWS=',F5.2)
1750 ! CALL wrf_message( message )
1754 !&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
1755 ! BEGINING OF DOWNDRAFT CACULATION
1756 !&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
1758 !...LET DOWNDRAFT ORIGINATE AT THE LEVEL OF MINIMUM SATURATION EQUIVALENT
1759 !...POTENTIAL TEMPERATURE (SEQT) IN THE CLOUD LAYER, EXTEND DOWNWARD TO THE
1760 !...SURFACE, OR TO THE LAYER BELOW CLOUD BASE AT WHICH ENVIR SEQT IS LESS
1761 !...THAN MIN SEQT IN THE CLOUD LAYER...LET DOWNDRAFT DETRAIN OVER A LAYER
1762 !...OF SPECIFIED PRESSURE-DEPTH (DPDD)...
1765 KSTART=MAX0(KKPBL,KLCL)
1766 THTMIN=THTES(KSTART+1)
1768 DO NK=KSTART+2,LTOP-1
1769 THTMIN=MIN(THTMIN,THTES(NK))
1770 IF(THTMIN.EQ.THTES(NK))KMIN=NK
1773 IF(LFS .GE. LTOP) LFS=LTOP-1
1774 IF(RATIO2(LFS).GT.0.)CALL ENVIRTHT(P0(LFS),T0(LFS),Q0(LFS), &
1775 THETEE(LFS),0.,RL, &
1776 SVP1,SVP2,SVPT0,SVP3,I,J)
1777 ! IF(RATIO2(LFS).GT.0.)CALL ENVIRTHT2(P0(LFS),T0(LFS),Q0(LFS), &
1778 ! THETEE(LFS),ALIQ,BLIQ,CLIQ,DLIQ)
1780 IF( ABS(THETEE(LFS)-THETEU(LFS)) < 1.E-3 ) THEN ! DENG 20140110 fix to avoid dividing by 0
1783 EQFRC(LFS)=(THTES(LFS)-THETEU(LFS))/(THETEE(LFS)-THETEU(LFS))
1785 EQFRC(LFS)=MAX(EQFRC(LFS),0.)
1786 EQFRC(LFS)=MIN(EQFRC(LFS),1.)
1787 THETED(LFS)=THTES(LFS)
1789 !...ESTIMATE THE EFFECT OF MELTING ON THE DOWNDRAFT...
1792 DTMLTD=0.5*(QU(KLCL)-QU(LTOP))*RLF/CP
1796 TZ(LFS)=T0(LFS)-DTMLTD
1797 ES=1.E3*SVP1*EXP(SVP2*(TZ(LFS)-SVPT0)/(TZ(LFS)-SVP3))
1798 QS = 0.622*ES/(P0(LFS)-ES)
1799 QD(LFS)=EQFRC(LFS)*Q0(LFS)+(1.-EQFRC(LFS))*QU(LFS)
1800 THTAD(LFS)=TZ(LFS)*(P00/P0(LFS))**(0.2854*(1.-0.28*QD(LFS)))
1801 IF( QD(LFS) .GE. QS ) THEN
1802 THETED(LFS)=THTAD(LFS)* &
1803 EXP((3374.6525/TZ(LFS)-2.5403)*QS*(1.+0.81*QS))
1805 CALL ENVIRTHT(P0(LFS),TZ(LFS),QD(LFS), &
1806 THETED(LFS),0.,RL, &
1807 SVP1,SVP2,SVPT0,SVP3,I,J)
1808 ! CALL ENVIRTHT2(P0(LFS),TZ(LFS),QD(LFS), &
1809 ! THETED(LFS),ALIQ,BLIQ,CLIQ,DLIQ)
1812 !...DETERMINE THE LOWEST LEVEL TO WHICH DOWNDRAFT CAN PENETRATE (LDB)...
1814 loop107: DO NK=1,LFS
1816 IF(THETED(LFS).GT.THTES(ND) .OR. ND.EQ.1)THEN
1822 !...ASSUME ALL OF DOWNDRAFT DETRAINMENT OCCURS AT ITS BASE, SO THE TOP OF THE
1823 !...DETRAINMENT LAYER (LDT) IS THE SAME AS LDB...
1827 loop115: DO NK=LDB,LFS
1831 FRC=(DPDD+DP(NK)-DPT)/DP(NK)
1847 !...MAKE A FIRST GUESS AT INITIAL DOWNDRAFT MASS FLUX, DETERMINE ITS VERTICAL
1850 TVD(LFS)=T0(LFS)*(1.+0.608*QES(LFS))
1851 RDD=P0(LFS)/(R*TVD(LFS))
1854 DER(LFS)=EQFRC(LFS)*DMF(LFS)
1860 DDR(ND)=-DMF(LDT+1)*DP(ND)*FRC/DPDD
1861 DMF(ND)=DMF(ND1)+DDR(ND)
1863 THETED(ND)=THETED(ND1)
1866 DER(ND)=DMF(LFS)*0.03*DP(ND)/RAD
1868 DMF(ND)=DMF(ND1)+DER(ND)
1869 IF(RATIO2(ND).GT.0.)CALL ENVIRTHT(P0(ND),T0(ND),Q0(ND), &
1871 SVP1,SVP2,SVPT0,SVP3,I,J)
1872 ! IF(RATIO2(ND).GT.0.)CALL ENVIRTHT2(P0(ND),T0(ND),Q0(ND), &
1873 ! THETEE(ND),ALIQ,BLIQ,CLIQ,DLIQ)
1874 THETED(ND)=(THETED(ND1)*DMF(ND1)+THETEE(ND)*DER(ND))/DMF(ND)
1875 QD(ND)=(QD(ND1)*DMF(ND1)+Q0(ND)*DER(ND))/DMF(ND)
1879 !...DETERMINE TOTAL DOWNDRAFT EVAPORATION RATE (TDER)
1883 TZ(ND)=TPDDBG(P0(ND),THETED(LDT),T0(ND),QS,QD(ND),1.0, &
1885 SVP1,SVP2,SVPT0,SVP3)
1886 ! CALL TPMIX2DD(p0(ND),theted(LDT),tz(ND),qs,ktau,i,j,nd)
1888 ES=1.E3*SVP1*EXP(SVP2*(TZ(ND)-SVPT0)/(TZ(ND)-SVP3))
1889 QS=0.622*ES/(P0(ND)-ES)
1890 DQSSDT=SVP2*(SVPT0-SVP3)/((TZ(ND)-SVP3)*(TZ(ND)-SVP3))
1892 DTMP=RL*QS*(1.-RHBC)/(CP+RL*RHBC*QS*DQSSDT)
1894 ES=RHBC*1.E3*SVP1*EXP(SVP2*(T1RH-SVPT0)/(T1RH-SVP3))
1895 QSRH=0.622*ES/(P0(ND)-ES)
1897 !...CHECK TO SEE IF MIXING RATIO AT SPECIFIED RH IS LESS THAN ACTUAL
1898 !...MIXING RATIO...IF SO, ADJUST TO GIVE ZERO EVAPORATION...
1900 IF(QSRH.LT.QD(ND))THEN
1906 TDER=TDER + (QS-QD(ND))*DDR(ND)
1908 THTAD(ND)=TZ(ND)*(P00/P0(ND))**(0.2854*(1.-0.28*QD(ND)))
1911 !...IF DOWNDRAFT DOES NOT EVAPORATE ANY WATER FOR SPECIFIED RELATIVE
1912 !...HUMIDITY, NO DOWNDRAFT IS ALLOWED...
1939 !...ADJUST DOWNDRAFT MASS FLUX SO THAT EVAPORATION RATE IN DOWNDRAFT IS
1940 !...CONSISTENT WITH PRECIPITATION EFFICIENCY RELATIONSHIP...
1942 DEVDMF=TDER/DMF(LFS)
1947 !...PPR IS THE TOTAL AMOUNT OF PRECIPITATION THAT FALLS OUT OF THE UPDRAFT
1948 !...FROM CLOUD BASE TO THE LFS...UPDRAFT MASS FLUX WILL BE INCREASED UP TO
1949 !...THE LFS TO ACCOUNT FOR UPDRAFT AIR MIXING WITH ENVIRONMENTAL AIR TO MAKE
1950 !...THE UPDRAFT, SO PPR WILL INCREASE PROPORTIONATELY...
1953 PPR=PPR+PPTLIQ(NM)+PPTICE(NM)
1956 DPPTDF=(1.-PEFF)*PPR*(1.-EQFRC(LFS))/UMF(LFS)
1961 !...CNDTNF IS THE AMOUNT OF CONDENSATE TRANSFERRED ALONG WITH UPDRAFT MASS TO
1962 !...THE DOWNDRAFT AT THE LFS...
1964 CNDTNF=(RLIQ(LFS)+RICE(LFS))*(1.-EQFRC(LFS))
1965 DMFLFS=RCED/(DEVDMF+DPPTDF+CNDTNF)
1966 IF(DMFLFS.GT.0.)THEN
1970 !...DDINC IS THE FACTOR BY WHICH TO INCREASE THE FIRST-GUESS DOWNDRAFT MASS FLUX
1971 !...TO SATISFY THE PRECIP EFFICIENCY RELATIONSHIP, UPDINC IS THE FACTOR BY WHICH
1972 !...TO INCREASE THE UPDRAFT MASS FLUX BELOW THE LFS TO ACCOUNT FOR THE TRANSFER
1973 !...OF MASS FROM UPDRAFT TO DOWNDRAFT...
1975 DDINC=DMFLFS/DMF(LFS)
1977 UPDINC=(UMF(LFS)-(1.-EQFRC(LFS))*DMFLFS)/UMF(LFS)
1982 DMF(NK)=DMF(NK)*DDINC
1983 DER(NK)=DER(NK)*DDINC
1984 DDR(NK)=DDR(NK)*DDINC
1986 CPR=TRPPT+PPR*(UPDINC-1.)
1987 PPTFLX = PPTFLX+PEFF*PPR*(UPDINC-1.)
1990 !...ADJUST UPDRAFT MASS FLUX, MASS DETRAINMENT RATE, AND LIQUID WATER AND ICE
1991 ! DETRAINMENT RATES TO BE CONSISTENT WITH THE TRANSFER OF THE ESTIMATED MASS
1992 ! FROM THE UPDRAFT TO THE DOWNDRAFT AT THE LFS...
1995 UMF(NK)=UMF(NK)*UPDINC
1996 UDR(NK)=UDR(NK)*UPDINC
1997 UER(NK)=UER(NK)*UPDINC
1998 PPTLIQ(NK)=PPTLIQ(NK)*UPDINC
1999 PPTICE(NK)=PPTICE(NK)*UPDINC
2000 DETLQ(NK)=DETLQ(NK)*UPDINC
2001 DETIC(NK)=DETIC(NK)*UPDINC
2030 !...SET LIMITS ON THE UPDRAFT AND DOWNDRAFT MASS FLUXES SO THAT THE INFLOW
2031 ! INTO CONVECTIVE DRAFTS FROM A GIVEN LAYER IS NO MORE THAN IS AVAILABLE
2032 ! IN THAT LAYER INITIALLY...
2038 IF((UER(NK)-DER(NK)).GT.0.) &
2039 AINCM1=EMS(NK)/((UER(NK)-DER(NK))*TIMEC)
2040 AINCMX=MIN(AINCMX,AINCM1)
2044 IF(AINCMX.LT.AINC)AINC=AINCMX
2046 !...SAVE THE RELEVENT VARIABLES FOR A UNIT UPDRFT AND DOWNDRFT...THEY WILL BE
2047 ! ADJUSTED BY THE FACTOR AINC TO SATISFY THE STABILIZATION CLOSURE...
2054 DETLQ2(NK)=DETLQ(NK)
2055 DETIC2(NK)=DETIC(NK)
2063 IF(NK.GT.ML .AND. NK.LT.LTOP)THEN
2064 PPTMLT=PPTMLT+PPTICE(NK+1)
2072 IF(AINC/AINCMX.GT.0.999)GOTO 255
2077 !...FIND THE MAXIMUM TKE VALUE BETWEEN LLC AND KLCL... AND USE IT TO
2082 TKEMAX=AMAX1(TKEMAX,TKE0(KK))
2084 TKEMAX=AMIN1(TKEMAX,10.)
2085 TKEMAX=AMAX1(TKEMAX,1.0)
2086 DSOURCE=Z0(K)-Z0(LLC)+0.5*(DZQ(K)+DZQ(LLC))
2087 TIMECS=DSOURCE/WPBLTP*45.0
2088 AINC2=TKEMAX*DPTHMX1*DXSQ/(VMFLCL*G*TIMECS)
2090 IF( i == 1 .AND. j == 1 ) write(808,'(i7,f10.3, 2i4)') ktau, xtime/60.,LLC, KLCL
2091 IF( i == 1 .AND. j == 1 ) write(809,'(i7,4f10.3)') ktau, xtime/60.,TKEMAX, &
2094 !&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
2095 ! BEGINING OF CLOSURE ASSUMPTION SELECTIONS
2096 !&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
2098 IF(CAPEI(I,J) .LT. 100.0) THEN ! averaging KF number of clouds
2099 NT = NINT(15.0*60.0/(0.5*DT))-1 ! for 15 min.
2108 !...DETERMINE OMEGA VALUE NECESSARY AT TOP AND BOTTOM OF EACH LAYER TO
2109 !...SATISFY MASS CONTINUITY...
2113 DOMGDP(NK)=-(UER(NK)-DER(NK)-UDR(NK)-DDR(NK))*EMSD(NK)
2115 OMG(NK)=OMG(NK-1)-DP(NK-1)*DOMGDP(NK-1)
2116 DTT1 = 0.75*DP(NK-1)/(ABS(OMG(NK))+1.E-10)
2122 ! KFLAG=2: CLOUD TOP LOWER THAN LFC
2123 ! KFLAG=3: CLOUD TOP HIGHER THAN LFC BUT LOWER THAN 4 KM
2124 ! KFLAG=4: CLOUD TOP HIGHER THAN 4 KM
2126 IF(KFLAG .EQ. 2) GO TO 176
2128 IF((CLDDPTH+ZLCL) .LE. ZLFC) THEN
2141 NSTEP=NINT(TIMEC/DTT+1)
2142 DTIME=TIMEC/FLOAT(NSTEP)
2143 FXM(NK)=OMG(NK)*DXSQ/G
2145 wsubsub(nk)=-omg(nk)/rhoe(nk)/g
2149 loop495: DO NTC=1,NSTEP
2151 !...ASSIGN THETA AND Q VALUES AT THE TOP AND BOTTOM OF EACH LAYER BASED ON THE
2152 !...SIGN OF OMEGA...
2167 ! THIS PART IS ALSO MODIFIED TO INCLUDE THE SUBSIDANCE EFFECT
2168 ! ON DEAD CLOUD. THE FLUXES INTO THE LAYER ARE MODIFIED
2169 ! TO CONSIDER THE EFFECT ON QC,THETA,QV, GD ID ADIABATIC LAPSE
2170 ! RATE AND GM IS MOIST ADIABATIC LAPSE RATE
2172 IF(OMG(NK).LE.0.)THEN
2173 THFXIN(NK)=-FXM(NK)*THPA(NK-1)
2174 QFXIN(NK)=-FXM(NK)*QPA(NK-1)
2175 QCFXIN(NK)=-FXM(NK)*QCPA(NK-1)
2176 DCAFXIN(NK) = -FXM(NK)*DCA(NK-1)
2177 THFXOUT(NK-1)=THFXOUT(NK-1)+THFXIN(NK)
2178 QFXOUT(NK-1)=QFXOUT(NK-1)+QFXIN(NK)
2179 QCFXOUT(NK-1)=QCFXOUT(NK-1)+QCFXIN(NK)
2180 DCAFXOUT(NK-1)=DCAFXOUT(NK-1)+DCAFXIN(NK)
2183 CPM=CP*(1.+0.887*Q0(NK))
2184 IF(T0(NK) .GT. TO) THEN
2186 DQSSDT=QES(NK)*SVP2*(SVPT0-SVP3) &
2187 /((T0(NK)-SVP3)*(T0(NK)-SVP3))
2190 DQSSDT=QES(NK)*6.15E3/(T0(NK)*T0(NK))
2192 GM=GD/(1.0+RL/CPM*DQSSDT)
2193 DTEMPDT=(GD-GM)*OMG(NK)/RHOE(NK)/G
2194 IF((QCPA(NK)-DTEMPDT*CP/RL*DTIME) .LE. 0.0) &
2195 DTEMPDT=QCPA(NK)/(CP/RL*DTIME)
2196 DTHETADT=DTEMPDT*(P00/P0(NK))**(0.2854*(1.-0.28*Q0(NK)))
2197 THFXOUT(NK)=FXM(NK)*(THPA(NK)-DTHETADT*DTIME)
2198 QFXOUT(NK)=FXM(NK)*(QPA(NK) +DTEMPDT*CP/RL*DTIME)
2199 QCFXOUT(NK)=FXM(NK)*(QCPA(NK)-DTEMPDT*CP/RL*DTIME)
2200 DCAFXOUT(NK)=FXM(NK)*DCA(NK)
2201 THFXIN(NK-1)=THFXIN(NK-1)+THFXOUT(NK)
2202 QFXIN(NK-1)=QFXIN(NK-1)+QFXOUT(NK)
2203 QCFXIN(NK-1)=QCFXIN(NK-1)+QCFXOUT(NK)
2204 DCAFXIN(NK-1)=DCAFXIN(NK-1)+DCAFXOUT(NK)
2208 !...UPDATE THE THETA AND QV VALUES AT EACH LEVEL...
2211 IF( NK .GT. KKPBL .OR. NK .LT. LLC) THEN
2212 THPA(NK)=THPA(NK)+ &
2213 (THFXIN(NK)+UDR(NK)*THTAU(NK)+DDR(NK)*THTAD(NK)- &
2214 THFXOUT(NK)-(UER(NK)-DER(NK))*THTA0(NK))*DTIME*EMSD(NK)
2216 (QFXIN(NK)+UDR(NK)*QDT(NK)+DDR(NK)*QD(NK) &
2217 -QFXOUT(NK)-(UER(NK)-DER(NK))*Q0(NK))*DTIME*EMSD(NK)
2219 THPA(NK)=THPA(NK)+ &
2220 (THFXIN(NK)+UDR(NK)*THTAU(NK)+DDR(NK)*THTAD(NK)- &
2221 THFXOUT(NK)-UER(NK)*THMIX+DER(NK)*THTA0(NK))* &
2224 (QFXIN(NK)+UDR(NK)*QDT(NK)+DDR(NK)*QD(NK) &
2225 -QFXOUT(NK)-UER(NK)*QMIX+DER(NK)*Q0(NK))* &
2228 QCPA(NK)=QCPA(NK)+ &
2229 (QCFXIN(NK)+DETLQ(NK)+DETIC(NK)-QCFXOUT(NK))*DTIME*EMSD(NK)
2231 ! ADDING DEAD CLOUD AREA DCA WHICH WILL BE USED IN LOOP 320 TO CALCULATED
2232 ! THE TENDENCY DDCADT IN LOOP 320, THE TENDENCY (DQCDCDT) FOR DEAD CLOUD
2233 ! LIQUID WATER CONTENT QCDC IS SOLVE AS A RESIDUAL OF DQLDT-DDCADT
2235 DCA(NK)=DCA(NK)+(DCAFXIN(NK)-DCAFXOUT(NK)+UDR(NK))*DTIME*EMSD(NK)
2246 !...CHECK TO SEE IF MIXING RATIO DIPS BELOW ZERO ANYWHERE; IF SO, BORROW
2247 !...MOISTURE FROM ADJACENT LAYERS TO BRING IT BACK UP ABOVE ZERO; WITH
2248 !...INDEX NK-1, MINIMUM VALUE FOR NK=2...
2251 IF(QQG(NK).LT.0.)THEN
2252 TMA = QQG(NK+1)*EMS(NK+1)
2253 TMB = QQG(NK-1)*EMS(NK-1)
2254 TMM = (QQG(NK)-1.E-9)*EMS(NK )
2255 IF(TMA .NE. 0.0 .AND. TMB .NE. 0.0)THEN
2256 BCOEFF = -TMM/((TMA*TMA)/TMB+TMB)
2257 ACOEFF = BCOEFF*TMA/TMB
2258 ELSE IF(TMA .EQ. 0.0 .AND. TMB .EQ. 0.0) THEN
2261 ELSE IF(TMA .EQ. 0.0) THEN
2264 ELSE IF(TMB .EQ. 0.0) THEN
2268 TMB = TMB*(1.-BCOEFF)
2269 TMA = TMA*(1.-ACOEFF)
2271 QQG(NK+1) = TMA*EMSD(NK+1)
2272 QQG(NK-1) = TMB*EMSD(NK-1)
2275 TOPOMG = (UDR(LTOP)-UER(LTOP))*DP(LTOP)*EMSD(LTOP)
2276 IF(ABS(TOPOMG-OMG(LTOP)).GT. 1.E-3)THEN
2277 IF ( wrf_dm_on_monitor()) THEN
2278 CALL get_wrf_debug_level( dbg_level )
2279 IF( dbg_level >= 10 .AND. i == i0 .AND. j == j0 ) THEN
2280 WRITE(message,*)'ERROR: MASS DOES NOT BALANCE IN KF SCHEME;', &
2281 ' TOPOMG, OMG =',TOPOMG,OMG(LTOP)
2282 CALL wrf_message( message )
2289 !...CONVERT THETA TO T, FREEZE ALL SUPERCOOLED DETRAINED LIQUID WATER BECAUSE
2290 !...SUPERCOOLED WATER NOT ALLOWED IN EXMOIS...FREEZE SUPERCOOLED PRECIP IF
2291 !...FEEDING IT BACK TO EXMOIS...
2294 EXN(NK)=(P00/P0(NK))**(0.2854*(1.-0.28*QQG(NK)))
2295 TG(NK)=THTAG(NK)/EXN(NK)
2296 IF(NK.GT.ML)DTFM(NK)=DETLQ(NK)*RLF*EMSD(NK)/CP
2297 TG(NK)=TG(NK)+DTFM(NK)*timec
2298 TVG(NK)=TG(NK)*(1.+0.608*QQG(NK))
2301 !...ALLOW FROZEN PRECIP TO MELT OVER A LAYER 200mb DEEP IF PRECIP IS NOT FED
2302 !...BACK TO EXMOIS...
2306 loop231: DO K = 1,ML
2311 TG(NK)=TG(NK)+DTMLTE*TIMEC
2313 DTFM(NK)=DTMLTE*(2.E4+DP(NK)-TDP)/DP(NK)
2314 TG(NK)=TG(NK)+DTMLTE*TIMEC*(2.E4+DP(NK)-TDP)/DP(NK)
2319 IF(KFLAG .EQ. 2 .OR. KFLAG .EQ. 3) GO TO 265
2321 ! COMPUTE NEW CLOUD AND CHANGE IN AVAILABLE BUOYANT ENERGY.
2323 !...THE FOLLOWING COMPUTATIONS ARE SIMILAR TO THAT FOR UPDRAFT
2329 ROCPQ=0.2854*(1.-0.28*QQG(NK))
2330 THMIX2=THMIX2+DP(NK)*TG(NK)*(P00/P0(NK))**ROCPQ
2331 QMIX2=QMIX2+DP(NK)*QQG(NK)
2332 PMIX2=PMIX2+DP(NK)*P0(NK)
2334 THMIX2=THMIX2/DPTHMX
2338 ROCPQ=0.2854*(1.-0.28*QMIX2)
2339 TMIX2=THMIX2*(PMIX2/P00)**ROCPQ
2340 ES=1.E3*SVP1*EXP(SVP2*(TMIX2-SVPT0)/(TMIX2-SVP3))
2341 QS=0.622*ES/(PMIX2-ES)
2344 CPM=CP*(1.+0.887*QMIX2)
2345 DQSSDT=QS*SVP2*(SVPT0-SVP3)/((TMIX2-SVP3)*(TMIX2-SVP3))
2346 DQ=(QMIX2-QS)/(1.+RL*DQSSDT/CPM)
2347 TMIX2=TMIX2+RL/CP*DQ
2349 ROCPQ=0.2854*(1.-0.28*QMIX2)
2350 THMIX2=TMIX2*(P00/PMIX2)**ROCPQ
2355 QMIX2=MAX(QMIX2,QMIN)
2356 EMIX2=QMIX2*PMIX2/(0.622+QMIX2)
2357 TLOG=LOG(EMIX2/SVP1/1000.)
2358 TDPT=(SVP2*SVPT0-SVP3*TLOG)/(SVP2-TLOG)
2359 TTLCL=TDPT-(.212+1.571E-3*(TDPT-T00)-4.36E-4*(TMIX2-T00))* &
2361 TTLCL=MIN(TTLCL,TMIX2)
2363 PPLCL=P00*(TTLCL/THMIX2)**CPORQ
2365 TVLCL=TTLCL*(1.+0.608*QMIX2)
2367 loop235: DO NK=LC,KL
2369 IF(PPLCL.GE.P0(NK)) EXIT loop235
2374 DLP=LOG(PPLCL/P0(K))/LOG(P0(KLCL)/P0(K))
2376 !...ESTIMATE ENVIRONMENTAL TEMPERATURE AND MIXING RATIO AT THE LCL...
2378 TENV=TG(K)+(TG(KLCL)-TG(K))*DLP
2379 QENV=QQG(K)+(QQG(KLCL)-QQG(K))*DLP
2380 TVEN=TENV*(1.+0.608*QENV)
2381 TVBAR=0.5*(TVG(K)+TVEN)
2382 ZLCL1=Z0(K)+R*TVBAR*LOG(P0(K)/PPLCL)/G
2383 TVAVG=0.5*(TVEN+TG(KLCL)*(1.+0.608*QQG(KLCL)))
2384 PPLCL=P0(KLCL)*EXP(G/(R*TVAVG)*(Z0(KLCL)-ZLCL1))
2385 THETEU(K)=TMIX2*(1.E5/PMIX2)**(0.2854*(1.-0.28*QMIX2))* &
2386 EXP((3374.6525/TTLCL-2.5403)*QMIX2* &
2388 ES=1.E3*SVP1*EXP(SVP2*(TENV-SVPT0)/(TENV-SVP3))
2389 QESE=0.622*ES/(PPLCL-ES)
2390 THTESG(K)=TENV*(1.E5/PPLCL)**(0.2854*(1.-0.28*QESE))* &
2391 EXP((3374.6525/TENV-2.5403)*QESE*(1.+0.81*QESE))
2393 !...COMPUTE ADJUSTED ABE(ABEG).
2397 THATA = TMIX2*(1.E5/PMIX2)**0.286
2398 THTFC = THATA*EXP((XLV0-XLV1*TTLCL)*QMIX2/(CP*TTLCL))
2401 ES=1.E3*SVP1*EXP(SVP2*(TG(NK1)-SVPT0)/(TG(NK1)-SVP3))
2402 QESE=0.622*ES/(P0(NK1)-ES)
2403 THTESG(NK1)=TG(NK1)*(1.E5/P0(NK1))**(0.2854*(1.-0.28*QESE))* &
2404 EXP((3374.6525/TG(NK1)-2.5403)*QESE*(1.+0.81*QESE))
2410 BE=((2.*THTUDL)/(THTESG(NK1)+THTESG(NK))-1.)*DZZ
2411 IF(BE.GT.0.)ABEG=ABEG+BE*G
2414 !...FIND OUT HOW MUCH CAPE HAS BEEN REMOVED...
2422 IF(NCOUNT .LT. 10) THEN
2426 IF(CLDDPTH .GE. 4.E3) THEN
2429 ELSE IF((CLDDPTH) .LT. 4.E3 .AND. &
2430 CLDDPTH+ZLCL .GT. ZLFC) THEN
2431 C1=CLDDPTH+ZLCL-ZLFC
2433 IF( ABS(C2) < 0.001 ) STOP 901
2437 VAL = VAL + AINCKFSA(I,II,J)
2439 AINC=(AINC+VAL)/FLOAT(NT+1)
2441 AINC3=C3*AINC+(1-C3)*AINC2
2448 DABE=MAX(ABE-ABEG,0.1*ABE)
2449 FABE=ABEG/(ABE+1.E-8)
2450 IF(AINC/AINCMX.GT.0.999 .AND. FABE.GT.1.05-STAB) THEN
2452 IF(CLDDPTH .GE. 4.E3) THEN
2455 ELSE IF((CLDDPTH) .LT. 4.E3 .AND. &
2456 CLDDPTH+ZLCL .GT. ZLFC) THEN
2457 C1=CLDDPTH+ZLCL-ZLFC
2459 IF( ABS(C2) < 0.001 ) STOP 902
2463 VAL = VAL + AINCKFSA(I,II,J)
2465 AINC=(AINC+VAL)/FLOAT(NT+1)
2467 AINC3=C3*AINC+(1-C3)*AINC2
2474 IF(NCOUNT.GT.10)THEN
2476 IF(CLDDPTH .GE. 4.E3) THEN
2479 ELSE IF((CLDDPTH) .LT. 4.E3 .AND. &
2480 CLDDPTH+ZLCL .GT. ZLFC) THEN
2481 C1=CLDDPTH+ZLCL-ZLFC
2483 IF( ABS(C2) < 0.001 ) STOP 903
2487 VAL = VAL + AINCKFSA(I,II,J)
2489 AINC=(AINC+VAL)/FLOAT(NT+1)
2491 AINC3=C3*AINC+(1-C3)*AINC2
2498 IF(FABE.LE.1.05-STAB.AND.FABE.GE.0.95-STAB) THEN
2500 IF(CLDDPTH .GE. 4.E3) THEN
2503 ELSE IF((CLDDPTH) .LT. 4.E3 .AND. &
2504 CLDDPTH+ZLCL .GT. ZLFC) THEN
2505 C1=CLDDPTH+ZLCL-ZLFC
2507 IF( ABS(C2) < 0.001 ) STOP 904
2511 VAL = VAL + AINCKFSA(I,II,J)
2513 AINC=(AINC+VAL)/FLOAT(NT+1)
2515 AINC3=C3*AINC+(1-C3)*AINC2
2522 !...ADJUST MASS FLUX BY THE FACTOR AINC TO CONVERGE TO SPECIFIED DEGREE OF STAB-
2525 IF ( wrf_dm_on_monitor()) THEN
2526 CALL get_wrf_debug_level( dbg_level )
2527 IF( dbg_level >= 10 .AND. i == i0 .AND. j == j0 ) THEN
2528 WRITE(message,1080) LFS,LDB,LDT,TIMEC,NSTEP,NCOUNT,FABE,AINC
2529 1080 FORMAT(2X,'LFS,LDB,LDT =',3I3,' TIMEC, NSTEP=',F5.0,I3, &
2530 'NCOUNT, FABE, AINC=',I2,1X,F5.3,F6.2)
2531 CALL wrf_message(message)
2535 AINC=AINC*STAB*ABE/(DABE+1.E-8)
2539 AINC=MIN(AINCMX,AINC)
2541 AINC=MAX(AINC,AINCMIN)
2546 UMF(NK)=UMF2(NK)*AINC
2547 DMF(NK)=DMF2(NK)*AINC
2548 DETLQ(NK)=DETLQ2(NK)*AINC
2549 DETIC(NK)=DETIC2(NK)*AINC
2550 UDR(NK)=UDR2(NK)*AINC
2551 UER(NK)=UER2(NK)*AINC
2552 DER(NK)=DER2(NK)*AINC
2553 DDR(NK)=DDR2(NK)*AINC
2558 !...IF THE DOWNDRAFT OVERDRAWS THE INITIAL MASS AVAILABLE AT THE LFS, ALLOW
2559 !...PEFF TO CHANGE SO THAT DOWNDRAFT MASS FLUX IS NOT THE LIMITING FACTOR
2560 !...IN THE TOTAL CONVECTIVE MASS FLUX. THIS IS USUALLY NECESSARY ONLY WHEN
2561 !...THE DOWNDRAFT IS VERY SHALLOW...
2563 DMFMIN=UER(LFS)-EMS(LFS)/TIMEC
2564 IF(DER(LFS).LT.DMFMIN .AND. DMFMIN.LT.0.)THEN
2567 DER2(NK)=DER2(NK)*RF
2568 DDR2(NK)=DDR2(NK)*RF
2569 DMF2(NK)=DMF2(NK)*RF
2570 DER(NK)=DER2(NK)*AINC
2571 DDR(NK)=DDR2(NK)*AINC
2572 DMF(NK)=DMF2(NK)*AINC
2577 UPDIN2=1.-(1.-EQFRC(LFS))*DMF(LFS)*UPDINC/UMF(LFS)
2581 CPR=TRPPT+PPR*(UPDIN2-1.)
2582 PEFF=1.-(TDER+(1.-EQFRC(LFS))*DMF(LFS)*(RLIQ(LFS)+RICE(LFS)))/ &
2586 F1=UPDIN2/(AINC*UPDINC)
2589 UMF(NK)=UMF2(NK)*AINC
2591 UDR(NK)=UDR2(NK)*AINC
2593 UER(NK)=UER2(NK)*AINC
2594 DETLQ2(NK)=DETLQ(NK)*F1
2595 DETLQ(NK)=DETLQ2(NK)*AINC
2596 DETIC2(NK)=DETIC(NK)*F1
2597 DETIC(NK)=DETIC2(NK)*AINC
2598 PPTML2=PPTML2-PPTICE(NK)*(1.-UPDIN2/UPDINC)
2599 PPTLIQ(NK)=PPTLIQ(NK)*F1*AINC
2600 PPTICE(NK)=PPTICE(NK)*F1*AINC
2612 CLDUA(K)= AINC*AU0/DXSQ ! updraft fraction
2616 ! IF ( wrf_dm_on_monitor()) THEN
2617 ! CALL get_wrf_debug_level( dbg_level )
2618 ! IF( dbg_level >= 10 .AND. i == i0 .AND. j == j0 ) THEN
2619 ! WRITE(message,1080)LFS,LDB,LDT,TIMEC,NSTEP,NCOUNT,FABE,AINC
2620 ! CALL wrf_message(message)
2624 !...SEND FINAL PARAMETERIZED VALUES TO OUTPUT FILES...
2626 ! IF ( wrf_dm_on_monitor()) THEN
2627 ! CALL get_wrf_debug_level( dbg_level )
2628 ! IF( dbg_level >= 10 .AND. i == i0 .AND. j == j0 ) THEN
2629 ! WRITE(message,3071)EQFRC(LFS),UPDINC
2630 ! CALL wrf_message(message)
2631 !3071 FORMAT('EQFRC(LFS) =',F7.4,'UPDINC =',F8.4)
2632 ! WRITE(message,969)
2633 ! CALL wrf_message(message)
2634 !969 FORMAT(1x,' P ',' DP ',' DT K/D ', &
2635 ! ' DR K/D ',' OMG ', &
2636 ! ' DOMGDP ',' UMF ',' UER ',' UDR ',' DMF ',' DER ' &
2637 ! ,' DDR ',' EMS ',' W0 ',' DETLQ ',' DETIC')
2643 DTT=(TG(K)-T0(K))*86400./TIMEC
2645 DR=-(QQG(K)-Q0(K))*RL*86400./(TIMEC*CP)
2646 UDFRC=UDR(K)*TIMEC*EMSD(K)
2647 UEFRC=UER(K)*TIMEC*EMSD(K)
2648 DDFRC=DDR(K)*TIMEC*EMSD(K)
2649 DEFRC=-DER(K)*TIMEC*EMSD(K)
2651 ! IF ( wrf_dm_on_monitor()) THEN
2652 ! CALL get_wrf_debug_level( dbg_level )
2653 ! IF( dbg_level >= 10 .AND. i == i0 .AND. j == j0 ) THEN
2654 ! WRITE(message,'(F8.2,3(F8.2),2(F8.3),F8.2,2F8.3,F8.2,6F7.3)') &
2655 ! P0(K)/100.,DP(K)/100.,DTT,DR,OMG(K),DOMGDP(K)*1.E4, &
2656 ! UMF(K)/1.E6,UEFRC,UDFRC,DMF(K)/1.E6,DEFRC,DDFRC,EMS(K)/1.E11, &
2657 ! W0AVG0(K)*1.E2,DETLQ(K)*TIMEC*EMSD(K)*1.E3,DETIC(K)* &
2658 ! TIMEC*EMSD(K)*1.E3
2659 ! CALL wrf_message(message)
2668 tt7(k)=OMG(k)/G*DXSQ*Q0(k)
2670 CLDBMFLX(I,J)=UMF(KCBASE)/1.0E+6
2673 ! IF ( wrf_dm_on_monitor()) THEN
2674 ! CALL get_wrf_debug_level( dbg_level )
2675 ! IF( dbg_level >= 10 .AND. i == i0 .AND. j == j0 ) THEN
2676 ! WRITE(message,'(A3,15A7,2A8)') &
2677 ! 'K','P','Z','T0','TG','DT','TU','TD','Q0','QQG', &
2678 ! 'DQ','QU','QD','QCG','WU','WD','RH0','RHG'
2679 ! CALL wrf_message(message)
2687 IF(K.LT.LC .OR. K.GT.LTOP)TUC=0.
2689 IF((K.LT.LDB .OR. K.GT.LDT) .AND. K.NE.LFS)TDC=0.
2690 ES=1.E3*SVP1*EXP(SVP2*(TG(K)-SVPT0)/(TG(K)-SVP3))
2691 QGS=ES*0.622/(P0(K)-ES)
2695 ! IF ( wrf_dm_on_monitor()) THEN
2696 ! CALL get_wrf_debug_level( dbg_level )
2697 ! IF( dbg_level >= 10 .AND. i == i0 .AND. j == j0 ) THEN
2698 ! WRITE(message,'(I3,F7.2,F7.0,10F7.2,F7.3,2F7.2,2F8.3)') &
2699 ! K,P0(K)/100.,Z0(K),T0(K)-T00,TG(K)-T00,DTT,TUC, &
2700 ! TDC,Q0(K)*1000.,QQG(K)*1000.,(QQG(K)-Q0(K))*1000.,QU(K)* &
2701 ! 1000.,QD(K)*1000.,QCG(K)*1000.,WU(K),WD(K),RH_0,RHG
2702 ! CALL wrf_message(message)
2708 !...IF CALCULATIONS ABOVE SHOW AN ERROR IN THE MASS BUDGET, PRINT OUT A SOUNDING
2709 !...TO BE USED LATER FOR DIAGNOSTIC PURPOSES, THEN ABORT RUN...
2712 IF ( wrf_dm_on_monitor()) THEN
2713 CALL get_wrf_debug_level( dbg_level )
2714 IF( dbg_level >= 10 .AND. i == i0 .AND. j == j0 ) THEN
2716 WRITE(message,'(2X,F6.0,2X,F7.2,2X,F5.1,2X,F6.3,2(2X,F5.1),2X,F7.2,2X,F7.4)') &
2717 Z0(K),P0(K)/100.,T0(K)-273.16,Q0(K)*1000., &
2718 U0(K),V0(K),DP(K)/100.,W0AVG0(K)
2719 CALL wrf_message(message)
2725 CNDTNF=(1.-EQFRC(LFS))*(RLIQ(LFS)+RICE(LFS))*DMF(LFS)
2727 ! IF ( wrf_dm_on_monitor()) THEN
2728 ! CALL get_wrf_debug_level( dbg_level )
2729 ! IF( dbg_level >= 10 .AND. i == i0 .AND. j == j0 ) THEN
2730 ! WRITE(message,1095)CPR*AINC,TDER+PPTFLX+CNDTNF
2731 !1095 FORMAT(' ',' PPT PRODUCTION RATE= ',F10.0,' TOTAL EVAP+PPT= ',F10.0)
2732 ! CALL wrf_message(message)
2736 ! EVALUATE MOISTURE BUDGET...
2742 QINIT=QINIT+Q0(NK)*EMS(NK)
2743 QFNL=QFNL+(QQG(NK)+QCG(NK))*DP(NK)*DXSQ/G
2744 QCFINL=QCFINL+QCG(NK)*DP(NK)*DXSQ/G
2746 QFNL=QFNL+PPTFLX*TIMEC
2747 ERR2=(QFNL-QINIT)*100./QINIT
2748 RELERR=ERR2*QINIT/(PPTFLX*TIMEC+1.E-10)
2750 IF ( wrf_dm_on_monitor()) THEN
2751 CALL get_wrf_debug_level( dbg_level )
2752 IF( dbg_level >= 10 .AND. i == i0 .AND. j == j0 ) THEN
2753 WRITE(message,*)'QFNL-QINIT, QCFINL =',QFNL-QINIT,QCFINL
2754 CALL wrf_message(message)
2755 WRITE(message,1110)QINIT,QFNL,ERR2
2756 CALL wrf_message(message)
2757 WRITE(message,1200)RELERR
2758 CALL wrf_message(message)
2759 1110 FORMAT(' ','INITIAL WATER =',E12.5,' FINAL WATER =',E12.5, &
2760 ' TOTAL WATER CHANGE =',F8.2,'%')
2761 1200 FORMAT(' ','MOISTURE ERROR AS FUNCTION OF TOTAL PPT =',F9.3,'%')
2762 ! WRITE(message,*)'TDER, CPR, USR, TRPPT =',TDER,CPR*AINC,USR*AINC,TRPPT*AINC
2763 ! CALL wrf_message(message)
2767 !...IF THE ADVECTIVE TIME PERIOD (TADVEC) IS LESS THAN SPECIFIED MINIMUM FOR
2768 !...TIMEC, ALLOW FEEDBACK TO OCCUR ONLY DURING TADVEC...
2770 IF(TADVEC.LT.TIMEC)NIC=NINT(TADVEC/(0.5*DT2))
2772 !...CALCULATE CONVECTIVE TENDENCIES...
2774 loop320: DO K = KX,1,-1
2775 DTDT(K) = (TG(K)-T0(K))/TIMEC
2776 DQDT(K) = (QQG(K)-Q0(K))/TIMEC
2777 DQLDT(K)= (QCG(K)-QC0(K))/TIMEC
2778 DQRDT(K)= 0.0 ! set this to zero for now, unlike kfpara (don't remember why yet)
2779 DDCADT(K)=(DCA(K)-DCA0(K))/TIMEC
2780 IF(DQLDT(K) .LE. 1.0E-17 &
2781 .OR. RH0(K) .GT. RHCRIT) DDCADT(K)=0.0
2782 AREA=AMAX1((CLDAREAB(I,K,J)+DDCADT(K)*DT),0.0)
2783 IF(AREA .LE. 1.0E-17 &
2784 .OR. (DQLDT(K) .LE. 1.0E-17) &
2785 .OR. RH0(K) .GT. RHCRIT) THEN
2788 DQCDCDT(K)=(DQLDT(K)-CLDLIQB(I,K,J)*DDCADT(K))/AREA
2792 CLDATEN0(K)=DDCADT(K)
2793 CLDLCTN0(K)=DQCDCDT(K)
2794 tt4(k) = RLIQ(K)+RICE(K)
2799 ! CALCULATE THE CONVECTIVE RAINFALL
2801 RAINSHV(I,J)=.5*DT2*PPTFLX/DXSQ
2803 IF ( wrf_dm_on_monitor()) THEN
2804 CALL get_wrf_debug_level( dbg_level )
2805 IF( dbg_level >= 10 .AND. i == i0 .AND. j == j0 ) THEN
2806 WRITE(message,909) RAINSHV(I,J)*NIC
2807 909 FORMAT(' CONVECTIVE RAINFALL =',F8.4,' CM')
2808 CALL wrf_message(message)
2812 !...FEED BACK CONVECTIVE TENDENCIES TO RESOLVABLE SCALE EXCEPT THAT QC IS NOT
2813 ! FED BACK TO THE GRID SCALE WHEN THE GRID IS SUB-SATURATED. INSTEAD, IT
2814 ! IS DETRAINED TO FORM NBC. DCATEN(I,K): NBC AREA TENDENCY.
2815 ! QCDCTEN(I,K): NBC LIQUID/ICE WATER CONTENT.
2818 TTEN(K)=TTEN(K)+ DTDT(K)
2819 QVTEN(K)=QVTEN(K)+ DQDT(K)
2820 QRTEN(K)=QRTEN(K)+DQRDT(K)
2821 IF(RH0(K) .GT. RHCRIT) THEN
2822 QCTEN(K)=QCTEN(K)+DQLDT(K)
2824 DCATEN(K)=DCATEN(K)+DDCADT(K)
2825 QCDCTEN(K)=QCDCTEN(K)+DQCDCDT(K)
2830 ! raincn(i,j) is in cm. We can convert it to KG/m^2 in following way:
2832 ! 1cm=1cm*1g/cm^3=1g/cm^2=10^-3Kg/10^-4m^2=10Kg/m^2
2834 RAINSH(I,J) = RAINSH(I,J)+RAINSHV(I,J)
2840 PLFSG(I,J) = P0(LFS)
2841 TLFSG(I,J) = TU(LFS)
2842 PLDTG(I,J) = P0(LDT)
2843 TLDTG(I,J) = TLCL*(PLDTG(I,J)/PLCL)**ROVCP
2844 PLDBG(I,J) = P0(LDB)
2845 TLDBG(I,J) = TLCL*(PLDBG(I,J)/PLCL)**ROVCP
2846 PLLCG(I,J) = P0(LLC)
2847 TLLCG(I,J) = TU(LLC)
2849 nca_ctr2(i,j)=nca_ctr2(i,j)+1
2856 nca_ctr4(i,j)=nca_ctr4(i,j)+1
2862 IF( i == 1 .AND. j == 1 ) THEN
2863 write(32,*) xtime/60.,ZLCL
2864 write(33,*) xtime/60.,CLDDPTH+zlcl
2865 write(34,*) xtime/60.0,zlfc
2866 ! CALL MAXIM(wutemp,KX,KLCL+1,KX,KVAL1)
2867 ! CALL MINIM(wsubsub,KX,KLCL+1,KX,KVAL2)
2868 ! write(82,*) xtime/60.0,wutemp(kval1),wsubsub(kval2)
2869 write(63,*) xtime/60.,CLDBMFLX(I,J)
2870 write(98,*) xtime/60.,tt6(KCBASE),tt7(KCBASE)
2874 ! FIND NBC TOP (KDCT), NBC BASE (KDCB), LOCATION OF MAXIMUM NBC AREA
2875 ! (KAMAX) AND MAXIMUM CLD LIQUID WATER CONTENT (KLCMAX), AND THE
2876 ! LOCATION 1000M AWAY FROM KAMAX (K1000)
2881 loop429: DO K=KL-1,2,-1
2882 IF(CLDAREAB(I,K,J) .GT. 0.001 .OR. RH0(K) .GT. RHCRIT) THEN
2888 loop441: DO K=2,KL-1 ! UPWARD
2889 IF(CLDAREAB(I,K,J) .GT. 0.001 .OR. RH0(K) .GT. RHCRIT ) THEN
2896 DCLDTOP(I,J)=Z0(KDCT)
2897 DCLDBASE(I,J)=Z0(KDCB)
2902 IF(AINC .NE. 999.0) THEN
2909 IF( i == 1 .AND. j == 1 ) THEN
2910 write(93,*) xtime/60.,DCLDTOP(I,J)
2911 write(94,*) xtime/60.,DCLDBASE(I,J)
2912 IF(AINC .NE. 999.0) THEN
2913 write(19,*) xtime/60.,RAD
2914 write(25,*) xtime/60.,NUPDRAFT
2917 write(19,*) xtime/60.,VAL
2918 write(25,*) xtime/60.,VAL
2923 IF(KDCT .LE. 1) THEN
2925 nca_ctr3(i,j)=nca_ctr3(i,j)+1
2927 GOTO 345 ! END OF DISSIPATION CALCULATION
2933 IF( CLDAREAB(I,K,J) .GT. CLDAREAB(I,KAMAX,J) ) KAMAX = K
2934 IF( CLDLIQB(I,K,J) .GT. CLDLIQB(I,KLCMAX,J) ) KLCMAX = K
2937 loop430: DO K=KAMAX,1,-1
2938 IF(Z0(KAMAX)-Z0(K) .GE. 1000.0) THEN
2944 K1000=MAX(K1000,KDCB)
2946 ! WHEN THE GRID IS SATURATED, CONVERT NBC TO RESOLVABLE-SCALE CLOUD
2949 IF(RH0(K) .GT. RHCRIT) THEN
2950 CLQ=AMAX1(CLDLIQB(I,K,J)+QCDCTEN(K)*DT,0.0)
2951 AREA=AMAX1(CLDAREAB(I,K,J)+DCATEN(K)*DT,0.0)
2952 QCDCTEN(K)=QCDCTEN(K)-CLQ/DT
2953 DCATEN(K)=DCATEN(K)-AREA/DT
2954 QCTEN(K)=QCTEN(K)+AREA*CLQ/DT
2957 !&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
2958 ! BEGINING OF DISSIPATION CACULATION
2960 !&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
2962 ! EVAPORATION OF NBC AT THE CLOUD EDGE *******************************
2965 IF ( wrf_dm_on_monitor()) THEN
2966 CALL get_wrf_debug_level( dbg_level )
2967 IF( dbg_level >= 10 .AND. i == i0 .AND. j == j0 ) THEN
2968 if( mod(ktau,KTAU1HUR) .eq. 0 ) then
2969 write(*, *) ' ------- a evaporation'
2977 RLC=AMAX1(CLDLIQB(I,K,J)+QCDCTEN(K)*DT,0.0)
2980 E2=(0.01+CLDAREAB(I,K,J))*DIFFK*VAL*SQRT(NUPDRAFT)
2981 IF(RLC .LE. 1.0E-17) CYCLE loop332
2982 EOVLC=AMIN1(E2/RLC,CLDAREAB(I,K,J)/DT)
2983 DCATEN(K)=DCATEN(K)-EOVLC
2987 QVTEN(K)=QVTEN(K)+EOVLC*RLC
2988 IF(T0(K) .LE. TO) THEN
2993 RCP=CP*(1.+0.887*Q0(K))
2995 TTEN(K)=TTEN(K)-EOVLC*RLC*RLOVCP
2998 ! VERTICAL DIFFUSION OF NBC LIQUID/ICE WATER CONTENT **********************
3000 ! CALCULAT KH (VERTICAL DIFF COEF ) AND KR ( RADIATIVE INDUCED VERTICAL
3001 ! DIFF COEF). KR IS CALCULATED AT KAMAX+1 (FULL LAYER AT CLOUD TOP), THEN
3002 ! CONSTANT UNTIL CLOUD TOP. IT LINEARLY DROPS TO ZERO AT K1000, WHICH IS
3003 ! THE LARGER ONE OF KDCB AND K1000.
3005 DO K=KDCB,KDCT+1 ! UPWARD
3010 tlong(k)=TEN_RADL0(K)
3011 tshort(k)=TEN_RADS0(K)
3015 CALL MINIM(tlong, KX,KDCB,KDCT,KRADLMAX)
3016 CALL MAXIM(tshort,KX,KDCB,KDCT,KRADSMAX)
3018 KR(KP1)=BBLS0(K)*BBLS0(K)/(T0(K)*(P00/P0(K))**ROCPQ) &
3019 *(ABS(TEN_RADL0(KRADLMAX))*DZQ(K)/15.0 &
3020 +ABS(TEN_RADS0(KRADSMAX))*DZQ(K)/50.0)
3023 IF(KDCT+1 .NE. K1000) KR(K)=KR(KAMAX+1)*(FLOAT(K-K1000) &
3024 /FLOAT(KAMAX+1-K1000))
3030 ! CALCULATE IN-CLOUD DIFF FLUXES ASSOCIATED WITH KV and KR. MAKE SURE
3031 ! THAT UPWARD FLUXES AT CLOUD TOP(KDCT+1) VANISH, SO THAT THERE IS NO
3032 ! LIQUID DIFFUSE UPWARD
3047 IF(K .EQ. KDCB) THEN
3052 AREA1=AMAX1(CLDAREAB(I,K,J)+DCATEN(K)*DT,0.0)
3053 AREA2=AMAX1(CLDAREAB(I,K-1,J)+DCATEN(K-1)*DT,0.0)
3054 CLQ1=AMAX1(CLDLIQB(I,K,J)+QCDCTEN(K)*DT,0.0)
3055 CLQ2=AMAX1(CLDLIQB(I,K-1,J)+QCDCTEN(K-1)*DT,0.0)
3056 LFLUX1(K)=-RHOE(K)*KV(K)*(AREA1*CLQ1-AREA2*CLQ2)/C1
3057 LFLUX2(K)=RHOE(K)*KR(K)*(AREA1*CLQ1-AREA2*CLQ2)/C1
3058 LFLUX1(K)=AMIN1(LFLUX1(K),0.0)
3059 LFLUX2(K)=AMIN1(LFLUX2(K),0.0)
3060 LFLUX(K)=LFLUX1(K)+LFLUX2(K)
3061 ! 0.05 IS USED HERE TO
3062 ! MAKE SURE THAT NOT MORE THAN 5% OF THE TOTAL LIQUID MASS AT THIS LAYER
3063 ! IS REMOVED BY IN-CLOUD MIXING IN A SINGLE TIME STEP.
3064 C1=LFLUX(K+1)-CLQ1*DP(K)/(G*DT)*0.05
3065 LFLUX(K)=AMAX1(LFLUX(K),C1)
3068 IF(RH0(K) .GT. RHCRIT .OR. &
3069 (CLDAREAB(I,K,J)+DCATEN(K)*DT) .LE. 1.0e-6) then
3075 ! CALCULATE DIFF TENDENCY ASSOCIATED WITH IN-CLOUD FLUXES CALCULATED ABOVE.
3076 ! FLUXES AT CLD BASE (KDCB) CARRY LIQUID TO THE LAYER BELOW THE CLD BASE
3077 ! AND EVAPORATE IN THAT LAYER
3080 IF ( wrf_dm_on_monitor()) THEN
3081 CALL get_wrf_debug_level( dbg_level )
3082 IF( dbg_level >= 10 .AND. i == i0 .AND. j == j0 ) THEN
3083 if( mod(ktau,KTAU1HUR) .eq. 0 ) then
3084 write(*, *) ' --- lc in-cloud mixing'
3090 ! THIS IS TO ENSURE THAT THE LAYER BELOW THE CLOUD BASE (KDCB-1) DOES
3091 ! NOT REACH SATURATION ONLY BECAUSE OF MIXING (USE 95% HERE). ADJUST
3092 ! LFLUX(KDCB) SO THAT THE AMOUNT OF MASS TRANPORTED TO THIS LAYER IS
3093 ! LESS THAN THE AMOUNT OF MASS NEEDED TO RAISE THE RH TO 95%.
3096 IF(Q0(KDCB-1)/QES(KDCB-1) .GT. RHCR) THEN
3099 VAL1=-G*(LFLUX(KDCB)-LFLUX(KDCB-1))/DP(KDCB-1)
3100 VAL2=(RHCR*QES(KDCB-1)-Q0(KDCB-1))/DT
3101 VAL=AMIN1(VAL1,VAL2)
3102 LFLUX(KDCB)=-VAL*DP(KDCB-1)/G
3105 loop436: DO K = KDCT, KDCB, -1
3106 AREA=AMAX1(CLDAREAB(I,K,J)+DCATEN(K)*DT,0.0)
3107 IF( RH0(K) .GT. RHCRIT .OR. AREA .LE. 1.0e-6 ) CYCLE loop436
3108 QCDCTEN(K)=QCDCTEN(K)-G*(LFLUX(K+1)-LFLUX(K))/DP(K)/AREA
3110 cldlctn1(k)=-G*(LFLUX(K+1)-LFLUX(K))/DP(K)/AREA
3115 IF(T0(K) .LE. TO) THEN
3120 RCP=CP*(1.+0.887*Q0(K))
3122 QVTEN(K)=QVTEN(K)-G*(LFLUX(K+1)-LFLUX(K))/DP(K)
3123 TTEN(K)=TTEN(K)+G*(LFLUX(K+1)-LFLUX(K))/DP(K)*RLOVCP
3125 ! CALCULATE DIFF TENDENCY ASSOCIATED WITH DOWNWARD FLUXES AT
3126 ! EXPOSED CLD BASE IF CLD AREA INCREASE WITH HEIGHT. THIS FLUXE WILL
3127 ! CAUSE LIQUID DECREASE IN THE CLD LAYER AND WATER VAPOR INCREASE IN THE
3128 ! LAYER BELOW THE EXPOSED CLD BASE DUE TO EVAPORATION
3131 IF ( wrf_dm_on_monitor()) THEN
3132 CALL get_wrf_debug_level( dbg_level )
3133 IF( dbg_level >= 10 .AND. i == i0 .AND. j == j0 ) THEN
3134 if(mod(ktau,KTAU1HUR) .eq. 0) then
3135 write(*, *) ' ----lc exp-cld-base mixing'
3141 loop440: DO K=KDCT,KDCB+1,-1
3142 AREADIFF=CLDAREAB(I,K,J)-CLDAREAB(I,K-1,J)
3143 AREADIFF=AMAX1(AREADIFF,0.0)
3144 CLQ=AMAX1(CLDLIQB(I,K,J)+QCDCTEN(K)*DT,0.0)
3145 C1=-CLQ*DP(K)/(G*DT)*0.05 ! limit of flux that remove 5% of
3146 ! all the liquid in the layer above
3147 FX1=-RHOE(K)*KV(K)*CLDLIQB(I,K,J)/15.*AREADIFF
3148 FX2=-RHOE(K)*KR(K)*CLDLIQB(I,K,J)/15.*AREADIFF
3152 IF((CLDAREAB(I,K,J)+DCATEN(K)*DT) .LE. 1.0E-6) CYCLE loop440
3154 IF(RH0(K) .GT. RHCRIT) CYCLE loop440
3156 ! THIS IS TO ENSURE THAT THE LAYER BELOW THE EXPOSED CLOUD BASE (K-1) DOES
3157 ! NOT REACH SATURATION ONLY BECAUSE OF MIXING (USE 95% HERE). ADJUST
3158 ! LFLUX(KDCB) SO THAT THE AMOUNT OF MASS TRANPORTED TO THIS LAYER IS
3159 ! LESS THAN THE AMOUNT OF MASS NEEDED TO RAISE THE RH TO 95%.
3162 IF(Q0(K-1)/QES(K-1) .GT. RHCR) THEN
3166 VAL2=(RHCR*QES(K-1)-Q0(K-1))/DT
3167 VAL=AMIN1(VAL1,VAL2)
3171 AREA=AMAX1(CLDAREAB(I,K,J)+DCATEN(K)*DT,0.0)
3172 IF(AREA .LE. 1.0E-6) CYCLE loop440 ! this line was not in MM5
3173 QCDCTEN(K)=QCDCTEN(K)+G*FX/DP(K)/AREA
3175 cldlctn2(k)=G*FX/DP(K)/AREA
3177 IF(T0(K-1) .LE. TO) THEN
3180 RL=XLV0-XLV1*T0(K-1)
3182 RCP=CP*(1.+0.887*Q0(K-1))
3184 QVTEN(K-1)=QVTEN(K-1)-G*FX/DP(K-1)
3185 TTEN(K-1)=TTEN(K-1)+G*FX/DP(K-1)*RLOVCP
3188 ! CLOUD TOP ENTRAINMENT INSTABILITY (CTEI) ********************************
3189 ! RANDALL (JAS 1980), DEARDOFF (JAS 1980) AND DEL GENIO (J. CLIMATE 1996)
3194 IF(RH0(KDCT) .GT. RHCRIT) GOTO 340
3198 IF(KDCT .LE. 0) GOTO 340
3199 IF(T0(KDCT) .GE. TO) THEN
3200 HIN=CP*T0(KDCT)+G*Z0(KDCT)+XLV*QES(KDCT)
3202 HIN=CP*T0(KDCT)+G*Z0(KDCT)+XLS*QES(KDCT)
3204 IF(T0(KDCT+1) .GE. TO) THEN
3205 HOUT=CP*T0(KDCT+1)+G*Z0(KDCT+1)+XLV*Q0(KDCT+1)
3207 HOUT=CP*T0(KDCT+1)+G*Z0(KDCT+1)+XLS*Q0(KDCT+1)
3210 QIN=QES(KDCT)+CLDLIQB(I,KDCT,J)
3213 RATIO=DELTH/(XLV*DELTQ+1.E-8)
3214 RKAPA=CP*0.5*(T0(KDCT)+T0(KDCT+1))/XLV
3216 IF(T0(KDCT) .GT. TO) THEN
3217 DQSSDT=QES(KDCT)*SVP2*(SVPT0-SVP3) &
3218 /((T0(KDCT)-SVP3)*(T0(KDCT)-SVP3))
3219 RL=XLV0-XLV1*T0(KDCT)
3221 DQSSDT=QES(KDCT)*6.15E3/(T0(KDCT)*T0(KDCT))
3224 RCP=CP*(1.+0.887*Q0(KDCT))
3228 BEITA=(1+(1+DELTA)*GAMA*RKAPA)/(1+GAMA)
3229 RATIOMIN=RKAPA/BEITA
3230 RATIOMAX=(1+GAMA)*(1+(1-DELTA)*RKAPA) &
3231 /(2+(1+(1+DELTA)*RKAPA)*GAMA)
3233 IF(RATIO .LE. RATIOMIN) THEN
3236 ELSE IF(RATIO .GE. RATIOMAX) THEN
3239 SIGMMA=EFOLD*((RATIO-RATIOMIN)/(RATIOMAX-RATIOMIN))**EX
3243 IF ( wrf_dm_on_monitor()) THEN
3244 CALL get_wrf_debug_level( dbg_level )
3245 IF( dbg_level >= 10 .AND. i == i0 .AND. j == j0 ) THEN
3246 if( mod(ktau,KTAU1HUR) .eq. 0 ) then
3247 write(* ,*) ' -------- lc CTEI '
3253 ! LOCATE K WHERE ITS DISTANCE FROM KDCT IS 100M
3256 loop335: DO L=KDCT-1,KDCB,-1
3257 IF((Z0(KDCT)+0.5*DZQ(KDCT))-(Z0(L)-0.5*DZQ(L)) .GE. DEPTHMAX) THEN
3265 IF(RH0(KDCT+1) .GT. RHCR) GOTO 340
3267 loop344: DO L=KDCT,K100,-1
3268 IF(RH0(L) .GT. RHCRIT) CYCLE loop344
3269 WFUN=FLOAT(L-K100+1)/FLOAT(KDCT-K100+1)
3270 AREA=AMAX1(CLDAREAB(I,L,J)+DCATEN(L)*DT,0.0)
3271 IF(T0(L) .LE. TO) THEN
3276 RCP=CP*(1.+0.887*Q0(L))
3279 VAL1=SIGMMA*CLDLIQB(I,L,J)*WFUN
3280 QCDCTEN(L)=QCDCTEN(L)-VAL1
3284 QVTEN(KDCT+1)=QVTEN(KDCT+1) &
3285 +VAL1*AREA*DP(L)/DP(KDCT+1)
3286 TTEN(L)=TTEN(L)-VAL1*AREA*RLOVCP
3287 VAL=Q0(KDCT+1) + QVTEN(KDCT+1)*DT
3289 ! ENSURING THAT THE LAYER ABOVE CLOUD TOP DOES NOT REACH SATURATION (RH=95%)
3290 ! ONLY BECAUSE OF CTEI. IF IT HAPPENS DUE TO CTEI THEN REMOVE THIS EFFECT
3292 IF( VAL/QES(KDCT+1) .GT. RHCR ) THEN
3293 QVTEN(KDCT+1)=QVTEN(KDCT+1) &
3294 -VAL1*DP(L)/DP(KDCT+1)
3295 TTEN(L)=TTEN(L)+VAL1*AREA*RLOVCP
3301 ! PRECIPITATION (DRIZZLE) PROCESS ****************************************
3304 IF ( wrf_dm_on_monitor()) THEN
3305 CALL get_wrf_debug_level( dbg_level )
3306 IF( dbg_level >= 10 .AND. i == i0 .AND. j == j0 ) THEN
3307 if( mod(ktau,KTAU1HUR) .eq. 0 ) then
3308 write( *,*) ' ------ lc drizzle'
3321 G3PBS=GAMMA(3.+BVTS)
3322 PRACS=PIE*N0S*AVTS*G3PBS*.25*ESI ! from MM5
3326 SC2=AMAX1(0.0,CLDLIQB(I,K,J))
3327 SC3=AMAX1(0.0,QR0(K))
3329 SC7=(RHOE(K)*SC3*PPI/1000.)**0.25
3332 PPIS=1./(PIE*N0S*RHOS)
3333 SC7=(RHOE(K)*SC3*PPIS/1000.)**0.25
3335 IF(TOUT .LT. TO)THEN
3336 XNC=XN0*EXP(0.6*(TO-TOUT))/RHOE(K) ! XN0 = 1.E-2 in MM5 domain/initial/param.F
3337 XNC=AMAX1(XNC,10000./RHOE(K))
3338 !... AUTOCONVERSION OF CLOUD ICE TO SNOW:
3339 PRC(K)=AMAX1(0.,(SC2-XMMAX*XNC)/DT)
3340 !... ACCRETION OF CLOUD ICE BY SNOW:
3341 IF(SC3 .LT. 1.0E-17)THEN
3344 PRA(K)=PRACS*SC7**BVTS3*SC2
3347 !--- AUTOCONVERSION OF CLOUD WATER TO RAINWATER:
3348 PRC(K)=AMAX1(0.,QCK1*(SC2-QCTH))
3349 !--- ACCRETION OF CLOUD WATER BY RAINWATER:
3351 IF (SC3 .LT. 1.0E-17) THEN
3355 PRAC=PIE*N0R*AVT*G3PB*0.25
3356 PRA(K)=PRAC*SC7**BVT3*SC2
3361 VAL=MIN(VAL,CLDLIQB(I,K,J)/DT)
3362 AREA=AMAX1(CLDAREAB(I,K,J)+DCATEN(K)*DT,0.0)
3363 IF(AREA .LT. 1.0E-17) VAL=0.0
3364 QRTEN(K)=QRTEN(K)+VAL*AREA
3365 QCDCTEN(K)=QCDCTEN(K)-VAL
3372 ! ICE SEDIMENTATION AS A SINK TERM TO CLDLIQ ******************************
3375 IF ( wrf_dm_on_monitor()) THEN
3376 CALL get_wrf_debug_level( dbg_level )
3377 IF( dbg_level >= 10 .AND. i == i0 .AND. j == j0 ) THEN
3378 if( mod(ktau,KTAU1HUR) .eq. 0 ) then
3379 write( *,*) ' ----- lc ice settling'
3380 write(18,*) ' ----- lc ice settling'
3387 CLQ=AMAX1(CLDLIQB(I,K,J)+QCDCTEN(K)*DT,0.0)
3388 AREA=AMAX1(CLDAREAB(I,K,J)+DCATEN(K)*DT,0.0)
3395 ! NOTE: RHO2=RHO/(PSB*1000) WHERE RHO IS THE AIR DENSITY IN KG/M^3
3396 ! NSTEP IS THE # OF TIME STEPS NEEDED FOR A DROPLET TO MOVE FROM THE LAYER-TOP
3397 ! TO THE LAYER-BOTTOM
3399 RHO2=P0(K)/(R*( T0(K)+DT*TTEN(K)))
3400 IF( (T0(K)+DT*TTEN(K)) .GT.TO)THEN
3404 ! NOTE: SEDIMENTATION FORMULA OF HEYMSFIELD AND DONNER (1990, JAS)
3406 VT2C=3.29*(RHO2* SCR3(K) )**0.16 ! m/s
3409 RGVC(K)=G*RHO2*VT2C ! rho*g*vt2c/(1000*ps)
3410 NSTEP=MAX0(IFIX(RGVC(K)*DT/DSIGMA(K)+1.),NSTEP) ! dvt2c*dt/DZ
3415 'IN SUB. SHALLOW (ICE SETTLING), NSTEP TOO LARGE, PROBABLY NAN'
3418 FALOUTC(K)=RGVC(K)*SCR3(K)
3421 loop341: DO K=KL-1,2,-1
3422 AREA=AMAX1(CLDAREAB(I,K,J)+DCATEN(K)*DT,0.0)
3423 CLQ=AMAX1(CLDLIQB(I,K,J)+QCDCTEN(K)*DT,0.0)
3424 IF(RH0(K) .GT. RHCRIT) CYCLE loop341
3425 IF(AREA .LE. 1.E-4) CYCLE loop341
3426 FALTNDC=(FALOUTC(K)-FALOUTC(K+1))/DSIGMA(K)
3427 C1=AMIN1(FALTNDC,AREA*CLQ/DT*NSTEP)
3429 QCDCTEN(K)=QCDCTEN(K)-C1/AREA/NSTEP
3431 cldlctn4(k) = cldlctn4(k)-C1/AREA/NSTEP ! 1-D graphics
3433 SCR3(K)=SCR3(K)-C1*DT/NSTEP/AREA
3434 QCTEN(K-1)=QCTEN(K-1)+C1*DSIGMA(K)/DSIGMA(K-1)/NSTEP
3435 ! if(i.eq.82.and.j.eq.74) then
3437 RGVC(K)=AMAX1(RGVC(K)/DSIGMA(K),RGVC(K+1)/DSIGMA(K+1))*DSIGMA(K)
3441 !&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
3442 345 CONTINUE ! END OF DISSIPATION CACULATION
3443 !&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
3445 ! PUT INTO TAU-1 ARRAYS
3447 CLDDPTHB(I,J)=CLDDPTH
3456 IF( i == 1 .AND. j == 1 ) THEN
3459 EE=Q0(NK)*P0(NK)/(0.622+Q0(NK))
3460 TLOG=LOG(EE/SVP1/1000.)
3461 TDPT=(SVP2*SVPT0-SVP3*TLOG)/(SVP2-TLOG)
3462 TSAT=TDPT-(.212+1.571E-3*(TDPT-T00)-4.36E-4*(T0(NK)-T00))* &
3464 THTA=T0(NK)*(1.E5/P0(NK))**(0.2854*(1.-0.28*Q0(NK)))
3466 EXP((3374.6525/TSAT-2.5403)*Q0(NK)*(1.+0.81*Q0(NK)))
3467 thtetmp(nk)=THETEE(NK)
3471 if(mod(ktau,KTAU1HUR) .eq. 0) then
3472 write(*,878) xtime/60.0, zpbl, Zlcl,Zlfc,CLDDPTHB(I,J)
3473 write(18,878) Zlcl,Zlfc,CLDDPTH
3474 878 format(5x,'xtime=',f6.1,' Zpbl=',f5.1,' Zlcl=',f6.1,1x,'Zlfc=',f8.1, &
3475 1x,'CLD_Depth=',f7.1)
3478 KK=INT(PLOTFRQ*(KTAU1HUR/60.))
3479 IF( MOD(KTAU-1,KK) .EQ. 0) THEN
3480 write(17,*) xtime/60.0,ktau,ZPBL,ZLCL,LLC,KPBL,KLCL, &
3481 CLDTOP,KX-LTOP+1,KX-KDCB+1,KX-KDCT+1,RHCRIT
3482 ! write(43,*) xtime/60.0,ktau,ZPBL,ZLCL,LLC,KPBL,KLCL, &
3483 ! CLDTOP,LTOP,KDCB,KDCT
3485 write(17,*) kl-k+1,p0(k)/100.0,z0(k),CLDUA(k)*100.0, &
3486 CLDAREAB(I,K,J)*100.0, &
3487 CLDLIQB(I,K,J)*1000.0, &
3488 CLDAREAB(I,K,J)*CLDLIQB(I,K,J)*1000.0, &
3496 ! write(43,*) k,p0(k),z0(k), &
3504 ! cldlctn5(k)*bb ! g/hour
3509 KK=INT(PLOTFRQ*(KTAU1HUR/60.))
3510 IF( MOD(KTAU-1,KK) .EQ. 0) THEN
3512 write(10,*) xtime/60.0, ktau-1
3515 wsp_plot(k) = sqrt(u0(k)**2+v0(k)**2)
3516 if( ABS(wsp_plot(k)) < 0.001 ) then
3518 else if(v0(k) .gt. 0.) then
3519 wdr_plot(k)=atan(u0(k)/v0(k))
3520 wdr_plot(k)=wdr_plot(k)*180./pie+180.
3521 else if (v0(k) .lt. 0.) then
3522 if( u0(k) .gt. 0.0 ) then
3523 wdr_plot(k)=atan(u0(k)/v0(k))
3524 wdr_plot(k)=wdr_plot(k)*180./PIE+360.
3525 else if( u0(k) .lt. 0.0 ) then
3526 wdr_plot(k)=atan(u0(k)/v0(k))
3527 wdr_plot(k)=wdr_plot(k)*180./PIE
3529 else if (u0(k) .gt.0.) then
3536 qqq = AMAX1(qqq,1.0E-25)
3537 EES=qqq*p0(k)/100.0/(0.622+qqq)
3538 IF( t0(k) .GT. TO ) THEN
3539 TLOG=LOG(EES/SVP1/10.)
3540 td_plot(k) = (SVP2*SVPT0-SVP3*TLOG)/(SVP2-TLOG)-SVPT0
3542 TLOG=LOG(EES/0.611/10.)
3543 td_plot(k) = 6150./(22.514-TLOG)-SVPT0
3546 write(10,*) p0(k)/100.0, t0(k)-SVPT0, td_plot(k), wsp_plot(k), wdr_plot(k)
3549 write(10,*) (TUG(K),K=1,KL),TPBLG(I,J),PPBLG(I,J),TLCLG(I,J), &
3550 PLCLG(I,J), PCLDTPG(I,J), TCLDTPG(I,J), &
3551 CLDHGTG(I,J),PLET,TLET,PLFSG(I,J),TLFSG(I,J),PLDTG(I,J), &
3552 TLDTG(I,J),PLDBG(I,J),TLDBG(I,J),PLLCG(I,J),TLLCG(I,J), &
3556 KK=INT(PLOTFRQ*(KTAU1HUR/60.))
3557 IF( MOD(KTAU-1,KK) .EQ. 0) THEN
3559 write(7,*) xtime/60.0,ktau,ZPBL,ZLCL,LLC,KKPBL,KLCL, &
3560 CLDTOP,kx-LTOP+1,kx-KDCB+1,kx-KDCT+1
3562 write(7,*) kx-k+1, p0(k)/100.0, z_at_w0(k)-ht, tke0(k)
3565 write(67,*) (TKE0(K),K=KXP1-KL/3+1,1,-1), (z_at_w0(k)-ht,k=KXP1-KL/3+1,1,-1)
3571 END SUBROUTINE deng_shcu
3573 !====================================================================
3574 SUBROUTINE deng_shcu_init(RTHSHTEN,RQVSHTEN,RQCSHTEN,RQRSHTEN, &
3575 RUSHTEN,RVSHTEN,RDCASHTEN,RQCDCSHTEN,W0AVG, &
3576 PBLHAVG, TKEAVG, cldareaa, cldareab, &
3577 cldliqa, cldliqb, ca_rad, cw_rad, &
3578 wub, pblmax, ltopb, clddpthb, cldtopb, &
3579 capesave, ainckfsa, radsave, &
3580 rainsh, rainshvb, kdcldtop, kdcldbas, &
3583 SVP1,SVP2,SVP3,SVPT0, &
3584 ids, ide, jds, jde, kds, kde, &
3585 ims, ime, jms, jme, kms, kme, &
3586 its, ite, jts, jte, kts, kte )
3587 !--------------------------------------------------------------------
3589 !--------------------------------------------------------------------
3590 INTEGER , INTENT(IN) :: ids, ide, jds, jde, kds, kde, &
3591 ims, ime, jms, jme, kms, kme, &
3592 its, ite, jts, jte, kts, kte
3594 LOGICAL , INTENT(IN) :: restart
3595 REAL , INTENT(IN) :: SVP1,SVP2,SVP3,SVPT0
3597 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ), INTENT(OUT) :: &
3607 REAL , DIMENSION( ims:ime , kms:kme , jms:jme ) , INTENT(OUT) :: W0AVG, &
3610 REAL , DIMENSION( ims:ime , jms:jme), INTENT(OUT) :: pblmax, &
3611 rainsh, rainshvb, clddpthb, cldtopb, capesave, radsave, xtime1, &
3614 REAL , DIMENSION( ims:ime , 1:100, jms:jme ), INTENT(OUT) :: ainckfsa
3616 INTEGER , DIMENSION( ims:ime , jms:jme), INTENT(OUT) :: ltopb &
3619 REAL , DIMENSION( ims:ime , kms:kme, jms:jme ), INTENT(OUT) :: wub, &
3620 cldareaa, cldareab, cldliqa, cldliqb, ca_rad, cw_rad
3623 INTEGER :: i, j, k, itf, jtf, ktf
3629 IF(.NOT.RESTART)THEN
3635 RTHSHTEN(i,k,j) = 0.
3636 RQVSHTEN(i,k,j) = 0.
3637 RQCSHTEN(i,k,j) = 0.
3638 RQRSHTEN(i,k,j) = 0.
3639 RDCASHTEN(i,k,j) = 0.
3640 RQCDCSHTEN(i,k,j) = 0.
3644 cldareaa(i,k,j) = 0.0
3645 cldareab(i,k,j) = 0.0
3646 cldliqa(i,k,j) = 0.0
3647 cldliqb(i,k,j) = 0.0
3669 ainckfsa(i,k,j) = 0.0
3676 CALL KF_LUTAB(SVP1,SVP2,SVP3,SVPT0)
3677 ! CALL KF_LUTABBG(SVP1,SVP2,SVP3,SVPT0)
3679 END SUBROUTINE deng_shcu_init
3681 !==========================================================
3682 SUBROUTINE time_avg_2d( dt, ADAPT_STEP_FLAG, time_period_avg_min &
3683 ,array2d, array2d_avg &
3687 INTEGER, INTENT(IN ) :: its,ite, jts,jte
3689 REAL, INTENT(IN ) :: time_period_avg_min, dt ! time window to perform
3690 !a running mean value
3691 LOGICAL ,INTENT(IN) :: adapt_step_flag
3692 REAL, DIMENSION( its:ite , jts:jte ), INTENT(IN ) :: array2d
3693 REAL, DIMENSION( its:ite , jts:jte ), INTENT(INOUT) :: array2d_avg
3695 INTEGER :: i, j, ntst
3696 REAL :: tst, AVGfctr, fctr, den
3698 NTST = NINT( time_period_avg_min * 60.0 / dt ) ! number of time steps in time_period_avg_min
3700 IF( TST <= 0 ) STOP 'Denominator has to be greater than zero - deng_shcu_driver'
3702 if (ADAPT_STEP_FLAG) then
3703 AVGfctr = MAX( time_period_avg_min*60,dt ) - dt
3705 den = MAX( time_period_avg_min*60,dt )
3714 array2d_avg(i,j) = ( array2d_avg(i,j) * AVGfctr + array2d(i,j) * fctr ) / den
3718 ! write(*,'(5f10.4)') array2d(1,1), array2d_avg(1,1), AVGfctr, fctr, den
3720 END SUBROUTINE time_avg_2d
3722 !==========================================================
3723 SUBROUTINE time_avg_3d( dt, ADAPT_STEP_FLAG, time_period_avg_min &
3724 ,array3d, array3d_avg &
3725 ,its,ite, jts,jte, kts,kte &
3728 INTEGER, INTENT(IN ) :: its,ite, jts,jte, kts,kte
3730 REAL, INTENT(IN ) :: time_period_avg_min, dt ! time window to perform
3731 !a running mean value
3732 LOGICAL ,INTENT(IN) :: adapt_step_flag
3733 REAL, DIMENSION( its:ite , kts:kte , jts:jte ), INTENT(IN ) :: array3d
3734 REAL, DIMENSION( its:ite , kts:kte , jts:jte ), INTENT(INOUT) :: array3d_avg
3736 INTEGER :: i, j, k, ntst
3737 REAL :: tst, AVGfctr, fctr, den
3739 NTST = NINT( time_period_avg_min * 60.0 / dt ) ! number of time steps in time_period_avg_min
3741 IF( TST <= 0 ) STOP 'Denominator has to be greater than zero - deng_shcu_driver'
3743 if (ADAPT_STEP_FLAG) then
3744 AVGfctr = MAX( time_period_avg_min*60,dt ) - dt
3746 den = MAX( time_period_avg_min*60,dt )
3756 array3d_avg(i,k,j) = ( array3d_avg(i,k,j) * AVGfctr + array3d(i,k,j) * fctr ) / den
3762 ! write(*,'(i3,5f10.4)') k, array3d(1,k,1), array3d_avg(1,k,1), AVGfctr, fctr, den
3765 END SUBROUTINE time_avg_3d
3767 !====================================================================
3768 SUBROUTINE CONDLOAD(QLIQ,QICE,WTW,DZ,BOTERM,ENTERM,RATE,QNEWLQ, &
3769 QNEWIC,QLQOUT,QICOUT,G)
3770 ! 9/18/88...THIS PRECIPITATION FALLOUT SCHEME IS BASED ON THE SCHEME US
3771 ! BY OGURA AND CHO (1973). LIQUID WATER FALLOUT FROM A PARCEL IS CAL-
3772 ! CULATED USING THE EQUATION DQ=-RATE*Q*DT, BUT TO SIMULATE A QUASI-
3773 ! CONTINUOUS PROCESS, AND TO ELIMINATE A DEPENDENCY ON VERTICAL
3774 ! RESOLUTION THIS IS EXPRESSED AS Q=Q*EXP(-RATE*DZ).
3775 !----------------------
3777 !----------------------
3778 REAL, INTENT(IN ) :: G
3779 REAL, INTENT(IN ) :: DZ,BOTERM,ENTERM,RATE
3780 REAL, INTENT(INOUT) :: QLQOUT,QICOUT,WTW,QLIQ,QICE,QNEWLQ,QNEWIC
3781 REAL :: QTOT,QNEW,QEST,G1,WAVG,CONV,RATIO3,OLDQ,RATIO4,DQ,PPTDRG
3783 IF(ABS(WTW).LT.1.E-4) WTW=1.E-4
3787 ! ESTIMATE THE VERTICAL VELOCITY SO THAT AN AVERAGE VERTICAL VELOCITY
3788 ! BE CALCULATED TO ESTIMATE THE TIME REQUIRED FOR ASCENT BETWEEN MODEL
3791 QEST=0.5*(QTOT+QNEW)
3792 G1=WTW+BOTERM-ENTERM-2.*G*DZ*QEST/1.5
3794 WAVG=0.5*(SQRT(WTW)+SQRT(G1))
3797 ! RATIO3 IS THE FRACTION OF LIQUID WATER IN FRESH CONDENSATE, RATIO4 IS
3798 ! THE FRACTION OF LIQUID WATER IN THE TOTAL AMOUNT OF CONDENSATE INVOLV
3799 ! IN THE PRECIPITATION PROCESS - NOTE THAT ONLY 60% OF THE FRESH CONDEN
3800 ! SATE IS IS ALLOWED TO PARTICIPATE IN THE CONVERSION PROCESS...
3802 RATIO3=QNEWLQ/(QNEW+1.E-8)
3806 RATIO4=(0.6*QNEWLQ+QLIQ)/(QTOT+1.E-8)
3807 QTOT=QTOT*EXP(-CONV)
3809 ! DETERMINE THE AMOUNT OF PRECIPITATION THAT FALLS OUT OF THE UPDRAFT
3810 ! PARCEL AT THIS LEVEL...
3814 QICOUT=(1.-RATIO4)*DQ
3816 ! ESTIMATE THE MEAN LOAD OF CONDENSATE ON THE UPDRAFT IN THE LAYER, CAL
3817 ! LATE VERTICAL VELOCITY
3819 PPTDRG=0.5*(OLDQ+QTOT-0.2*QNEW)
3820 WTW=WTW+BOTERM-ENTERM-2.*G*DZ*PPTDRG/1.5
3821 IF(ABS(WTW).LT.1.E-4)WTW=1.E-4
3823 ! DETERMINE THE NEW LIQUID WATER AND ICE CONCENTRATIONS INCLUDING LOSSE
3824 ! DUE TO PRECIPITATION AND GAINS FROM CONDENSATION...
3826 QLIQ=RATIO4*QTOT+RATIO3*0.4*QNEW
3827 QICE=(1.-RATIO4)*QTOT+(1.-RATIO3)*0.4*QNEW
3831 END SUBROUTINE CONDLOAD
3832 !====================================================================
3833 SUBROUTINE DTFRZNEW(TU,P,THTEU,QVAP,QLIQ,QICE,RATIO2, &
3834 QNWFRZ,RL,FRC1,EFFQ,IFLAG,XLV0,XLV1,XLS0,XLS1, &
3835 ! ALIQ,BLIQ,CLIQ,DLIQ,AICE,BICE,CICE,DICE, &
3836 SVP1,SVP2,SVPT0,SVP3)
3837 !-----------------------------------------------------------------------
3839 !-----------------------------------------------------------------------
3840 REAL, INTENT(IN ) :: P, SVP1,SVP2,SVPT0,SVP3, &
3841 XLV0,XLV1,XLS0,XLS1, EFFQ
3843 REAL, INTENT(INOUT) :: TU, THTEU, QVAP, QLIQ, QICE, RATIO2, &
3845 INTEGER, INTENT(INOUT) :: IFLAG
3846 REAL :: A, B, C, C5, RLC, RLS, RLF, QVAP1, &
3847 RV, CS, QLQFRZ, QNEW, ESLIQ, ESICE, &
3848 CP, DQVAP, DTFRZ, TU1, ES, pi
3850 !...ALLOW GLACIATION OF THE UPDRAFT TO OCCUR AS AN APPROXIMATELY LINEAR
3851 ! FUNCTION OF TEMPERATURE IN THE TEMPERATURE RANGE TTFRZ TO TBFRZ...
3856 !...ADJUST THE LIQUID WATER CONCENTRATIONS FROM FRESH CONDENSATE AND THA
3857 ! BROUGHT UP FROM LOWER LEVELS TO AN AMOUNT THAT WOULD BE PRESENT IF N
3858 ! LIQUID WATER HAD FROZEN THUS FAR...THIS IS NECESSARY BECAUSE THE
3859 ! EXPRESSION FOR TEMP CHANGE IS MULTIPLIED BY THE FRACTION EQUAL TO TH
3860 ! PARCEL TEMP DECREASE SINCE THE LAST MODEL LEVEL DIVIDED BY THE TOTAL
3861 ! GLACIATION INTERVAL, SO THAT EFFECTIVELY THIS APPROXIMATELY ALLOWS A
3862 ! AMOUNT OF LIQUID WATER TO FREEZE WHICH IS EQUAL TO THIS SAME FRACTIO
3863 ! OF THE LIQUID WATER THAT WAS PRESENT BEFORE THE GLACIATION PROCESS W
3864 ! INITIATED...ALSO, TO ALLOW THETAU TO CONVERT APPROXIMATELY LINEARLY
3865 ! ITS VALUE WITH RESPECT TO ICE, WE NEED TO ALLOW A PORTION OF THE FRE
3866 ! CONDENSATE TO CONTRIBUTE TO THE GLACIATION PROCESS; THE FRACTIONAL
3867 ! AMOUNT THAT APPLIES TO THIS PORTION IS 1/2 OF THE FRACTIONAL AMOUNT
3868 ! FROZEN OF THE "OLD" CONDENSATE BECAUSE THIS FRESH CONDENSATE IS ONLY
3869 ! PRODUCED GRADUALLY OVER THE LAYER...NOTE THAT IN TERMS OF THE DYNAMI
3870 ! OF THE PRECIPITATION PROCESS, IE. PRECIPITATION FALLOUT, THIS FRACTI
3871 ! AMNT OF FRESH CONDENSATE HAS ALREADY BEEN INCLUDED IN THE ICE CATEGO
3874 QNEW=QNWFRZ*EFFQ*0.5
3875 ! ESLIQ=ALIQ*EXP((BLIQ*TU-CLIQ)/(TU-DLIQ))
3876 ESLIQ=1.E3*SVP1*EXP(SVP2*(TU-SVPT0)/(TU-SVP3))
3877 ! ESICE=AICE*EXP((BICE*TU-CICE)/(TU-DICE))
3878 ESICE=611.0*EXP(22.514-6.15E3/TU)
3879 RLC=2.5E6-2369.276*(TU-273.16)
3880 RLS=2833922.-259.532*(TU-273.16)
3882 CP=1005.7*(1.+0.89*QVAP)
3884 ! A = D(ES)/DT IS THAT CALCULATED FROM BUCK`S (1981) EMPIRICAL FORMULAS
3885 ! FOR SATURATION VAPOR PRESSURE...
3887 ! A=(CICE-BICE*DICE)/((TU-DICE)*(TU-DICE))
3891 DQVAP=B*(ESLIQ-ESICE)/(RLS+RLS*C)-RLF*(QLQFRZ+QNEW)/(RLS+RLS/C)
3892 DTFRZ=(RLF*(QLQFRZ+QNEW)+B*(ESLIQ-ESICE))/(CP+A*B*ESICE)
3896 QVAP=QVAP-FRC1*DQVAP
3897 ES=QVAP*P/(0.622+QVAP)
3898 ! ESLIQ=ALIQ*EXP((BLIQ*TU-CLIQ)/(TU-DLIQ))
3899 ESLIQ=1.E3*SVP1*EXP(SVP2*(TU-SVPT0)/(TU-SVP3))
3900 ! ESICE=AICE*EXP((BICE*TU-CICE)/(TU-DICE))
3901 ESICE=611.0*EXP(22.514-6.15E3/TU)
3902 RATIO2=(ESLIQ-ES)/(ESLIQ-ESICE)
3904 ! TYPICALLY, RATIO2 IS VERY CLOSE TO (TTFRZ-TU)/(TTFRZ-TBFRZ), USUALLY
3905 ! WITHIN 1% (USING TU BEFORE GALCIATION EFFECTS ARE APPLIED); IF THE
3906 ! INITIAL UPDRAFT TEMP IS BELOW TBFRZ AND RATIO2 IS STILL LESS THAN 1,
3907 ! AN ADJUSTMENT TO FRC1 AND RATIO2 IS INTRODUCED SO THAT GLACIATION
3908 ! EFFECTS ARE NOT UNDERESTIMATED; CONVERSELY, IF RATIO2 IS GREATER THAN
3909 ! FRC1 IS ADJUSTED SO THAT GLACIATION EFFECTS ARE NOT OVERESTIMATED...
3911 IF(IFLAG.GT.0.AND.RATIO2.LT.1)THEN
3912 FRC1=FRC1+(1.-RATIO2)
3914 QVAP=QVAP1-FRC1*DQVAP
3919 IF(RATIO2.GT.1.)THEN
3920 FRC1=FRC1-(RATIO2-1.)
3921 FRC1=AMAX1(0.0,FRC1)
3923 QVAP=QVAP1-FRC1*DQVAP
3928 ! CALCULATE A HYBRID VALUE OF THETAU, ASSUMING THAT THE LATENT HEAT OF
3929 ! VAPORIZATION/SUBLIMATION CAN BE ESTIMATED USING THE SAME WEIGHTING
3930 ! FUNCTION AS THAT USED TO CALCULATE SATURATION VAPOR PRESSURE, CALCU-
3931 ! LATE NEW LIQUID WATER AND ICE CONCENTRATIONS...
3935 RL=RATIO2*RLS+(1.-RATIO2)*RLC
3936 PI=(1.E5/P)**(0.2854*(1.-0.28*QVAP))
3937 THTEU=TU*PI*EXP(RL*QVAP*C5/TU*(1.+0.81*QVAP))
3939 QICE=QICE+FRC1*DQVAP+QLIQ
3942 QICE=QICE+FRC1*(DQVAP+QLQFRZ)
3943 QLIQ=QLIQ-FRC1*QLQFRZ
3947 END SUBROUTINE DTFRZNEW
3948 ! ***********************************************************************
3949 !====================================================================
3950 !====================================================================
3951 SUBROUTINE ENVIRTHT(P1,T1,Q1,THT1,R1,RL, &
3952 ! ALIQ,BLIQ,CLIQ,DLIQ,AICE,BICE,CICE,DICE, &
3953 SVP1,SVP2,SVPT0,SVP3,I,J)
3954 !-----------------------------------------------------------------------
3956 !-----------------------------------------------------------------------
3957 REAL, INTENT(IN ) :: P1,T1,Q1,R1,RL,SVP1,SVP2,SVPT0,SVP3
3958 INTEGER, INTENT(IN ) :: I,J
3959 REAL, INTENT( OUT) :: THT1
3960 REAL :: EE,TLOG,TDPT,TSAT,THT,TFPT
3961 REAL :: T00,P00,C1,C2,C3,C4,C5,tlogic, tsatlq, tsatic
3962 !-----------------------------------------------------------------------
3963 DATA T00,P00,C1,C2,C3,C4,C5/273.16,1.E5,3374.6525,2.5403,3114.834, &
3966 ! CALCULATE ENVIRONMENTAL EQUIVALENT POTENTIAL TEMPERATURE...
3969 ! EE=Q1*P1/(0.622+Q1)
3970 EE=max(Q1*P1/(0.622+Q1),1.e-9)
3971 ! TLOG=ALOG(EE/ALIQ)
3972 ! TDPT=(CLIQ-DLIQ*TLOG)/(BLIQ-TLOG)
3973 TLOG=ALOG(EE/SVP1/1000.)
3974 TDPT=(SVP2*SVPT0-SVP3*TLOG)/(SVP2-TLOG)
3975 TSAT=TDPT-(.212+1.571E-3*(TDPT-T00)-4.36E-4*(T1-T00))*(T1-TDPT)
3976 THT=T1*(P00/P1)**(0.2854*(1.-0.28*Q1))
3977 THT1=THT*EXP((C1/TSAT-C2)*Q1*(1.+0.81*Q1))
3978 ELSEIF(ABS(R1-1.).LT.1.E-6)THEN
3979 ! EE=Q1*P1/(0.622+Q1)
3980 EE=max(Q1*P1/(0.622+Q1),1.e-9)
3981 ! TLOG=ALOG(EE/AICE)
3982 ! TFPT=(CICE-DICE*TLOG)/(BICE-TLOG)
3984 TFPT=6150./(22.514-TLOG)
3985 THT=T1*(P00/P1)**(0.2854*(1.-0.28*Q1))
3986 TSAT=TFPT-(.182+1.13E-3*(TFPT-T00)-3.58E-4*(T1-T00))*(T1-TFPT)
3987 THT1=THT*EXP((C3/TSAT-C4)*Q1*(1.+0.81*Q1))
3989 ! EE=Q1*P1/(0.622+Q1)
3990 EE=max(Q1*P1/(0.622+Q1),1.e-9)
3991 ! TLOG=ALOG(EE/ALIQ)
3992 ! TDPT=(CLIQ-DLIQ*TLOG)/(BLIQ-TLOG)
3993 ! TLOGIC=ALOG(EE/AICE)
3994 ! TFPT=(CICE-DICE*TLOGIC)/(BICE-TLOGIC)
3995 TLOG=ALOG(EE/SVP1/1000.)
3996 TDPT=(SVP2*SVPT0-SVP3*TLOG)/(SVP2-TLOG)
3997 TLOGIC=ALOG(EE/611.0)
3998 TFPT=6150./(22.514-TLOGIC)
3999 THT=T1*(P00/P1)**(0.2854*(1.-0.28*Q1))
4000 TSATLQ=TDPT-(.212+1.571E-3*(TDPT-T00)-4.36E-4*(T1-T00))*(T1-TDPT)
4001 TSATIC=TFPT-(.182+1.13E-3*(TFPT-T00)-3.58E-4*(T1-T00))*(T1-TFPT)
4002 TSAT=R1*TSATIC+(1.-R1)*TSATLQ
4003 THT1=THT*EXP(RL*Q1*C5/TSAT*(1.+0.81*Q1))
4004 ! NaN 326. NaN 30.88963 NaN 0.0 NaN -Infinity -Infinity 0
4007 END SUBROUTINE ENVIRTHT
4008 !====================================================================
4009 SUBROUTINE ENVIRTHT2(P1,T1,Q1,THT1,ALIQ,BLIQ,CLIQ,DLIQ)
4011 !-----------------------------------------------------------------------
4013 !-----------------------------------------------------------------------
4014 REAL, INTENT(IN ) :: P1,T1,Q1,ALIQ,BLIQ,CLIQ,DLIQ
4015 REAL, INTENT(INOUT) :: THT1
4016 REAL :: EE,TLOG,ASTRT,AINC,A1,TP,VALUE,AINTRP,TDPT,TSAT,THT, &
4017 T00,P00,C1,C2,C3,C4,C5
4019 !-----------------------------------------------------------------------
4020 DATA T00,P00,C1,C2,C3,C4,C5/273.16,1.E5,3374.6525,2.5403,3114.834, &
4023 ! CALCULATE ENVIRONMENTAL EQUIVALENT POTENTIAL TEMPERATURE...
4025 ! NOTE: Calculations for mixed/ice phase no longer used...jsk 8/00
4026 ! For example, KF90 Eq. 10 no longer used
4029 ! TLOG=ALOG(EE/ALIQ)
4030 ! ...calculate LOG term using lookup table...
4037 value=(indlu-1)*ainc+astrt
4038 aintrp=(a1-value)/ainc
4039 tlog=aintrp*alu(indlu+1)+(1-aintrp)*alu(indlu)
4041 TDPT=(CLIQ-DLIQ*TLOG)/(BLIQ-TLOG)
4042 TSAT=TDPT-(.212+1.571E-3*(TDPT-T00)-4.36E-4*(T1-T00))*(T1-TDPT)
4043 THT=T1*(P00/P1)**(0.2854*(1.-0.28*Q1))
4044 THT1=THT*EXP((C1/TSAT-C2)*Q1*(1.+0.81*Q1))
4046 END SUBROUTINE ENVIRTHT2
4047 ! ***********************************************************************
4048 !====================================================================
4049 SUBROUTINE PROF5(EQ,EE,UD)
4050 !-----------------------------------------------------------------------
4051 ! THIS SUBROUTINE INTEGRATES THE AREA UNDER THE CURVE IN THE GAUSSIAN
4052 ! DISTRIBUTION...THE NUMERICAL APPROXIMATION TO THE INTEGRAL IS TAKEN FROM
4053 ! `HANDBOOK OF MATHEMATICAL FUNCTIONS WITH FORMULAS, GRAPHS AND MATHEMATICAL
4054 ! TABLES` ED. BY ABRAMOWITZ AND STEGUN, NAT`L BUREAU OF STANDARDS APPLIED
4055 ! MATHEMATICS SERIES. JUNE, 1964., MAY, 1968.
4058 !-----------------------------------------------------------------------
4060 !-----------------------------------------------------------------------
4061 REAL, INTENT(IN ) :: EQ
4062 REAL, INTENT( OUT) :: EE,UD
4063 REAL :: SQRT2P,A1,A2,A3,P,SIGMA,FE,X,Y,EY,E45,T1,T2,C1,C2
4064 !-----------------------------------------------------------------------
4065 !*********************************************************************
4066 !***** GAUSSIAN TYPE MIXING PROFILE....******************************
4067 DATA SQRT2P,A1,A2,A3,P,SIGMA,FE/2.506628,0.4361836,-0.1201676, &
4068 0.9372980,0.33267,0.166666667,0.202765151/
4075 C1=A1*T1+A2*T1*T1+A3*T1*T1*T1
4076 C2=A1*T2+A2*T2*T2+A3*T2*T2*T2
4078 EE=SIGMA*(0.5*(SQRT2P-E45*C1-EY*C2)+SIGMA*(E45-EY))-E45*EQ*EQ/2.
4079 UD=SIGMA*(0.5*(EY*C2-E45*C1)+SIGMA*(E45-EY))-E45*(0.5+EQ*EQ/2.-EQ)
4081 EE=SIGMA*(0.5*(EY*C2-E45*C1)+SIGMA*(E45-EY))-E45*EQ*EQ/2.
4082 UD=SIGMA*(0.5*(SQRT2P-E45*C1-EY*C2)+SIGMA*(E45-EY))-E45*(0.5+EQ* &
4088 END SUBROUTINE PROF5
4089 ! ***********************************************************************
4090 !====================================================================
4091 FUNCTION TPDD(P,THTED,TGS,RS,RD,RH,XLV0,XLV1, &
4092 ! ALIQ,BLIQ,CLIQ,DLIQ,AICE,BICE,CICE,DICE, &
4093 SVP1,SVP2,SVPT0,SVP3)
4094 !************************* TPDD.FOR ************************************
4095 ! THIS SUBROUTINE ITERATIVELY EXTRACTS TEMPERATURE FROM EQUIVALENT *
4096 ! POTENTIAL TEMP. IT IS DESIGNED FOR USE WITH DOWNDRAFT CALCULATIONS.
4097 ! IF RELATIVE HUMIDITY IS SPECIFIED TO BE LESS THAN 100%, PARCEL *
4098 ! TEMP, SPECIFIC HUMIDITY, AND LIQUID WATER CONTENT ARE ITERATIVELY *
4100 !-----------------------------------------------------------------------
4102 !-----------------------------------------------------------------------
4103 REAL, INTENT(IN ) :: P,THTED,TGS,RD,RH,XLV0,XLV1,SVP1,SVP2,SVPT0,SVP3
4104 ! REAL, INTENT( OUT ) :: tpdd
4106 REAL, INTENT(INOUT) :: RS
4107 REAL :: ES, PI, THTGS, F0, T1, T0, CP, F1, DT, DSSDT, T1RH, RSRH, RL
4109 !-----------------------------------------------------------------------
4110 ! ES=ALIQ*EXP((BLIQ*TGS-CLIQ)/(TGS-DLIQ))
4111 ES=1.E3*SVP1*EXP(SVP2*(TGS-SVPT0)/(TGS-SVP3))
4113 PI=(1.E5/P)**(0.2854*(1.-0.28*RS))
4114 THTGS=TGS*PI*EXP((3374.6525/TGS-2.5403)*RS*(1.+0.81*RS))
4120 !...ITERATE TO FIND WET-BULB TEMPERATURE...
4123 ! 90 ES=ALIQ*EXP((BLIQ*T1-CLIQ)/(T1-DLIQ))
4124 90 ES=1.E3*SVP1*EXP(SVP2*(T1-SVPT0)/(T1-SVP3))
4126 PI=(1.E5/P)**(0.2854*(1.-0.28*RS))
4127 THTGS=T1*PI*EXP((3374.6525/T1-2.5403)*RS*(1.+0.81*RS))
4129 IF(ABS(F1).LT.0.05)GOTO 50
4131 IF(ITCNT.GT.10)GOTO 50
4132 DT=F1*(T1-T0)/(F1-F0)
4139 !...IF RELATIVE HUMIDITY IS SPECIFIED TO BE LESS THAN 100%, ESTIMATE THE
4140 ! TEMPERATURE AND MIXING RATIO WHICH WILL YIELD THE APPROPRIATE VALUE.
4142 IF(RH.EQ.1.)GOTO 110
4143 DSSDT=SVP2*(SVPT0-SVP3)/((T1-SVP3)*(T1-SVP3))
4144 DT=RL*RS*(1.-RH)/(CP+RL*RH*RS*DSSDT)
4146 ! ES=RH*ALIQ*EXP((BLIQ*T1RH-CLIQ)/(T1RH-DLIQ))
4147 ES=RH*1.E3*SVP1*EXP(SVP2*(T1RH-SVPT0)/(T1RH-SVP3))
4148 RSRH=0.622*ES/(P-ES)
4150 !...CHECK TO SEE IF MIXING RATIO AT SPECIFIED RH IS LESS THAN ACTUAL
4151 !...MIXING RATIO...IF SO, ADJUST TO GIVE ZERO EVAPORATION...
4155 T1RH=T1+(RS-RSRH)*RL/CP
4160 ! IF(ITCNT.GT.10)PRINT*,'***** NUMBER OF ITERATIONS IN TPDD = ',
4164 !====================================================================
4165 FUNCTION TPDDBG(P,THTED,TGS,RS,RD,RH,XLV0,XLV1, &
4166 ! ALIQ,BLIQ,CLIQ,DLIQ,AICE,BICE,CICE,DICE, &
4167 SVP1,SVP2,SVPT0,SVP3)
4168 !************************* TPDD.FOR ************************************
4169 ! THIS SUBROUTINE ITERATIVELY EXTRACTS TEMPERATURE FROM EQUIVALENT *
4170 ! POTENTIAL TEMP. IT IS DESIGNED FOR USE WITH DOWNDRAFT CALCULATIONS.
4171 ! IF RELATIVE HUMIDITY IS SPECIFIED TO BE LESS THAN 100%, PARCEL *
4172 ! TEMP, SPECIFIC HUMIDITY, AND LIQUID WATER CONTENT ARE ITERATIVELY *
4174 !-----------------------------------------------------------------------
4176 ! Modified BJG 1/17/2014
4179 !-----------------------------------------------------------------------
4180 REAL, INTENT(IN ) :: P,THTED,TGS,RD,RH,XLV0,XLV1,SVP1,SVP2,SVPT0,SVP3
4181 ! REAL, INTENT( OUT ) :: tpddbg
4183 REAL, INTENT(INOUT) :: RS
4184 REAL :: ES, PI, THTGS, F0, T1, T0, CP, F1, DT, DSSDT, T1RH, RSRH, RL
4187 !-----------------------------------------------------------------------
4188 ! ES=ALIQ*EXP((BLIQ*TGS-CLIQ)/(TGS-DLIQ))
4189 ES=1.E3*SVP1*EXP(SVP2*(TGS-SVPT0)/(TGS-SVP3))
4191 PI=(1.E5/P)**(0.2854*(1.-0.28*RS))
4192 THTGS=TGS*PI*EXP((3374.6525/TGS-2.5403)*RS*(1.+0.81*RS))
4203 !...ITERATE TO FIND WET-BULB TEMPERATURE...
4206 ! 90 ES=ALIQ*EXP((BLIQ*T1-CLIQ)/(T1-DLIQ))
4207 90 ES=1.E3*SVP1*EXP(SVP2*(t2-SVPT0)/(t2-SVP3))
4209 PI=(1.E5/P)**(0.2854*(1.-0.28*RS))
4210 THTGS=t2*PI*EXP((3374.6525/t2-2.5403)*RS*(1.+0.81*RS))
4213 if((f1 * f2).lt.0.0) then
4223 IF(ABS(F1).LT.0.05)GOTO 50
4225 IF(ITCNT.GT.10)GOTO 50
4226 DT=F1*(T1-T0)/(F1-F0)
4228 if(abs(dt).lt.abs( (t1-t0)/2.0 )) then
4229 dt = (t1 - t0) / 2.0
4239 !...IF RELATIVE HUMIDITY IS SPECIFIED TO BE LESS THAN 100%, ESTIMATE THE
4240 ! TEMPERATURE AND MIXING RATIO WHICH WILL YIELD THE APPROPRIATE VALUE.
4242 IF(RH.EQ.1.)GOTO 110
4243 DSSDT=SVP2*(SVPT0-SVP3)/((T1-SVP3)*(T1-SVP3))
4244 DT=RL*RS*(1.-RH)/(CP+RL*RH*RS*DSSDT)
4246 ! ES=RH*ALIQ*EXP((BLIQ*T1RH-CLIQ)/(T1RH-DLIQ))
4247 ES=RH*1.E3*SVP1*EXP(SVP2*(T1RH-SVPT0)/(T1RH-SVP3))
4248 RSRH=0.622*ES/(P-ES)
4250 !...CHECK TO SEE IF MIXING RATIO AT SPECIFIED RH IS LESS THAN ACTUAL
4251 !...MIXING RATIO...IF SO, ADJUST TO GIVE ZERO EVAPORATION...
4255 T1RH=T1+(RS-RSRH)*RL/CP
4260 ! IF(ITCNT.GT.10)PRINT*,'***** NUMBER OF ITERATIONS IN TPDD = ',
4264 !====================================================================
4265 SUBROUTINE TPMIX(P,THTU,TU,QU,QLIQ,QICE,QNEWLQ,QNEWIC,RATIO2,RL, &
4266 XLV0,XLV1,XLS0,XLS1, &
4267 ! ALIQ,BLIQ,CLIQ,DLIQ,AICE,BICE,CICE,DICE, &
4268 SVP1,SVP2,SVPT0,SVP3)
4269 !-----------------------------------------------------------------------
4271 !-----------------------------------------------------------------------
4272 REAL, INTENT(IN ) :: P,THTU,RATIO2,RL, &
4273 XLV0,XLV1,XLS0,XLS1,SVP1,SVP2,SVPT0,SVP3
4274 REAL, INTENT( OUT) :: QNEWLQ,QNEWIC
4275 REAL, INTENT(INOUT) :: TU,QU,QLIQ,QICE
4276 REAL :: C5, RV, ES, QS, PI, THTGS, ESLIQ, ESICE, F0, T1, T0, &
4277 F1, DT, QNEW, QTOT, DQICE, DQLIQ, RLL, CP, dq
4279 !-----------------------------------------------------------------------
4281 !...THIS SUBROUTINE ITERATIVELY EXTRACTS WET-BULB TEMPERATURE FROM EQUIV
4282 ! POTENTIAL TEMPERATURE, THEN CHECKS TO SEE IF SUFFICIENT MOISTURE IS
4283 ! AVAILABLE TO ACHIEVE SATURATION...IF NOT, TEMPERATURE IS ADJUSTED
4284 ! ACCORDINGLY, IF SO, THE RESIDUAL LIQUID WATER/ICE CONCENTRATION IS
4290 ! ITERATE TO FIND WET BULB TEMPERATURE AS A FUNCTION OF EQUIVALENT POT
4291 ! TEMP AND PRS, ASSUMING SATURATION VAPOR PRESSURE...RATIO2 IS THE DEG
4294 IF(RATIO2.LT.1.E-6)THEN
4295 ! ES=ALIQ*EXP((BLIQ*TU-CLIQ)/(TU-DLIQ))
4296 ES=1.E3*SVP1*EXP(SVP2*(TU-SVPT0)/(TU-SVP3))
4298 PI=(1.E5/P)**(0.2854*(1.-0.28*QS))
4299 THTGS=TU*PI*EXP((3374.6525/TU-2.5403)*QS*(1.+0.81*QS))
4300 ELSEIF(ABS(RATIO2-1.).LT.1.E-6)THEN
4301 ! ES=AICE*EXP((BICE*TU-CICE)/(TU-DICE))
4302 ES=611.0*EXP(22.514-6.15E3/TU)
4304 PI=(1.E5/P)**(0.2854*(1.-0.28*QS))
4305 THTGS=TU*PI*EXP((3114.834/TU-0.278296)*QS*(1.+0.81*QS))
4307 ! ESLIQ=ALIQ*EXP((BLIQ*TU-CLIQ)/(TU-DLIQ))
4308 ! ESICE=AICE*EXP((BICE*TU-CICE)/(TU-DICE))
4309 ESLIQ=1.E3*SVP1*EXP(SVP2*(TU-SVPT0)/(TU-SVP3))
4310 ESICE=611.0*EXP(22.514-6.15E3/TU)
4311 ES=(1.-RATIO2)*ESLIQ+RATIO2*ESICE
4313 PI=(1.E5/P)**(0.2854*(1.-0.28*QS))
4314 THTGS=TU*PI*EXP(RL*QS*C5/TU*(1.+0.81*QS))
4320 90 IF(RATIO2.LT.1.E-6)THEN
4321 ! ES=ALIQ*EXP((BLIQ*T1-CLIQ)/(T1-DLIQ))
4322 ES=1.E3*SVP1*EXP(SVP2*(T1-SVPT0)/(T1-SVP3))
4324 PI=(1.E5/P)**(0.2854*(1.-0.28*QS))
4325 THTGS=T1*PI*EXP((3374.6525/T1-2.5403)*QS*(1.+0.81*QS))
4326 ELSEIF(ABS(RATIO2-1.).LT.1.E-6)THEN
4327 ! ES=AICE*EXP((BICE*T1-CICE)/(T1-DICE))
4328 ES=611.0*EXP(22.514-6.15E3/T1)
4330 PI=(1.E5/P)**(0.2854*(1.-0.28*QS))
4331 THTGS=T1*PI*EXP((3114.834/T1-0.278296)*QS*(1.+0.81*QS))
4333 ! ESLIQ=ALIQ*EXP((BLIQ*T1-CLIQ)/(T1-DLIQ))
4334 ! ESICE=AICE*EXP((BICE*T1-CICE)/(T1-DICE))
4335 ESLIQ=1.E3*SVP1*EXP(SVP2*(T1-SVPT0)/(T1-SVP3))
4336 ESICE=611.0*EXP(22.514-6.15E3/T1)
4337 ES=(1.-RATIO2)*ESLIQ+RATIO2*ESICE
4339 PI=(1.E5/P)**(0.2854*(1.-0.28*QS))
4340 THTGS=T1*PI*EXP(RL*QS*C5/T1*(1.+0.81*QS))
4343 IF(ABS(F1).LT.0.01)GOTO 50
4345 IF(ITCNT.GT.10)GOTO 50
4346 DT=F1*(T1-T0)/(F1-F0)
4352 ! IF THE PARCEL IS SUPERSATURATED, CALCULATE CONCENTRATION OF FRESH
4361 ! IF THE PARCEL IS SUBSATURATED, TEMPERATURE AND MIXING RATIO MUST BE
4362 ! ADJUSTED...IF LIQUID WATER OR ICE IS PRESENT, IT IS ALLOWED TO EVAPO
4369 ! IF THERE IS ENOUGH LIQUID OR ICE TO SATURATE THE PARCEL, TEMP STAYS
4370 ! WET BULB VALUE, VAPOR MIXING RATIO IS AT SATURATED LEVEL, AND THE MI
4371 ! RATIOS OF LIQUID AND ICE ARE ADJUSTED TO MAKE UP THE ORIGINAL SATURA
4372 ! DEFICIT... OTHERWISE, ANY AVAILABLE LIQ OR ICE VAPORIZES AND APPROPR
4373 ! ADJUSTMENTS TO PARCEL TEMP; VAPOR, LIQUID, AND ICE MIXING RATIOS ARE
4375 !...NOTE THAT THE LIQ AND ICE MAY BE PRESENT IN PROPORTIONS SLIGHTLY DIF
4376 ! THAN SUGGESTED BY THE VALUE OF RATIO2...CHECK TO MAKE SURE THAT LIQ
4377 ! ICE CONCENTRATIONS ARE NOT REDUCED TO BELOW ZERO WHEN EVAPORATION/
4378 ! SUBLIMATION OCCURS...
4383 QLIQ=QLIQ-(1.-RATIO2)*DQ
4388 QICE=QICE-RATIO2*DQ+DQICE
4397 IF(RATIO2.LT.1.E-6)THEN
4399 ELSEIF(ABS(RATIO2-1.).LT.1.E-6)THEN
4404 CP=1005.7*(1.+0.89*QU)
4405 IF(QTOT.LT.1.E-10)THEN
4407 !...IF NO LIQUID WATER OR ICE IS AVAILABLE, TEMPERATURE IS GIVEN BY:
4408 T1=T1+RLL*(DQ/(1.+DQ))/CP
4412 !...IF SOME LIQ WATER/ICE IS AVAILABLE, BUT NOT ENOUGH TO ACHIEVE SATURA
4413 ! THE TEMPERATURE IS GIVEN BY:
4414 T1=T1+RLL*((DQ-QTOT)/(1+DQ-QTOT))/CP
4422 QNEWLQ=(1.-RATIO2)*QNEW
4424 ! IF(ITCNT.GT.10)PRINT*,'***** NUMBER OF ITERATIONS IN TPMIX =',
4427 END SUBROUTINE TPMIX
4429 !===============================================================================
4431 SUBROUTINE TPMIX2(p,thes,tu,qu,qliq,qice,qnewlq,qnewic,XLV1,XLV0,ktau,i,j,nk,tracker)
4433 ! Lookup table variables:
4434 ! INTEGER, PARAMETER :: (KFNT=250,KFNP=220)
4435 ! REAL, SAVE, DIMENSION(1:KFNT,1:KFNP) :: TTAB,QSTAB
4436 ! REAL, SAVE, DIMENSION(1:KFNP) :: THE0K
4437 ! REAL, SAVE, DIMENSION(1:200) :: ALU
4438 ! REAL, SAVE :: RDPR,RDTHK,PLUTOP
4439 ! End of Lookup table variables:
4440 !-----------------------------------------------------------------------
4442 !-----------------------------------------------------------------------
4443 REAL, INTENT(IN ) :: P,THES,XLV1,XLV0
4444 REAL, INTENT(OUT ) :: QNEWLQ,QNEWIC
4445 REAL, INTENT(INOUT) :: TU,QU,QLIQ,QICE
4446 REAL :: TP,QQ,BTH,TTH,PP,T00,T10,T01,T11,Q00,Q10,Q01,Q11, &
4447 TEMP,QS,QNEW,DQ,QTOT,RLL,CPP
4448 INTEGER :: IPTB,ITHTB
4449 INTEGER, INTENT(IN ) :: ktau,i,j,nk,tracker ! aj
4450 !-----------------------------------------------------------------------
4452 !c******** LOOKUP TABLE VARIABLES... ****************************
4453 ! parameter(kfnt=250,kfnp=220)
4455 ! COMMON/KFLUT/ ttab(kfnt,kfnp),qstab(kfnt,kfnp),the0k(kfnp),
4456 ! * alu(200),rdpr,rdthk,plutop
4457 !C***************************************************************
4459 !c***********************************************************************
4460 !c scaling pressure and tt table index
4461 !c***********************************************************************
4468 !***********************************************************************
4469 ! base and scaling factor for the
4470 !***********************************************************************
4472 ! scaling the and tt table index
4473 bth=(the0k(iptb+1)-the0k(iptb))*qq+the0k(iptb)
4474 tth=(thes-bth)*rdthk
4477 IF(IPTB.GE.220 .OR. IPTB.LE.1 .OR. ITHTB.GE.250 .OR. ITHTB.LE.1)THEN
4478 write(98,'(a,6i5,2f9.2,i3)')'*** OUT OF BOUNDS ***', ktau,i,j,nk,IPTB, ITHTB, &
4479 p/100.0, thes, tracker
4483 t00=ttab(ithtb ,iptb )
4484 t10=ttab(ithtb+1,iptb )
4485 t01=ttab(ithtb ,iptb+1)
4486 t11=ttab(ithtb+1,iptb+1)
4488 q00=qstab(ithtb ,iptb )
4489 q10=qstab(ithtb+1,iptb )
4490 q01=qstab(ithtb ,iptb+1)
4491 q11=qstab(ithtb+1,iptb+1)
4493 !***********************************************************************
4494 ! parcel temperature
4495 !***********************************************************************
4497 temp=(t00+(t10-t00)*pp+(t01-t00)*qq+(t00-t10-t01+t11)*pp*qq)
4499 qs=(q00+(q10-q00)*pp+(q01-q00)*qq+(q00-q10-q01+q11)*pp*qq)
4507 ! IF THE PARCEL IS SUBSATURATED, TEMPERATURE AND MIXING RATIO MUST BE
4508 ! ADJUSTED...IF LIQUID WATER IS PRESENT, IT IS ALLOWED TO EVAPORATE
4513 ! IF THERE IS ENOUGH LIQUID OR ICE TO SATURATE THE PARCEL, TEMP STAYS AT ITS
4514 ! WET BULB VALUE, VAPOR MIXING RATIO IS AT SATURATED LEVEL, AND THE MIXING
4515 ! RATIOS OF LIQUID AND ICE ARE ADJUSTED TO MAKE UP THE ORIGINAL SATURATION
4516 ! DEFICIT... OTHERWISE, ANY AVAILABLE LIQ OR ICE VAPORIZES AND APPROPRIATE
4517 ! ADJUSTMENTS TO PARCEL TEMP; VAPOR, LIQUID, AND ICE MIXING RATIOS ARE MADE.
4519 !...subsaturated values only occur in calculations involving various mixtures of
4520 !...updraft and environmental air for estimation of entrainment and detrainment.
4521 !...For these purposes, assume that reasonable estimates can be given using
4522 !...liquid water saturation calculations only - i.e., ignore the effect of the
4523 !...ice phase in this process only...will not affect conservative properties...
4526 qliq=qliq-dq*qliq/(qtot+1.e-10)
4527 qice=qice-dq*qice/(qtot+1.e-10)
4531 CPP=1004.5*(1.+0.89*QU)
4532 IF(QTOT.LT.1.E-10)THEN
4534 !...IF NO LIQUID WATER OR ICE IS AVAILABLE, TEMPERATURE IS GIVEN BY:
4535 TEMP=TEMP+RLL*(DQ/(1.+DQ))/CPP
4538 !...IF SOME LIQ WATER/ICE IS AVAILABLE, BUT NOT ENOUGH TO ACHIEVE SATURATION,
4539 ! THE TEMPERATURE IS GIVEN BY:
4541 TEMP=TEMP+RLL*((DQ-QTOT)/(1+DQ-QTOT))/CPP
4553 END SUBROUTINE TPMIX2
4555 !===============================================================================
4556 SUBROUTINE TPMIXBG(P,THTU,TU,QU,QLIQ,QICE,QNEWLQ,QNEWIC,RATIO2,RL, &
4557 XLV0,XLV1,XLS0,XLS1, &
4558 ! ALIQ,BLIQ,CLIQ,DLIQ,AICE,BICE,CICE,DICE, &
4559 SVP1,SVP2,SVPT0,SVP3)
4560 !-----------------------------------------------------------------------
4562 !-----------------------------------------------------------------------
4563 REAL, INTENT(IN ) :: P,THTU,RATIO2,RL, &
4564 XLV0,XLV1,XLS0,XLS1,SVP1,SVP2,SVPT0,SVP3
4565 REAL, INTENT( OUT) :: QNEWLQ,QNEWIC
4566 REAL, INTENT(INOUT) :: TU,QU,QLIQ,QICE
4567 REAL :: C5, RV, ES, QS, PI, THTGS, ESLIQ, ESICE, F0, T1, T0, &
4568 F1, DT, QNEW, QTOT, DQICE, DQLIQ, RLL, CP, dq
4571 !-----------------------------------------------------------------------
4573 !...THIS SUBROUTINE ITERATIVELY EXTRACTS WET-BULB TEMPERATURE FROM EQUIV
4574 ! POTENTIAL TEMPERATURE, THEN CHECKS TO SEE IF SUFFICIENT MOISTURE IS
4575 ! AVAILABLE TO ACHIEVE SATURATION...IF NOT, TEMPERATURE IS ADJUSTED
4576 ! ACCORDINGLY, IF SO, THE RESIDUAL LIQUID WATER/ICE CONCENTRATION IS
4579 ! Modified BJG 1/17/2014
4585 tu = thtu / (1.e5/p) ** 0.2854
4589 ! ITERATE TO FIND WET BULB TEMPERATURE AS A FUNCTION OF EQUIVALENT POT
4590 ! TEMP AND PRS, ASSUMING SATURATION VAPOR PRESSURE...RATIO2 IS THE DEG
4593 IF(RATIO2.LT.1.E-6)THEN
4594 ! ES=ALIQ*EXP((BLIQ*TU-CLIQ)/(TU-DLIQ))
4595 ES=1.E3*SVP1*EXP(SVP2*(TU-SVPT0)/(TU-SVP3))
4597 PI=(1.E5/P)**(0.2854*(1.-0.28*QS))
4598 THTGS=TU*PI*EXP((3374.6525/TU-2.5403)*QS*(1.+0.81*QS))
4599 ELSEIF(ABS(RATIO2-1.).LT.1.E-6)THEN
4600 ! ES=AICE*EXP((BICE*TU-CICE)/(TU-DICE))
4601 ES=611.0*EXP(22.514-6.15E3/TU)
4603 PI=(1.E5/P)**(0.2854*(1.-0.28*QS))
4604 THTGS=TU*PI*EXP((3114.834/TU-0.278296)*QS*(1.+0.81*QS))
4606 ! ESLIQ=ALIQ*EXP((BLIQ*TU-CLIQ)/(TU-DLIQ))
4607 ! ESICE=AICE*EXP((BICE*TU-CICE)/(TU-DICE))
4608 ESLIQ=1.E3*SVP1*EXP(SVP2*(TU-SVPT0)/(TU-SVP3))
4609 ESICE=611.0*EXP(22.514-6.15E3/TU)
4610 ES=(1.-RATIO2)*ESLIQ+RATIO2*ESICE
4612 PI=(1.E5/P)**(0.2854*(1.-0.28*QS))
4613 THTGS=TU*PI*EXP(RL*QS*C5/TU*(1.+0.81*QS))
4625 90 IF(RATIO2.LT.1.E-6)THEN
4626 ! ES=ALIQ*EXP((BLIQ*T1-CLIQ)/(T1-DLIQ))
4627 ES=1.E3*SVP1*EXP(SVP2*(t2-SVPT0)/(t2-SVP3))
4629 PI=(1.E5/P)**(0.2854*(1.-0.28*QS))
4630 THTGS=t2*PI*EXP((3374.6525/t2-2.5403)*QS*(1.+0.81*QS))
4631 ELSEIF(ABS(RATIO2-1.).LT.1.E-6)THEN
4632 ! ES=AICE*EXP((BICE*T1-CICE)/(T1-DICE))
4633 ES=611.0*EXP(22.514-6.15E3/t2)
4635 PI=(1.E5/P)**(0.2854*(1.-0.28*QS))
4636 THTGS=t2*PI*EXP((3114.834/t2-0.278296)*QS*(1.+0.81*QS))
4638 ! ESLIQ=ALIQ*EXP((BLIQ*T1-CLIQ)/(T1-DLIQ))
4639 ! ESICE=AICE*EXP((BICE*T1-CICE)/(T1-DICE))
4640 ESLIQ=1.E3*SVP1*EXP(SVP2*(t2-SVPT0)/(t2-SVP3))
4641 ESICE=611.0*EXP(22.514-6.15E3/t2)
4642 ES=(1.-RATIO2)*ESLIQ+RATIO2*ESICE
4644 PI=(1.E5/P)**(0.2854*(1.-0.28*QS))
4645 THTGS=t2*PI*EXP(RL*QS*C5/t2*(1.+0.81*QS))
4649 if((f1 * f2).lt.0.0) then
4659 IF(ABS(F1).LT.0.01)GOTO 50
4661 IF(ITCNT.GT.10)GOTO 50
4662 DT=F1*(T1-T0)/(F1-F0)
4664 if(abs(dt).lt.abs( (t1-t0)/2.0 )) then
4665 dt = (t1 - t0) / 2.0
4673 ! IF THE PARCEL IS SUPERSATURATED, CALCULATE CONCENTRATION OF FRESH
4682 ! IF THE PARCEL IS SUBSATURATED, TEMPERATURE AND MIXING RATIO MUST BE
4683 ! ADJUSTED...IF LIQUID WATER OR ICE IS PRESENT, IT IS ALLOWED TO EVAPO
4690 ! IF THERE IS ENOUGH LIQUID OR ICE TO SATURATE THE PARCEL, TEMP STAYS
4691 ! WET BULB VALUE, VAPOR MIXING RATIO IS AT SATURATED LEVEL, AND THE MI
4692 ! RATIOS OF LIQUID AND ICE ARE ADJUSTED TO MAKE UP THE ORIGINAL SATURA
4693 ! DEFICIT... OTHERWISE, ANY AVAILABLE LIQ OR ICE VAPORIZES AND APPROPR
4694 ! ADJUSTMENTS TO PARCEL TEMP; VAPOR, LIQUID, AND ICE MIXING RATIOS ARE
4696 !...NOTE THAT THE LIQ AND ICE MAY BE PRESENT IN PROPORTIONS SLIGHTLY DIF
4697 ! THAN SUGGESTED BY THE VALUE OF RATIO2...CHECK TO MAKE SURE THAT LIQ
4698 ! ICE CONCENTRATIONS ARE NOT REDUCED TO BELOW ZERO WHEN EVAPORATION/
4699 ! SUBLIMATION OCCURS...
4704 QLIQ=QLIQ-(1.-RATIO2)*DQ
4709 QICE=QICE-RATIO2*DQ+DQICE
4718 IF(RATIO2.LT.1.E-6)THEN
4720 ELSEIF(ABS(RATIO2-1.).LT.1.E-6)THEN
4725 CP=1005.7*(1.+0.89*QU)
4726 IF(QTOT.LT.1.E-10)THEN
4728 !...IF NO LIQUID WATER OR ICE IS AVAILABLE, TEMPERATURE IS GIVEN BY:
4729 T1=T1+RLL*(DQ/(1.+DQ))/CP
4733 !...IF SOME LIQ WATER/ICE IS AVAILABLE, BUT NOT ENOUGH TO ACHIEVE SATURA
4734 ! THE TEMPERATURE IS GIVEN BY:
4735 T1=T1+RLL*((DQ-QTOT)/(1+DQ-QTOT))/CP
4743 QNEWLQ=(1.-RATIO2)*QNEW
4745 ! IF(ITCNT.GT.10)PRINT*,'***** NUMBER OF ITERATIONS IN TPMIX =',
4748 END SUBROUTINE TPMIXBG
4750 !===============================================================================
4751 SUBROUTINE TPMIX2DD(p,thes,ts,qs,ktau,i,j,nk)
4753 ! Lookup table variables:
4754 ! INTEGER, PARAMETER :: (KFNT=250,KFNP=220)
4755 ! REAL, SAVE, DIMENSION(1:KFNT,1:KFNP) :: TTAB,QSTAB
4756 ! REAL, SAVE, DIMENSION(1:KFNP) :: THE0K
4757 ! REAL, SAVE, DIMENSION(1:200) :: ALU
4758 ! REAL, SAVE :: RDPR,RDTHK,PLUTOP
4759 ! End of Lookup table variables:
4760 !-----------------------------------------------------------------------
4762 !-----------------------------------------------------------------------
4763 REAL, INTENT(IN ) :: P,THES
4764 REAL, INTENT(INOUT) :: TS,QS
4765 INTEGER, INTENT(IN ) :: ktau,i,j,nk ! avail for debugging aj
4766 REAL :: TP,QQ,BTH,TTH,PP,T00,T10,T01,T11,Q00,Q10,Q01,Q11
4767 INTEGER :: IPTB,ITHTB
4768 CHARACTER*256 :: MESS
4769 !-----------------------------------------------------------------------
4772 !******** LOOKUP TABLE VARIABLES (F77 format)... ****************************
4773 ! parameter(kfnt=250,kfnp=220)
4775 ! COMMON/KFLUT/ ttab(kfnt,kfnp),qstab(kfnt,kfnp),the0k(kfnp), &
4776 ! alu(200),rdpr,rdthk,plutop
4777 !***************************************************************
4779 !***********************************************************************
4780 ! scaling pressure and tt table index
4781 !***********************************************************************
4787 !***********************************************************************
4788 ! base and scaling factor for the
4789 !***********************************************************************
4791 ! scaling the and tt table index
4792 bth=(the0k(iptb+1)-the0k(iptb))*qq+the0k(iptb)
4793 tth=(thes-bth)*rdthk
4796 IF(IPTB.GE.220 .OR. IPTB.LE.1 .OR. ITHTB.GE.250 .OR. ITHTB.LE.1)THEN
4797 write(97,'(a,6i5,2f9.2)')'*** OUT OF BOUNDS ***', ktau,i,j,nk,IPTB, ITHTB, p/100., thes
4801 t00=ttab(ithtb ,iptb )
4802 t10=ttab(ithtb+1,iptb )
4803 t01=ttab(ithtb ,iptb+1)
4804 t11=ttab(ithtb+1,iptb+1)
4806 q00=qstab(ithtb ,iptb )
4807 q10=qstab(ithtb+1,iptb )
4808 q01=qstab(ithtb ,iptb+1)
4809 q11=qstab(ithtb+1,iptb+1)
4811 !***********************************************************************
4812 ! parcel temperature and saturation mixing ratio
4813 !***********************************************************************
4815 ts=(t00+(t10-t00)*pp+(t01-t00)*qq+(t00-t10-t01+t11)*pp*qq)
4817 qs=(q00+(q10-q00)*pp+(q01-q00)*qq+(q00-q10-q01+q11)*pp*qq)
4819 END SUBROUTINE TPMIX2DD
4821 !===============================================================================
4823 REAL FUNCTION GAMMA(X)
4824 !D DOUBLE PRECISION FUNCTION DGAMMA(X)
4825 !-----------------------------------------------------------------------
4827 !-----------------------------------------------------------------------
4828 REAL, INTENT(IN ) :: X
4829 ! REAL, INTENT( OUT) :: GAMMA
4830 !----------------------------------------------------------------------
4832 ! THIS ROUTINE CALCULATES THE GAMMA FUNCTION FOR A REAL ARGUMENT X.
4833 ! COMPUTATION IS BASED ON AN ALGORITHM OUTLINED IN REFERENCE 1.
4834 ! THE PROGRAM USES RATIONAL FUNCTIONS THAT APPROXIMATE THE GAMMA
4835 ! FUNCTION TO AT LEAST 20 SIGNIFICANT DECIMAL DIGITS. COEFFICIENTS
4836 ! FOR THE APPROXIMATION OVER THE INTERVAL (1,2) ARE UNPUBLISHED.
4837 ! THOSE FOR THE APPROXIMATION FOR X .GE. 12 ARE FROM REFERENCE 2.
4838 ! THE ACCURACY ACHIEVED DEPENDS ON THE ARITHMETIC SYSTEM, THE
4839 ! COMPILER, THE INTRINSIC FUNCTIONS, AND PROPER SELECTION OF THE
4840 ! MACHINE-DEPENDENT CONSTANTS.
4843 !*******************************************************************
4844 !*******************************************************************
4846 ! EXPLANATION OF MACHINE-DEPENDENT CONSTANTS
4848 ! BETA - RADIX FOR THE FLOATING-POINT REPRESENTATION
4849 ! MAXEXP - THE SMALLEST POSITIVE POWER OF BETA THAT OVERFLOWS
4850 ! XBIG - THE LARGEST ARGUMENT FOR WHICH GAMMA(X) IS REPRESENTABLE
4851 ! IN THE MACHINE, I.E., THE SOLUTION TO THE EQUATION
4852 ! GAMMA(XBIG) = BETA**MAXEXP
4853 ! XINF - THE LARGEST MACHINE REPRESENTABLE FLOATING-POINT NUMBER;
4854 ! APPROXIMATELY BETA**MAXEXP
4855 ! EPS - THE SMALLEST POSITIVE FLOATING-POINT NUMBER SUCH THAT
4857 ! XMININ - THE SMALLEST POSITIVE FLOATING-POINT NUMBER SUCH THAT
4858 ! 1/XMININ IS MACHINE REPRESENTABLE
4860 ! APPROXIMATE VALUES FOR SOME IMPORTANT MACHINES ARE:
4864 ! CRAY-1 (S.P.) 2 8191 966.961
4866 ! UNDER NOS (S.P.) 2 1070 177.803
4868 ! SUN, ETC.) (S.P.) 2 128 35.040
4870 ! SUN, ETC.) (D.P.) 2 1024 171.624
4871 ! IBM 3033 (D.P.) 16 63 57.574
4872 ! VAX D-FORMAT (D.P.) 2 127 34.844
4873 ! VAX G-FORMAT (D.P.) 2 1023 171.489
4877 ! CRAY-1 (S.P.) 5.45E+2465 7.11E-15 1.84E-2466
4879 ! UNDER NOS (S.P.) 1.26E+322 3.55E-15 3.14E-294
4881 ! SUN, ETC.) (S.P.) 3.40E+38 1.19E-7 1.18E-38
4883 ! SUN, ETC.) (D.P.) 1.79D+308 2.22D-16 2.23D-308
4884 ! IBM 3033 (D.P.) 7.23D+75 2.22D-16 1.39D-76
4885 ! VAX D-FORMAT (D.P.) 1.70D+38 1.39D-17 5.88D-39
4886 ! VAX G-FORMAT (D.P.) 8.98D+307 1.11D-16 1.12D-308
4888 !**************************************************************
4889 !*************************************************************
4893 ! THE PROGRAM RETURNS THE VALUE XINF FOR SINGULARITIES OR
4894 ! WHEN OVERFLOW WOULD OCCUR. THE COMPUTATION IS BELIEVED
4895 ! TO BE FREE OF UNDERFLOW AND OVERFLOW.
4898 ! INTRINSIC FUNCTIONS REQUIRED ARE:
4900 ! INT, DBLE, EXP, LOG, REAL, SIN
4903 ! REFERENCES: `AN OVERVIEW OF SOFTWARE DEVELOPMENT FOR SPECIAL
4904 ! FUNCTIONS`, W. J. CODY, LECTURE NOTES IN MATHEMATICS,
4905 ! 506, NUMERICAL ANALYSIS DUNDEE, 1975, G. A. WATSON
4906 ! (ED.), SPRINGER VERLAG, BERLIN, 1976.
4908 ! COMPUTER APPROXIMATIONS, HART, ET. AL., WILEY AND
4909 ! SONS, NEW YORK, 1968.
4911 ! LATEST MODIFICATION: OCTOBER 12, 1989
4913 ! AUTHORS: W. J. CODY AND L. STOLTZ
4914 ! APPLIED MATHEMATICS DIVISION
4915 ! ARGONNE NATIONAL LABORATORY
4918 !------------------------------------------------------
4923 C,CONV,EPS,FACT,HALF,ONE,P,PI,Q,RES,SQRTPI,SUM,TWELVE, &
4924 TWO,XBIG,XDEN,XINF,XMININ,XNUM,Y,Y1,YSQ,Z,ZERO
4925 DIMENSION C(7),P(8),Q(8)
4926 !-------------------------------------------------------------
4927 ! MATHEMATICAL CONSTANTS
4928 !-----------------------------------------------------------
4929 DATA ONE,HALF,TWELVE,TWO,ZERO/1.0E0,0.5E0,12.0E0,2.0E0,0.0E0/, &
4930 SQRTPI/0.9189385332046727417803297E0/, &
4931 PI/3.1415926535897932384626434E0/
4932 !D DATA ONE,HALF,TWELVE,TWO,ZERO/1.0D0,0.5D0,12.0D0,2.0D0,0.0D0/,
4933 !D 1 SQRTPI/0.9189385332046727417803297D0/,
4934 !D 2 PI/3.1415926535897932384626434D0/
4935 !----------------------------------------------------------------
4936 ! MACHINE DEPENDENT PARAMETERS
4937 !--------------------------------------------------------------
4938 DATA XBIG,XMININ,EPS/35.040E0,1.18E-38,1.19E-7/, &
4940 !D DATA XBIG,XMININ,EPS/171.624D0,2.23D-308,2.22D-16/,
4942 !---------------------------------------------------------
4943 ! NUMERATOR AND DENOMINATOR COEFFICIENTS FOR RATIONAL MINIMAX
4944 ! APPROXIMATION OVER (1,2).
4945 !-----------------------------------------------------------
4946 DATA P/-1.71618513886549492533811E+0,2.47656508055759199108314E+1, &
4947 -3.79804256470945635097577E+2,6.29331155312818442661052E+2, &
4948 8.66966202790413211295064E+2,-3.14512729688483675254357E+4, &
4949 -3.61444134186911729807069E+4,6.64561438202405440627855E+4/
4950 DATA Q/-3.08402300119738975254353E+1,3.15350626979604161529144E+2, &
4951 -1.01515636749021914166146E+3,-3.10777167157231109440444E+3, &
4952 2.25381184209801510330112E+4,4.75584627752788110767815E+3, &
4953 -1.34659959864969306392456E+5,-1.15132259675553483497211E+5/
4954 !D DATA P/-1.71618513886549492533811D+0,2.47656508055759199108314D+1,
4955 !D 1 -3.79804256470945635097577D+2,6.29331155312818442661052D+2,
4956 !D 2 8.66966202790413211295064D+2,-3.14512729688483675254357D+4,
4957 !D 3 -3.61444134186911729807069D+4,6.64561438202405440627855D+4/
4958 !D DATA Q/-3.08402300119738975254353D+1,3.15350626979604161529144D+2,
4959 !D 1 -1.01515636749021914166146D+3,-3.10777167157231109440444D+3,
4960 !D 2 2.25381184209801510330112D+4,4.75584627752788110767815D+3,
4961 !D 3 -1.34659959864969306392456D+5,-1.15132259675553483497211D+5/
4962 !----------------------------------------------------------------------
4963 ! COEFFICIENTS FOR MINIMAX APPROXIMATION OVER (12, INF).
4964 !--------------------------------------------------------------------
4965 DATA C/-1.910444077728E-03,8.4171387781295E-04, &
4966 -5.952379913043012E-04,7.93650793500350248E-04, &
4967 -2.777777777777681622553E-03,8.333333333333333331554247E-02, &
4969 !D DATA C/-1.910444077728D-03,8.4171387781295D-04,
4970 !D 1 -5.952379913043012D-04,7.93650793500350248D-04,
4971 !D 2 -2.777777777777681622553D-03,8.333333333333333331554247D-02,
4972 !D 3 5.7083835261D-03/
4973 !--------------------------------------------------------------------
4974 ! STATEMENT FUNCTIONS FOR CONVERSION BETWEEN INTEGER AND FLOAT
4975 !------------------------------------------------------------------
4977 !D CONV(I) = DBLE(I)
4983 !----------------------------------------------------------
4984 ! ARGUMENT IS NEGATIVE
4985 !--------------------------------------------------------
4990 IF(Y1.NE.AINT(Y1*HALF)*TWO)PARITY=.TRUE.
4991 FACT=-PI/SIN(PI*RES)
4998 !-------------------------------------------
4999 ! ARGUMENT IS POSITIVE
5000 !-----------------------------------------
5002 !---------------------------------------
5004 !-------------------------------------
5011 ELSEIF(Y.LT.TWELVE)THEN
5014 !---------------------------
5015 ! 0.0 .LT. ARGUMENT .LT. 1.0
5016 !--------------------------
5020 !--------------------------
5021 ! 1.0 .LT. ARGUMENT .LT. 12.0, REDUCE ARGUMENT IF NECESSARY
5022 !-----------------------------------------------------------
5027 !------------------------------------------------------
5028 ! EVALUATE APPROXIMATION FOR 1.0 .LT. ARGUMENT .LT. 2.0
5029 !-----------------------------------------------------
5038 !-----------------------------------------------
5039 ! ADJUST RESULT FOR CASE 0.0 .LT. ARGUMENT .LT. 1.0
5040 !----------------------------------------------
5043 !-------------------------------------------------
5044 ! ADJUST RESULT FOR CASE 2.0 .LT. ARGUMENT .LT. 12.0
5045 !------------------------------------------------
5052 !----------------------------------------------
5053 ! EVALUATE FOR ARGUMENT .GE. 12.0,
5054 !--------------------------------------------
5062 SUM=SUM+(Y-HALF)*LOG(Y)
5069 !-----------------------------
5070 ! FINAL ADJUSTMENTS AND RETURN
5071 !------------------------------
5073 IF(FACT.NE.ONE)RES=FACT/RES
5077 ! ---------- LAST LINE OF GAMMA -
5079 !====================================================================
5080 SUBROUTINE MINIM(ARRAY,KDIM,KS,KEND,KT)
5081 DIMENSION ARRAY(KDIM)
5086 IF(ARRAY(K).LT.X)THEN
5092 END SUBROUTINE MINIM
5093 !====================================================================
5094 SUBROUTINE MAXIM(ARRAY,KDIM,KS,KE,MAX)
5095 DIMENSION ARRAY(KDIM)
5107 END SUBROUTINE MAXIM
5108 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
5110 ! Interpolating from p surface to sigma surface
5111 subroutine interp1d(pp,p,datain,dataout,kl,km)
5113 !CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
5115 !---------------------------------
5116 INTEGER, INTENT(IN ) :: kl, km
5117 REAL, dimension(km), INTENT(IN ) :: p, datain
5118 REAL, dimension(kl), INTENT(IN ) :: pp
5119 REAL, dimension(kl), INTENT( OUT) :: dataout
5121 INTEGER :: i, j, k1, k2, kmin
5122 REAL :: pmin, pdif, pmindif
5128 if( abs( pdif ) .le. pmin ) then
5135 if( pmindif .le. 0.0 ) then
5143 dataout(i) = (datain(k2)-datain(k1))/LOG(p(k2)/p(k1)) &
5144 *LOG(pp(i)/p(k1))+datain(k1)
5148 end subroutine interp1d
5149 !====================================================================
5152 subroutine kf_lutab(SVP1,SVP2,SVP3,SVPT0)
5154 ! This subroutine is a lookup table.
5155 ! Given a series of series of saturation equivalent potential
5156 ! temperatures, the temperature is calculated.
5158 !--------------------------------------------------------------------
5160 !--------------------------------------------------------------------
5161 ! Lookup table variables
5162 ! INTEGER, SAVE, PARAMETER :: KFNT=250,KFNP=220
5163 ! REAL, SAVE, DIMENSION(1:KFNT,1:KFNP) :: TTAB,QSTAB
5164 ! REAL, SAVE, DIMENSION(1:KFNP) :: THE0K
5165 ! REAL, SAVE, DIMENSION(1:200) :: ALU
5166 ! REAL, SAVE :: RDPR,RDTHK,PLUTOP
5167 ! End of Lookup table variables
5169 INTEGER :: KP,IT,ITCNT,I
5170 REAL :: DTH,TMIN,TOLER,PBOT,DPR, &
5171 TEMP,P,ES,QS,PI,THES,TGUES,THGUES,F0,T1,T0,THGS,F1,DT, &
5173 ! REAL :: ALIQ,BLIQ,CLIQ,DLIQ,SVP1,SVP2,SVP3,SVPT0
5174 REAL :: ALIQ,BLIQ,CLIQ,DLIQ
5175 REAL, INTENT(IN) :: SVP1,SVP2,SVP3,SVPT0
5177 ! equivalent potential temperature increment
5179 ! minimum starting temp
5181 ! tolerance for accuracy of temperature
5183 ! top pressure (pascals)
5185 ! bottom pressure (pascals)
5194 ! compute parameters
5196 ! 1._over_(sat. equiv. theta increment)
5198 ! pressure increment
5200 DPR=(PBOT-PLUTOP)/REAL(KFNP-1)
5201 ! dpr=(pbot-plutop)/REAL(kfnp-1)
5202 ! 1._over_(pressure increment)
5204 ! compute the spread of thes
5205 ! thespd=dth*(kfnt-1)
5207 ! calculate the starting sat. equiv. theta
5213 es=aliq*exp((bliq*temp-cliq)/(temp-dliq))
5215 pi=(1.e5/p)**(0.2854*(1.-0.28*qs))
5216 the0k(kp)=temp*pi*exp((3374.6525/temp-2.5403)*qs* &
5220 ! compute temperatures for each sat. equiv. potential temp.
5227 ! define sat. equiv. pot. temp.
5229 ! iterate to find temperature
5230 ! find initial guess
5236 es=aliq*exp((bliq*tgues-cliq)/(tgues-dliq))
5238 pi=(1.e5/p)**(0.2854*(1.-0.28*qs))
5239 thgues=tgues*pi*exp((3374.6525/tgues-2.5403)*qs* &
5247 es=aliq*exp((bliq*t1-cliq)/(t1-dliq))
5249 pi=(1.e5/p)**(0.2854*(1.-0.28*qs))
5250 thtgs=t1*pi*exp((3374.6525/t1-2.5403)*qs*(1.+0.81*qs))
5252 if(abs(f1).lt.toler)then
5256 dt=f1*(t1-t0)/(f1-f0)
5266 ! lookup table for tlog(emix/aliq)
5268 ! set up intial values for lookup tables
5279 END SUBROUTINE KF_LUTAB
5281 !====================================================================
5282 subroutine kf_lutabbg(SVP1,SVP2,SVP3,SVPT0)
5284 ! This subroutine is a lookup table.
5285 ! Given a series of series of saturation equivalent potential
5286 ! temperatures, the temperature is calculated.
5288 !--------------------------------------------------------------------
5290 !--------------------------------------------------------------------
5291 ! Lookup table variables
5292 ! INTEGER, SAVE, PARAMETER :: KFNT=250,KFNP=220
5293 ! REAL, SAVE, DIMENSION(1:KFNT,1:KFNP) :: TTAB,QSTAB
5294 ! REAL, SAVE, DIMENSION(1:KFNP) :: THE0K
5295 ! REAL, SAVE, DIMENSION(1:200) :: ALU
5296 ! REAL, SAVE :: RDPR,RDTHK,PLUTOP
5297 ! End of Lookup table variables
5299 INTEGER :: KP,IT,ITCNT,I
5300 REAL :: DTH,TMIN,TOLER,PBOT,DPR, &
5301 TEMP,P,ES,QS,PI,THES,TGUES,THGUES,F0,T1,T0,THGS,F1,DT, &
5304 ! REAL :: ALIQ,BLIQ,CLIQ,DLIQ,SVP1,SVP2,SVP3,SVPT0
5305 REAL :: ALIQ,BLIQ,CLIQ,DLIQ
5306 REAL, INTENT(IN) :: SVP1,SVP2,SVP3,SVPT0
5308 ! equivalent potential temperature increment
5310 ! minimum starting temp
5312 ! tolerance for accuracy of temperature
5314 ! top pressure (pascals)
5316 ! bottom pressure (pascals)
5325 ! compute parameters
5327 ! 1._over_(sat. equiv. theta increment)
5329 ! pressure increment
5331 DPR=(PBOT-PLUTOP)/REAL(KFNP-1)
5332 ! dpr=(pbot-plutop)/REAL(kfnp-1)
5333 ! 1._over_(pressure increment)
5335 ! compute the spread of thes
5336 ! thespd=dth*(kfnt-1)
5338 ! calculate the starting sat. equiv. theta
5344 es=aliq*exp((bliq*temp-cliq)/(temp-dliq))
5346 pi=(1.e5/p)**(0.2854*(1.-0.28*qs))
5347 the0k(kp)=temp*pi*exp((3374.6525/temp-2.5403)*qs* &
5351 ! compute temperatures for each sat. equiv. potential temp.
5358 ! define sat. equiv. pot. temp.
5360 ! iterate to find temperature
5361 ! find initial guess
5367 es=aliq*exp((bliq*tgues-cliq)/(tgues-dliq))
5369 pi=(1.e5/p)**(0.2854*(1.-0.28*qs))
5370 thgues=tgues*pi*exp((3374.6525/tgues-2.5403)*qs* &
5383 ! es=aliq*exp((bliq*t1-cliq)/(t1-dliq))
5384 es=aliq*exp((bliq*t2-cliq)/(t2-dliq))
5386 pi=(1.e5/p)**(0.2854*(1.-0.28*qs))
5387 ! thtgs=t1*pi*exp((3374.6525/t1-2.5403)*qs*(1.+0.81*qs))
5388 thtgs=t2*pi*exp((3374.6525/t2-2.5403)*qs*(1.+0.81*qs))
5393 if((f1 * f2).lt.0.0) then
5404 if(abs(f1).lt.toler)then
5408 dt=f1*(t1-t0)/(f1-f0)
5410 if(abs(dt).lt.abs( (t1-t0)/2.0 )) then
5411 dt = (t1 - t0) / 2.0
5424 ! lookup table for tlog(emix/aliq)
5426 ! set up intial values for lookup tables
5437 END SUBROUTINE KF_LUTABBG
5438 !====================================================================
5440 END MODULE module_shcu_deng