6 !-----------------------------------------------------------------
7 SUBROUTINE CU_OSAS(DT,ITIMESTEP,STEPCU, &
8 RTHCUTEN,RQVCUTEN,RQCCUTEN,RQICUTEN, &
9 RUCUTEN,RVCUTEN, & ! gopal's doing for SAS
10 RAINCV,PRATEC,HTOP,HBOT, &
11 U3D,V3D,W,T3D,QV3D,QC3D,QI3D,PI3D,RHO3D, &
12 DZ8W,PCPS,P8W,XLAND,CU_ACT_FLAG, &
14 STORE_RAND,MOMMIX, & ! gopal's doing
15 P_QI,P_FIRST_SCALAR, &
16 ids,ide, jds,jde, kds,kde, &
17 ims,ime, jms,jme, kms,kme, &
18 its,ite, jts,jte, kts,kte )
20 !-------------------------------------------------------------------
21 USE MODULE_GFS_MACHINE , ONLY : kind_phys
22 USE MODULE_GFS_FUNCPHYS , ONLY : gfuncphys
23 USE MODULE_GFS_PHYSCONS, grav => con_g, CP => con_CP, HVAP => con_HVAP &
24 &, RV => con_RV, FV => con_fvirt, T0C => con_T0C &
25 &, CVAP => con_CVAP, CLIQ => con_CLIQ &
26 &, EPS => con_eps, EPSM1 => con_epsm1 &
27 &, ROVCP => con_rocp, RD => con_rd
28 !-------------------------------------------------------------------
30 !-------------------------------------------------------------------
31 !-- U3D 3D u-velocity interpolated to theta points (m/s)
32 !-- V3D 3D v-velocity interpolated to theta points (m/s)
33 !-- TH3D 3D potential temperature (K)
34 !-- T3D temperature (K)
35 !-- QV3D 3D water vapor mixing ratio (Kg/Kg)
36 !-- QC3D 3D cloud mixing ratio (Kg/Kg)
37 !-- QI3D 3D ice mixing ratio (Kg/Kg)
38 !-- P8w 3D pressure at full levels (Pa)
39 !-- Pcps 3D pressure (Pa)
40 !-- PI3D 3D exner function (dimensionless)
41 !-- rr3D 3D dry air density (kg/m^3)
42 !-- RUBLTEN U tendency due to
43 ! PBL parameterization (m/s^2)
44 !-- RVBLTEN V tendency due to
45 ! PBL parameterization (m/s^2)
46 !-- RTHBLTEN Theta tendency due to
47 ! PBL parameterization (K/s)
48 !-- RQVBLTEN Qv tendency due to
49 ! PBL parameterization (kg/kg/s)
50 !-- RQCBLTEN Qc tendency due to
51 ! PBL parameterization (kg/kg/s)
52 !-- RQIBLTEN Qi tendency due to
53 ! PBL parameterization (kg/kg/s)
55 !-- MOMMIX MOMENTUM MIXING COEFFICIENT (can be set in the namelist)
56 !-- RUCUTEN U tendency due to Cumulus Momentum Mixing (gopal's doing for SAS)
57 !-- RVCUTEN V tendency due to Cumulus Momentum Mixing (gopal's doing for SAS)
59 !-- CP heat capacity at constant pressure for dry air (J/kg/K)
60 !-- GRAV acceleration due to gravity (m/s^2)
62 !-- RD gas constant for dry air (J/kg/K)
64 !-- P_QI species index for cloud ice
65 !-- dz8w dz between full levels (m)
66 !-- z height above sea level (m)
67 !-- PSFC pressure at the surface (Pa)
68 !-- UST u* in similarity theory (m/s)
69 !-- PBL PBL height (m)
70 !-- PSIM similarity stability function for momentum
71 !-- PSIH similarity stability function for heat
72 !-- HFX upward heat flux at the surface (W/m^2)
73 !-- QFX upward moisture flux at the surface (kg/m^2/s)
74 !-- TSK surface temperature (K)
75 !-- GZ1OZ0 log(z/z0) where z0 is roughness length
76 !-- WSPD wind speed at lowest model level (m/s)
77 !-- BR bulk Richardson number in surface layer
79 !-- rvovrd R_v divided by R_d (dimensionless)
80 !-- EP1 constant for virtual temperature (R_v/R_d - 1) (dimensionless)
81 !-- KARMAN Von Karman constant
82 !-- ids start index for i in domain
83 !-- ide end index for i in domain
84 !-- jds start index for j in domain
85 !-- jde end index for j in domain
86 !-- kds start index for k in domain
87 !-- kde end index for k in domain
88 !-- ims start index for i in memory
89 !-- ime end index for i in memory
90 !-- jms start index for j in memory
91 !-- jme end index for j in memory
92 !-- kms start index for k in memory
93 !-- kme end index for k in memory
94 !-- its start index for i in tile
95 !-- ite end index for i in tile
96 !-- jts start index for j in tile
97 !-- jte end index for j in tile
98 !-- kts start index for k in tile
99 !-- kte end index for k in tile
100 !-------------------------------------------------------------------
104 INTEGER, INTENT(IN) :: ids,ide, jds,jde, kds,kde, &
105 ims,ime, jms,jme, kms,kme, &
106 its,ite, jts,jte, kts,kte, &
113 REAL, INTENT(IN) :: &
117 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(INOUT) :: &
122 REAL, DIMENSION(ims:ime, jms:jme, kms:kme), INTENT(INOUT) :: &
123 RUCUTEN, & ! gopal's doing for SAS
124 RVCUTEN ! gopal's doing for SAS
125 REAL, OPTIONAL, INTENT(IN) :: MOMMIX
126 REAL, DIMENSION( ims:ime , jms:jme ), OPTIONAL, &
127 INTENT(IN) :: STORE_RAND
129 REAL, DIMENSION(ims:ime, jms:jme), INTENT(IN) :: &
132 REAL, DIMENSION(ims:ime, jms:jme), INTENT(INOUT) :: &
135 REAL, DIMENSION(ims:ime, jms:jme), INTENT(OUT) :: &
139 LOGICAL, DIMENSION(IMS:IME,JMS:JME), INTENT(INOUT) :: &
143 REAL, DIMENSION(ims:ime, kms:kme, jms:jme), INTENT(IN) :: &
157 !--------------------------- LOCAL VARS ------------------------------
159 REAL, DIMENSION(ims:ime, jms:jme) :: &
163 REAL (kind=kind_phys) :: &
169 REAL (kind=kind_phys), DIMENSION(its:ite) :: &
177 REAL (kind=kind_phys), DIMENSION(its:ite, kts:kte+1) :: &
180 REAL (kind=kind_phys), DIMENSION(its:ite, kts:kte) :: &
193 REAL (kind=kind_phys), DIMENSION(its:ite, kts:kte, 2) :: &
196 INTEGER, DIMENSION(its:ite) :: &
215 !-----------------------------------------------------------------------
220 CU_ACT_FLAG(I,J)=.TRUE.
235 PSFC(i,j)=P8w(i,kms,j)
239 if(igpvs.eq.0) CALL GFUNCPHYS
242 !------------- J LOOP (OUTER) --------------------------------------------------
246 ! --------------- compute zi and zl -----------------------------------------
254 ZI(I,K)=ZI(I,KM)+dz8w(i,km,j)
261 ZL(I,KM)=(ZI(I,K)+ZI(I,KM))*0.5
266 ZL(I,KTE)=2.*ZI(I,KTE)-ZL(I,KTE-1)
269 ! --------------- end compute zi and zl -------------------------------------
271 ! Based on some important findings from Morris Bender, XKT2 was defined in
272 ! terms of random number instead of random number based cloud tops
273 ! Also, these random numbers are stored and are changed only once in
274 ! approximately 5 minutes interval now. This is gopal's doing for HWRF.
276 ! call random_number(XKT2)
279 ! XKT2 was defined in terms of random number instead of random number based cloud tops
281 call init_random_seed()
282 call random_number(XKT2)
291 XKT2(i) = STORE_RAND(i,j)
298 SLIMSK(i)=ABS(XLAND(i,j)-2.)
308 PRSL(I,K)=Pcps(i,k,j)*.001
309 PHIL(I,K)=ZL(I,K)*GRAV
310 DOT(i,k)=-5.0E-4*GRAV*rho3d(i,k,j)*(w(i,k,j)+w(i,kp,j))
316 DEL(i,k)=PRSL(i,k)*GRAV/RD*dz8w(i,k,j)/T3D(i,k,j)
319 Q1(i,k)=QV3D(i,k,j)/(1.+QV3D(i,k,j))
321 QL(i,k,1)=QI3D(i,k,j)/(1.+QI3D(i,k,j))
322 QL(i,k,2)=QC3D(i,k,j)/(1.+QC3D(i,k,j))
323 PRSLK(I,K)=(PRSL(i,k)*.01)**ROVCP
330 PRSI(i,k)=PRSI(i,km)-del(i,km)
335 CALL OSASCNV(IM,IM,KX,JCAP,DELT,DEL,PRSL,PS,PHIL, &
336 QL,Q1,T1,U1,V1,RCS,CLDWRK,RN,KBOT, &
337 KTOP,KUO,SLIMSK,DOT,XKT2,NCLOUD)
339 !!! make more like GFDL ... eliminate shallow convection.....
340 !!! CALL SHALCV(IM,IM,KX,DELT,DEL,PRSI,PRSL,PRSLK,KUO,Q1,T1,DPSHC)
342 CALL SHALCV(IM,IM,KX,DELT,DEL,PRSI,PRSL,PRSLK,KUO,Q1,T1,DPSHC)
346 RAINCV(I,J)=RN(I)*1000./STEPCU
347 PRATEC(I,J)=RN(I)*1000./(STEPCU * DT)
354 RTHCUTEN(I,K,J)=(T1(I,K)-T3D(I,K,J))/PI3D(I,K,J)*RDELT
355 RQVCUTEN(I,K,J)=(Q1(I,K)/(1.-q1(i,k))-QV3D(I,K,J))*RDELT
359 !===============================================================================
360 ! ADD MOMENTUM MIXING TERM AS TENDENCIES. This is gopal's doing for SAS
361 ! MOMMIX is the reduction factor set to 0.7 by default. Because NMM has
362 ! divergence damping term, a reducion factor for cumulum mixing may be
363 ! required otherwise storms were too weak.
364 !===============================================================================
369 RUCUTEN(I,J,K)=MOMMIX*(U1(I,K)-U3D(I,K,J))*RDELT
370 RVCUTEN(I,J,K)=MOMMIX*(V1(I,K)-V3D(I,K,J))*RDELT
376 IF(P_QC .ge. P_FIRST_SCALAR)THEN
379 RQCCUTEN(I,K,J)=(QL(I,K,2)/(1.-ql(i,k,2))-QC3D(I,K,J))*RDELT
384 IF(P_QI .ge. P_FIRST_SCALAR)THEN
387 RQICUTEN(I,K,J)=(QL(I,K,1)/(1.-ql(i,k,1))-QI3D(I,K,J))*RDELT
392 ENDDO ! Outer most J loop
394 END SUBROUTINE CU_OSAS
396 !====================================================================
397 SUBROUTINE osasinit(RTHCUTEN,RQVCUTEN,RQCCUTEN,RQICUTEN, &
398 RUCUTEN,RVCUTEN, & ! gopal's doing for SAS
399 RESTART,P_QC,P_QI,P_FIRST_SCALAR, &
401 ids, ide, jds, jde, kds, kde, &
402 ims, ime, jms, jme, kms, kme, &
403 its, ite, jts, jte, kts, kte )
404 !--------------------------------------------------------------------
406 !--------------------------------------------------------------------
407 LOGICAL , INTENT(IN) :: allowed_to_read,restart
408 INTEGER , INTENT(IN) :: ids, ide, jds, jde, kds, kde, &
409 ims, ime, jms, jme, kms, kme, &
410 its, ite, jts, jte, kts, kte
411 INTEGER , INTENT(IN) :: P_FIRST_SCALAR, P_QI, P_QC
413 REAL, DIMENSION( ims:ime , kms:kme , jms:jme ) , INTENT(OUT) :: &
418 REAL, DIMENSION( ims:ime , jms:jme , kms:kme ) , INTENT(OUT) :: &
419 RUCUTEN, & ! gopal's doing for SAS
422 INTEGER :: i, j, k, itf, jtf, ktf
430 IF(.not.restart .or. .not.allowed_to_read)THEN
431 !end of zhang's doing
440 RUCUTEN(i,j,k)=0. ! gopal's doing for SAS
441 RVCUTEN(i,j,k)=0. ! gopal's doing for SAS
446 IF (P_QC .ge. P_FIRST_SCALAR) THEN
456 IF (P_QI .ge. P_FIRST_SCALAR) THEN
467 END SUBROUTINE osasinit
469 ! ------------------------------------------------------------------------
471 SUBROUTINE OSASCNV(IM,IX,KM,JCAP,DELT,DEL,PRSL,PS,PHIL,QL, &
472 & Q1,T1,U1,V1,RCS,CLDWRK,RN,KBOT,KTOP,KUO,SLIMSK, &
474 ! for cloud water version
475 ! parameter(ncloud=0)
476 ! SUBROUTINE OSASCNV(KM,JCAP,DELT,DEL,SL,SLK,PS,QL,
477 ! & Q1,T1,U1,V1,RCS,CLDWRK,RN,KBOT,KTOP,KUO,SLIMSK,
480 USE MODULE_GFS_MACHINE , ONLY : kind_phys
481 USE MODULE_GFS_FUNCPHYS ,ONLY : fpvs
482 USE MODULE_GFS_PHYSCONS, grav => con_g, CP => con_CP, HVAP => con_HVAP &
483 &, RV => con_RV, FV => con_fvirt, T0C => con_T0C &
484 &, CVAP => con_CVAP, CLIQ => con_CLIQ &
485 &, EPS => con_eps, EPSM1 => con_epsm1
489 ! include 'constant.h'
491 integer IM, IX, KM, JCAP, ncloud, &
492 & KBOT(IM), KTOP(IM), KUO(IM), J
493 real(kind=kind_phys) DELT
494 real(kind=kind_phys) PS(IM), DEL(IX,KM), PRSL(IX,KM), &
495 ! real(kind=kind_phys) DEL(IX,KM), PRSL(IX,KM),
496 & QL(IX,KM,2), Q1(IX,KM), T1(IX,KM), &
497 & U1(IX,KM), V1(IX,KM), RCS(IM), &
498 & CLDWRK(IM), RN(IM), SLIMSK(IM), &
499 & DOT(IX,KM), XKT2(IM), PHIL(IX,KM)
501 integer I, INDX, jmn, k, knumb, latd, lond, km1
503 real(kind=kind_phys) adw, alpha, alphal, alphas, &
504 & aup, beta, betal, betas, &
505 & c0, cpoel, dellat, delta, &
506 & desdt, deta, detad, dg, &
507 & dh, dhh, dlnsig, dp, &
508 & dq, dqsdp, dqsdt, dt, &
509 & dt2, dtmax, dtmin, dv1, &
510 & dv1q, dv2, dv2q, dv1u, &
511 & dv1v, dv2u, dv2v, dv3u, &
512 & dv3v, dv3, dv3q, dvq1, &
513 & dz, dz1, e1, edtmax, &
514 & edtmaxl, edtmaxs, el2orc, elocp, &
516 & evef, evfact, evfactl, fact1, &
517 & fact2, factor, fjcap, fkm, &
518 & fuv, g, gamma, onemf, &
519 & onemfu, pdetrn, pdpdwn, pprime, &
520 & qc, qlk, qrch, qs, &
521 & rain, rfact, shear, tem1, &
522 & tem2, terr, val, val1, &
523 & val2, w1, w1l, w1s, &
524 & w2, w2l, w2s, w3, &
525 & w3l, w3s, w4, w4l, &
526 & w4s, xdby, xpw, xpwd, &
527 & xqc, xqrch, xlambu, mbdt, &
531 integer JMIN(IM), KB(IM), KBCON(IM), KBDTR(IM), &
532 & KT2(IM), KTCON(IM), LMIN(IM), &
533 & kbm(IM), kbmax(IM), kmax(IM)
535 real(kind=kind_phys) AA1(IM), ACRT(IM), ACRTFCT(IM), &
536 & DELHBAR(IM), DELQ(IM), DELQ2(IM), &
537 & DELQBAR(IM), DELQEV(IM), DELTBAR(IM), &
538 & DELTV(IM), DTCONV(IM), EDT(IM), &
539 & EDTO(IM), EDTX(IM), FLD(IM), &
540 & HCDO(IM), HKBO(IM), HMAX(IM), &
541 & HMIN(IM), HSBAR(IM), UCDO(IM), &
542 & UKBO(IM), VCDO(IM), VKBO(IM), &
543 & PBCDIF(IM), PDOT(IM), PO(IM,KM), &
544 & PWAVO(IM), PWEVO(IM), &
545 ! & PSFC(IM), PWAVO(IM), PWEVO(IM), &
546 & QCDO(IM), QCOND(IM), QEVAP(IM), &
547 & QKBO(IM), RNTOT(IM), VSHEAR(IM), &
548 & XAA0(IM), XHCD(IM), XHKB(IM), &
549 & XK(IM), XLAMB(IM), XLAMD(IM), &
550 & XMB(IM), XMBMAX(IM), XPWAV(IM), &
551 & XPWEV(IM), XQCD(IM), XQKB(IM)
553 ! PHYSICAL PARAMETERS
555 PARAMETER(CPOEL=CP/HVAP,ELOCP=HVAP/CP, &
556 & EL2ORC=HVAP*HVAP/(RV*CP))
557 PARAMETER(TERR=0.,C0=.002,DELTA=fv)
558 PARAMETER(FACT1=(CVAP-CLIQ)/RV,FACT2=HVAP/RV-FACT1*T0C)
559 ! LOCAL VARIABLES AND ARRAYS
560 real(kind=kind_phys) PFLD(IM,KM), TO(IM,KM), QO(IM,KM), &
561 & UO(IM,KM), VO(IM,KM), QESO(IM,KM)
563 real(kind=kind_phys) QLKO_KTCON(IM), DELLAL(IM), TVO(IM,KM), &
564 & DBYO(IM,KM), ZO(IM,KM), SUMZ(IM,KM), &
565 & SUMH(IM,KM), HEO(IM,KM), HESO(IM,KM), &
566 & QRCD(IM,KM), DELLAH(IM,KM), DELLAQ(IM,KM),&
567 & DELLAU(IM,KM), DELLAV(IM,KM), HCKO(IM,KM), &
568 & UCKO(IM,KM), VCKO(IM,KM), QCKO(IM,KM), &
569 & ETA(IM,KM), ETAU(IM,KM), ETAD(IM,KM), &
570 & QRCDO(IM,KM), PWO(IM,KM), PWDO(IM,KM), &
573 LOGICAL TOTFLG, CNVFLG(IM), DWNFLG(IM), DWNFLG2(IM), FLG(IM)
575 real(kind=kind_phys) PCRIT(15), ACRITT(15), ACRIT(15)
577 DATA PCRIT/850.,800.,750.,700.,650.,600.,550.,500.,450.,400., &
578 & 350.,300.,250.,200.,150./
579 DATA ACRITT/.0633,.0445,.0553,.0664,.075,.1082,.1521,.2216, &
580 & .3151,.3677,.41,.5255,.7663,1.1686,1.6851/
582 ! DATA ACRITT/.203,.515,.521,.566,.625,.665,.659,.688, &
583 ! & .743,.813,.886,.947,1.138,1.377,1.896/
585 real(kind=kind_phys) TF, TCR, TCRF, RZERO, RONE
586 parameter (TF=233.16, TCR=263.16, TCRF=1.0/(TCR-TF))
587 parameter (RZERO=0.0,RONE=1.0)
588 !-----------------------------------------------------------------------
608 ACRIT(K) = ACRITT(K) * (975. - PCRIT(K))
611 !cmr dtmin = max(dt2,1200.)
613 dtmin = max(dt2, val )
614 !cmr dtmax = max(dt2,3600.)
616 dtmax = max(dt2, val )
617 ! MODEL TUNABLE PARAMETERS ARE ALL HERE
627 ! change for hurricane model
633 ! change for hurricane model
648 fjcap = (float(jcap) / 126.) ** 2
649 !cmr fjcap = max(fjcap,1.)
651 fjcap = max(fjcap,val)
652 fkm = (float(km) / 28.) ** 2
653 !cmr fkm = max(fkm,1.)
663 !CCCC IF(IM.EQ.384) THEN
666 !CCCC ELSEIF(IM.EQ.768) THEN
672 ! DEFINE TOP LAYER FOR SEARCH OF THE DOWNDRAFT ORIGINATING LAYER
673 ! AND THE MAXIMUM THETAE FOR UPDRAFT
684 IF (prSL(I,K)*tx1(I) .GT. 0.45) KBMAX(I) = K + 1
685 IF (prSL(I,K)*tx1(I) .GT. 0.70) KBM(I) = K + 1
686 IF (prSL(I,K)*tx1(I) .GT. 0.04) KMAX(I) = MIN(KM,K + 1)
690 KBMAX(I) = MIN(KBMAX(I),KMAX(I))
691 KBM(I) = MIN(KBM(I),KMAX(I))
694 ! CONVERT SURFACE PRESSURE TO MB FROM CB
699 if (K .le. kmax(i)) then
700 PFLD(I,k) = PRSL(I,K) * 10.0
716 ! P IS PRESSURE OF THE LAYER (MB)
717 ! T IS TEMPERATURE AT T-DT (K)..TN
718 ! Q IS MIXING RATIO AT T-DT (KG/KG)..QN
719 ! TO IS TEMPERATURE AT T+DT (K)... THIS IS AFTER ADVECTION AND TURBULAN
720 ! QO IS MIXING RATIO AT T+DT (KG/KG)..Q1
724 if (k .le. kmax(i)) then
725 !jfe QESO(I,k) = 10. * FPVS(T1(I,k))
727 QESO(I,k) = 0.01 * fpvs(T1(I,K)) ! fpvs is in Pa
729 QESO(I,k) = EPS * QESO(I,k) / (PFLD(I,k) + EPSM1*QESO(I,k))
730 !cmr QESO(I,k) = MAX(QESO(I,k),1.E-8)
732 QESO(I,k) = MAX(QESO(I,k), val1)
733 !cmr QO(I,k) = max(QO(I,k),1.e-10)
735 QO(I,k) = max(QO(I,k), val2 )
736 ! QO(I,k) = MIN(QO(I,k),QESO(I,k))
737 TVO(I,k) = TO(I,k) + DELTA * TO(I,k) * QO(I,k)
743 ! HYDROSTATIC HEIGHT ASSUME ZERO TERR
747 ZO(I,k) = PHIL(I,k) / G
750 ! COMPUTE MOIST STATIC ENERGY
753 if (K .le. kmax(i)) then
754 ! tem = G * ZO(I,k) + CP * TO(I,k)
755 tem = PHIL(I,k) + CP * TO(I,k)
756 HEO(I,k) = tem + HVAP * QO(I,k)
757 HESO(I,k) = tem + HVAP * QESO(I,k)
758 ! HEO(I,k) = MIN(HEO(I,k),HESO(I,k))
763 ! DETERMINE LEVEL WITH LARGEST MOIST STATIC ENERGY
764 ! THIS IS THE LEVEL WHERE UPDRAFT STARTS
773 if (k .le. kbm(i)) then
774 IF(HEO(I,k).GT.HMAX(I).AND.CNVFLG(I)) THEN
782 ! TOL(k) = .5 * (TO(I,k) + TO(I,k+1))
783 ! QOL(k) = .5 * (QO(I,k) + QO(I,k+1))
784 ! QESOL(I,k) = .5 * (QESO(I,k) + QESO(I,k+1))
785 ! HEOL(I,k) = .5 * (HEO(I,k) + HEO(I,k+1))
786 ! HESOL(I,k) = .5 * (HESO(I,k) + HESO(I,k+1))
790 if (k .le. kmax(i)-1) then
791 DZ = .5 * (ZO(I,k+1) - ZO(I,k))
792 DP = .5 * (PFLD(I,k+1) - PFLD(I,k))
793 !jfe ES = 10. * FPVS(TO(I,k+1))
795 ES = 0.01 * fpvs(TO(I,K+1)) ! fpvs is in Pa
797 PPRIME = PFLD(I,k+1) + EPSM1 * ES
798 QS = EPS * ES / PPRIME
799 DQSDP = - QS / PPRIME
800 DESDT = ES * (FACT1 / TO(I,k+1) + FACT2 / (TO(I,k+1)**2))
801 DQSDT = QS * PFLD(I,k+1) * DESDT / (ES * PPRIME)
802 GAMMA = EL2ORC * QESO(I,k+1) / (TO(I,k+1)**2)
803 DT = (G * DZ + HVAP * DQSDP * DP) / (CP * (1. + GAMMA))
804 DQ = DQSDT * DT + DQSDP * DP
805 TO(I,k) = TO(I,k+1) + DT
806 QO(I,k) = QO(I,k+1) + DQ
807 PO(I,k) = .5 * (PFLD(I,k) + PFLD(I,k+1))
814 if (k .le. kmax(I)-1) then
815 !jfe QESO(I,k) = 10. * FPVS(TO(I,k))
817 QESO(I,k) = 0.01 * fpvs(TO(I,K)) ! fpvs is in Pa
819 QESO(I,k) = EPS * QESO(I,k) / (PO(I,k) + EPSM1*QESO(I,k))
820 !cmr QESO(I,k) = MAX(QESO(I,k),1.E-8)
822 QESO(I,k) = MAX(QESO(I,k), val1)
823 !cmr QO(I,k) = max(QO(I,k),1.e-10)
825 QO(I,k) = max(QO(I,k), val2 )
826 ! QO(I,k) = MIN(QO(I,k),QESO(I,k))
827 HEO(I,k) = .5 * G * (ZO(I,k) + ZO(I,k+1)) + &
828 & CP * TO(I,k) + HVAP * QO(I,k)
829 HESO(I,k) = .5 * G * (ZO(I,k) + ZO(I,k+1)) + &
830 & CP * TO(I,k) + HVAP * QESO(I,k)
831 UO(I,k) = .5 * (UO(I,k) + UO(I,k+1))
832 VO(I,k) = .5 * (VO(I,k) + VO(I,k+1))
837 ! HEO(I,k) = HEO(I,k)
838 ! hesol(k) = HESO(I,k)
839 ! IF(LAT.EQ.LATD.AND.lon.eq.lond.and.CNVFLG(I)) THEN
841 ! PRINT 6001, (HEO(I,K),K=1,KMAX)
843 ! PRINT 6001, (HESO(I,K),K=1,KMAX)
845 ! PRINT 6002, (TO(I,K)-273.16,K=1,KMAX)
847 ! PRINT 6003, (QO(I,K),K=1,KMAX)
849 ! PRINT 6003, (QESO(I,K),K=1,KMAX)
852 ! LOOK FOR CONVECTIVE CLOUD BASE AS THE LEVEL OF FREE CONVECTION
857 HKBO(I) = HEO(I,INDX)
868 if (k .le. kbmax(i)) then
869 IF(FLG(I).AND.K.GT.KB(I)) THEN
871 IF(HKBO(I).GT.HSBAR(I)) THEN
881 PBCDIF(I) = -PFLD(I,KBCON(I)) + PFLD(I,KB(I))
882 PDOT(I) = 10.* DOT(I,KBCON(I))
883 IF(PBCDIF(I).GT.150.) CNVFLG(I) = .FALSE.
884 IF(KBCON(I).EQ.KMAX(I)) CNVFLG(I) = .FALSE.
890 TOTFLG = TOTFLG .AND. (.NOT. CNVFLG(I))
893 ! FOUND LFC, CAN DEFINE REST OF VARIABLES
894 6001 FORMAT(2X,-2P10F12.2)
895 6002 FORMAT(2X,10F12.2)
896 6003 FORMAT(2X,3P10F12.2)
899 ! DETERMINE ENTRAINMENT RATE BETWEEN KB AND KBCON
903 if(SLIMSK(I).eq.1.) alpha = alphal
906 DZ = .5 * (ZO(I,KBCON(I)) + ZO(I,KBCON(I)-1)) - ZO(I,1)
908 DZ = .5 * (ZO(I,KBCON(I)) + ZO(I,KBCON(I)-1)) &
909 & - .5 * (ZO(I,KB(I)) + ZO(I,KB(I)-1))
911 IF(KBCON(I).NE.KB(I)) THEN
912 !cmr XLAMB(I) = -ALOG(ALPHA) / DZ
913 XLAMB(I) = - LOG(ALPHA) / DZ
919 ! DETERMINE UPDRAFT MASS FLUX
922 if (k .le. kmax(i) .and. CNVFLG(I)) then
930 if (k .le. kbmax(i)) then
931 IF(CNVFLG(I).AND.K.LT.KBCON(I).AND.K.GE.KB(I)) THEN
932 DZ = .5 * (ZO(I,k+1) - ZO(I,k-1))
933 ETA(I,k) = ETA(I,k+1) * EXP(-XLAMB(I) * DZ)
940 IF(CNVFLG(I).AND.KB(I).EQ.1.AND.KBCON(I).GT.1) THEN
941 DZ = .5 * (ZO(I,2) - ZO(I,1))
942 ETA(I,1) = ETA(I,2) * EXP(-XLAMB(I) * DZ)
947 ! WORK UP UPDRAFT CLOUD PROPERTIES
952 HCKO(I,INDX) = HKBO(I)
953 QCKO(I,INDX) = QKBO(I)
954 UCKO(I,INDX) = UKBO(I)
955 VCKO(I,INDX) = VKBO(I)
960 ! CLOUD PROPERTY BELOW CLOUD BASE IS MODIFIED BY THE ENTRAINMENT PROCES
964 if (k .le. kmax(i)-1) then
965 IF(CNVFLG(I).AND.K.GT.KB(I).AND.K.LE.KBCON(I)) THEN
966 FACTOR = ETA(I,k-1) / ETA(I,k)
968 HCKO(I,k) = FACTOR * HCKO(I,k-1) + ONEMF * &
969 & .5 * (HEO(I,k) + HEO(I,k+1))
970 UCKO(I,k) = FACTOR * UCKO(I,k-1) + ONEMF * &
971 & .5 * (UO(I,k) + UO(I,k+1))
972 VCKO(I,k) = FACTOR * VCKO(I,k-1) + ONEMF * &
973 & .5 * (VO(I,k) + VO(I,k+1))
974 DBYO(I,k) = HCKO(I,k) - HESO(I,k)
976 IF(CNVFLG(I).AND.K.GT.KBCON(I)) THEN
977 HCKO(I,k) = HCKO(I,k-1)
978 UCKO(I,k) = UCKO(I,k-1)
979 VCKO(I,k) = VCKO(I,k-1)
980 DBYO(I,k) = HCKO(I,k) - HESO(I,k)
985 ! DETERMINE CLOUD TOP
992 ! IF(DBYO(I,kK).GE.0..AND.FLG(I).AND.KK.GT.KBCON(I)) THEN
999 if (k .le. kmax(i)) then
1000 IF(DBYO(I,k).LT.0..AND.FLG(I).AND.K.GT.KBCON(I)) THEN
1008 IF(CNVFLG(I).AND.(PFLD(I,KBCON(I)) - PFLD(I,KTCON(I))).LT.150.) &
1009 & CNVFLG(I) = .FALSE.
1013 TOTFLG = TOTFLG .AND. (.NOT. CNVFLG(I))
1017 ! SEARCH FOR DOWNDRAFT ORIGINATING LEVEL ABOVE THETA-E MINIMUM
1020 HMIN(I) = HEO(I,KBCON(I))
1025 DO K = KBCON(I), KBMAX(I)
1026 IF(HEO(I,k).LT.HMIN(I).AND.CNVFLG(I)) THEN
1033 ! Make sure that JMIN(I) is within the cloud
1037 JMIN(I) = MIN(LMIN(I),KTCON(I)-1)
1039 JMIN(I) = MAX(JMIN(I),KBCON(I)+1)
1047 if (k .le. kmax(i)-1) then
1048 if(CNVFLG(I).and.k.gt.JMIN(I).and.k.le.KTCON(I)) THEN
1049 SUMZ(I,k) = SUMZ(I,k-1) + .5 * (ZO(I,k+1) - ZO(I,k-1))
1050 SUMH(I,k) = SUMH(I,k-1) + .5 * (ZO(I,k+1) - ZO(I,k-1)) &
1059 ! call random_number(XKT2)
1062 KT2(I) = nint(XKT2(I)*float(KTCON(I)-JMIN(I))-.5)+JMIN(I)+1
1063 ! KT2(I) = nint(sqrt(XKT2(I))*float(KTCON(I)-JMIN(I))-.5) + JMIN(I) + 1
1064 ! KT2(I) = nint(ranf() *float(KTCON(I)-JMIN(I))-.5) + JMIN(I) + 1
1065 tem1 = (HCKO(I,JMIN(I)) - HESO(I,KT2(I)))
1066 tem2 = (SUMZ(I,KT2(I)) * HESO(I,KT2(I)) - SUMH(I,KT2(I)))
1067 if (abs(tem2) .gt. 0.000001) THEN
1068 XLAMB(I) = tem1 / tem2
1072 ! XLAMB(I) = (HCKO(I,JMIN(I)) - HESO(I,KT2(I)))
1073 ! & / (SUMZ(I,KT2(I)) * HESO(I,KT2(I)) - SUMH(I,KT2(I)))
1074 XLAMB(I) = max(XLAMB(I),RZERO)
1075 XLAMB(I) = min(XLAMB(I),2.3/SUMZ(I,KT2(I)))
1080 DWNFLG(I) = CNVFLG(I)
1081 DWNFLG2(I) = CNVFLG(I)
1083 if(KT2(I).ge.KTCON(I)) DWNFLG(I) = .false.
1084 if(XLAMB(I).le.1.e-30.or.HCKO(I,JMIN(I))-HESO(I,KT2(I)).le.1.e-30)&
1085 & DWNFLG(I) = .false.
1086 do k = JMIN(I), KT2(I)
1087 if(DWNFLG(I).and.HEO(I,k).gt.HESO(I,KT2(I))) DWNFLG(I)=.false.
1089 ! IF(CNVFLG(I).AND.(PFLD(KBCON(I))-PFLD(KTCON(I))).GT.PDETRN)
1090 ! & DWNFLG(I)=.FALSE.
1091 IF(CNVFLG(I).AND.(PFLD(I,KBCON(I))-PFLD(I,KTCON(I))).LT.PDPDWN) &
1092 & DWNFLG2(I)=.FALSE.
1098 if (k .le. kmax(i)-1) then
1099 IF(DWNFLG(I).AND.K.GT.JMIN(I).AND.K.LE.KT2(I)) THEN
1100 DZ = .5 * (ZO(I,k+1) - ZO(I,k-1))
1101 ! ETA(I,k) = ETA(I,k-1) * EXP( XLAMB(I) * DZ)
1102 ! to simplify matter, we will take the linear approach here
1104 ETA(I,k) = ETA(I,k-1) * (1. + XLAMB(I) * dz)
1105 ETAU(I,k) = ETAU(I,k-1) * (1. + (XLAMB(I)+xlambu) * dz)
1113 if (k .le. kmax(i)-1) then
1114 ! IF(.NOT.DWNFLG(I).AND.K.GT.JMIN(I).AND.K.LE.KT2(I)) THEN
1115 IF(.NOT.DWNFLG(I).AND.K.GT.JMIN(I).AND.K.LE.KTCON(I)) THEN
1116 DZ = .5 * (ZO(I,k+1) - ZO(I,k-1))
1117 ETAU(I,k) = ETAU(I,k-1) * (1. + xlambu * dz)
1122 ! IF(LAT.EQ.LATD.AND.lon.eq.lond.and.CNVFLG(I)) THEN
1123 ! PRINT *, ' LMIN(I), KT2(I)=', LMIN(I), KT2(I)
1124 ! PRINT *, ' KBOT, KTOP, JMIN(I) =', KBCON(I), KTCON(I), JMIN(I)
1126 ! IF(LAT.EQ.LATD.AND.lon.eq.lond) THEN
1127 ! print *, ' xlamb =', xlamb
1128 ! print *, ' eta =', (eta(k),k=1,KT2(I))
1129 ! print *, ' ETAU =', (ETAU(I,k),k=1,KT2(I))
1130 ! print *, ' HCKO =', (HCKO(I,k),k=1,KT2(I))
1131 ! print *, ' SUMZ =', (SUMZ(I,k),k=1,KT2(I))
1132 ! print *, ' SUMH =', (SUMH(I,k),k=1,KT2(I))
1140 ! CLOUD PROPERTY ABOVE CLOUD Base IS MODIFIED BY THE DETRAINMENT PROCESS
1144 if (k .le. kmax(i)-1) then
1146 IF(CNVFLG(I).AND.K.GT.KBCON(I).AND.K.LE.KTCON(I)) THEN
1147 !jfe IF(K.GT.KBCON(I).AND.K.LE.KTCON(I)) THEN
1148 FACTOR = ETA(I,k-1) / ETA(I,k)
1150 fuv = ETAU(I,k-1) / ETAU(I,k)
1152 HCKO(I,k) = FACTOR * HCKO(I,k-1) + ONEMF * &
1153 & .5 * (HEO(I,k) + HEO(I,k+1))
1154 UCKO(I,k) = fuv * UCKO(I,k-1) + ONEMFu * &
1155 & .5 * (UO(I,k) + UO(I,k+1))
1156 VCKO(I,k) = fuv * VCKO(I,k-1) + ONEMFu * &
1157 & .5 * (VO(I,k) + VO(I,k+1))
1158 DBYO(I,k) = HCKO(I,k) - HESO(I,k)
1163 ! IF(LAT.EQ.LATD.AND.lon.eq.lond.and.CNVFLG(I)) THEN
1164 ! PRINT *, ' UCKO=', (UCKO(I,k),k=KBCON(I)+1,KTCON(I))
1165 ! PRINT *, ' uenv=', (.5*(UO(I,k)+UO(I,k-1)),k=KBCON(I)+1,KTCON(I))
1168 if(CNVFLG(I).and.DWNFLG2(I).and.JMIN(I).le.KBCON(I)) &
1172 DWNFLG2(I) = .false.
1178 TOTFLG = TOTFLG .AND. (.NOT. CNVFLG(I))
1183 ! COMPUTE CLOUD MOISTURE PROPERTY AND PRECIPITATION
1191 if (k .le. kmax(i)) then
1192 IF(CNVFLG(I).AND.K.GT.KB(I).AND.K.LT.KTCON(I)) THEN
1193 DZ = .5 * (ZO(I,k+1) - ZO(I,k-1))
1194 DZ1 = (ZO(I,k) - ZO(I,k-1))
1195 GAMMA = EL2ORC * QESO(I,k) / (TO(I,k)**2)
1197 & + GAMMA * DBYO(I,k) / (HVAP * (1. + GAMMA))
1198 FACTOR = ETA(I,k-1) / ETA(I,k)
1200 QCKO(I,k) = FACTOR * QCKO(I,k-1) + ONEMF * &
1201 & .5 * (QO(I,k) + QO(I,k+1))
1202 DQ = ETA(I,k) * QCKO(I,k) - ETA(I,k) * QRCH
1203 RHBAR(I) = RHBAR(I) + QO(I,k) / QESO(I,k)
1205 ! BELOW LFC CHECK IF THERE IS EXCESS MOISTURE TO RELEASE LATENT HEAT
1208 ETAH = .5 * (ETA(I,k) + ETA(I,k-1))
1209 QLK = DQ / (ETA(I,k) + ETAH * C0 * DZ)
1210 AA1(I) = AA1(I) - DZ1 * G * QLK
1212 PWO(I,k) = ETAH * C0 * DZ * QLK
1214 PWAVO(I) = PWAVO(I) + PWO(I,k)
1221 RHBAR(I) = RHBAR(I) / float(KTCON(I) - KB(I) - 1)
1224 ! this section is ready for cloud water
1226 if(ncloud.gt.0) THEN
1228 ! compute liquid and vapor separation at cloud top
1233 GAMMA = EL2ORC * QESO(I,K) / (TO(I,K)**2)
1235 & + GAMMA * DBYO(I,K) / (HVAP * (1. + GAMMA))
1236 DQ = QCKO(I,K-1) - QRCH
1238 ! CHECK IF THERE IS EXCESS MOISTURE TO RELEASE LATENT HEAT
1248 ! CALCULATE CLOUD WORK FUNCTION AT T+DT
1252 if (k .le. kmax(i)) then
1253 IF(CNVFLG(I).AND.K.GT.KBCON(I).AND.K.LE.KTCON(I)) THEN
1254 DZ1 = ZO(I,k) - ZO(I,k-1)
1255 GAMMA = EL2ORC * QESO(I,k-1) / (TO(I,k-1)**2)
1256 RFACT = 1. + DELTA * CP * GAMMA &
1257 & * TO(I,k-1) / HVAP
1259 & DZ1 * (G / (CP * TO(I,k-1))) &
1260 & * DBYO(I,k-1) / (1. + GAMMA) &
1264 & DZ1 * G * DELTA * &
1265 !cmr & MAX( 0.,(QESO(I,k-1) - QO(I,k-1))) &
1266 & MAX(val,(QESO(I,k-1) - QO(I,k-1)))
1272 IF(CNVFLG(I).AND.AA1(I).LE.0.) DWNFLG(I) = .FALSE.
1273 IF(CNVFLG(I).AND.AA1(I).LE.0.) DWNFLG2(I) = .FALSE.
1274 IF(CNVFLG(I).AND.AA1(I).LE.0.) CNVFLG(I) = .FALSE.
1279 TOTFLG = TOTFLG .AND. (.NOT. CNVFLG(I))
1283 !cccc IF(LAT.EQ.LATD.AND.lon.eq.lond.and.CNVFLG(I)) THEN
1284 !cccc PRINT *, ' AA1(I) BEFORE DWNDRFT =', AA1(I)
1287 !------- DOWNDRAFT CALCULATIONS
1290 !--- DETERMINE DOWNDRAFT STRENGTH IN TERMS OF WINDSHEAR
1299 if (k .le. kmax(i)) then
1300 IF(K.GE.KB(I).AND.K.LE.KTCON(I).AND.CNVFLG(I)) THEN
1301 shear=rcs(I) * sqrt((UO(I,k+1)-UO(I,k)) ** 2 &
1302 & + (VO(I,k+1)-VO(I,k)) ** 2)
1303 VSHEAR(I) = VSHEAR(I) + SHEAR
1311 KNUMB = KTCON(I) - KB(I) + 1
1312 KNUMB = MAX(KNUMB,1)
1313 VSHEAR(I) = 1.E3 * VSHEAR(I) / (ZO(I,KTCON(I))-ZO(I,KB(I)))
1314 E1=1.591-.639*VSHEAR(I) &
1315 & +.0953*(VSHEAR(I)**2)-.00496*(VSHEAR(I)**3)
1317 !cmr EDT(I) = MIN(EDT(I),.9)
1319 EDT(I) = MIN(EDT(I),val)
1320 !cmr EDT(I) = MAX(EDT(I),.0)
1322 EDT(I) = MAX(EDT(I),val)
1327 ! DETERMINE DETRAINMENT RATE BETWEEN 1 AND KBDTR
1331 if(SLIMSK(I).eq.1.) beta = betal
1334 KBDTR(I) = MAX(KBDTR(I),1)
1336 IF(KBDTR(I).GT.1) THEN
1337 DZ = .5 * ZO(I,KBDTR(I)) + .5 * ZO(I,KBDTR(I)-1) &
1339 XLAMD(I) = LOG(BETA) / DZ
1343 ! DETERMINE DOWNDRAFT MASS FLUX
1346 IF(k .le. kmax(i)) then
1356 if (k .le. kbmax(i)) then
1357 IF(CNVFLG(I).AND.K.LT.KBDTR(I)) THEN
1358 DZ = .5 * (ZO(I,k+1) - ZO(I,k-1))
1359 ETAD(I,k) = ETAD(I,k+1) * EXP(XLAMD(I) * DZ)
1366 IF(CNVFLG(I).AND.KBDTR(I).GT.1) THEN
1367 DZ = .5 * (ZO(I,2) - ZO(I,1))
1368 ETAD(I,k) = ETAD(I,k+1) * EXP(XLAMD(I) * DZ)
1372 !--- DOWNDRAFT MOISTURE PROPERTIES
1381 HCDO(I) = HEO(I,JMN)
1383 QRCDO(I,JMN) = QESO(I,JMN)
1390 if (k .le. kmax(i)-1) then
1391 IF(CNVFLG(I).AND.K.LT.JMIN(I)) THEN
1394 GAMMA = EL2ORC * DQ / DT**2
1395 DH = HCDO(I) - HESO(I,k)
1396 QRCDO(I,k) = DQ+(1./HVAP)*(GAMMA/(1.+GAMMA))*DH
1397 DETAD = ETAD(I,k+1) - ETAD(I,k)
1398 PWDO(I,k) = ETAD(I,k+1) * QCDO(I) - &
1399 & ETAD(I,k) * QRCDO(I,k)
1400 PWDO(I,k) = PWDO(I,k) - DETAD * &
1401 & .5 * (QRCDO(I,k) + QRCDO(I,k+1))
1402 QCDO(I) = QRCDO(I,k)
1403 PWEVO(I) = PWEVO(I) + PWDO(I,k)
1408 ! IF(LAT.EQ.LATD.AND.lon.eq.lond.and.DWNFLG(I)) THEN
1409 ! PRINT *, ' PWAVO(I), PWEVO(I) =', PWAVO(I), PWEVO(I)
1412 !--- FINAL DOWNDRAFT STRENGTH DEPENDENT ON PRECIP
1413 !--- EFFICIENCY (EDT), NORMALIZED CONDENSATE (PWAV), AND
1414 !--- EVAPORATE (PWEV)
1418 if(SLIMSK(I).eq.0.) edtmax = edtmaxs
1420 IF(PWEVO(I).LT.0.) THEN
1421 EDTO(I) = -EDTO(I) * PWAVO(I) / PWEVO(I)
1422 EDTO(I) = MIN(EDTO(I),EDTMAX)
1432 !--- DOWNDRAFT CLOUDWORK FUNCTIONS
1437 if (k .le. kmax(i)-1) then
1438 IF(DWNFLG2(I).AND.K.LT.JMIN(I)) THEN
1439 GAMMA = EL2ORC * QESO(I,k+1) / TO(I,k+1)**2
1444 DZ=-1.*(ZO(I,k+1)-ZO(I,k))
1445 AA1(I)=AA1(I)+EDTO(I)*DZ*(G/(CP*DT))*((DHH-DH)/(1.+DG)) &
1446 & *(1.+DELTA*CP*DG*DT/HVAP)
1448 AA1(I)=AA1(I)+EDTO(I)* &
1449 !cmr & DZ*G*DELTA*MAX( 0.,(QESO(I,k+1)-QO(I,k+1))) &
1450 & DZ*G*DELTA*MAX(val,(QESO(I,k+1)-QO(I,k+1)))
1455 !cccc IF(LAT.EQ.LATD.AND.lon.eq.lond.and.DWNFLG2(I)) THEN
1456 !cccc PRINT *, ' AA1(I) AFTER DWNDRFT =', AA1(I)
1459 IF(AA1(I).LE.0.) CNVFLG(I) = .FALSE.
1460 IF(AA1(I).LE.0.) DWNFLG(I) = .FALSE.
1461 IF(AA1(I).LE.0.) DWNFLG2(I) = .FALSE.
1466 TOTFLG = TOTFLG .AND. (.NOT. CNVFLG(I))
1472 !--- WHAT WOULD THE CHANGE BE, THAT A CLOUD WITH UNIT MASS
1473 !--- WILL DO TO THE ENVIRONMENT?
1477 IF(k .le. kmax(i) .and. CNVFLG(I)) THEN
1487 DP = 1000. * DEL(I,1)
1488 DELLAH(I,1) = EDTO(I) * ETAD(I,1) * (HCDO(I) &
1489 & - HEO(I,1)) * G / DP
1490 DELLAQ(I,1) = EDTO(I) * ETAD(I,1) * (QCDO(I) &
1491 & - QO(I,1)) * G / DP
1492 DELLAU(I,1) = EDTO(I) * ETAD(I,1) * (UCDO(I) &
1493 & - UO(I,1)) * G / DP
1494 DELLAV(I,1) = EDTO(I) * ETAD(I,1) * (VCDO(I) &
1495 & - VO(I,1)) * G / DP
1499 !--- CHANGED DUE TO SUBSIDENCE AND ENTRAINMENT
1503 if (k .le. kmax(i)-1) then
1504 IF(CNVFLG(I).AND.K.LT.KTCON(I)) THEN
1506 IF(K.LE.KB(I)) AUP = 0.
1508 IF(K.GT.JMIN(I)) ADW = 0.
1510 DV2 = .5 * (HEO(I,k) + HEO(I,k+1))
1513 DV2Q = .5 * (QO(I,k) + QO(I,k+1))
1516 DV2U = .5 * (UO(I,k) + UO(I,k+1))
1519 DV2V = .5 * (VO(I,k) + VO(I,k+1))
1521 DP = 1000. * DEL(I,K)
1522 DZ = .5 * (ZO(I,k+1) - ZO(I,k-1))
1523 DETA = ETA(I,k) - ETA(I,k-1)
1524 DETAD = ETAD(I,k) - ETAD(I,k-1)
1525 DELLAH(I,k) = DELLAH(I,k) + &
1526 & ((AUP * ETA(I,k) - ADW * EDTO(I) * ETAD(I,k)) * DV1 &
1527 & - (AUP * ETA(I,k-1) - ADW * EDTO(I) * ETAD(I,k-1))* DV3 &
1528 & - AUP * DETA * DV2 &
1529 & + ADW * EDTO(I) * DETAD * HCDO(I)) * G / DP
1530 DELLAQ(I,k) = DELLAQ(I,k) + &
1531 & ((AUP * ETA(I,k) - ADW * EDTO(I) * ETAD(I,k)) * DV1Q &
1532 & - (AUP * ETA(I,k-1) - ADW * EDTO(I) * ETAD(I,k-1))* DV3Q &
1533 & - AUP * DETA * DV2Q &
1534 & +ADW*EDTO(I)*DETAD*.5*(QRCDO(I,k)+QRCDO(I,k-1))) * G / DP
1535 DELLAU(I,k) = DELLAU(I,k) + &
1536 & ((AUP * ETA(I,k) - ADW * EDTO(I) * ETAD(I,k)) * DV1U &
1537 & - (AUP * ETA(I,k-1) - ADW * EDTO(I) * ETAD(I,k-1))* DV3U &
1538 & - AUP * DETA * DV2U &
1539 & + ADW * EDTO(I) * DETAD * UCDO(I) &
1541 DELLAV(I,k) = DELLAV(I,k) + &
1542 & ((AUP * ETA(I,k) - ADW * EDTO(I) * ETAD(I,k)) * DV1V &
1543 & - (AUP * ETA(I,k-1) - ADW * EDTO(I) * ETAD(I,k-1))* DV3V &
1544 & - AUP * DETA * DV2V &
1545 & + ADW * EDTO(I) * DETAD * VCDO(I) &
1557 DP = 1000. * DEL(I,INDX)
1559 DELLAH(I,INDX) = ETA(I,INDX-1) * &
1560 & (HCKO(I,INDX-1) - DV1) * G / DP
1562 DELLAQ(I,INDX) = ETA(I,INDX-1) * &
1563 & (QCKO(I,INDX-1) - DVQ1) * G / DP
1565 DELLAU(I,INDX) = ETA(I,INDX-1) * &
1566 & (UCKO(I,INDX-1) - DV1U) * G / DP
1568 DELLAV(I,INDX) = ETA(I,INDX-1) * &
1569 & (VCKO(I,INDX-1) - DV1V) * G / DP
1573 DELLAL(I) = ETA(I,INDX-1) * QLKO_KTCON(I) * g / dp
1577 !------- FINAL CHANGED VARIABLE PER UNIT MASS FLUX
1581 if (k .le. kmax(i)) then
1582 IF(CNVFLG(I).and.k.gt.KTCON(I)) THEN
1588 IF(CNVFLG(I).AND.K.LE.KTCON(I)) THEN
1589 QO(I,k) = DELLAQ(I,k) * MBDT + Q1(I,k)
1590 DELLAT = (DELLAH(I,k) - HVAP * DELLAQ(I,k)) / CP
1591 TO(I,k) = DELLAT * MBDT + T1(I,k)
1592 !cmr QO(I,k) = max(QO(I,k),1.e-10)
1594 QO(I,k) = max(QO(I,k), val )
1599 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1601 !--- THE ABOVE CHANGED ENVIRONMENT IS NOW USED TO CALULATE THE
1602 !--- EFFECT THE ARBITRARY CLOUD (WITH UNIT MASS FLUX)
1603 !--- WOULD HAVE ON THE STABILITY,
1604 !--- WHICH THEN IS USED TO CALCULATE THE REAL MASS FLUX,
1605 !--- NECESSARY TO KEEP THIS CHANGE IN BALANCE WITH THE LARGE-SCALE
1606 !--- DESTABILIZATION.
1608 !--- ENVIRONMENTAL CONDITIONS AGAIN, FIRST HEIGHTS
1612 IF(k .le. kmax(i) .and. CNVFLG(I)) THEN
1613 !jfe QESO(I,k) = 10. * FPVS(TO(I,k))
1615 QESO(I,k) = 0.01 * fpvs(TO(I,K)) ! fpvs is in Pa
1617 QESO(I,k) = EPS * QESO(I,k) / (PFLD(I,k)+EPSM1*QESO(I,k))
1618 !cmr QESO(I,k) = MAX(QESO(I,k),1.E-8)
1620 QESO(I,k) = MAX(QESO(I,k), val )
1621 TVO(I,k) = TO(I,k) + DELTA * TO(I,k) * QO(I,k)
1632 ! HYDROSTATIC HEIGHT ASSUME ZERO TERR
1635 ! IF(CNVFLG(I)) THEN
1636 ! DLNSIG = LOG(PRSL(I,1)/PS(I))
1637 ! ZO(I,1) = TERR - DLNSIG * RD / G * TVO(I,1)
1642 ! IF(k .le. kmax(i) .and. CNVFLG(I)) THEN
1643 ! DLNSIG = LOG(PRSL(I,K) / PRSL(I,K-1))
1644 ! ZO(I,k) = ZO(I,k-1) - DLNSIG * RD / G
1645 ! & * .5 * (TVO(I,k) + TVO(I,k-1))
1650 !--- MOIST STATIC ENERGY
1654 IF(k .le. kmax(i)-1 .and. CNVFLG(I)) THEN
1655 DZ = .5 * (ZO(I,k+1) - ZO(I,k))
1656 DP = .5 * (PFLD(I,k+1) - PFLD(I,k))
1657 !jfe ES = 10. * FPVS(TO(I,k+1))
1659 ES = 0.01 * fpvs(TO(I,K+1)) ! fpvs is in Pa
1661 PPRIME = PFLD(I,k+1) + EPSM1 * ES
1662 QS = EPS * ES / PPRIME
1663 DQSDP = - QS / PPRIME
1664 DESDT = ES * (FACT1 / TO(I,k+1) + FACT2 / (TO(I,k+1)**2))
1665 DQSDT = QS * PFLD(I,k+1) * DESDT / (ES * PPRIME)
1666 GAMMA = EL2ORC * QESO(I,k+1) / (TO(I,k+1)**2)
1667 DT = (G * DZ + HVAP * DQSDP * DP) / (CP * (1. + GAMMA))
1668 DQ = DQSDT * DT + DQSDP * DP
1669 TO(I,k) = TO(I,k+1) + DT
1670 QO(I,k) = QO(I,k+1) + DQ
1671 PO(I,k) = .5 * (PFLD(I,k) + PFLD(I,k+1))
1677 IF(k .le. kmax(i)-1 .and. CNVFLG(I)) THEN
1678 !jfe QESO(I,k) = 10. * FPVS(TO(I,k))
1680 QESO(I,k) = 0.01 * fpvs(TO(I,K)) ! fpvs is in Pa
1682 QESO(I,k) = EPS * QESO(I,k) / (PO(I,k) + EPSM1 * QESO(I,k))
1683 !cmr QESO(I,k) = MAX(QESO(I,k),1.E-8)
1685 QESO(I,k) = MAX(QESO(I,k), val1)
1686 !cmr QO(I,k) = max(QO(I,k),1.e-10)
1688 QO(I,k) = max(QO(I,k), val2 )
1689 ! QO(I,k) = MIN(QO(I,k),QESO(I,k))
1690 HEO(I,k) = .5 * G * (ZO(I,k) + ZO(I,k+1)) + &
1691 & CP * TO(I,k) + HVAP * QO(I,k)
1692 HESO(I,k) = .5 * G * (ZO(I,k) + ZO(I,k+1)) + &
1693 & CP * TO(I,k) + HVAP * QESO(I,k)
1700 HEO(I,k) = G * ZO(I,k) + CP * TO(I,k) + HVAP * QO(I,k)
1701 HESO(I,k) = G * ZO(I,k) + CP * TO(I,k) + HVAP * QESO(I,k)
1702 ! HEO(I,k) = MIN(HEO(I,k),HESO(I,k))
1708 XHKB(I) = HEO(I,INDX)
1709 XQKB(I) = QO(I,INDX)
1710 HCKO(I,INDX) = XHKB(I)
1711 QCKO(I,INDX) = XQKB(I)
1716 !**************************** STATIC CONTROL
1719 !------- MOISTURE AND CLOUD WORK FUNCTIONS
1723 if (k .le. kmax(i)-1) then
1724 ! IF(CNVFLG(I).AND.K.GT.KB(I).AND.K.LE.KBCON(I)) THEN
1725 IF(CNVFLG(I).AND.K.GT.KB(I).AND.K.LE.KTCON(I)) THEN
1726 FACTOR = ETA(I,k-1) / ETA(I,k)
1728 HCKO(I,k) = FACTOR * HCKO(I,k-1) + ONEMF * &
1729 & .5 * (HEO(I,k) + HEO(I,k+1))
1731 ! IF(CNVFLG(I).AND.K.GT.KBCON(I)) THEN
1732 ! HEO(I,k) = HEO(I,k-1)
1739 if (k .le. kmax(i)-1) then
1740 IF(CNVFLG(I).AND.K.GT.KB(I).AND.K.LT.KTCON(I)) THEN
1741 DZ = .5 * (ZO(I,k+1) - ZO(I,k-1))
1742 GAMMA = EL2ORC * QESO(I,k) / (TO(I,k)**2)
1743 XDBY = HCKO(I,k) - HESO(I,k)
1744 !cmr XDBY = MAX(XDBY,0.)
1746 XDBY = MAX(XDBY,val)
1748 & + GAMMA * XDBY / (HVAP * (1. + GAMMA))
1749 FACTOR = ETA(I,k-1) / ETA(I,k)
1751 QCKO(I,k) = FACTOR * QCKO(I,k-1) + ONEMF * &
1752 & .5 * (QO(I,k) + QO(I,k+1))
1753 DQ = ETA(I,k) * QCKO(I,k) - ETA(I,k) * XQRCH
1755 ETAH = .5 * (ETA(I,k) + ETA(I,k-1))
1756 QLK = DQ / (ETA(I,k) + ETAH * C0 * DZ)
1757 XAA0(I) = XAA0(I) - (ZO(I,k) - ZO(I,k-1)) * G * QLK
1759 XPW = ETAH * C0 * DZ * QLK
1761 XPWAV(I) = XPWAV(I) + XPW
1764 ! IF(CNVFLG(I).AND.K.GT.KBCON(I).AND.K.LT.KTCON(I)) THEN
1765 IF(CNVFLG(I).AND.K.GT.KBCON(I).AND.K.LE.KTCON(I)) THEN
1766 DZ1 = ZO(I,k) - ZO(I,k-1)
1767 GAMMA = EL2ORC * QESO(I,k-1) / (TO(I,k-1)**2)
1768 RFACT = 1. + DELTA * CP * GAMMA &
1769 & * TO(I,k-1) / HVAP
1770 XDBY = HCKO(I,k-1) - HESO(I,k-1)
1772 & + DZ1 * (G / (CP * TO(I,k-1))) &
1773 & * XDBY / (1. + GAMMA) &
1777 & DZ1 * G * DELTA * &
1778 !cmr & MAX( 0.,(QESO(I,k-1) - QO(I,k-1))) &
1779 & MAX(val,(QESO(I,k-1) - QO(I,k-1)))
1784 !cccc IF(LAT.EQ.LATD.AND.lon.eq.lond.and.CNVFLG(I)) THEN
1785 !cccc PRINT *, ' XAA BEFORE DWNDRFT =', XAA0(I)
1788 !------- DOWNDRAFT CALCULATIONS
1791 !--- DOWNDRAFT MOISTURE PROPERTIES
1799 XHCD(I) = HEO(I,JMN)
1801 QRCD(I,JMN) = QESO(I,JMN)
1806 if (k .le. kmax(i)-1) then
1807 IF(DWNFLG2(I).AND.K.LT.JMIN(I)) THEN
1810 GAMMA = EL2ORC * DQ / DT**2
1811 DH = XHCD(I) - HESO(I,k)
1812 QRCD(I,k)=DQ+(1./HVAP)*(GAMMA/(1.+GAMMA))*DH
1813 DETAD = ETAD(I,k+1) - ETAD(I,k)
1814 XPWD = ETAD(I,k+1) * QRCD(I,k+1) - &
1815 & ETAD(I,k) * QRCD(I,k)
1816 XPWD = XPWD - DETAD * &
1817 & .5 * (QRCD(I,k) + QRCD(I,k+1))
1818 XPWEV(I) = XPWEV(I) + XPWD
1826 if(SLIMSK(I).eq.0.) edtmax = edtmaxs
1828 IF(XPWEV(I).GE.0.) THEN
1831 EDTX(I) = -EDTX(I) * XPWAV(I) / XPWEV(I)
1832 EDTX(I) = MIN(EDTX(I),EDTMAX)
1841 !--- DOWNDRAFT CLOUDWORK FUNCTIONS
1846 if (k .le. kmax(i)-1) then
1847 IF(DWNFLG2(I).AND.K.LT.JMIN(I)) THEN
1848 GAMMA = EL2ORC * QESO(I,k+1) / TO(I,k+1)**2
1853 DZ=-1.*(ZO(I,k+1)-ZO(I,k))
1854 XAA0(I)=XAA0(I)+EDTX(I)*DZ*(G/(CP*DT))*((DHH-DH)/(1.+DG)) &
1855 & *(1.+DELTA*CP*DG*DT/HVAP)
1857 XAA0(I)=XAA0(I)+EDTX(I)* &
1858 !cmr & DZ*G*DELTA*MAX( 0.,(QESO(I,k+1)-QO(I,k+1))) &
1859 & DZ*G*DELTA*MAX(val,(QESO(I,k+1)-QO(I,k+1)))
1864 !cccc IF(LAT.EQ.LATD.AND.lon.eq.lond.and.DWNFLG2(I)) THEN
1865 !cccc PRINT *, ' XAA AFTER DWNDRFT =', XAA0(I)
1868 ! CALCULATE CRITICAL CLOUD WORK FUNCTION
1873 ! IF(CNVFLG(I).AND.SLIMSK(I).NE.1.) THEN
1874 IF(PFLD(I,KTCON(I)).LT.PCRIT(15))THEN
1875 ACRT(I)=ACRIT(15)*(975.-PFLD(I,KTCON(I))) &
1877 ELSE IF(PFLD(I,KTCON(I)).GT.PCRIT(1))THEN
1880 !cmr K = IFIX((850. - PFLD(I,KTCON(I)))/50.) + 2
1881 K = int((850. - PFLD(I,KTCON(I)))/50.) + 2
1884 ACRT(I)=ACRIT(K)+(ACRIT(K-1)-ACRIT(K))* &
1885 & (PFLD(I,KTCON(I))-PCRIT(K))/(PCRIT(K-1)-PCRIT(K))
1888 ! ACRT(I) = .5 * (PFLD(I,KBCON(I)) - PFLD(I,KTCON(I)))
1894 if(SLIMSK(I).eq.1.) THEN
1905 !C IF(CNVFLG(I).AND.SLIMSK(I).EQ.1.) THEN
1906 ! ACRTFCT(I) = PDOT(I) / W3
1908 ! modify critical cloud workfunction by cloud base vertical velocity
1910 IF(PDOT(I).LE.W4) THEN
1911 ACRTFCT(I) = (PDOT(I) - W4) / (W3 - W4)
1912 ELSEIF(PDOT(I).GE.-W4) THEN
1913 ACRTFCT(I) = - (PDOT(I) + W4) / (W4 - W3)
1917 !cmr ACRTFCT(I) = MAX(ACRTFCT(I),-1.)
1919 ACRTFCT(I) = MAX(ACRTFCT(I),val1)
1920 !cmr ACRTFCT(I) = MIN(ACRTFCT(I),1.)
1922 ACRTFCT(I) = MIN(ACRTFCT(I),val2)
1923 ACRTFCT(I) = 1. - ACRTFCT(I)
1925 ! modify ACRTFCT(I) by colume mean rh if RHBAR(I) is greater than 80 percent
1927 ! if(RHBAR(I).ge..8) THEN
1928 ! ACRTFCT(I) = ACRTFCT(I) * (.9 - min(RHBAR(I),.9)) * 10.
1931 ! modify adjustment time scale by cloud base vertical velocity
1933 DTCONV(I) = DT2 + max((1800. - DT2),RZERO) * &
1934 & (PDOT(I) - W2) / (W1 - W2)
1935 ! DTCONV(I) = MAX(DTCONV(I), DT2)
1936 ! DTCONV(I) = 1800. * (PDOT(I) - w2) / (w1 - w2)
1937 DTCONV(I) = max(DTCONV(I),dtmin)
1938 DTCONV(I) = min(DTCONV(I),dtmax)
1943 !--- LARGE SCALE FORCING
1948 ! F = AA1(I) / DTCONV(I)
1949 FLD(I) = (AA1(I) - ACRT(I) * ACRTFCT(I)) / DTCONV(I)
1950 IF(FLD(I).LE.0.) FLG(I) = .FALSE.
1954 ! XAA0(I) = MAX(XAA0(I),0.)
1955 XK(I) = (XAA0(I) - AA1(I)) / MBDT
1956 IF(XK(I).GE.0.) FLG(I) = .FALSE.
1959 !--- KERNEL, CLOUD BASE MASS FLUX
1963 XMB(I) = -FLD(I) / XK(I)
1964 XMB(I) = MIN(XMB(I),XMBMAX(I))
1967 ! IF(LAT.EQ.LATD.AND.lon.eq.lond.and.CNVFLG(I)) THEN
1968 ! print *, ' RHBAR(I), ACRTFCT(I) =', RHBAR(I), ACRTFCT(I)
1969 ! PRINT *, ' A1, XA =', AA1(I), XAA0(I)
1970 ! PRINT *, ' XMB(I), ACRT =', XMB(I), ACRT
1974 TOTFLG = TOTFLG .AND. (.NOT. CNVFLG(I))
1978 ! restore t0 and QO to t1 and q1 in case convection stops
1982 if (k .le. kmax(i)) then
1985 !jfe QESO(I,k) = 10. * FPVS(T1(I,k))
1987 QESO(I,k) = 0.01 * fpvs(T1(I,K)) ! fpvs is in Pa
1989 QESO(I,k) = EPS * QESO(I,k) / (PFLD(I,k) + EPSM1*QESO(I,k))
1990 !cmr QESO(I,k) = MAX(QESO(I,k),1.E-8)
1992 QESO(I,k) = MAX(QESO(I,k), val )
1996 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1998 !--- FEEDBACK: SIMPLY THE CHANGES FROM THE CLOUD WITH UNIT MASS FLUX
1999 !--- MULTIPLIED BY THE MASS FLUX NECESSARY TO KEEP THE
2000 !--- EQUILIBRIUM WITH THE LARGER-SCALE.
2010 if (k .le. kmax(i)) then
2011 IF(CNVFLG(I).AND.K.LE.KTCON(I)) THEN
2013 IF(K.Le.KB(I)) AUP = 0.
2015 IF(K.GT.JMIN(I)) ADW = 0.
2016 DELLAT = (DELLAH(I,k) - HVAP * DELLAQ(I,k)) / CP
2017 T1(I,k) = T1(I,k) + DELLAT * XMB(I) * DT2
2018 Q1(I,k) = Q1(I,k) + DELLAQ(I,k) * XMB(I) * DT2
2019 U1(I,k) = U1(I,k) + DELLAU(I,k) * XMB(I) * DT2
2020 V1(I,k) = V1(I,k) + DELLAV(I,k) * XMB(I) * DT2
2021 DP = 1000. * DEL(I,K)
2022 DELHBAR(I) = DELHBAR(I) + DELLAH(I,k)*XMB(I)*DP/G
2023 DELQBAR(I) = DELQBAR(I) + DELLAQ(I,k)*XMB(I)*DP/G
2024 DELTBAR(I) = DELTBAR(I) + DELLAT*XMB(I)*DP/G
2031 if (k .le. kmax(i)) then
2032 IF(CNVFLG(I).AND.K.LE.KTCON(I)) THEN
2033 !jfe QESO(I,k) = 10. * FPVS(T1(I,k))
2035 QESO(I,k) = 0.01 * fpvs(T1(I,K)) ! fpvs is in Pa
2037 QESO(I,k) = EPS * QESO(I,k)/(PFLD(I,k) + EPSM1*QESO(I,k))
2038 !cmr QESO(I,k) = MAX(QESO(I,k),1.E-8)
2040 QESO(I,k) = MAX(QESO(I,k), val )
2044 if(ncloud.gt.0.and.CNVFLG(I).and.k.eq.KTCON(I)) THEN
2045 tem = DELLAL(I) * XMB(I) * dt2
2046 tem1 = MAX(RZERO, MIN(RONE, (TCR-t1(I,K))*TCRF))
2047 if (QL(I,k,2) .gt. -999.0) then
2048 QL(I,k,1) = QL(I,k,1) + tem * tem1 ! Ice
2049 QL(I,k,2) = QL(I,k,2) + tem *(1.0-tem1) ! Water
2051 tem2 = QL(I,k,1) + tem
2052 QL(I,k,1) = tem2 * tem1 ! Ice
2053 QL(I,k,2) = tem2 - QL(I,k,1) ! Water
2055 ! QL(I,k) = QL(I,k) + DELLAL(I) * XMB(I) * dt2
2056 dp = 1000. * del(i,k)
2057 DELLAL(I) = DELLAL(I) * XMB(I) * dp / g
2063 ! IF(LAT.EQ.LATD.AND.lon.eq.lond.and.CNVFLG(I) ) THEN
2064 ! PRINT *, ' DELHBAR, DELQBAR, DELTBAR ='
2065 ! PRINT *, DELHBAR, HVAP*DELQBAR, CP*DELTBAR
2066 ! PRINT *, ' DELLBAR ='
2067 ! PRINT 6003, HVAP*DELLbar
2068 ! PRINT *, ' DELLAQ ='
2069 ! PRINT 6003, (HVAP*DELLAQ(I,k)*XMB(I),K=1,KMAX)
2070 ! PRINT *, ' DELLAT ='
2071 ! PRINT 6003, (DELLAH(i,k)*XMB(I)-HVAP*DELLAQ(I,k)*XMB(I), &
2082 if (k .le. kmax(i)) then
2083 IF(CNVFLG(I).AND.K.LE.KTCON(I)) THEN
2085 IF(K.Le.KB(I)) AUP = 0.
2087 IF(K.GT.JMIN(I)) ADW = 0.
2088 rain = AUP * PWO(I,k) + ADW * EDTO(I) * PWDO(I,k)
2089 RNTOT(I) = RNTOT(I) + rain * XMB(I) * .001 * dt2
2096 if (k .le. kmax(i)) then
2100 IF(CNVFLG(I).AND.K.LE.KTCON(I)) THEN
2102 IF(K.Le.KB(I)) AUP = 0.
2104 IF(K.GT.JMIN(I)) ADW = 0.
2105 rain = AUP * PWO(I,k) + ADW * EDTO(I) * PWDO(I,k)
2106 RN(I) = RN(I) + rain * XMB(I) * .001 * dt2
2108 IF(FLG(I).AND.K.LE.KTCON(I)) THEN
2109 evef = EDT(I) * evfact
2110 if(SLIMSK(I).eq.1.) evef=EDT(I) * evfactl
2111 ! if(SLIMSK(I).eq.1.) evef=.07
2112 ! if(SLIMSK(I).ne.1.) evef = 0.
2113 QCOND(I) = EVEF * (Q1(I,k) - QESO(I,k)) &
2114 & / (1. + EL2ORC * QESO(I,k) / T1(I,k)**2)
2115 DP = 1000. * DEL(I,K)
2116 IF(RN(I).GT.0..AND.QCOND(I).LT.0.) THEN
2117 QEVAP(I) = -QCOND(I) * (1.-EXP(-.32*SQRT(DT2*RN(I))))
2118 QEVAP(I) = MIN(QEVAP(I), RN(I)*1000.*G/DP)
2119 DELQ2(I) = DELQEV(I) + .001 * QEVAP(I) * dp / g
2121 if(RN(I).gt.0..and.QCOND(I).LT.0..and. &
2122 & DELQ2(I).gt.RNTOT(I)) THEN
2123 QEVAP(I) = 1000.* g * (RNTOT(I) - DELQEV(I)) / dp
2126 IF(RN(I).GT.0..AND.QEVAP(I).gt.0.) THEN
2127 Q1(I,k) = Q1(I,k) + QEVAP(I)
2128 T1(I,k) = T1(I,k) - ELOCP * QEVAP(I)
2129 RN(I) = RN(I) - .001 * QEVAP(I) * DP / G
2130 DELTV(I) = - ELOCP*QEVAP(I)/DT2
2131 DELQ(I) = + QEVAP(I)/DT2
2132 DELQEV(I) = DELQEV(I) + .001*dp*QEVAP(I)/g
2134 DELLAQ(I,k) = DELLAQ(I,k) + DELQ(I) / XMB(I)
2135 DELQBAR(I) = DELQBAR(I) + DELQ(I)*DP/G
2136 DELTBAR(I) = DELTBAR(I) + DELTV(I)*DP/G
2141 ! IF(LAT.EQ.LATD.AND.lon.eq.lond.and.CNVFLG(I) ) THEN
2142 ! PRINT *, ' DELLAH ='
2143 ! PRINT 6003, (DELLAH(k)*XMB(I),K=1,KMAX)
2144 ! PRINT *, ' DELLAQ ='
2145 ! PRINT 6003, (HVAP*DELLAQ(I,k)*XMB(I),K=1,KMAX)
2146 ! PRINT *, ' DELHBAR, DELQBAR, DELTBAR ='
2147 ! PRINT *, DELHBAR, HVAP*DELQBAR, CP*DELTBAR
2148 ! PRINT *, ' PRECIP =', HVAP*RN(I)*1000./DT2
2149 !CCCC PRINT *, ' DELLBAR ='
2150 !CCCC PRINT *, HVAP*DELLbar
2153 ! PRECIPITATION RATE CONVERTED TO ACTUAL PRECIP
2154 ! IN UNIT OF M INSTEAD OF KG
2159 ! IN THE EVENT OF UPPER LEVEL RAIN EVAPORATION AND LOWER LEVEL DOWNDRAF
2160 ! MOISTENING, RN CAN BECOME NEGATIVE, IN THIS CASE, WE BACK OUT OF TH
2161 ! HEATING AND THE MOISTENING
2163 if(RN(I).lt.0..and..not.FLG(I)) RN(I) = 0.
2164 IF(RN(I).LE.0.) THEN
2176 if (k .le. kmax(i)) then
2177 IF(CNVFLG(I).AND.RN(I).LE.0.) THEN
2186 END SUBROUTINE OSASCNV
2188 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2190 SUBROUTINE SHALCV(IM,IX,KM,DT,DEL,PRSI,PRSL,PRSLK,KUO,Q,T,DPSHC)
2192 USE MODULE_GFS_MACHINE , ONLY : kind_phys
2193 USE MODULE_GFS_PHYSCONS, grav => con_g, CP => con_CP, HVAP => con_HVAP &
2198 ! include 'constant.h'
2200 integer IM, IX, KM, KUO(IM)
2201 real(kind=kind_phys) DEL(IX,KM), PRSI(IX,KM+1), PRSL(IX,KM), &
2203 & Q(IX,KM), T(IX,KM), DT, DPSHC
2207 real(kind=kind_phys) ck, cpdt, dmse, dsdz1, dsdz2, &
2208 & dsig, dtodsl, dtodsu, eldq, g, &
2211 integer k,k1,k2,kliftl,kliftu,kt,N2,I,iku,ik1,ik,ii
2212 integer INDEX2(IM), KLCL(IM), KBOT(IM), KTOP(IM),kk &
2215 ! PHYSICAL PARAMETERS
2216 PARAMETER(G=GRAV, GOCP=G/CP)
2217 ! BOUNDS OF PARCEL ORIGIN
2218 PARAMETER(KLIFTL=2,KLIFTU=2)
2220 real(kind=kind_phys) Q2(IM*KM), T2(IM*KM), &
2221 & PRSL2(IM*KM), PRSLK2(IM*KM), &
2222 & AL(IM*(KM-1)), AD(IM*KM), AU(IM*(KM-1))
2223 !-----------------------------------------------------------------------
2224 ! COMPRESS FIELDS TO POINTS WITH NO DEEP CONVECTION
2225 ! AND MOIST STATIC INSTABILITY.
2231 IF(KUO(I).EQ.0) THEN
2232 ELDQ = HVAP*(Q(I,K)-Q(I,K+1))
2233 CPDT = CP*(T(I,K)-T(I,K+1))
2234 RTDLS = (PRSL(I,K)-PRSL(I,K+1)) / &
2235 & PRSI(I,K+1)*RD*0.5*(T(I,K)+T(I,K+1))
2236 DMSE = ELDQ+CPDT-RTDLS
2237 LSHC(I) = LSHC(I).OR.DMSE.GT.0.
2256 PRSL2(IK) = PRSL(II,K)
2257 PRSLK2(IK) = PRSLK(II,K)
2266 if (prsi(ii,1)-prsi(ii,k) .le. dpshc) ktopm(i) = k
2270 !-----------------------------------------------------------------------
2271 ! COMPUTE MOIST ADIABAT AND DETERMINE LIMITS OF SHALLOW CONVECTION.
2272 ! CHECK FOR MOIST STATIC INSTABILITY AGAIN WITHIN CLOUD.
2273 CALL MSTADBT3(N2,KM-1,KLIFTL,KLIFTU,PRSL2,PRSLK2,T2,Q2, &
2274 & KLCL,KBOT,KTOP,AL,AU)
2276 KBOT(I) = min(KLCL(I)-1, ktopm(i)-1)
2277 KTOP(I) = min(KTOP(I)+1, ktopm(i))
2283 IF(K.GE.KBOT(I).AND.K.LT.KTOP(I)) THEN
2286 ELDQ = HVAP * (Q2(IK)-Q2(IKU))
2287 CPDT = CP * (T2(IK)-T2(IKU))
2288 RTDLS = (PRSL2(IK)-PRSL2(IKU)) / &
2289 & PRSI(index2(i),K+1)*RD*0.5*(T2(IK)+T2(IKU))
2290 DMSE = ELDQ + CPDT - RTDLS
2291 LSHC(I) = LSHC(I).OR.DMSE.GT.0.
2299 IF(.NOT.LSHC(I)) THEN
2303 K1 = MIN(K1,KBOT(I))
2304 K2 = MAX(K2,KTOP(I))
2308 !-----------------------------------------------------------------------
2309 ! SET EDDY VISCOSITY COEFFICIENT CKU AT SIGMA INTERFACES.
2310 ! COMPUTE DIAGONALS AND RHS FOR TRIDIAGONAL MATRIX SOLVER.
2311 ! EXPAND FINAL FIELDS.
2321 ! DTODSU= DT/DEL(K+1)
2322 ! DSIG=SL(K)-SL(K+1)
2326 DTODSL = DT/DEL(II,K)
2327 DTODSU = DT/DEL(II,K+1)
2328 DSIG = PRSL(II,K) - PRSL(II,K+1)
2331 IF(K.EQ.KBOT(I)) THEN
2333 ELSEIF(K.EQ.KTOP(I)-1) THEN
2335 ELSEIF(K.EQ.KTOP(I)-2) THEN
2337 ELSEIF(K.GT.KBOT(I).AND.K.LT.KTOP(I)-2) THEN
2342 DSDZ1 = CK*DSIG*AU(IK)*GOCP
2343 DSDZ2 = CK*DSIG*AU(IK)*AU(IK)
2344 AU(IK) = -DTODSL*DSDZ2
2345 AL(IK) = -DTODSU*DSDZ2
2346 AD(IK) = AD(IK)-AU(IK)
2348 T2(IK) = T2(IK)+DTODSL*DSDZ1
2349 T2(IKU) = T2(IKU)-DTODSU*DSDZ1
2353 CALL TRIDI2T3(N2,KT,AL(IK1),AD(IK1),AU(IK1),Q2(IK1),T2(IK1), &
2354 & AU(IK1),Q2(IK1),T2(IK1))
2359 Q(INDEX2(I),K) = Q2(IK)
2360 T(INDEX2(I),K) = T2(IK)
2363 !-----------------------------------------------------------------------
2365 END SUBROUTINE SHALCV
2366 !-----------------------------------------------------------------------
2367 SUBROUTINE TRIDI2T3(L,N,CL,CM,CU,R1,R2,AU,A1,A2)
2368 !yt INCLUDE DBTRIDI2;
2370 USE MODULE_GFS_MACHINE , ONLY : kind_phys
2373 real(kind=kind_phys) fk
2375 real(kind=kind_phys) &
2376 & CL(L,2:N),CM(L,N),CU(L,N-1),R1(L,N),R2(L,N), &
2377 & AU(L,N-1),A1(L,N),A2(L,N)
2378 !-----------------------------------------------------------------------
2387 FK=1./(CM(I,K)-CL(I,K)*AU(I,K-1))
2389 A1(I,K)=FK*(R1(I,K)-CL(I,K)*A1(I,K-1))
2390 A2(I,K)=FK*(R2(I,K)-CL(I,K)*A2(I,K-1))
2394 FK=1./(CM(I,N)-CL(I,N)*AU(I,N-1))
2395 A1(I,N)=FK*(R1(I,N)-CL(I,N)*A1(I,N-1))
2396 A2(I,N)=FK*(R2(I,N)-CL(I,N)*A2(I,N-1))
2400 A1(I,K)=A1(I,K)-AU(I,K)*A1(I,K+1)
2401 A2(I,K)=A2(I,K)-AU(I,K)*A2(I,K+1)
2404 !-----------------------------------------------------------------------
2406 END SUBROUTINE TRIDI2T3
2407 !-----------------------------------------------------------------------
2409 SUBROUTINE MSTADBT3(IM,KM,K1,K2,PRSL,PRSLK,TENV,QENV, &
2410 & KLCL,KBOT,KTOP,TCLD,QCLD)
2411 !yt INCLUDE DBMSTADB;
2413 USE MODULE_GFS_MACHINE, ONLY : kind_phys
2414 USE MODULE_GFS_FUNCPHYS, ONLY : FTDP, FTHE, FTLCL, STMA
2415 USE MODULE_GFS_PHYSCONS, EPS => con_eps, EPSM1 => con_epsm1, FV => con_FVirt
2419 ! include 'constant.h'
2421 integer k,k1,k2,km,i,im
2422 real(kind=kind_phys) pv,qma,slklcl,tdpd,thelcl,tlcl
2423 real(kind=kind_phys) tma,tvcld,tvenv
2425 real(kind=kind_phys) PRSL(IM,KM), PRSLK(IM,KM), TENV(IM,KM), &
2426 & QENV(IM,KM), TCLD(IM,KM), QCLD(IM,KM)
2427 INTEGER KLCL(IM), KBOT(IM), KTOP(IM)
2429 real(kind=kind_phys) SLKMA(IM), THEMA(IM)
2430 !-----------------------------------------------------------------------
2431 ! DETERMINE WARMEST POTENTIAL WET-BULB TEMPERATURE BETWEEN K1 AND K2.
2432 ! COMPUTE ITS LIFTING CONDENSATION LEVEL.
2440 PV = 1000.0 * PRSL(I,K)*QENV(I,K)/(EPS-EPSM1*QENV(I,K))
2441 TDPD = TENV(I,K)-FTDP(PV)
2443 TLCL = FTLCL(TENV(I,K),TDPD)
2444 SLKLCL = PRSLK(I,K)*TLCL/TENV(I,K)
2449 THELCL=FTHE(TLCL,SLKLCL)
2450 IF(THELCL.GT.THEMA(I)) THEN
2456 !-----------------------------------------------------------------------
2457 ! SET CLOUD TEMPERATURES AND HUMIDITIES WHEREVER THE PARCEL LIFTED UP
2458 ! THE MOIST ADIABAT IS BUOYANT WITH RESPECT TO THE ENVIRONMENT.
2472 IF(PRSLK(I,K).LE.SLKMA(I)) THEN
2473 KLCL(I)=MIN(KLCL(I),K)
2474 CALL STMA(THEMA(I),PRSLK(I,K),TMA,QMA)
2475 ! TMA=FTMA(THEMA(I),PRSLK(I,K),QMA)
2476 TVCLD=TMA*(1.+FV*QMA)
2477 TVENV=TENV(I,K)*(1.+FV*QENV(I,K))
2478 IF(TVCLD.GT.TVENV) THEN
2479 KBOT(I)=MIN(KBOT(I),K)
2480 KTOP(I)=MAX(KTOP(I),K)
2481 TCLD(I,K)=TMA-TENV(I,K)
2482 QCLD(I,K)=QMA-QENV(I,K)
2487 !-----------------------------------------------------------------------
2489 END SUBROUTINE MSTADBT3
2492 ! random seeds - ZCX
2493 SUBROUTINE init_random_seed()
2494 INTEGER :: i, n, clock
2495 INTEGER, DIMENSION(:), ALLOCATABLE :: seed
2497 CALL RANDOM_SEED(size = n)
2500 CALL SYSTEM_CLOCK(COUNT=clock)
2502 seed = clock + 37 * (/ (i - 1, i = 1, n) /)
2503 CALL RANDOM_SEED(PUT = seed)
2508 END MODULE module_cu_osas