1 !-----------------------------------------------------------------------
3 !WRF:MODEL_LAYER:PHYSICS
5 !-----------------------------------------------------------------------
9 !-----------------------------------------------------------------------
10 USE MODULE_MODEL_CONSTANTS
11 !-----------------------------------------------------------------------
15 & ,DTTOP=0.,EFIFC=5.0,EFIMN=0.20,EFMNT=0.70 &
16 & ,ELIWV=2.683E6,ENPLO=20000.,ENPUP=15000. &
17 & ,EPSDN=1.05,EPSDT=0. &
18 & ,EPSNTP=.0001,EPSNTT=.0001,EPSPR=1.E-7 &
20 & ,FR=1.00,FSL=0.85,FSS=0.85,GAM=0.5,PEPS=1./2.5 &
21 & ,FUP=0.,FCC=5.00,CRMN=0.14,CRMX=85.0 &
22 & ,PBM=13000.,PFRZ=15000.,PNO=1000. &
23 & ,PONE=2500.,PQM=20000. &
24 & ,PSH=20000.,PSHU=45000. &
25 & ,RENDP=1./(ENPLO-ENPUP) &
26 & ,RHLSC=0.00,RHHSC=1.10 &
28 & ,STABDF=0.90,STABDS=0.90 &
29 & ,STABS=1.0,STRESH=1.10 &
30 & ,DTSHAL=-1.0,TREL=2400.
32 REAL,PARAMETER :: DTtrigr=-0.0 &
33 ,DTPtrigr=DTtrigr*PONE !<-- Average parcel virtual temperature deficit over depth PONE.
34 !<-- NOTE: CAPEtrigr is scaled by the cloud base temperature (see below)
36 REAL,PARAMETER :: DSPBFL=-3875.*FR &
43 REAL,PARAMETER :: PL=2500.,PLQ=70000.,PH=105000. &
44 & ,THL=210.,THH=365.,THHQ=325.
46 INTEGER,PARAMETER :: ITB=76,JTB=134,ITBQ=152,JTBQ=440
48 INTEGER,PARAMETER :: ITREFI_MAX=3
50 !*** ARRAYS FOR LOOKUP TABLES
52 REAL,DIMENSION(ITB),PRIVATE,SAVE :: STHE,THE0
53 REAL,DIMENSION(JTB),PRIVATE,SAVE :: QS0,SQS
54 REAL,DIMENSION(ITBQ),PRIVATE,SAVE :: STHEQ,THE0Q
55 REAL,DIMENSION(ITB,JTB),PRIVATE,SAVE :: PTBL
56 REAL,DIMENSION(JTB,ITB),PRIVATE,SAVE :: TTBL
57 REAL,DIMENSION(JTBQ,ITBQ),PRIVATE,SAVE :: TTBLQ
59 !*** SHARE COPIES FOR MODULE_BL_MYJPBL
61 REAL,DIMENSION(JTB) :: QS0_EXP,SQS_EXP
62 REAL,DIMENSION(ITB,JTB) :: PTBL_EXP
64 REAL,PARAMETER :: RDP=(ITB-1.)/(PH-PL),RDPQ=(ITBQ-1.)/(PH-PLQ) &
65 & ,RDQ=ITB-1,RDTH=(JTB-1.)/(THH-THL) &
66 & ,RDTHE=JTB-1.,RDTHEQ=JTBQ-1. &
69 REAL,PARAMETER :: AVGEFI=(EFIMN+1.)*0.5
71 !-----------------------------------------------------------------------
75 !-----------------------------------------------------------------------
77 & IDS,IDE,JDS,JDE,KDS,KDE &
78 & ,IMS,IME,JMS,JME,KMS,KME &
79 & ,ITS,ITE,JTS,JTE,KTS,KTE &
80 & ,DT,ITIMESTEP,STEPCU,CCLDFRA,CONVCLD &
81 & ,RAINCV,PRATEC,CUTOP,CUBOT,KPBL &
82 & ,TH,T,QV,QCCONV,QICONV,BMJ_RAD_FEEDBACK &
83 & ,PINT,PMID,PI,RHO,DZ8W &
84 & ,CP,R,ELWV,ELIV,G,TFRZ,D608 &
85 & ,CLDEFI,LOWLYR,XLAND,CU_ACT_FLAG &
87 & ,RTHCUTEN,RQVCUTEN &
89 !-----------------------------------------------------------------------
91 !-----------------------------------------------------------------------
92 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
93 & ,IMS,IME,JMS,JME,KMS,KME &
94 & ,ITS,ITE,JTS,JTE,KTS,KTE
96 INTEGER,INTENT(IN) :: ITIMESTEP,STEPCU
98 INTEGER,DIMENSION(IMS:IME,JMS:JME),INTENT(IN) :: KPBL,LOWLYR
100 REAL,INTENT(IN) :: CP,DT,ELIV,ELWV,G,R,TFRZ,D608
102 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(IN) :: XLAND
104 REAL,DIMENSION(IMS:IME,KMS:KME,JMS:JME),INTENT(IN) :: DZ8W &
109 REAL,DIMENSION(IMS:IME,KMS:KME,JMS:JME),INTENT(INOUT) :: CCLDFRA &
113 REAL,DIMENSION(IMS:IME,KMS:KME,JMS:JME) &
115 & ,INTENT(INOUT) :: RQVCUTEN,RTHCUTEN
117 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(INOUT) :: CLDEFI,RAINCV, &
120 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(OUT) :: CUBOT,CUTOP
122 LOGICAL,INTENT(IN) :: bmj_rad_feedback
123 LOGICAL,DIMENSION(IMS:IME,JMS:JME),INTENT(INOUT) :: CU_ACT_FLAG
126 !-----------------------------------------------------------------------
130 !-----------------------------------------------------------------------
131 INTEGER :: LBOT,LPBL,LTOP
133 REAL :: DTCNVC,LANDMASK,PCPCOL,PSFC,PTOP
134 REAL :: PAVG,PWCOL,DQCOL,DQCOLMIN
135 REAL :: CUMX,QCIS,RRP,PRRT,MCOL,MPVPR,FACTL
138 REAL,DIMENSION(KTS:KTE) :: DPCOL,DQDT,DTDT,PCOL,QCOL,TCOL
139 REAL,DIMENSION(KTS:KTE) :: PVPR,JPR
141 INTEGER :: I,J,K,KFLIP,LMH
143 !*** Begin debugging convection
144 REAL :: DELQ,DELT,PLYR
146 LOGICAL :: PRINT_DIAG
147 !*** End debugging convection
149 !-----------------------------------------------------------------------
150 !***********************************************************************
151 !-----------------------------------------------------------------------
153 !*** PREPARE TO CALL BMJ CONVECTION SCHEME
155 !-----------------------------------------------------------------------
157 !*** Begin debugging convection
161 !*** End debugging convection
166 CU_ACT_FLAG(I,J)=.TRUE.
193 PSFC=PINT(I,LOWLYR(I,J),J)
194 PTOP=PINT(I,KTE+1,J) ! KTE+1=KME
196 !*** CONVERT TO BMJ LAND MASK (1.0 FOR SEA; 0.0 FOR LAND)
198 LANDMASK=XLAND(I,J)-1.
200 !*** FILL 1-D VERTICAL ARRAYS
201 !*** AND FLIP DIRECTION SINCE BMJ SCHEME
202 !*** COUNTS DOWNWARD FROM THE DOMAIN'S TOP
207 !*** CONVERT FROM MIXING RATIO TO SPECIFIC HUMIDITY
209 QCOL(K)=MAX(EPSQ,QV(I,KFLIP,J)/(1.+QV(I,KFLIP,J)))
211 PCOL(K)=PMID(I,KFLIP,J)
212 ! DPCOL(K)=PINT(I,KFLIP,J)-PINT(I,KFLIP+1,J)
213 DPCOL(K)=RHO(I,KFLIP,J)*G*DZ8W(I,KFLIP,J)
216 !*** LOWEST LAYER ABOVE GROUND MUST ALSO BE FLIPPED
218 LMH=KTE+1-LOWLYR(I,J)
220 !-----------------------------------------------------------------------
224 !-----------------------------------------------------------------------
225 !*** Begin debugging convection
227 ! IF(I==IMD.AND.J==JMD)PRINT_DIAG=.TRUE.
228 !*** End debugging convection
229 !-----------------------------------------------------------------------
230 CALL BMJ(ITIMESTEP,I,J,DTCNVC,LMH,LANDMASK,CLDEFI(I,J) &
231 & ,DPCOL,PCOL,QCOL,TCOL,PSFC,PTOP &
232 & ,DQDT,DTDT,PCPCOL,LBOT,LTOP,LPBL &
233 & ,PWCOL,DQCOL,DQCOLMIN &
234 & ,CP,R,ELWV,ELIV,G,TFRZ,D608 &
236 & ,IDS,IDE,JDS,JDE,KDS,KDE &
237 & ,IMS,IME,JMS,JME,KMS,KME &
238 & ,ITS,ITE,JTS,JTE,KTS,KTE)
239 !-----------------------------------------------------------------------
241 !*** COMPUTE HEATING AND MOISTENING TENDENCIES
243 IF ( PRESENT( RTHCUTEN ) .AND. PRESENT( RQVCUTEN )) THEN
246 RTHCUTEN(I,K,J)=DTDT(KFLIP)/PI(I,K,J)
248 !*** CONVERT FROM SPECIFIC HUMIDTY BACK TO MIXING RATIO
250 RQVCUTEN(I,K,J)=DQDT(KFLIP)/(1.-QCOL(KFLIP))**2
254 !*** ALL UNITS IN BMJ SCHEME ARE MKS, THUS CONVERT PRECIP FROM METERS
255 !*** TO MILLIMETERS PER STEP FOR OUTPUT.
257 RAINCV(I,J)=PCPCOL*1.E3/STEPCU
258 PRATEC(I,J)=PCPCOL*1.E3/(STEPCU * DT)
260 !*** CONVECTIVE CLOUD TOP AND BOTTOM FROM THIS CALL
262 CUTOP(I,J)=REAL(KTE+1-LTOP)
263 CUBOT(I,J)=REAL(KTE+1-LBOT)
265 IF ( bmj_rad_feedback ) THEN
267 IF (DQCOL.GT.DQCOLMIN) THEN
269 !*** CONVECTIVE CLOUD FRACTION: BASED ON SLINGO (1987) WITH A POISSON
270 !*** VERTICAL PROFILE. PLEASE NOTE THAT THE BMJ PRECIPITATION RATE
271 !*** (PRATEC) HAS TO BE CONVERTED FROM MMS-1 TO MMDAY-1.
280 PRRT=(PRATEC(I,J)*86400.0)/CRMN
281 RRP=0.8/(LOG(CRMX/CRMN))
282 IF (PRRT<CRMX/CRMN) THEN
288 !*** COMPUTE THE CONVECTIVE CLOUD FRACTION (CCLDFRA) AT EACH MODEL LEVEL.
289 !*** FOR N>=17 USE THE STERLING APPROXIMATION AS FOR N=17 IT GIVES A RELATIVE
290 !*** ERROR OF ~9.4x10E-8.
292 TTOP=NINT(CUTOP(I,J))
293 BBOT=NINT(CUBOT(I,J))
296 IF (K.GE.BBOT.AND.K.LE.TTOP) THEN
297 JPR(K)=(1./PEPS)*((PMID(I,K,J)-PMID(I,TTOP,J))/(PMID(I,BBOT,J)-PMID(I,TTOP,J)))
306 IF (JPR(BBOT).LT.17) THEN
308 PVPR(K)=(PAVG)**(JPR(K))/GAMMA(JPR(K)+1.)
312 FACTL=JPR(K)*LOG(JPR(K))-JPR(K)+1./2.*LOG(2.*JPR(K)*ACOS(-1.))+ &
313 LOG(1.+1./(12.*JPR(K))+1./(288.*JPR(K)**2))
314 PVPR(K)=EXP((JPR(K))*LOG(1.*PAVG)-FACTL)
319 PVPR(K)=PVPR(K)/MPVPR
322 CCLDFRA(I,K,J)=CUMX*PVPR(K)
325 !*** COMPUTE THE CONVECTIVE CLOUD CONDENSATES (QCCONV,QICONV). PLEASE NOTE THAT
326 !*** THE EQUATION FOR QCIS IS VALID FOR PRRTs IN THE RANGE 10**(-7) TO 10**3.
330 DO K=CUBOT(I,J),CUTOP(I,J)
332 MCOL=RHO(I,K,J)*DZ8W(I,K,J)*QCOL(KFLIP)*CCLDFRA(I,K,J)+MCOL
334 CONVCLD(I,J)=PWCOL**GAM*(DQCOL-DQCOLMIN)**(1.-GAM)
335 QCIS=CONVCLD(I,J)/MCOL
338 IF (TCOL(KFLIP)>=TFRZ) THEN
340 QCCONV(I,K,J)=(QCIS*QCOL(KFLIP)*CCLDFRA(I,K,J))/(1.-QCOL(KFLIP))
342 QICONV(I,K,J)=(QCIS*QCOL(KFLIP)*CCLDFRA(I,K,J))/(1.-QCOL(KFLIP))
351 !-----------------------------------------------------------------------
352 !*** Begin debugging convection
357 IF(LBOT>0.AND.LTOP<LBOT)THEN
360 DELQ=DELQ+DPCOL(K)*DTCNVC*ABS(DQDT(K))
361 DELT=DELT+DPCOL(K)*DTCNVC*ABS(DTDT(K))
367 WRITE(6,"(2a,2i4,3e12.4,f7.2,4i3)") &
368 '{cu3 i,j,PCPCOL,DTavg,DQavg,PLYR,' &
369 ,'LBOT,LTOP,CUBOT,CUTOP = ' &
370 ,i,j, PCPCOL,DELT,1000.*DELQ,.01*PLYR &
371 ,LBOT,LTOP,NINT(CUBOT(I,J)),NINT(CUTOP(I,J))
376 WRITE(6,"(a,i3,2e12.4,f7.2)") '{cu3a KFLIP,DT,DQ,DP = ' &
377 ,KFLIP,DTCNVC*DTDT(K),1000.*DTCNVC*DQDT(K),.01*DPCOL(K)
381 !*** End debugging convection
382 !-----------------------------------------------------------------------
387 END SUBROUTINE BMJDRV
388 !-----------------------------------------------------------------------
389 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
390 !-----------------------------------------------------------------------
392 !-----------------------------------------------------------------------
393 & (ITIMESTEP,I,J,DTCNVC,LMH,SM,CLDEFI &
394 & ,DPRS,PRSMID,Q,T,PSFC,PT &
395 & ,DQDT,DTDT,PCPCOL,LBOT,LTOP,LPBL &
396 & ,PWCOL,DQCOL,DQCOLMIN &
397 & ,CP,R,ELWV,ELIV,G,TFRZ,D608 &
399 & ,IDS,IDE,JDS,JDE,KDS,KDE &
400 & ,IMS,IME,JMS,JME,KMS,KME &
401 & ,ITS,ITE,JTS,JTE,KTS,KTE)
402 !-----------------------------------------------------------------------
404 !-----------------------------------------------------------------------
405 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
406 ,IMS,IME,JMS,JME,KMS,KME &
407 ,ITS,ITE,JTS,JTE,KTS,KTE &
410 INTEGER,INTENT(IN) :: LMH,LPBL
412 INTEGER,INTENT(OUT) :: LBOT,LTOP
414 REAL,INTENT(IN) :: CP,D608,DTCNVC,ELIV,ELWV,G,PSFC,PT,R,SM,TFRZ
416 REAL,DIMENSION(KTS:KTE),INTENT(IN) :: DPRS,PRSMID,Q,T
418 REAL,INTENT(INOUT) :: CLDEFI,PCPCOL,PWCOL,DQCOL,DQCOLMIN
420 REAL,DIMENSION(KTS:KTE),INTENT(INOUT) :: DQDT,DTDT
422 !-----------------------------------------------------------------------
423 !*** DEFINE LOCAL VARIABLES
424 !-----------------------------------------------------------------------
426 REAL,DIMENSION(KTS:KTE) :: APEK,APESK,EL,FPK &
427 ,PK,PSK,QK,QREFK,QSATK &
429 ,THVMOD,THVREF,TK,TREFK
430 REAL,DIMENSION(KTS:KTE) :: APE,DIFQ,DIFT,THEE,THES,TREF
432 REAL,DIMENSION(KTS:KTE) :: CPE,CPEcnv,DTV,DTVcnv,THEScnv !<-- CPE for shallow convection buoyancy check (24 Aug 2006)
434 LOGICAL :: DEEP,SHALLOW
436 !*** Begin debugging convection
437 LOGICAL :: PRINT_DIAG
438 !*** End debugging convection
440 !-----------------------------------------------------------------------
444 !-----------------------------------------------------------------------
445 REAL :: APEKL,APEKXX,APEKXY,APES,APESTS &
446 & ,AVRGT,AVRGTL,BQ,BQK,BQS00K,BQS10K &
447 & ,CAPA,CUP,DEN,DENTPY,DEPMIN,DEPTH &
448 & ,DEPWL,DHDT,DIFQL,DIFTL,DP,DPKL,DPLO,DPMIX,DPOT &
449 & ,DPUP,DQREF,DRHDP,DRHEAT,DSP &
450 & ,DSP0,DSP0K,DSPB,DSPBK,DSPT,DSPTK &
451 & ,DSQ,DST,DSTQ,DTHEM,DTDP,EFI &
452 & ,FEFI,FFUP,FPRS,FPTK,HCORR &
453 & ,OTSUM,P,P00K,P01K,P10K,P11K &
454 & ,PART1,PART2,PART3,PBOT,PBOTFC,PBTK &
455 & ,PK0,PKB,PKL,PKT,PKXXXX,PKXXXY &
456 & ,PLMH,PELEVFC,PBTmx,plo,POTSUM,PP1,PPK,PRECK &
457 & ,PRWD,PDQD,PRESK,PSP,PSUM,PTHRS,PTOP,PTPK,PUP &
458 & ,QBT,QKL,QNEW,QOTSUM,QQ1,QQK,QRFKL &
459 & ,QRFTP,QSP,QSUM,QUP,RDP0T &
460 & ,RDPSUM,RDTCNVC,RHH,RHL,RHMAX,ROTSUM,RTBAR,RHAVG &
461 & ,SM1,SMIX,SQ,SQK,SQS00K,SQS10K,STABDL,SUMDE,SUMDP &
462 & ,SUMDT,TAUK,TAUKSC,TCORR,THBT,THERKX,THERKY &
463 & ,THESP,THSKL,THTPK,THVMKL,TKL,TNEW &
464 & ,TQ,TQK,TREFKX,TRFKL,trmlo,trmup,TSKL,tsp,TTH &
466 & ,CAPEcnv,PSPcnv,THBTcnv,CAPEtrigr,CAPE &
467 & ,TLEV2,QSAT1,QSAT2,RHSHmax
469 INTEGER :: IQ,IQTB,IT,ITER,ITREFI,ITTB,ITTBK,KB,KNUMH,KNUML &
470 & ,L,L0,L0M1,LB,LBM1,LCOR,LPT1 &
471 & ,LQM,LSHU,LTP1,LTP2,LTSH, LBOTcnv,LTOPcnv,LMID
472 !-----------------------------------------------------------------------
474 REAL,PARAMETER :: DSPBSL=DSPBFL*FSL,DSP0SL=DSP0FL*FSL &
475 & ,DSPTSL=DSPTFL*FSL &
476 & ,DSPBSS=DSPBFS*FSS,DSP0SS=DSP0FS*FSS &
479 REAL,PARAMETER :: ELEVFC=0.6,STEFI=1.
481 REAL,PARAMETER :: SLOPBL=(DSPBFL-DSPBSL)/(1.-EFIMN) &
482 & ,SLOP0L=(DSP0FL-DSP0SL)/(1.-EFIMN) &
483 & ,SLOPTL=(DSPTFL-DSPTSL)/(1.-EFIMN) &
484 & ,SLOPBS=(DSPBFS-DSPBSS)/(1.-EFIMN) &
485 & ,SLOP0S=(DSP0FS-DSP0SS)/(1.-EFIMN) &
486 & ,SLOPTS=(DSPTFS-DSPTSS)/(1.-EFIMN) &
487 & ,SLOPST=(STABDF-STABDS)/(1.-EFIMN) &
488 & ,SLOPE=(1.-EFMNT)/(1.-EFIMN)
490 REAL :: A23M4L,CPRLG,ELOCP,RCP,QWAT
491 !-----------------------------------------------------------------------
492 !***********************************************************************
493 !-----------------------------------------------------------------------
495 CPRLG=CP/(ROW*G*ELWV)
498 A23M4L=A2*(A3-A4)*ELWV
500 DEPMIN=PSH*PSFC*RSFCP
508 !-----------------------------------------------------------------------
510 TAUKSC=DTCNVC/(1.0*TREL)
511 !-----------------------------------------------------------------------
512 !-----------------------------PREPARATIONS------------------------------
513 !-----------------------------------------------------------------------
523 APE(L)=(1.E5/APESTS)**CAPA
529 !-----------------------------------------------------------------------
530 !----------------SEARCH FOR MAXIMUM BUOYANCY LEVEL----------------------
531 !-----------------------------------------------------------------------
535 PBTmx=PRSMID(LMH)-PONE
542 !-----------------------------------------------------------------------
543 !----------------TRIAL MAXIMUM BUOYANCY LEVEL VARIABLES-----------------
544 !-----------------------------------------------------------------------
546 max_buoy_loop: DO KB=LMH,1,-1
548 !-----------------------------------------------------------------------
551 ! IF (PKL<PELEVFC .OR. T(KB)<=TFRZ) EXIT
552 IF (PKL<PELEVFC) EXIT
556 !-----------------------------------------------------------------------
557 !*** SEARCH OVER A SCALED DEPTH IN FINDING THE PARCEL
558 !*** WITH THE MAX THETA-E
559 !-----------------------------------------------------------------------
566 !----------------KEEPING INDICES WITHIN THE TABLE-----------------------
570 ELSE IF(ITTB>=JTB)THEN
574 !--------------BASE AND SCALING FACTOR FOR SPEC. HUMIDITY---------------
580 !--------------SCALING SPEC. HUMIDITY & TABLE INDEX---------------------
581 BQ=(BQS10K-BQS00K)*QQ1+BQS00K
582 SQ=(SQS10K-SQS00K)*QQ1+SQS00K
586 !----------------KEEPING INDICES WITHIN THE TABLE-----------------------
590 ELSE IF(IQTB>=ITB)THEN
594 !--------------SATURATION PRESSURE AT FOUR SURROUNDING TABLE PTS.-------
602 !--------------SATURATION POINT VARIABLES AT THE BOTTOM-----------------
604 PSP=P00K+(P10K-P00K)*PP1+(P01K-P00K)*QQ1 &
605 & +(P00K-P10K-P01K+P11K)*PP1*QQ1
606 APES=(1.E5/PSP)**CAPA
607 THESP=THBT*EXP(ELOCP*QBT*APES/THBT)
609 !-----------------------------------------------------------------------
610 !-----------CHOOSE CLOUD BASE AS MODEL LEVEL JUST BELOW PSP-------------
611 !-----------------------------------------------------------------------
615 IF(P<PSP.AND.P>=PQM)LBOT=L+1
618 !*** WARNING: LBOT MUST NOT BE > LMH-1 IN SHALLOW CONVECTION
619 !*** MAKE SURE CLOUD BASE IS AT LEAST PONE ABOVE THE SURFACE
622 IF(PBOT>=PBTmx.OR.LBOT>=LMH)THEN
630 !-----------------------------------------------------------------------
631 !----------------CLOUD TOP COMPUTATION----------------------------------
632 !-----------------------------------------------------------------------
640 !-----------------------------------------------------------------------
641 !### BEGIN: ########### WARNING ########### WARNING ###########
642 !-----------------------------------------------------------------------
644 !### IMPORTANT: THIS "DO KB=LMH,1,-1" loop must be broken up into two
645 ! separate loops in order for entrainment as programmed below to work
648 !--------------- ENTRAINMENT DURING PARCEL ASCENT --------------------
658 ! FEFI=(CLDEFI-EFIMN)*SLOPE+EFMNT
659 ! FFUP=FUP/(FEFI*FEFI)
663 ! ELSEIF(PBOT>ENPUP)THEN
664 ! FPRS=(PBOT-ENPUP)*RENDP
669 ! FFUP=FFUP*FPRS*FPRS*0.5
676 ! THES(L)=((-FFUP*DPLO+1.)*THES(L+1) &
677 ! & +(THEE(L)*DPUP+THEE(L+1)*DPLO)*FFUP) &
681 !-----------------------------------------------------------------------
682 !### END: ########### WARNING ########### WARNING ###########
683 !-----------------------------------------------------------------------
685 !-----------------------------------------------------------------------
686 !!*** COMPUTE PARCEL TEMPERATURE ALONG THE ASCENT TRAJECTORY
687 !!*** SCALING PRESSURE & TT TABLE INDEX.
688 !-----------------------------------------------------------------------
696 ! CALL TTBLEX(ITB,JTB,PL,PRESK,RDP,RDTHE &
697 ! & ,STHE,THE0,THES(L),TTBL,TREF(L))
699 ! CALL TTBLEX(ITBQ,JTBQ,PLQ,PRESK,RDPQ,RDTHEQ &
700 ! & ,STHEQ,THE0Q,THES(L),TTBLQ,TREF(L))
705 !!-----------------------------------------------------------------------
706 !!----------------BUOYANCY CHECK-----------------------------------------
707 !!-----------------------------------------------------------------------
710 ! IF(TREF(L)>T(L)-DTTOP)LTOP=L
713 !!*** CLOUD TOP PRESSURE
717 !------------------FIRST ENTROPY CHECK----------------------------------
723 !-----------------------------------------------------------------------
724 ! lbot_ltop: IF(LBOT>LTOP)THEN
725 !-----------------------------------------------------------------------
726 !-- Begin: Buoyancy check including deep convection (24 Aug 2006)
727 !-----------------------------------------------------------------------
732 CAPEtrigr=DTPtrigr/T(LBOT)
734 !--- Below cloud base
741 TRMUP=(TUP*(QBT*0.608+1.) &
742 & -T(L)*(Q(L)*0.608+1.))*0.5 &
743 & /(T(L)*(Q(L)*0.608+1.))
745 DENTPY=DTV(L)*DP+DENTPY
747 IF (DENTPY < CAPEtrigr) GO TO 170
755 TRMLO=(TUP*(QBT*0.608+1.) &
756 & -T(L)*(Q(L)*0.608+1.))*0.5 &
757 & /(T(L)*(Q(L)*0.608+1.))
758 ENDIF ! IF(KB>LBOT) THEN
765 TSP=(T(L+1)-T(L))/(PLO-PBOT) &
767 QSP=(Q(L+1)-Q(L))/(PLO-PBOT) &
770 TRMUP=(TUP*(QBT*0.608+1.) &
771 & -TSP*(QSP*0.608+1.))*0.5 &
772 & /(TSP*(QSP*0.608+1.))
774 DENTPY=DTV(L)*DP+DENTPY
781 !--- Calculate updraft temperature along moist adiabat (TUP)
784 CALL TTBLEX(ITB,JTB,PL,PUP,RDP,RDTHE &
785 & ,STHE,THE0,THES(L),TTBL,TUP)
787 CALL TTBLEX(ITBQ,JTBQ,PLQ,PUP,RDPQ,RDTHEQ &
788 & ,STHEQ,THE0Q,THES(L),TTBLQ,TUP)
791 QUP=PQ0/PUP*EXP(A2*(TUP-A3)/(TUP-A4))
792 QWAT=QBT-QUP !-- Water loading effects, reversible adiabat
794 TRMUP=(TUP*(QUP*0.608+1.-QWAT) &
795 & -T(L)*(Q(L)*0.608+1.))*0.5 &
796 & /(T(L)*(Q(L)*0.608+1.))
797 DENTPY=(TRMLO+TRMUP)*DP+DENTPY
799 DTV(L)=(DTV(L)+(TRMLO+TRMUP)*DP)/(PRSMID(LBOT+1)-PRSMID(LBOT))
801 IF (DENTPY < CAPEtrigr) GO TO 170
806 !-----------------------------------------------------------------------
807 !--- In cloud above cloud base
808 !-----------------------------------------------------------------------
813 !--- Calculate updraft temperature along moist adiabat (TUP)
816 CALL TTBLEX(ITB,JTB,PL,PUP,RDP,RDTHE &
817 & ,STHE,THE0,THES(L),TTBL,TUP)
819 CALL TTBLEX(ITBQ,JTBQ,PLQ,PUP,RDPQ,RDTHEQ &
820 & ,STHEQ,THE0Q,THES(L),TTBLQ,TUP)
823 QUP=PQ0/PUP*EXP(A2*(TUP-A3)/(TUP-A4))
824 QWAT=QBT-QUP !-- Water loading effects, reversible adiabat
826 TRMUP=(TUP*(QUP*0.608+1.-QWAT) &
827 & -T(L)*(Q(L)*0.608+1.))*0.5 &
828 & /(T(L)*(Q(L)*0.608+1.))
830 DENTPY=DTV(L)*DP+DENTPY
833 IF (DENTPY < CAPEtrigr) GO TO 170
839 !-----------------------------------------------------------------------
844 !-----------------------------------------------------------------------
845 !--- Cloud top level (LTOP) is located where CAPE is a maximum
846 !--- Exit cloud-top search if CAPE < CAPEtrigr
847 !-----------------------------------------------------------------------
850 IF (CPE(L) < CAPEtrigr) THEN
852 ELSE IF (CPE(L) > CAPE) THEN
856 ENDDO !-- End DO L=KB,KTS,-1
860 !-----------------------------------------------------------------------
861 !--------------- CHECK FOR MAXIMUM INSTABILITY ------------------------
862 !-----------------------------------------------------------------------
863 IF(CAPE > CAPEcnv) THEN
874 ENDIF ! End IF(CAPE > CAPEcnv) THEN
878 !-----------------------------------------------------------------------
882 !-----------------------------------------------------------------------
883 !------------------------ MAXIMUM INSTABILITY ------------------------
884 !-----------------------------------------------------------------------
886 IF(CAPEcnv > 0.) THEN
902 !-----------------------------------------------------------------------
903 !----- Quick exit if cloud is too thin or no CAPE is present ---------
904 !-----------------------------------------------------------------------
906 IF(PTOP>PBOT-PNO.OR.LTOP>LBOT-2.OR.CAPEcnv<=0.)THEN
911 CLDEFI=AVGEFI*SM+STEFI*(1.-SM)
912 ! CLDEFI=(EFIMN-0.2)*SM+(1.+0.2)*(1.-SM)
916 !*** DEPTH OF CLOUD REQUIRED TO MAKE THE POINT A DEEP CONVECTION POINT
917 !*** IS A SCALED VALUE OF PSFC.
921 IF(DEPTH>=DEPMIN) THEN
925 ! CLDEFI=(EFIMN-0.1)*SM+(1.+0.1)*(1.-SM)
929 !-----------------------------------------------------------------------
930 !DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD
931 !DCDCDCDCDCDCDCDCDCDCDC DEEP CONVECTION DCDCDCDCDCDCDCDCDCDCDCDCDCD
932 !DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD
933 !-----------------------------------------------------------------------
939 !-----------------------------------------------------------------------
940 !--------------INITIALIZE VARIABLES IN THE CONVECTIVE COLUMN------------
941 !-----------------------------------------------------------------------
943 !*** ONE SHOULD NOTE THAT THE VALUES ASSIGNED TO THE ARRAY TREFK
944 !*** IN THE FOLLOWING LOOP ARE REALLY ONLY RELEVANT IN ANCHORING THE
945 !*** REFERENCE TEMPERATURE PROFILE AT LEVEL LB. WHEN BUILDING THE
946 !*** REFERENCE PROFILE FROM CLOUD BASE, THEN ASSIGNING THE
947 !*** AMBIENT TEMPERATURE TO TREFK IS ACCEPTABLE. HOWEVER, WHEN
948 !*** BUILDING THE REFERENCE PROFILE FROM SOME OTHER LEVEL (SUCH AS
949 !*** ONE LEVEL ABOVE THE GROUND), THEN TREFK SHOULD BE FILLED WITH
950 !*** THE TEMPERATURES IN TREF(L) WHICH ARE THE TEMPERATURES OF
951 !*** THE MOIST ADIABAT THROUGH CLOUD BASE. BY THE TIME THE LINE
952 !*** NUMBERED 450 HAS BEEN REACHED, TREFK ACTUALLY DOES HOLD THE
953 !*** REFERENCE TEMPERATURE PROFILE.
970 !--- Calculate temperature along moist adiabat (TREF)
973 CALL TTBLEX(ITB,JTB,PL,PKL,RDP,RDTHE &
974 & ,STHE,THE0,THES(L),TTBL,TREF(L))
976 CALL TTBLEX(ITBQ,JTBQ,PLQ,PKL,RDPQ,RDTHEQ &
977 & ,STHEQ,THE0Q,THES(L),TTBLQ,TREF(L))
979 THERK (L)=TREF(L)*APEKL
982 !------------DEEP CONVECTION REFERENCE TEMPERATURE PROFILE------------
988 STABDL=(EFI-EFIMN)*SLOPST+STABDS
990 !------------TEMPERATURE REFERENCE PROFILE BELOW FREEZING LEVEL-------
1002 IF(T(L+1)<TFRZ)GO TO 430
1003 TREFKX=((THERKY-THERKX)*STABDL &
1004 & +TREFKX*APEKXX)/APEKXY
1015 !--------------FREEZING LEVEL AT OR ABOVE THE CLOUD TOP-----------------
1019 !--------------TEMPERATURE REFERENCE PROFILE ABOVE FREEZING LEVEL-------
1023 DTHEM=THERK(L0)-TREFK(L0)*APEK(L0)
1026 TREFK(L)=(THERK(L)-(PK(L)-PKT)*DTHEM*RDP0T)/APEK(L)
1030 !-----------------------------------------------------------------------
1031 !--------------DEEP CONVECTION REFERENCE HUMIDITY PROFILE---------------
1032 !-----------------------------------------------------------------------
1034 !*** DEPWL IS THE PRESSURE DIFFERENCE BETWEEN CLOUD BASE AND
1035 !*** THE FREEZING LEVEL
1039 DEPTH=PFRZ*PSFC*RSFCP
1043 !-------------FIRST ADJUSTMENT OF TEMPERATURE PROFILE-------------------
1049 ! SUMDT=(TK(L)-TREFK(L))*DPRS(L)+SUMDT
1050 ! SUMDP=SUMDP+DPRS(L)
1056 ! TREFK(L)=TREFK(L)+TCORR
1059 !-----------------------------------------------------------------------
1060 !--------------- ITERATION LOOP FOR CLOUD EFFICIENCY -------------------
1061 !-----------------------------------------------------------------------
1063 cloud_efficiency : DO ITREFI=1,ITREFI_MAX
1065 !-----------------------------------------------------------------------
1066 DSPBK=((EFI-EFIMN)*SLOPBS+DSPBSS*PBOTFC)*SM &
1067 & +((EFI-EFIMN)*SLOPBL+DSPBSL*PBOTFC)*SM1
1068 DSP0K=((EFI-EFIMN)*SLOP0S+DSP0SS*PBOTFC)*SM &
1069 & +((EFI-EFIMN)*SLOP0L+DSP0SL*PBOTFC)*SM1
1070 DSPTK=((EFI-EFIMN)*SLOPTS+DSPTSS*PBOTFC)*SM &
1071 & +((EFI-EFIMN)*SLOPTL+DSPTSL*PBOTFC)*SM1
1073 !-----------------------------------------------------------------------
1078 !*** SATURATION PRESSURE DIFFERENCE
1080 IF(DEPWL>=DEPTH)THEN
1082 DSP=((PK0-PK(L))*DSPTK+(PK(L)-PKT)*DSP0K)/(PK0-PKT)
1084 DSP=((PKB-PK(L))*DSP0K+(PK(L)-PK0)*DSPBK)/(PKB-PK0)
1089 DSP=((PK0-PK(L))*DSPTK+(PK(L)-PKT)*DSP0K)/(PK0-PKT)
1093 !*** HUMIDITY PROFILE
1096 APESK(L)=(1.E5/PSK(L))**CAPA
1099 THSK(L)=TREFK(L)*APEK(L)
1100 QREFK(L)=PQ0/PSK(L)*EXP(A2*(THSK(L)-A3*APESK(L)) &
1101 & /(THSK(L)-A4*APESK(L)))
1107 !-----------------------------------------------------------------------
1109 !*** ENTHALPY CONSERVATION INTEGRAL
1111 !-----------------------------------------------------------------------
1112 enthalpy_conservation : DO ITER=1,2
1119 SUMDE=((TK(L)-TREFK(L))*CP+(QK(L)-QREFK(L))*EL(L))*DPRS(L) &
1121 DHDT=(QREFK(L)*A23M4L/((TREFK(L)*APEK(L)/APESK(L))-A4)**2+CP)*DPRS(L) &
1126 HCORR=SUMDE/(SUMDP-DPRS(LTOP))
1127 DHDT=DHDT/(SUMDP-DPRS(LTOP))
1137 !*** ABOVE LQM CORRECT TEMPERATURE ONLY
1141 TREFK(L)=TREFK(L)+HCORR*RCP
1146 !*** BELOW LQM CORRECT BOTH TEMPERATURE AND MOISTURE
1149 TREFK(L)=HCORR/DHDT+TREFK(L)
1150 THSKL=TREFK(L)*APEK(L)
1151 QREFK(L)=PQ0/PSK(L)*EXP(A2*(THSKL-A3*APESK(L)) &
1152 & /(THSKL-A4*APESK(L)))
1155 ENDDO enthalpy_conservation
1156 !-----------------------------------------------------------------------
1158 !*** HEATING, MOISTENING, PRECIPITATION
1160 !-----------------------------------------------------------------------
1170 DIFTL=(TREFK(L)-TKL )*TAUK
1171 DIFQL=(QREFK(L)-QK(L))*TAUK
1172 AVRGTL=(TKL+TKL+DIFTL)
1175 DSQ=DIFQL*EL(L)*DPOT+DSQ
1176 AVRGT=AVRGTL*DPRS(L)+AVRGT
1177 PRECK=DIFTL*DPRS(L)+PRECK
1178 PDQD=(QK(L)-QREFK(L))*DPRS(L)+PDQD
1179 PRWD=QK(L)*DPRS(L)+PRWD
1187 AVRGT=AVRGT/(SUMDP+SUMDP)
1189 ! DRHEAT=PRECK*CP/AVRGT
1190 DRHEAT=(PRECK*SM+MAX(1.E-7,PRECK)*(1.-SM))*CP/AVRGT !As in Eta!
1191 DRHEAT=MAX(DRHEAT,1.E-20)
1192 EFI=EFIFC*DENTPY/DRHEAT
1193 !-----------------------------------------------------------------------
1196 !-----------------------------------------------------------------------
1198 ENDDO cloud_efficiency
1200 !-----------------------------------------------------------------------
1202 !-----------------------------------------------------------------------
1203 !---------------------- DEEP CONVECTION --------------------------------
1204 !-----------------------------------------------------------------------
1206 IF(DENTPY>=EPSNTP.AND.PRECK>EPSPR)THEN
1209 FEFI=EFMNT+SLOPE*(EFI-EFIMN)
1210 FEFI=(DENTPY-EPSNTP)*FEFI/DENTPY
1213 !*** UPDATE PRECIPITATION AND TENDENCIES OF TEMPERATURE AND MOISTURE
1219 DQCOLMIN=(CRMN*TREL)/(FEFI*86400.)
1222 DTDT(L)=DIFT(L)*FEFI*RDTCNVC
1223 DQDT(L)=DIFQ(L)*FEFI*RDTCNVC
1228 !-----------------------------------------------------------------------
1229 !*** REDUCE THE CLOUD TOP
1230 !-----------------------------------------------------------------------
1234 ! DEPMIN=PSH*PSFC*RSFCP
1237 !*** ITERATE DEEP CONVECTION PROCEDURE IF NEEDED
1239 ! IF(DEPTH>=DEPMIN)THEN
1244 CLDEFI=EFIMN*SM+STEFI*(1.-SM)
1245 ! CLDEFI=(EFIMN-0.1)*SM+(1.+0.1)*(1.-SM)
1247 !*** SEARCH FOR SHALLOW CLOUD TOP
1252 ! DEPMIN=PSH*PSFC*RSFCP
1254 PTPK=MAX(PSHU, PK(LBOT)-DEPMIN)
1256 !*** CLOUD TOP IS THE LEVEL JUST BELOW PBTK-PSH or JUST BELOW PSHU
1259 IF(PK(L)<=PTPK)LTOP=L+1
1264 !!*** HIGHEST LEVEL ALLOWED IS LEVEL JUST BELOW PSHU
1266 ! IF(PTPK<=PSHU)THEN
1269 ! IF(PK(L)<=PSHU)LSHU=L+1
1276 ! if(ltop>=lbot)then
1279 !!!!!! pbot=pk(lbot)
1289 ! QSATK(L)=PQ0/PK(L)*EXP(A2*(TK(L)-A3)/(TK(L)-A4))
1292 ! RHH=QK(LTOP)/QSATK(LTOP)
1297 ! RHL=QK(L)/QSATK(L)
1298 ! DRHDP=(RHH-RHL)/(PK(L-1)-PK(L))
1300 ! IF(DRHDP>RHMAX)THEN
1308 !-----------------------------------------------------------------------
1309 !-- Make shallow cloud top a function of virtual temperature excess (DTV)
1310 !-----------------------------------------------------------------------
1314 IF (DTV(L) > 0.) THEN
1322 !*** CLOUD MUST BE AT LEAST TWO LAYERS THICK
1324 ! IF(LBOT-LTOP<2)LTOP=LBOT-2 (eliminate this criterion)
1326 !-- End: Buoyancy check (24 Aug 2006)
1333 !DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD
1334 !DCDCDCDCDCDCDC END OF DEEP CONVECTION DCDCDCDCDCDCD
1335 !DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD
1337 !-----------------------------------------------------------------------
1338 !-----------------------------------------------------------------------
1340 !-----------------------------------------------------------------------
1341 !-----------------------------------------------------------------------
1343 !----------------GATHER SHALLOW CONVECTION POINTS-----------------------
1345 ! IF(PTOP<=PBOT-PNO.AND.LTOP<=LBOT-2)THEN
1346 ! DEPMIN=PSH*PSFC*RSFCP
1348 !! if(lpbl<lbot)lbot=lpbl
1349 !! if(lbot>lmh-1)lbot=lmh-1
1350 !! pbot=prsmid(lbot)
1352 ! IF(PTOP+1.>=PBOT-DEPMIN)SHALLOW=.TRUE.
1358 !***********************************************************************
1359 !-----------------------------------------------------------------------
1360 !*** Begin debugging convection
1362 WRITE(6,"(a,2i3,L2,3e12.4)") &
1363 '{cu2a lbot,ltop,shallow,pbot,ptop,depmin = ' &
1364 ,lbot,ltop,shallow,pbot,ptop,depmin
1366 !*** End debugging convection
1367 !-----------------------------------------------------------------------
1369 IF(.NOT.SHALLOW)GO TO 800
1371 !-----------------------------------------------------------------------
1372 !***********************************************************************
1373 !-----------------------------------------------------------------------
1374 !SCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCS
1375 !SCSCSCSCSCSCSC SHALLOW CONVECTION CSCSCSCSCSCSCSCSCSCS
1376 !SCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCS
1377 !-----------------------------------------------------------------------
1387 QSATK(L) =PQ0/PK(L)*EXP(A2*(TK(L)-A3)/(TK(L)-A4))
1390 THVMKL =TKL*APEKL*(QKL*D608+1.)
1400 !-----------------------------------------------------------------------
1401 !-- Begin: Raise cloud top if avg RH>RHSHmax and CAPE>0
1402 ! RHSHmax=RH at cloud base associated with a DSP of PONE
1403 !-----------------------------------------------------------------------
1405 TLEV2=T(LBOT)*((PK(LBOT)-PONE)/PK(LBOT))**CAPA
1406 QSAT1=PQ0/PK(LBOT)*EXP(A2*(T(LBOT)-A3)/(TK(LBOT)-A4))
1407 QSAT2=PQ0/(PK(LBOT)-PONE)*EXP(A2*(TLEV2-A3)/(TLEV2-A4))
1413 RHAVG=RHAVG+DPRS(L)*QK(L)/QSATK(L)
1417 IF (RHAVG/SUMDP > RHSHmax) THEN
1420 RHAVG=RHAVG+DPRS(L)*QK(L)/QSATK(L)
1422 IF (CPE(L) > 0.) THEN
1427 IF (RHAVG/SUMDP <= RHSHmax) EXIT
1428 IF (PK(L) <= PSHU) EXIT
1433 !-- End: Raise cloud top if avg RH>RHSHmax and CAPE>0
1435 !---------------------------SHALLOW CLOUD TOP---------------------------
1440 !-----------------------------------------------------------------------
1441 !*** Begin debugging convection
1443 WRITE(6,"(a,4e12.4)") '{cu2b PBOT,PTOP,DEPTH,DEPMIN= ' &
1444 ,PBOT,PTOP,DEPTH,DEPMIN
1446 !*** End debugging convection
1447 !-----------------------------------------------------------------------
1449 !BSF IF(DEPTH<DEPMIN)THEN
1452 !-----------------------------------------------------------------------
1453 IF(PTOP>PBOT-PNO.OR.LTOP>LBOT-2)THEN
1461 !--------------SCALING POTENTIAL TEMPERATURE & TABLE INDEX AT TOP-------
1463 THTPK=T(LTP1)*APE(LTP1)
1465 TTHK=(THTPK-THL)*RDTH
1466 QQK =TTHK-AINT(TTHK)
1479 !--------------BASE AND SCALING FACTOR FOR SPEC. HUMIDITY AT TOP--------
1486 !--------------SCALING SPEC. HUMIDITY & TABLE INDEX AT TOP--------------
1488 BQK=(BQS10K-BQS00K)*QQK+BQS00K
1489 SQK=(SQS10K-SQS00K)*QQK+SQS00K
1491 ! TQK=(Q(LTOP)-BQK)/SQK*RDQ
1492 TQK=(Q(LTP1)-BQK)/SQK*RDQ
1507 !----------------CLOUD TOP SATURATION POINT PRESSURE--------------------
1509 PART1=(PTBL(IQ+1,IT)-PTBL(IQ,IT))*PPK
1510 PART2=(PTBL(IQ,IT+1)-PTBL(IQ,IT))*QQK
1511 PART3=(PTBL(IQ ,IT )-PTBL(IQ+1,IT ) &
1512 & -PTBL(IQ ,IT+1)+PTBL(IQ+1,IT+1))*PPK*QQK
1513 PTPK=PTBL(IQ,IT)+PART1+PART2+PART3
1514 !-----------------------------------------------------------------------
1516 IF(ABS(DPMIX).LT.3000.)DPMIX=-3000.
1518 !----------------TEMPERATURE PROFILE SLOPE------------------------------
1520 SMIX=(THTPK-THBT)/DPMIX*STABS
1522 TREFKX=TREFK(LBOT+1)
1531 TREFKX=((PKXXXY-PKXXXX)*SMIX &
1532 & +TREFKX*APEKXX)/APEKXY
1534 IF(L<=LMID) TREFK(L)=MAX(TREFK(L), TK(L)+DTSHAL)
1541 !----------------TEMPERATURE REFERENCE PROFILE CORRECTION---------------
1547 SUMDT=(TK(L)-TREFK(L))*DPRS(L)+SUMDT
1552 FPK(LBOT)=TREFK(LBOT)
1557 TRFKL =TREFK(L)+TCORR
1562 !----------------HUMIDITY PROFILE EQUATIONS-----------------------------
1574 PSUM =DPKL *DPRS(L)+PSUM
1575 QSUM =QK(L)*DPRS(L)+QSUM
1576 RTBAR =2./(TREFK(L)+TK(L))
1577 OTSUM =DPRS(L)*RTBAR+OTSUM
1578 POTSUM=DPKL *RTBAR*DPRS(L)+POTSUM
1579 QOTSUM=QK(L) *RTBAR*DPRS(L)+QOTSUM
1580 DST =(TREFK(L)-TK(L))*RTBAR*DPRS(L)/EL(L)+DST
1586 POTSUM=POTSUM*ROTSUM
1587 QOTSUM=QOTSUM*ROTSUM
1590 !-----------------------------------------------------------------------
1591 !*** Begin debugging convection
1593 WRITE(6,"(a,5e12.4)") '{cu2c DST,PSUM,QSUM,POTSUM,QOTSUM = ' &
1594 ,DST,PSUM,QSUM,POTSUM,QOTSUM
1596 !*** End debugging convection
1597 !-----------------------------------------------------------------------
1599 !----------------ENSURE POSITIVE ENTROPY CHANGE-------------------------
1612 !----------------CHECK FOR ISOTHERMAL ATMOSPHERE------------------------
1616 IF(-DEN/PSUM<5.E-5)THEN
1623 !----------------SLOPE OF THE REFERENCE HUMIDITY PROFILE----------------
1626 DQREF=(QOTSUM-DSTQ-QSUM)/DEN
1629 !-------------- HUMIDITY DOES NOT INCREASE WITH HEIGHT------------------
1639 !----------------HUMIDITY AT THE CLOUD TOP------------------------------
1641 QRFTP=QSUM-DQREF*PSUM
1643 !----------------HUMIDITY PROFILE---------------------------------------
1646 QRFKL=(FPK(L)-FPTK)*DQREF+QRFTP
1648 !*** TOO DRY CLOUDS NOT ALLOWED
1650 TNEW=(TREFK(L)-TK(L))*TAUKSC+TK(L)
1651 QSATK(L)=PQ0/PK(L)*EXP(A2*(TNEW-A3)/(TNEW-A4))
1652 QNEW=(QRFKL-QK(L))*TAUKSC+QK(L)
1654 IF(QNEW<QSATK(L)*RHLSC)THEN
1662 !-------------TOO MOIST CLOUDS NOT ALLOWED------------------------------
1664 IF(QNEW>QSATK(L)*RHHSC)THEN
1673 THVREF(L)=TREFK(L)*APEK(L)*(QRFKL*D608+1.)
1677 !------------------ ELIMINATE CLOUDS WITH BOTTOMS TOO DRY --------------
1679 ! qnew=(qrefk(lbot)-qk(lbot))*tauksc+qk(lbot)
1681 ! if(qnew<qk(lbot+1)*stresh)then !!?? stresh too large!!
1689 !-------------- ELIMINATE IMPOSSIBLE SLOPES (BETTS,DTHETA/DQ)------------
1692 DTDP=(THVREF(L-1)-THVREF(L))/(PRSMID(L)-PRSMID(L-1))
1703 !-----------------------------------------------------------------------
1704 !--------------RELAXATION TOWARD REFERENCE PROFILES---------------------
1705 !-----------------------------------------------------------------------
1708 DTDT(L)=(TREFK(L)-TK(L))*TAUKSC*RDTCNVC
1709 DQDT(L)=(QREFK(L)-QK(L))*TAUKSC*RDTCNVC
1712 !-----------------------------------------------------------------------
1713 !*** Begin debugging convection
1716 WRITE(6,"(a,i3,4e12.4)") '{cu2 KFLIP,DT,DTDT,DQ,DQDT = ' &
1717 ,KTE+1-L,TREFK(L)-TK(L),DTDT(L),QREFK(L)-QK(L),DQDT(L)
1720 !*** End debugging convection
1721 !-----------------------------------------------------------------------
1723 !-----------------------------------------------------------------------
1724 !SCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCS
1725 !SCSCSCSCSCSCSC END OF SHALLOW CONVECTION SCSCSCSCSCSCSCS
1726 !SCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCSCS
1727 !-----------------------------------------------------------------------
1729 !-----------------------------------------------------------------------
1731 !-----------------------------------------------------------------------
1732 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1733 !-----------------------------------------------------------------------
1735 & (ITBX,JTBX,PLX,PRSMID,RDPX,RDTHEX,STHE &
1736 & ,THE0,THESP,TTBL,TREF)
1737 !-----------------------------------------------------------------------
1738 ! ******************************************************************
1740 ! * EXTRACT TEMPERATURE OF THE MOIST ADIABAT FROM *
1741 ! * THE APPROPRIATE TTBL *
1743 ! ******************************************************************
1744 !-----------------------------------------------------------------------
1746 !-----------------------------------------------------------------------
1747 INTEGER,INTENT(IN) :: ITBX,JTBX
1749 REAL,INTENT(IN) :: PLX,PRSMID,RDPX,RDTHEX,THESP
1751 REAL,DIMENSION(ITBX),INTENT(IN) :: STHE,THE0
1753 REAL,DIMENSION(JTBX,ITBX),INTENT(IN) :: TTBL
1755 REAL,INTENT(OUT) :: TREF
1756 !-----------------------------------------------------------------------
1757 REAL :: BTHE00K,BTHE10K,BTHK,PK,PP,QQ,STHE00K,STHE10K,STHK &
1758 & ,T00K,T01K,T10K,T11K,TPK,TTHK
1760 INTEGER :: IPTB,ITHTB
1761 !-----------------------------------------------------------------------
1762 !----------------SCALING PRESSURE & TT TABLE INDEX----------------------
1763 !-----------------------------------------------------------------------
1768 !----------------KEEPING INDICES WITHIN THE TABLE-----------------------
1778 !----------------BASE AND SCALING FACTOR FOR THETAE---------------------
1781 BTHE10K=THE0(IPTB+1)
1782 STHE10K=STHE(IPTB+1)
1783 !----------------SCALING THE & TT TABLE INDEX---------------------------
1784 BTHK=(BTHE10K-BTHE00K)*QQ+BTHE00K
1785 STHK=(STHE10K-STHE00K)*QQ+STHE00K
1786 TTHK=(THESP-BTHK)/STHK*RDTHEX
1789 !----------------KEEPING INDICES WITHIN THE TABLE-----------------------
1799 !----------------TEMPERATURE AT FOUR SURROUNDING TT TABLE PTS.----------
1800 T00K=TTBL(ITHTB,IPTB)
1801 T10K=TTBL(ITHTB+1,IPTB)
1802 T01K=TTBL(ITHTB,IPTB+1)
1803 T11K=TTBL(ITHTB+1,IPTB+1)
1804 !-----------------------------------------------------------------------
1805 !----------------PARCEL TEMPERATURE-------------------------------------
1806 !-----------------------------------------------------------------------
1807 TREF=(T00K+(T10K-T00K)*PP+(T01K-T00K)*QQ &
1808 & +(T00K-T10K-T01K+T11K)*PP*QQ)
1809 !-----------------------------------------------------------------------
1810 END SUBROUTINE TTBLEX
1811 !-----------------------------------------------------------------------
1812 !-----------------------------------------------------------------------
1813 SUBROUTINE BMJINIT(RTHCUTEN,RQVCUTEN,RQCCUTEN,RQRCUTEN &
1814 & ,CLDEFI,LOWLYR,CP,RD,RESTART &
1816 & ,IDS,IDE,JDS,JDE,KDS,KDE &
1817 & ,IMS,IME,JMS,JME,KMS,KME &
1818 & ,ITS,ITE,JTS,JTE,KTS,KTE)
1819 !-----------------------------------------------------------------------
1821 !-----------------------------------------------------------------------
1822 LOGICAL,INTENT(IN) :: RESTART,ALLOWED_TO_READ
1823 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
1824 & ,IMS,IME,JMS,JME,KMS,KME &
1825 & ,ITS,ITE,JTS,JTE,KTS,KTE
1827 REAL,INTENT(IN) :: CP,RD
1829 REAL,DIMENSION(IMS:IME,KMS:KME,JMS:JME),INTENT(OUT) :: &
1835 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(OUT) :: CLDEFI
1837 INTEGER,DIMENSION(IMS:IME,JMS:JME),INTENT(INOUT) :: LOWLYR
1839 REAL,PARAMETER :: EPS=1.E-9
1841 REAL, DIMENSION(JTB) :: APP,APT,AQP,AQT,PNEW,POLD,QSNEW,QSOLD &
1842 & ,THENEW,THEOLD,TNEW,TOLD,Y2P,Y2T
1844 REAL,DIMENSION(JTBQ) :: APTQ,AQTQ,THENEWQ,THEOLDQ &
1847 INTEGER :: I,J,K,ITF,JTF,KTF
1848 INTEGER :: KTH,KTHM,KTHM1,KP,KPM,KPM1
1850 REAL :: APE,DP,DQS,DTH,DTHE,P,QS,QS0K,SQSK,STHEK &
1851 & ,TH,THE0K,DENOM,ELOCP
1852 !-----------------------------------------------------------------------
1859 IF(.NOT.RESTART)THEN
1878 !*** FOR NOW, ASSUME SIGMA MODE FOR LOWEST MODEL LAYER
1885 !-----------------------------------------------------------------------
1886 !----------------COARSE LOOK-UP TABLE FOR SATURATION POINT--------------
1887 !-----------------------------------------------------------------------
1894 DTH=(THH-THL)/REAL(KTHM-1)
1895 DP =(PH -PL )/REAL(KPM -1)
1898 !-----------------------------------------------------------------------
1906 APE=(100000./P)**(RD/CP)
1909 QSOLD(KP)=PQ0/P*EXP(A2*(TH-A3*APE)/DENOM)
1917 SQSK=QSOLD(KPM)-QSOLD(1)
1922 QSOLD(KP)=(QSOLD(KP)-QS0K)/SQSK
1923 IF((QSOLD(KP)-QSOLD(KP-1)).LT.EPS)QSOLD(KP)=QSOLD(KP-1)+EPS
1930 !-----------------------------------------------------------------------
1936 QSNEW(KP)=QSNEW(KP-1)+DQS
1942 CALL SPLINE(JTB,KPM,QSOLD,POLD,Y2P,KPM,QSNEW,PNEW,APP,AQP)
1945 PTBL(KP,KTH)=PNEW(KP)
1946 PTBL_EXP(KP,KTH)=PNEW(KP)
1948 !-----------------------------------------------------------------------
1950 !-----------------------------------------------------------------------
1951 !------------COARSE LOOK-UP TABLE FOR T(P) FROM CONSTANT THE------------
1952 !-----------------------------------------------------------------------
1962 APE=(1.E5/P)**(RD/CP)
1965 QS=PQ0/P*EXP(A2*(TH-A3*APE)/DENOM)
1969 ! QS=PQ0/P*EXP(A2*(TH-A3*APE)/(TH-A4*APE))
1971 THEOLD(KTH)=TH*EXP(ELOCP*QS/TOLD(KTH))
1975 STHEK=THEOLD(KTHM)-THEOLD(1)
1980 THEOLD(KTH)=(THEOLD(KTH)-THE0K)/STHEK
1981 IF((THEOLD(KTH)-THEOLD(KTH-1)).LT.EPS) &
1982 & THEOLD(KTH)=THEOLD(KTH-1) + EPS
1987 !-----------------------------------------------------------------------
1990 DTHE=1./REAL(KTHM-1)
1993 THENEW(KTH)=THENEW(KTH-1)+DTHE
1999 CALL SPLINE(JTB,KTHM,THEOLD,TOLD,Y2T,KTHM,THENEW,TNEW,APT,AQT)
2002 TTBL(KTH,KP)=TNEW(KTH)
2004 !-----------------------------------------------------------------------
2006 !-----------------------------------------------------------------------
2008 !-----------------------------------------------------------------------
2009 !---------------FINE LOOK-UP TABLE FOR SATURATION POINT-----------------
2010 !-----------------------------------------------------------------------
2016 DTH=(THHQ-THL)/REAL(KTHM-1)
2017 DP=(PH-PLQ)/REAL(KPM-1)
2021 !-----------------------------------------------------------------------
2022 !---------------FINE LOOK-UP TABLE FOR T(P) FROM CONSTANT THE-----------
2023 !-----------------------------------------------------------------------
2031 APE=(1.E5/P)**(RD/CP)
2034 QS=PQ0/P*EXP(A2*(TH-A3*APE)/DENOM)
2038 ! QS=PQ0/P*EXP(A2*(TH-A3*APE)/(TH-A4*APE))
2040 THEOLDQ(KTH)=TH*EXP(ELOCP*QS/TOLDQ(KTH))
2044 STHEK=THEOLDQ(KTHM)-THEOLDQ(1)
2049 THEOLDQ(KTH)=(THEOLDQ(KTH)-THE0K)/STHEK
2050 IF((THEOLDQ(KTH)-THEOLDQ(KTH-1))<EPS) &
2051 & THEOLDQ(KTH)=THEOLDQ(KTH-1)+EPS
2056 !-----------------------------------------------------------------------
2059 DTHE=1./REAL(KTHM-1)
2062 THENEWQ(KTH)=THENEWQ(KTH-1)+DTHE
2068 CALL SPLINE(JTBQ,KTHM,THEOLDQ,TOLDQ,Y2TQ,KTHM &
2069 & ,THENEWQ,TNEWQ,APTQ,AQTQ)
2072 TTBLQ(KTH,KP)=TNEWQ(KTH)
2074 !-----------------------------------------------------------------------
2076 !-----------------------------------------------------------------------
2077 END SUBROUTINE BMJINIT
2078 !-----------------------------------------------------------------------
2079 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
2080 !-----------------------------------------------------------------------
2081 SUBROUTINE SPLINE(JTBX,NOLD,XOLD,YOLD,Y2,NNEW,XNEW,YNEW,P,Q)
2082 ! ********************************************************************
2084 ! * THIS IS A ONE-DIMENSIONAL CUBIC SPLINE FITTING ROUTINE *
2085 ! * PROGRAMED FOR A SMALL SCALAR MACHINE. *
2087 ! * PROGRAMER Z. JANJIC *
2089 ! * NOLD - NUMBER OF GIVEN VALUES OF THE FUNCTION. MUST BE GE 3. *
2090 ! * XOLD - LOCATIONS OF THE POINTS AT WHICH THE VALUES OF THE *
2091 ! * FUNCTION ARE GIVEN. MUST BE IN ASCENDING ORDER. *
2092 ! * YOLD - THE GIVEN VALUES OF THE FUNCTION AT THE POINTS XOLD. *
2093 ! * Y2 - THE SECOND DERIVATIVES AT THE POINTS XOLD. IF NATURAL *
2094 ! * SPLINE IS FITTED Y2(1)=0. AND Y2(NOLD)=0. MUST BE *
2096 ! * NNEW - NUMBER OF VALUES OF THE FUNCTION TO BE CALCULATED. *
2097 ! * XNEW - LOCATIONS OF THE POINTS AT WHICH THE VALUES OF THE *
2098 ! * FUNCTION ARE CALCULATED. XNEW(K) MUST BE GE XOLD(1) *
2099 ! * AND LE XOLD(NOLD). *
2100 ! * YNEW - THE VALUES OF THE FUNCTION TO BE CALCULATED. *
2101 ! * P, Q - AUXILIARY VECTORS OF THE LENGTH NOLD-2. *
2103 ! ********************************************************************
2104 !-----------------------------------------------------------------------
2106 !-----------------------------------------------------------------------
2107 INTEGER,INTENT(IN) :: JTBX,NNEW,NOLD
2108 REAL,DIMENSION(JTBX),INTENT(IN) :: XNEW,XOLD,YOLD
2109 REAL,DIMENSION(JTBX),INTENT(INOUT) :: P,Q,Y2
2110 REAL,DIMENSION(JTBX),INTENT(OUT) :: YNEW
2112 INTEGER :: K,K1,K2,KOLD,NOLDM1
2113 REAL :: AK,BK,CK,DEN,DX,DXC,DXL,DXR,DYDXL,DYDXR &
2114 & ,RDX,RTDXC,X,XK,XSQ,Y2K,Y2KP1
2115 !-----------------------------------------------------------------------
2120 DYDXL=(YOLD(2)-YOLD(1))/DXL
2121 DYDXR=(YOLD(3)-YOLD(2))/DXR
2124 P(1)= RTDXC*(6.*(DYDXR-DYDXL)-DXL*Y2(1))
2127 IF(NOLD==3)GO TO 150
2128 !-----------------------------------------------------------------------
2133 DXR=XOLD(K+1)-XOLD(K)
2134 DYDXR=(YOLD(K+1)-YOLD(K))/DXR
2136 DEN=1./(DXL*Q(K-2)+DXC+DXC)
2138 P(K-1)= DEN*(6.*(DYDXR-DYDXL)-DXL*P(K-2))
2143 !-----------------------------------------------------------------------
2146 200 Y2(K)=P(K-1)+Q(K-1)*Y2(K+1)
2150 !-----------------------------------------------------------------------
2167 450 IF(K1==1)GO TO 500
2168 IF(K==KOLD)GO TO 550
2174 DX=XOLD(K+1)-XOLD(K)
2177 AK=.1666667*RDX*(Y2KP1-Y2K)
2179 CK=RDX*(YOLD(K+1)-YOLD(K))-.1666667*DX*(Y2KP1+Y2K+Y2K)
2184 YNEW(K1)=AK*XSQ*X+BK*XSQ+CK*X+YOLD(K)
2187 IF(K1<=NNEW)GO TO 300
2188 !-----------------------------------------------------------------------
2189 END SUBROUTINE SPLINE
2190 !-----------------------------------------------------------------------
2192 END MODULE MODULE_CU_BMJ
2194 !-----------------------------------------------------------------------