1 !-----------------------------------------------------------------------
3 MODULE MODULE_BL_MYJPBL
5 !-----------------------------------------------------------------------
7 USE MODULE_MODEL_CONSTANTS
9 !-----------------------------------------------------------------------
11 ! REFERENCES: Janjic (2002), NCEP Office Note 437
12 ! Mellor and Yamada (1982), Rev. Geophys. Space Phys.
15 ! MYJ UPDATES THE TURBULENT KINETIC ENERGY WITH THE PRODUCTION/
16 ! DISSIPATION TERM AND THE VERTICAL DIFFUSION TERM
17 ! (USING AN IMPLICIT FORMULATION) FROM MELLOR-YAMADA
18 ! LEVEL 2.5 AS EXTENDED BY JANJIC. EXCHANGE COEFFICIENTS FOR
19 ! THE SURFACE AND FOR ALL LAYER INTERFACES ARE COMPUTED FROM
20 ! MONIN-OBUKHOV THEORY.
21 ! THE TURBULENT VERTICAL EXCHANGE IS THEN EXECUTED.
23 !-----------------------------------------------------------------------
25 INTEGER :: ITRMX=5 ! Iteration count for mixing length computation
27 ! REAL,PARAMETER :: G=9.81,PI=3.1415926,R_D=287.04,R_V=461.6 &
29 REAL,PARAMETER :: PI=3.1415926,VKARMAN=0.4
30 ! REAL,PARAMETER :: CP=7.*R_D/2.
31 REAL,PARAMETER :: CAPA=R_D/CP
32 REAL,PARAMETER :: RLIVWV=XLS/XLV,ELOCP=2.72E6/CP
33 REAL,PARAMETER :: EPS1=1.E-12,EPS2=0.
34 REAL,PARAMETER :: EPSL=0.32,EPSRU=1.E-7,EPSRS=1.E-7 &
36 REAL,PARAMETER :: EPSA=1.E-8,EPSIT=1.E-4,EPSU2=1.E-4,EPSUST=0.07 &
38 REAL,PARAMETER :: ALPH=0.30,BETA=1./273.,EL0MAX=1000.,EL0MIN=1. &
39 & ,ELFC=0.23*0.5,GAM1=0.2222222222222222222 &
41 REAL,PARAMETER :: A1=0.659888514560862645 &
42 & ,A2x=0.6574209922667784586 &
43 & ,B1=11.87799326209552761 &
44 & ,B2=7.226971804046074028 &
45 & ,C1=0.000830955950095854396
46 REAL,PARAMETER :: A2S=17.2693882,A3S=273.16,A4S=35.86
47 REAL,PARAMETER :: ELZ0=0.,ESQ=5.0,EXCM=0.001 &
48 & ,FHNEU=0.8,GLKBR=10.,GLKBS=30. &
49 & ,QVISC=2.1E-5,RFC=0.191,RIC=0.505,SMALL=0.35 &
50 & ,SQPR=0.84,SQSC=0.84,SQVISC=258.2,TVISC=2.1E-5 &
51 & ,USTC=0.7,USTR=0.225,VISC=1.5E-5 &
52 & ,WOLD=0.15,WWST=1.2,ZTMAX=1.,ZTFC=1.,ZTMIN=-5.
54 REAL,PARAMETER :: SEAFC=0.98,PQ0SEA=PQ0*SEAFC
56 REAL,PARAMETER :: BTG=BETA*G,CZIV=SMALL*GLKBS &
57 ! & ,EP_1=R_V/R_D-1.,ESQHF=0.5*5.0,GRRS=GLKBR/GLKBS &
58 & ,ESQHF=0.5*5.0,GRRS=GLKBR/GLKBS &
59 & ,RB1=1./B1,RTVISC=1./TVISC,RVISC=1./VISC &
62 REAL,PARAMETER :: ADNH= 9.*A1*A2x*A2x*(12.*A1+3.*B2)*BTG*BTG &
63 & ,ADNM=18.*A1*A1*A2x*(B2-3.*A2x)*BTG &
64 & ,ANMH=-9.*A1*A2x*A2x*BTG*BTG &
65 & ,ANMM=-3.*A1*A2x*(3.*A2x+3.*B2*C1+18.*A1*C1-B2) &
67 & ,BDNH= 3.*A2x*(7.*A1+B2)*BTG &
69 & ,BEQH= A2x*B1*BTG+3.*A2x*(7.*A1+B2)*BTG &
70 & ,BEQM=-A1*B1*(1.-3.*C1)+6.*A1*A1 &
72 & ,BNMM=A1*(1.-3.*C1) &
73 & ,BSHH=9.*A1*A2x*A2x*BTG &
74 & ,BSHM=18.*A1*A1*A2x*C1 &
75 & ,BSMH=-3.*A1*A2x*(3.*A2x+3.*B2*C1+12.*A1*C1-B2) &
78 & ,CESM=A1*(1.-3.*C1) &
80 & ,ELFCS=VKARMAN*BTG &
81 & ,FZQ1=RTVISC*QVISC*ZQRZT &
82 & ,FZQ2=RTVISC*QVISC*ZQRZT &
83 & ,FZT1=RVISC *TVISC*SQPR &
84 & ,FZT2=CZIV*GRRS*TVISC*SQPR &
87 & ,RFAC=RIC/(FHNEU*RFC*RFC) &
94 !-----------------------------------------------------------------------
95 !*** FREE TERM IN THE EQUILIBRIUM EQUATION FOR (L/Q)**2
96 !-----------------------------------------------------------------------
98 REAL,PARAMETER :: AEQH=9.*A1*A2x*A2x*B1*BTG*BTG &
99 & +9.*A1*A2x*A2x*(12.*A1+3.*B2)*BTG*BTG &
100 & ,AEQM=3.*A1*A2x*B1*(3.*A2x+3.*B2*C1+18.*A1*C1-B2)&
101 & *BTG+18.*A1*A1*A2x*(B2-3.*A2x)*BTG
103 !-----------------------------------------------------------------------
104 !*** FORBIDDEN TURBULENCE AREA
105 !-----------------------------------------------------------------------
107 REAL,PARAMETER :: REQU=-AEQH/AEQM &
108 & ,EPSGH=1.E-9,EPSGM=REQU*EPSGH
110 !-----------------------------------------------------------------------
111 !*** NEAR ISOTROPY FOR SHEAR TURBULENCE, WW/Q2 LOWER LIMIT
112 !-----------------------------------------------------------------------
114 REAL,PARAMETER :: UBRYL=(18.*REQU*A1*A1*A2x*B2*C1*BTG &
115 & +9.*A1*A2x*A2x*B2*BTG*BTG) &
116 & /(REQU*ADNM+ADNH) &
117 & ,UBRY=(1.+EPSRS)*UBRYL,UBRY3=3.*UBRY
119 REAL,PARAMETER :: AUBH=27.*A1*A2x*A2x*B2*BTG*BTG-ADNH*UBRY3 &
120 & ,AUBM=54.*A1*A1*A2x*B2*C1*BTG -ADNM*UBRY3 &
121 & ,BUBH=(9.*A1*A2x+3.*A2x*B2)*BTG-BDNH*UBRY3 &
122 & ,BUBM=18.*A1*A1*C1 -BDNM*UBRY3 &
126 !-----------------------------------------------------------------------
130 !----------------------------------------------------------------------
131 SUBROUTINE MYJPBL(DT,STEPBL,HT,DZ &
132 & ,PMID,PINT,TH,T,EXNER,QV,QCW,QCI,QCS,QCR,QCG & !BSF
133 & ,U,V,RHO,TSK,QSFC,CHKLOWQ,THZ0,QZ0,UZ0,VZ0 & !BSF
134 & ,LOWLYR,XLAND,SICE,SNOW &
135 & ,TKE_MYJ,EXCH_H,USTAR,ZNT,EL_MYJ,PBLH,KPBL,CT &
136 & ,AKHS,AKMS,ELFLX,MIXHT & !PLee (3/07)
137 & ,RUBLTEN,RVBLTEN,RTHBLTEN,RQVBLTEN,RQCBLTEN &
138 & ,RQIBLTEN,RQSBLTEN,RQRBLTEN,RQGBLTEN & !BSF
139 & ,IDS,IDE,JDS,JDE,KDS,KDE &
140 & ,IMS,IME,JMS,JME,KMS,KME &
141 & ,ITS,ITE,JTS,JTE,KTS,KTE)
142 !----------------------------------------------------------------------
146 !----------------------------------------------------------------------
147 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
148 & ,IMS,IME,JMS,JME,KMS,KME &
149 & ,ITS,ITE,JTS,JTE,KTS,KTE
151 INTEGER,INTENT(IN) :: STEPBL
153 INTEGER,DIMENSION(IMS:IME,JMS:JME),INTENT(IN) :: LOWLYR
155 INTEGER,DIMENSION(IMS:IME,JMS:JME),INTENT(OUT) :: KPBL
157 REAL,INTENT(IN) :: DT
159 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(IN) :: HT,SICE,SNOW &
162 REAL,DIMENSION(IMS:IME,KMS:KME,JMS:JME),INTENT(IN) :: DZ,EXNER & !BSF
167 REAL,OPTIONAL,INTENT(IN),DIMENSION(IMS:IME,KMS:KME,JMS:JME):: & !BSF
168 QV,QCW,QCI,QCS,QCR,QCG !BSF
170 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(OUT) :: PBLH,MIXHT !PLee (3/07)
172 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(INOUT) :: AKHS,AKMS
174 REAL, INTENT(OUT), DIMENSION(IMS:IME,KMS:KME,JMS:JME) :: & !BSF
175 & EL_MYJ,RTHBLTEN & !BSF
178 REAL,OPTIONAL,INTENT(OUT),DIMENSION(IMS:IME,KMS:KME,JMS:JME):: & !BSF
179 & RQCBLTEN,RQVBLTEN & !BSF
180 & ,RQIBLTEN,RQSBLTEN & !BSF
181 & ,RQRBLTEN,RQGBLTEN !BSF
183 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(INOUT) :: CT,QSFC,QZ0 &
187 REAL,DIMENSION(IMS:IME,KMS:KME,JMS:JME) &
188 & ,INTENT(INOUT) :: EXCH_H,TKE_MYJ
190 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(IN) :: CHKLOWQ,ELFLX
192 !----------------------------------------------------------------------
197 !-- NSPECE is the number of mass SPECies to be vertically mixed
198 ! (NSPECS - starting number, NSPECE - ending number)
199 ! => Up to 7 species are possible (T,Q,QCW,QCI,QCS,QCR,QCG)
201 !-- Logic behind the order of QCW,QCI,QCS,QCR,QCG is based on
202 ! increasing terminal fall speed of hydrometeors from cloud
203 ! droplets with very low fall speeds (QCW) to fast falling
206 INTEGER, PARAMETER :: NSPECS=1, NSPECE=7 !BSF
208 !-- flQI,flQS,flQR,flQG controls what hydrometeors are present
209 ! that contribute to total condensate, CWM. These flags may also be
210 ! used in future high resolution runs where all condensate fields
211 ! could be vertically mixed (to be determined). It is assumed
212 ! that cloud water is always being passed into the scheme.
214 LOGICAL :: flQI,flQS,flQR,flQG !BSF
216 INTEGER :: I,J,K,KFLIP,LLOW,LMH,LMXL, NUMS,NSPEC,NSP !BSF
218 INTEGER,DIMENSION(ITS:ITE,JTS:JTE) :: LPBL
220 REAL :: AKHS_DENS,AKMS_DENS,APEX,DELTAZ,DQDT,DTDIF,DTDT & !BSF
221 & ,DTTURBL,DUDT,DVDT,EXNSFC,PSFC,PTOP,QFC1,QLOW,QOLD &
222 & ,RATIOMX,RDTTURBL,RG,RWMSK,SEAMASK,THNEW,THOLD,TX &
225 REAL, DIMENSION(NSPECS:NSPECE) :: CLOW,CTS,SZ0 !BSF
227 REAL,DIMENSION(KTS:KTE) :: CWMK,PK,Q2K,QK,THEK,TK,UK,VK & !BSF
228 & ,QCWK,QCIK,QCSK,QCRK,QCGK !BSF
230 REAL, DIMENSION(NSPECS:NSPECE,KTS:KTE) :: SPECIES
232 REAL,DIMENSION(KTS:KTE-1) :: AKHK,AKMK,EL,GH,GM
234 REAL,DIMENSION(KTS:KTE+1) :: ZHK
236 REAL,DIMENSION(ITS:ITE,JTS:JTE) :: THSK
238 REAL,DIMENSION(KTS:KTE,ITS:ITE) :: RHOK
240 REAL,DIMENSION(ITS:ITE,KTS:KTE,JTS:JTE) :: APE,THE, CWM !BSF
242 REAL,DIMENSION(ITS:ITE,KTS:KTE-1,JTS:JTE) :: AKH,AKM
244 REAL,DIMENSION(ITS:ITE,KTS:KTE+1,JTS:JTE) :: ZINT
248 INTEGER :: IMD,JMD,PRINT_DIAG
251 !----------------------------------------------------------------------
252 !**********************************************************************
253 !----------------------------------------------------------------------
260 !*** MAKE PREPARATIONS
262 !----------------------------------------------------------------------
264 NSPEC=3 !-- T, Q, Cloud water
270 IF (PRESENT(QCI)) THEN
274 !BSF IF (PRESENT(QCS)) THEN
278 !BSF IF (PRESENT(QCR)) THEN
282 !BSF IF (PRESENT(QCG)) THEN
312 ZINT(I,KTE+1,J)=HT(I,J) ! Z at bottom of lowest sigma layer
315 !!!!!! UNCOMMENT THESE LINES IF USING ETA COORDINATES
317 !!!!!! ZINT(I,KTE+1,J)=1.E-4 ! Z of bottom of lowest eta layer
318 !!!!!! ZHK(KTE+1)=1.E-4 ! Z of bottom of lowest eta layer
327 ZINT(I,K,J)=ZINT(I,K+1,J)+DZ(I,KFLIP,J)
331 CWM(I,K,J)=QCW(I,K,J) !BSF
332 IF (flQI) CWM(I,K,J)=CWM(I,K,J)+QCI(I,K,J) !BSF
333 !BSF IF (flQS) CWM(I,K,J)=CWM(I,K,J)+QCS(I,K,J)
334 !BSF IF (flQR) CWM(I,K,J)=CWM(I,K,J)+QCR(I,K,J)
335 !BSF IF (flQG) CWM(I,K,J)=CWM(I,K,J)+QCG(I,K,J)
336 THE(I,K,J)=(CWM(I,K,J)*(-ELOCP/TX)+1.)*TH(I,K,J)
341 EL_MYJ(its:ite,:,jts:jte) = 0.
343 !----------------------------------------------------------------------
344 setup_integration: DO J=JTS,JTE
345 !----------------------------------------------------------------------
349 !*** LOWEST LAYER ABOVE GROUND MUST BE FLIPPED
351 LMH=KTE-LOWLYR(I,J)+1
353 PTOP=PINT(I,KTE+1,J) ! KTE+1=KME
354 PSFC=PINT(I,LOWLYR(I,J),J)
356 !*** CONVERT LAND MASK (1 FOR SEA; 0 FOR LAND)
358 SEAMASK=XLAND(I,J)-1.
360 !*** FILL 1-D VERTICAL ARRAYS
361 !*** AND FLIP DIRECTION SINCE MYJ SCHEME
362 !*** COUNTS DOWNWARD FROM THE DOMAIN'S TOP
367 THEK(K)=THE(I,KFLIP,J)
368 RATIOMX=QV(I,KFLIP,J)
369 QK(K)=RATIOMX/(1.+RATIOMX)
370 CWMK(K)=CWM(I,KFLIP,J)
371 PK(K)=PMID(I,KFLIP,J)
375 !*** TKE=0.5*(q**2) ==> q**2=2.*TKE
377 Q2K(K)=2.*TKE_MYJ(I,KFLIP,J)
379 !*** COMPUTE THE HEIGHTS OF THE LAYER INTERFACES
384 ZHK(KTE+1)=HT(I,J) ! Z at bottom of lowest sigma layer
387 ! IF(I==IMD.AND.J==JMD)THEN
392 ! IF(I==227.AND.J==363)PRINT_DIAG=2
395 !----------------------------------------------------------------------
397 !*** FIND THE MIXING LENGTH
399 CALL MIXLEN(LMH,UK,VK,TK,THEK,QK,CWMK &
400 & ,Q2K,ZHK,GM,GH,EL &
401 & ,PBLH(I,J),LPBL(I,J),LMXL,CT(I,J),MIXHT(I,J) & !PLee (3/07)
402 & ,IDS,IDE,JDS,JDE,KDS,KDE &
403 & ,IMS,IME,JMS,JME,KMS,KME &
404 & ,ITS,ITE,JTS,JTE,KTS,KTE)
406 !----------------------------------------------------------------------
408 !*** SOLVE FOR THE PRODUCTION/DISSIPATION OF
409 !*** THE TURBULENT KINETIC ENERGY
412 CALL PRODQ2(LMH,DTTURBL,USTAR(I,J),GM,GH,EL,Q2K &
413 & ,IDS,IDE,JDS,JDE,KDS,KDE &
414 & ,IMS,IME,JMS,JME,KMS,KME &
415 & ,ITS,ITE,JTS,JTE,KTS,KTE)
417 !----------------------------------------------------------------------
418 !*** THE MODEL LAYER (COUNTING UPWARD) CONTAINING THE TOP OF THE PBL
419 !----------------------------------------------------------------------
421 KPBL(I,J)=KTE-LPBL(I,J)+1
423 !----------------------------------------------------------------------
425 !*** FIND THE EXCHANGE COEFFICIENTS IN THE FREE ATMOSPHERE
427 CALL DIFCOF(LMH,LMXL,GM,GH,EL,TK,Q2K,ZHK,AKMK,AKHK &
428 & ,IDS,IDE,JDS,JDE,KDS,KDE &
429 & ,IMS,IME,JMS,JME,KMS,KME &
430 & ,ITS,ITE,JTS,JTE,KTS,KTE,PRINT_DIAG) ! debug
432 !*** COUNTING DOWNWARD FROM THE TOP, THE EXCHANGE COEFFICIENTS AKH
433 !*** ARE DEFINED ON THE BOTTOMS OF THE LAYERS KTS TO KTE-1.
434 !*** COUNTING UPWARD FROM THE BOTTOM, THOSE SAME COEFFICIENTS AS
435 !*** EXCH_H ARE DEFINED ON THE BOTTOMS OF THE LAYERS KTS TO KTE-1
436 !*** THUS EXCH_H INDICES INCREASE UPWARD WITH K=KTS AT THE GROUND.
442 DELTAZ=0.5*(ZHK(KFLIP)-ZHK(KFLIP+2))
443 EXCH_H(I,K,J)=AKHK(KFLIP)*DELTAZ
446 !----------------------------------------------------------------------
448 !*** CARRY OUT THE VERTICAL DIFFUSION OF
449 !*** TURBULENT KINETIC ENERGY
452 CALL VDIFQ(LMH,DTDIF,Q2K,EL,ZHK &
453 & ,IDS,IDE,JDS,JDE,KDS,KDE &
454 & ,IMS,IME,JMS,JME,KMS,KME &
455 & ,ITS,ITE,JTS,JTE,KTS,KTE)
457 !*** SAVE THE NEW TKE AND MIXING LENGTH.
461 Q2K(KFLIP)=AMAX1(Q2K(KFLIP),EPSQ2)
462 TKE_MYJ(I,K,J)=0.5*Q2K(KFLIP)
463 IF(KFLIP<KTE)EL_MYJ(I,K,J)=EL(KFLIP) ! EL IS NOT DEFINED AT KTE (ground surface)
468 !----------------------------------------------------------------------
469 ENDDO setup_integration
470 !----------------------------------------------------------------------
472 !*** CONVERT SURFACE SENSIBLE TEMPERATURE TO POTENTIAL TEMPERATURE.
476 PSFC=PINT(I,LOWLYR(I,J),J)
477 THSK(I,J)=TSK(I,J)*(1.E5/PSFC)**CAPA
481 !----------------------------------------------------------------------
483 !----------------------------------------------------------------------
484 main_integration: DO J=JTS,JTE
485 !----------------------------------------------------------------------
489 !*** FILL 1-D VERTICAL ARRAYS
490 !*** AND FLIP DIRECTION SINCE MYJ SCHEME
491 !*** COUNTS DOWNWARD FROM THE DOMAIN'S TOP
495 THEK(K)=THE(I,KFLIP,J)
496 RATIOMX=QV(I,KFLIP,J)
497 QK(K)=RATIOMX/(1.+RATIOMX)
498 CWMK(K)=CWM(I,KFLIP,J)
499 QCWK(K)=QCW(I,KFLIP,J)
507 QCIK(K)=QCI(I,KFLIP,J)
508 SPECIES(NSP,K)=QCIK(K)
512 !BSF QCSK(K)=QCS(I,KFLIP,J)
513 !BSF SPECIES(NSP,K)=QCSK(K)
517 !BSF QCRK(K)=QCR(I,KFLIP,J)
518 !BSF SPECIES(NSP,K)=QCRK(K)
522 !BSF QCGK(K)=QCG(I,KFLIP,J)
523 !BSF SPECIES(NSP,K)=QCGK(K)
527 RHOK(K,I)=PMID(I,KFLIP,J)/(R_D*T(I,KFLIP,J)* &
528 & (1.+P608*QK(K)-CWMK(K)))
531 !*** COUNTING DOWNWARD FROM THE TOP, THE EXCHANGE COEFFICIENTS AKH
532 !*** ARE DEFINED ON THE BOTTOMS OF THE LAYERS KTS TO KTE-1. THESE COEFFICIENTS
533 !*** ARE ALSO MULTIPLIED BY THE DENSITY AT THE BOTTOM INTERFACE LEVEL.
536 AKHK(K)=AKH(I,K,J)*0.5*(RHOK(K,I)+RHOK(K+1,I))
539 ZHK(KTE+1)=ZINT(I,KTE+1,J)
541 SEAMASK=XLAND(I,J)-1.
542 THZ0(I,J)=(1.-SEAMASK)*THSK(I,J)+SEAMASK*THZ0(I,J)
545 AKHS_DENS=AKHS(I,J)*RHOK(KTE+1-LLOW,I)
548 QFC1=XLV*CHKLOWQ(I,J)*AKHS_DENS
550 IF(SNOW(I,J)>0..OR.SICE(I,J)>0.5)THEN
556 QSFC(I,J)=QLOW+ELFLX(I,J)/QFC1
560 PSFC=PINT(I,LOWLYR(I,J),J)
561 EXNSFC=(1.E5/PSFC)**CAPA
562 QSFC(I,J)=PQ0SEA/PSFC &
563 & *EXP(A2*(THSK(I,J)-A3*EXNSFC)/(THSK(I,J)-A4*EXNSFC))
566 QZ0 (I,J)=(1.-SEAMASK)*QSFC(I,J)+SEAMASK*QZ0 (I,J)
587 !*** LOWEST LAYER ABOVE GROUND MUST BE FLIPPED
589 LMH=KTE-LOWLYR(I,J)+1
591 !----------------------------------------------------------------------
592 !*** CARRY OUT THE VERTICAL DIFFUSION OF
593 !*** TEMPERATURE AND WATER VAPOR
594 !----------------------------------------------------------------------
596 CALL VDIFH(DTDIF,LMH,NSPECS,NSPECE,LPBL(I,J),SZ0 & !BSF
597 & ,AKHS_DENS,CLOW,CTS & !BSF
598 & ,SPECIES,NSPEC,AKHK,ZHK,RHOK(KTS,I) & !BSF
599 & ,IDS,IDE,JDS,JDE,KDS,KDE &
600 & ,IMS,IME,JMS,JME,KMS,KME &
601 & ,ITS,ITE,JTS,JTE,KTS,KTE,I,J)
602 !----------------------------------------------------------------------
604 !*** COMPUTE PRIMARY VARIABLE TENDENCIES
615 QCIK(K)=SPECIES(NSP,K)
616 CWMK(K)=CWMK(K)+QCIK(K)
620 !BSF QCSK(K)=SPECIES(NSP,K)
621 !BSF CWMK(K)=CWMK(K)+QCSK(K)
625 !BSF QCRK(K)=SPECIES(NSP,K)
626 !BSF CWMK(K)=CWMK(K)+QCRK(K)
630 !BSF QCGK(K)=SPECIES(NSP,K)
631 !BSF CWMK(K)=CWMK(K)+QCGK(K)
639 THNEW=THEK(KFLIP)+CWMK(KFLIP)*ELOCP*APE(I,K,J)
640 DTDT=(THNEW-THOLD)*RDTTURBL
641 QOLD=QV(I,K,J)/(1.+QV(I,K,J))
642 DQDT=(QK(KFLIP)-QOLD)*RDTTURBL
644 RQVBLTEN(I,K,J)=DQDT/(1.-QK(KFLIP))**2
646 RQCBLTEN(I,K,J)=(QCWK(KFLIP)-QCW(I,K,J))*RDTTURBL
647 IF (flQI) RQIBLTEN(I,K,J)=(QCIK(KFLIP)-QCI(I,K,J))*RDTTURBL
648 !BSF IF (flQS) RQSBLTEN(I,K,J)=(QCSK(KFLIP)-QCS(I,K,J))*RDTTURBL
649 !BSF IF (flQR) RQRBLTEN(I,K,J)=(QCRK(KFLIP)-QCR(I,K,J))*RDTTURBL
650 !BSF IF (flQG) RQGBLTEN(I,K,J)=(QCGK(KFLIP)-QCG(I,K,J))*RDTTURBL
655 ! IF(I==IMD.AND.J==JMD)THEN
660 ! IF(I==227.AND.J==363)PRINT_DIAG=0
663 PSFC=.01*PINT(I,LOWLYR(I,J),J)
664 ZSL_DIAG=0.5*DZ(I,1,J)
667 ! IF(PRINT_DIAG==1)THEN
669 ! write(6,"(a, 2i5, 2i3, 2f8.2, f6.2, 2f8.2)") &
670 ! '{turb4 i,j, Kpbl, Kmxl, Psfc, Zsfc, Zsl, Zpbl, Zmxl = ' &
671 ! , i, j, KPBL(i,j), KTE-LMXL+1, PSFC, ZHK(LMH+1), ZSL_diag &
672 ! , PBLH(i,j), ZHK(LMXL)-ZHK(LMH+1)
673 ! write(6,"(a, 2f7.2, f7.3, 3e11.4)") &
674 ! '{turb4 tsk, thsk, qz0, q**2_0, akhs, exch_0 = ' &
675 ! , tsk(i,j)-273.15, thsk(i,j), 1000.*qz0(i,j) &
676 ! , 2.*tke_myj(i,1,j), akhs(i,j), akhs(i,j)*ZSL_diag
678 ! '{turb5 k, Pmid, Pint_1, Tc, TH, DTH, GH, GM, EL, Q**2, Akh, EXCH_h, Dz, Dp'
680 ! KFLIP=KTE-K !-- Includes the KFLIP-1 in earlier versions
681 ! write(6,"(a,i3, 2f8.2, 2f8.3, 3e12.4, 4e11.4, f7.2, f6.2)") &
682 ! '{turb5 ', k, .01*pmid(i,k,j),.01*pint(i,k,j), T(i,k,j)-273.15 &
683 ! , th(i,k,j), DTTURBL*rthblten(i,k,j), GH(KFLIP), GM(KFLIP) &
684 ! , el_myj(i,KFLIP,j), 2.*tke_myj(i,k+1,j), akh(i,KFLIP,j) &
685 ! , exch_h(i,k,j), dz(i,k,j), .01*(pint(i,k,j)-pint(i,k+1,j))
688 ! ELSEIF(PRINT_DIAG==2)THEN
690 ! write(6,"(a, 2i5, 2i3, 2f8.2, f6.2, 2f8.2)") &
691 ! '}turb4 i,j, Kpbl, Kmxl, Psfc, Zsfc, Zsl, Zpbl, Zmxl = ' &
692 ! , i, j, KPBL(i,j), KTE-LMXL+1, PSFC, ZHK(LMH+1), ZSL_diag &
693 ! , PBLH(i,j), ZHK(LMXL)-ZHK(LMH+1)
694 ! write(6,"(a, 2f7.2, f7.3, 3e11.4)") &
695 ! '}turb4 tsk, thsk, qz0, q**2_0, akhs, exch_0 = ' &
696 ! , tsk(i,j)-273.15, thsk(i,j), 1000.*qz0(i,j) &
697 ! , 2.*tke_myj(i,1,j), akhs(i,j), akhs(i,j)*ZSL_diag
699 ! '}turb5 k, Pmid, Pint_1, Tc, TH, DTH, GH, GM, EL, Q**2, Akh, EXCH_h, Dz, Dp'
701 ! KFLIP=KTE-K !-- Includes the KFLIP-1 in earlier versions
702 ! write(6,"(a,i3, 2f8.2, 2f8.3, 3e12.4, 4e11.4, f7.2, f6.2)") &
703 ! '}turb5 ', k, .01*pmid(i,k,j),.01*pint(i,k,j), T(i,k,j)-273.15 &
704 ! , th(i,k,j), DTTURBL*rthblten(i,k,j), GH(KFLIP), GM(KFLIP) &
705 ! , el_myj(i,KFLIP,j), 2.*tke_myj(i,k+1,j), akh(i,KFLIP,j) &
706 ! , exch_h(i,k,j), dz(i,k,j), .01*(pint(i,k,j)-pint(i,k+1,j))
711 !----------------------------------------------------------------------
713 !----------------------------------------------------------------------
716 !*** FILL 1-D VERTICAL ARRAYS
717 !*** AND FLIP DIRECTION SINCE MYJ SCHEME
718 !*** COUNTS DOWNWARD FROM THE DOMAIN'S TOP
722 AKMK(K)=AKMK(K)*(RHOK(K,I)+RHOK(K+1,I))*0.5
726 AKMS_DENS=AKMS(I,J)*RHOK(KTE+1-LLOW,I)
734 ZHK(KTE+1)=ZINT(I,KTE+1,J)
736 !----------------------------------------------------------------------
737 !*** CARRY OUT THE VERTICAL DIFFUSION OF
738 !*** VELOCITY COMPONENTS
739 !----------------------------------------------------------------------
741 CALL VDIFV(LMH,DTDIF,UZ0(I,J),VZ0(I,J) &
742 & ,AKMS_DENS,UK,VK,AKMK,ZHK,RHOK(KTS,I) &
743 & ,IDS,IDE,JDS,JDE,KDS,KDE &
744 & ,IMS,IME,JMS,JME,KMS,KME &
745 & ,ITS,ITE,JTS,JTE,KTS,KTE,I,J)
747 !----------------------------------------------------------------------
749 !*** COMPUTE PRIMARY VARIABLE TENDENCIES
753 DUDT=(UK(KFLIP)-U(I,K,J))*RDTTURBL
754 DVDT=(VK(KFLIP)-V(I,K,J))*RDTTURBL
760 !----------------------------------------------------------------------
762 ENDDO main_integration
764 !----------------------------------------------------------------------
766 END SUBROUTINE MYJPBL
768 !----------------------------------------------------------------------
769 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
770 !----------------------------------------------------------------------
772 !----------------------------------------------------------------------
773 ! ******************************************************************
775 ! * LEVEL 2.5 MIXING LENGTH *
777 ! ******************************************************************
779 &(LMH,U,V,T,THE,Q,CWM,Q2,Z,GM,GH,EL,PBLH,LPBL,LMXL,CT,MIXHT & !PLee(3/07)
780 &,IDS,IDE,JDS,JDE,KDS,KDE &
781 &,IMS,IME,JMS,JME,KMS,KME &
782 &,ITS,ITE,JTS,JTE,KTS,KTE)
783 !----------------------------------------------------------------------
787 !----------------------------------------------------------------------
788 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
789 & ,IMS,IME,JMS,JME,KMS,KME &
790 & ,ITS,ITE,JTS,JTE,KTS,KTE
792 INTEGER,INTENT(IN) :: LMH
794 INTEGER,INTENT(OUT) :: LMXL,LPBL
796 REAL,DIMENSION(KTS:KTE),INTENT(IN) :: CWM,Q,Q2,T,THE,U,V
798 REAL,DIMENSION(KTS:KTE+1),INTENT(IN) :: Z
800 REAL,INTENT(OUT) :: PBLH,MIXHT !PLee (3/07)
802 REAL,DIMENSION(KTS:KTE-1),INTENT(OUT) :: EL,GH,GM
804 REAL,INTENT(INOUT) :: CT
805 !----------------------------------------------------------------------
811 REAL :: A,ADEN,B,BDEN,AUBR,BUBR,BLMX,EL0,ELOQ2X,GHL,GML &
812 & ,QOL2ST,QOL2UN,QDZL,RDZ,SQ,SREL,SZQ,TEM,THM,VKRMZ
814 REAL,DIMENSION(KTS:KTE) :: Q1
816 REAL,DIMENSION(KTS:KTE-1) :: DTH,ELM,REL
818 !----------------------------------------------------------------------
819 !**********************************************************************
820 !--------------FIND THE HEIGHT OF THE PBL-------------------------------
824 IF(Q2(K)<=EPSQ2*FH)THEN
832 !--------------THE HEIGHT OF THE PBL------------------------------------
834 110 PBLH=Z(LPBL+1)-Z(LMH+1)
836 !-----------------------------------------------------------------------
842 DTH(K)=THE(K)-THE(K+1)
846 IF(DTH(K)>0..AND.DTH(K+1)<=0.)THEN
853 !----------------------------------------------------------------------
856 GML=((U(K)-U(K+1))**2+(V(K)-V(K+1))**2)*RDZ*RDZ
859 TEM=(T(K)+T(K+1))*0.5
860 THM=(THE(K)+THE(K+1))*0.5
863 B=(ELOCP/TEM-1.-P608)*THM
865 GHL=(DTH(K)*((Q(K)+Q(K+1)+CWM(K)+CWM(K+1))*(0.5*P608)+1.) &
866 & +(Q(K)-Q(K+1)+CWM(K)-CWM(K+1))*A &
867 & +(CWM(K)-CWM(K+1))*B)*RDZ
869 IF(ABS(GHL)<=EPSGH)GHL=EPSGH
874 !----------------------------------------------------------------------
875 !*** FIND MAXIMUM MIXING LENGTHS AND THE LEVEL OF THE PBL TOP
876 !----------------------------------------------------------------------
885 IF(GML/GHL<=REQU)THEN
889 AUBR=(AUBM*GML+AUBH*GHL)*GHL
890 BUBR= BUBM*GML+BUBH*GHL
891 QOL2ST=(-0.5*BUBR+SQRT(BUBR*BUBR*0.25-AUBR*CUBR))*RCUBR
893 ELM(K)=MAX(SQRT(ELOQ2X*Q2(K)),EPSL)
896 ADEN=(ADNM*GML+ADNH*GHL)*GHL
897 BDEN= BDNM*GML+BDNH*GHL
898 QOL2UN=-0.5*BDEN+SQRT(BDEN*BDEN*0.25-ADEN)
899 ELOQ2X=1./(QOL2UN+EPSRU) ! repsr1/qol2un
900 ELM(K)=MAX(SQRT(ELOQ2X*Q2(K)),EPSL)
904 IF(ELM(LMH-1)==EPSL)LMXL=LMH
906 !----------------------------------------------------------------------
907 !*** THE HEIGHT OF THE MIXED LAYER
908 !----------------------------------------------------------------------
910 BLMX=Z(LMXL)-Z(LMH+1)
911 MIXHT=BLMX !PLee (3/07)
913 !----------------------------------------------------------------------
917 !----------------------------------------------------------------------
922 QDZL=(Q1(K)+Q1(K+1))*(Z(K+1)-Z(K+2))
923 SZQ=(Z(K+1)+Z(K+2)-Z(LMH+1)-Z(LMH+1))*QDZL+SZQ
927 !----------------------------------------------------------------------
928 !*** COMPUTATION OF ASYMPTOTIC L IN BLACKADAR FORMULA
929 !----------------------------------------------------------------------
931 EL0=MIN(ALPH*SZQ*0.5/SQ,EL0MAX)
934 !----------------------------------------------------------------------
935 !*** ABOVE THE PBL TOP
936 !----------------------------------------------------------------------
941 EL(K)=MIN((Z(K)-Z(K+2))*ELFC,ELM(K))
945 !----------------------------------------------------------------------
947 !----------------------------------------------------------------------
951 VKRMZ=(Z(K+1)-Z(LMH+1))*VKARMAN
952 EL(K)=MIN(VKRMZ/(VKRMZ/EL0+1.),ELM(K))
958 SREL=MIN(((REL(K-1)+REL(K+1))*0.5+REL(K))*0.5,REL(K))
959 EL(K)=MAX(SREL*ELM(K),EPSL)
962 !----------------------------------------------------------------------
963 END SUBROUTINE MIXLEN
964 !----------------------------------------------------------------------
965 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
966 !----------------------------------------------------------------------
968 !----------------------------------------------------------------------
969 ! ******************************************************************
971 ! * LEVEL 2.5 Q2 PRODUCTION/DISSIPATION *
973 ! ******************************************************************
975 &(LMH,DTTURBL,USTAR,GM,GH,EL,Q2 &
976 &,IDS,IDE,JDS,JDE,KDS,KDE &
977 &,IMS,IME,JMS,JME,KMS,KME &
978 &,ITS,ITE,JTS,JTE,KTS,KTE)
979 !----------------------------------------------------------------------
983 !----------------------------------------------------------------------
984 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
985 & ,IMS,IME,JMS,JME,KMS,KME &
986 & ,ITS,ITE,JTS,JTE,KTS,KTE
988 INTEGER,INTENT(IN) :: LMH
990 REAL,INTENT(IN) :: DTTURBL,USTAR
992 REAL,DIMENSION(KTS:KTE-1),INTENT(IN) :: GH,GM
993 REAL,DIMENSION(KTS:KTE-1),INTENT(INOUT) :: EL
995 REAL,DIMENSION(KTS:KTE),INTENT(INOUT) :: Q2
996 !----------------------------------------------------------------------
1002 REAL :: ADEN,AEQU,ANUM,ARHS,BDEN,BEQU,BNUM,BRHS,CDEN,CRHS &
1003 & ,DLOQ1,ELOQ11,ELOQ12,ELOQ13,ELOQ21,ELOQ22,ELOQ31,ELOQ32 &
1004 & ,ELOQ41,ELOQ42,ELOQ51,ELOQ52,ELOQN,EQOL2,GHL,GML &
1005 & ,RDEN1,RDEN2,RHS2,RHSP1,RHSP2,RHST2
1007 !----------------------------------------------------------------------
1008 !**********************************************************************
1009 !----------------------------------------------------------------------
1011 main_integration: DO K=1,LMH-1
1015 !----------------------------------------------------------------------
1016 !*** COEFFICIENTS OF THE EQUILIBRIUM EQUATION
1017 !----------------------------------------------------------------------
1019 AEQU=(AEQM*GML+AEQH*GHL)*GHL
1020 BEQU= BEQM*GML+BEQH*GHL
1022 !----------------------------------------------------------------------
1023 !*** EQUILIBRIUM SOLUTION FOR L/Q
1024 !----------------------------------------------------------------------
1026 EQOL2=-0.5*BEQU+SQRT(BEQU*BEQU*0.25-AEQU)
1028 !----------------------------------------------------------------------
1029 !*** IS THERE PRODUCTION/DISSIPATION ?
1030 !----------------------------------------------------------------------
1032 IF((GML+GHL*GHL<=EPSTRB) &
1033 & .OR.(GHL>=EPSGH.AND.GML/GHL<=REQU) &
1034 & .OR.(EQOL2<=EPS2))THEN
1036 !----------------------------------------------------------------------
1038 !----------------------------------------------------------------------
1042 !----------------------------------------------------------------------
1046 !----------------------------------------------------------------------
1048 !----------------------------------------------------------------------
1049 !----------------------------------------------------------------------
1050 !*** COEFFICIENTS OF THE TERMS IN THE NUMERATOR
1051 !----------------------------------------------------------------------
1053 ANUM=(ANMM*GML+ANMH*GHL)*GHL
1054 BNUM= BNMM*GML+BNMH*GHL
1056 !----------------------------------------------------------------------
1057 !*** COEFFICIENTS OF THE TERMS IN THE DENOMINATOR
1058 !----------------------------------------------------------------------
1060 ADEN=(ADNM*GML+ADNH*GHL)*GHL
1061 BDEN= BDNM*GML+BDNH*GHL
1064 !----------------------------------------------------------------------
1065 !*** COEFFICIENTS OF THE NUMERATOR OF THE LINEARIZED EQ.
1066 !----------------------------------------------------------------------
1068 ARHS=-(ANUM*BDEN-BNUM*ADEN)*2.
1072 !----------------------------------------------------------------------
1073 !*** INITIAL VALUE OF L/Q
1074 !----------------------------------------------------------------------
1076 DLOQ1=EL(K)/SQRT(Q2(K))
1078 !----------------------------------------------------------------------
1079 !*** FIRST ITERATION FOR L/Q, RHS=0
1080 !----------------------------------------------------------------------
1084 ELOQ31=ELOQ21*ELOQ11
1085 ELOQ41=ELOQ21*ELOQ21
1086 ELOQ51=ELOQ21*ELOQ31
1088 !----------------------------------------------------------------------
1090 !----------------------------------------------------------------------
1092 RDEN1=1./(ADEN*ELOQ41+BDEN*ELOQ21+CDEN)
1094 !----------------------------------------------------------------------
1096 !----------------------------------------------------------------------
1098 RHSP1=(ARHS*ELOQ51+BRHS*ELOQ31+CRHS*ELOQ11)*RDEN1*RDEN1
1100 !----------------------------------------------------------------------
1101 !*** FIRST-GUESS SOLUTION
1102 !----------------------------------------------------------------------
1104 ELOQ12=ELOQ11+(DLOQ1-ELOQ11)*EXP(RHSP1*DTTURBL)
1105 ELOQ12=MAX(ELOQ12,EPS1)
1107 !----------------------------------------------------------------------
1108 !*** SECOND ITERATION FOR L/Q
1109 !----------------------------------------------------------------------
1111 ELOQ22=ELOQ12*ELOQ12
1112 ELOQ32=ELOQ22*ELOQ12
1113 ELOQ42=ELOQ22*ELOQ22
1114 ELOQ52=ELOQ22*ELOQ32
1116 !----------------------------------------------------------------------
1118 !----------------------------------------------------------------------
1120 RDEN2=1./(ADEN*ELOQ42+BDEN*ELOQ22+CDEN)
1121 RHS2 =-(ANUM*ELOQ42+BNUM*ELOQ22)*RDEN2+RB1
1122 RHSP2= (ARHS*ELOQ52+BRHS*ELOQ32+CRHS*ELOQ12)*RDEN2*RDEN2
1125 !----------------------------------------------------------------------
1126 !*** CORRECTED SOLUTION
1127 !----------------------------------------------------------------------
1129 ELOQ13=ELOQ12-RHST2+(RHST2+DLOQ1-ELOQ12)*EXP(RHSP2*DTTURBL)
1130 ELOQ13=AMAX1(ELOQ13,EPS1)
1132 !----------------------------------------------------------------------
1133 !*** TWO ITERATIONS IS ENOUGH IN MOST CASES ...
1134 !----------------------------------------------------------------------
1139 Q2(K)=EL(K)*EL(K)/(ELOQN*ELOQN)
1140 Q2(K)=AMAX1(Q2(K),EPSQ2)
1141 IF(Q2(K)==EPSQ2)THEN
1149 !----------------------------------------------------------------------
1150 !*** END OF TURBULENT BRANCH
1151 !----------------------------------------------------------------------
1154 !----------------------------------------------------------------------
1155 !*** END OF PRODUCTION/DISSIPATION LOOP
1156 !----------------------------------------------------------------------
1158 ENDDO main_integration
1160 !----------------------------------------------------------------------
1161 !*** LOWER BOUNDARY CONDITION FOR Q2
1162 !----------------------------------------------------------------------
1164 Q2(LMH)=AMAX1(B1**(2./3.)*USTAR*USTAR,EPSQ2)
1165 !----------------------------------------------------------------------
1167 END SUBROUTINE PRODQ2
1169 !----------------------------------------------------------------------
1170 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1171 !----------------------------------------------------------------------
1173 ! ******************************************************************
1175 ! * LEVEL 2.5 DIFFUSION COEFFICIENTS *
1177 ! ******************************************************************
1178 &(LMH,LMXL,GM,GH,EL,T,Q2,Z,AKM,AKH &
1179 &,IDS,IDE,JDS,JDE,KDS,KDE &
1180 &,IMS,IME,JMS,JME,KMS,KME &
1181 &,ITS,ITE,JTS,JTE,KTS,KTE,PRINT_DIAG) ! debug
1182 !----------------------------------------------------------------------
1186 !----------------------------------------------------------------------
1187 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
1188 & ,IMS,IME,JMS,JME,KMS,KME &
1189 & ,ITS,ITE,JTS,JTE,KTS,KTE
1191 INTEGER,INTENT(IN) :: LMH,LMXL
1193 REAL,DIMENSION(KTS:KTE),INTENT(IN) :: Q2,T
1194 REAL,DIMENSION(KTS:KTE-1),INTENT(IN) :: EL,GH,GM
1195 REAL,DIMENSION(KTS:KTE+1),INTENT(IN) :: Z
1197 REAL,DIMENSION(KTS:KTE-1),INTENT(OUT) :: AKH,AKM
1198 !----------------------------------------------------------------------
1200 !*** LOCAL VARIABLES
1204 REAL :: ADEN,AKMIN,BDEN,BESH,BESM,CDEN,D2T,ELL,ELOQ2,ELOQ4,ELQDZ &
1205 & ,ESH,ESM,GHL,GML,Q1L,RDEN,RDZ
1207 !*** Begin debugging
1208 INTEGER,INTENT(IN) :: PRINT_DIAG
1212 !----------------------------------------------------------------------
1213 !**********************************************************************
1214 !----------------------------------------------------------------------
1225 !----------------------------------------------------------------------
1226 !*** COEFFICIENTS OF THE TERMS IN THE DENOMINATOR
1227 !----------------------------------------------------------------------
1229 ADEN=(ADNM*GML+ADNH*GHL)*GHL
1230 BDEN= BDNM*GML+BDNH*GHL
1233 !----------------------------------------------------------------------
1234 !*** COEFFICIENTS FOR THE SM DETERMINANT
1235 !----------------------------------------------------------------------
1239 !----------------------------------------------------------------------
1240 !*** COEFFICIENTS FOR THE SH DETERMINANT
1241 !----------------------------------------------------------------------
1243 BESH=BSHM*GML+BSHH*GHL
1245 !----------------------------------------------------------------------
1247 !----------------------------------------------------------------------
1249 RDEN=1./(ADEN*ELOQ4+BDEN*ELOQ2+CDEN)
1251 !----------------------------------------------------------------------
1253 !----------------------------------------------------------------------
1255 ESM=(BESM*ELOQ2+CESM)*RDEN
1256 ESH=(BESH*ELOQ2+CESH)*RDEN
1258 !----------------------------------------------------------------------
1259 !*** DIFFUSION COEFFICIENTS
1260 !----------------------------------------------------------------------
1262 RDZ=2./(Z(K)-Z(K+2))
1267 !----------------------------------------------------------------------
1269 !----------------------------------------------------------------------
1271 !----------------------------------------------------------------------
1273 !----------------------------------------------------------------------
1280 ! D2T=T(K-1)-2.*T(K)+T(K+1)
1281 ! IF(D2T<D2Tmin)THEN
1289 ! RDZ=2./(Z(K)-Z(K+2))
1291 ! AKM(K)=MAX(AKM(K),AKMIN)
1292 ! AKH(K)=MAX(AKH(K),AKMIN)
1295 !*** Begin debugging
1296 ! IF(PRINT_DIAG>0)THEN
1297 ! write(6,"(a,3i3)") '{turb1 lmxl,lmh,kinv=',lmxl,lmh,kinv
1298 ! write(6,"(a,3i3)") '}turb1 lmxl,lmh,kinv=',lmxl,lmh,kinv
1299 ! IF(PRINT_DIAG==1)THEN
1301 ! '{turb3 k, t, d2t, rdz, z(k), z(k+2), akmin, akh '
1304 ! '}turb3 k, t, d2t, rdz, z(k), z(k+2), akmin, akh '
1306 ! DO K=LMH-1,KINV-1,-1
1307 ! D2T=T(K-1)-2.*T(K)+T(K+1)
1308 ! RDZ=2./(Z(K)-Z(K+2))
1310 ! IF(PRINT_DIAG==1)THEN
1311 ! write(6,"(a,i3,f8.3,2e12.5,2f9.2,2e12.5)") '{turb3 ' &
1312 ! ,k,t(k)-273.15,d2t,rdz,z(k),z(k+2),akmin,akh(k)
1314 ! write(6,"(a,i3,f8.3,2e12.5,2f9.2,2e12.5)") '}turb3 ' &
1315 ! ,k,t(k)-273.15,d2t,rdz,z(k),z(k+2),akmin,akh(k)
1318 ! ENDIF !- IF (print_diag > 0) THEN
1319 ! ENDIF !- IF(KINV<LMH)THEN
1323 !----------------------------------------------------------------------
1325 END SUBROUTINE DIFCOF
1327 !----------------------------------------------------------------------
1328 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1329 !----------------------------------------------------------------------
1331 ! ******************************************************************
1333 ! * VERTICAL DIFFUSION OF Q2 (TKE) *
1335 ! ******************************************************************
1336 &(LMH,DTDIF,Q2,EL,Z &
1337 &,IDS,IDE,JDS,JDE,KDS,KDE &
1338 &,IMS,IME,JMS,JME,KMS,KME &
1339 &,ITS,ITE,JTS,JTE,KTS,KTE)
1340 !----------------------------------------------------------------------
1344 !----------------------------------------------------------------------
1345 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
1346 & ,IMS,IME,JMS,JME,KMS,KME &
1347 & ,ITS,ITE,JTS,JTE,KTS,KTE
1349 INTEGER,INTENT(IN) :: LMH
1351 REAL,INTENT(IN) :: DTDIF
1353 REAL,DIMENSION(KTS:KTE-1),INTENT(IN) :: EL
1354 REAL,DIMENSION(KTS:KTE+1),INTENT(IN) :: Z
1356 REAL,DIMENSION(KTS:KTE),INTENT(INOUT) :: Q2
1357 !----------------------------------------------------------------------
1359 !*** LOCAL VARIABLES
1363 REAL :: ADEN,AKQS,BDEN,BESH,BESM,CDEN,CF,DTOZS,ELL,ELOQ2,ELOQ4 &
1364 & ,ELQDZ,ESH,ESM,ESQHF,GHL,GML,Q1L,RDEN,RDZ
1366 REAL,DIMENSION(KTS:KTE-2) :: AKQ,CM,CR,DTOZ,RSQ2
1367 !----------------------------------------------------------------------
1368 !**********************************************************************
1369 !----------------------------------------------------------------------
1371 !*** VERTICAL TURBULENT DIFFUSION
1373 !----------------------------------------------------------------------
1377 DTOZ(K)=(DTDIF+DTDIF)/(Z(K)-Z(K+2))
1378 AKQ(K)=SQRT((Q2(K)+Q2(K+1))*0.5)*(EL(K)+EL(K+1))*ESQHF &
1380 CR(K)=-DTOZ(K)*AKQ(K)
1383 CM(1)=DTOZ(1)*AKQ(1)+1.
1387 CF=-DTOZ(K)*AKQ(K-1)/CM(K-1)
1388 CM(K)=-CR(K-1)*CF+(AKQ(K-1)+AKQ(K))*DTOZ(K)+1.
1389 RSQ2(K)=-RSQ2(K-1)*CF+Q2(K)
1392 DTOZS=(DTDIF+DTDIF)/(Z(LMH-1)-Z(LMH+1))
1393 AKQS=SQRT((Q2(LMH-1)+Q2(LMH))*0.5)*(EL(LMH-1)+ELZ0)*ESQHF &
1394 & /(Z(LMH)-Z(LMH+1))
1396 CF=-DTOZS*AKQ(LMH-2)/CM(LMH-2)
1398 Q2(LMH-1)=(DTOZS*AKQS*Q2(LMH)-RSQ2(LMH-2)*CF+Q2(LMH-1)) &
1399 & /((AKQ(LMH-2)+AKQS)*DTOZS-CR(LMH-2)*CF+1.)
1402 Q2(K)=(-CR(K)*Q2(K+1)+RSQ2(K))/CM(K)
1404 !----------------------------------------------------------------------
1406 END SUBROUTINE VDIFQ
1408 !----------------------------------------------------------------------
1409 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1410 !---------------------------------------------------------------------
1411 SUBROUTINE VDIFH(DTDIF,LMH,MSS,MSE,LPBL,SZ0 &
1413 & ,SPECIES,NSPEC,RKH,ZHK,RHO &
1414 & ,IDS,IDE,JDS,JDE,KDS,KDE &
1415 & ,IMS,IME,JMS,JME,KMS,KME &
1416 & ,ITS,ITE,JTS,JTE,KTS,KTE,I,J)
1417 ! ***************************************************************
1419 ! * VERTICAL DIFFUSION OF MASS VARIABLES *
1421 ! * Z. JANJIC MODIFIED TO WORK WITH ARBITRARY NUMBER OF SPECIES *
1424 ! ***************************************************************
1425 !---------------------------------------------------------------------
1429 !---------------------------------------------------------------------
1430 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
1431 & ,IMS,IME,JMS,JME,KMS,KME &
1432 & ,ITS,ITE,JTS,JTE,KTS,KTE,I,J
1434 INTEGER,INTENT(IN):: LMH,LPBL,MSS,MSE,NSPEC !BSF
1436 ! REAL,INTENT(IN) :: CHKLOWQ,CT,DTDIF,QZ0,RKHS,THZ0
1438 REAL,INTENT(IN):: DTDIF,RKHS
1440 REAL,DIMENSION(MSS:MSE),INTENT(IN):: CLOW,CTS,SZ0
1442 REAL,DIMENSION(KTS:KTE-1),INTENT(IN):: RKH
1444 REAL,DIMENSION(KTS:KTE ),INTENT(IN):: RHO
1446 REAL,DIMENSION(KTS:KTE+1),INTENT(IN):: ZHK
1448 REAL,DIMENSION(MSS:MSE,KTS:KTE),INTENT(INOUT):: SPECIES
1450 !----------------------------------------------------------------------
1452 !*** LOCAL VARIABLES
1456 REAL:: CF,CMB,CMSB,DTOZL,DTOZS,RCML,RHOK,RKHH,RKHZ,RKSS,RSSB
1458 REAL,DIMENSION(KTS:KTE-1):: CM,CR,DTOZ
1460 REAL,DIMENSION(MSS:MSE,KTS:KTE-1):: RKCT,RSS
1462 !----------------------------------------------------------------------
1463 !**********************************************************************
1464 !---PREPARATIONS-------------------------------------------------------
1466 DTOZ(K)=DTDIF/(ZHK(K)-ZHK(K+1))
1467 CR(K)=-DTOZ(K)*RKH(K)
1473 RKHZ=RKH(K)*(ZHK(K)-ZHK(K+2))
1475 RKCT(M,K)=RKHZ*CTS(M)*0.5
1479 !---TOP LEVEL----------------------------------------------------------
1481 CM(KTS)=DTOZ(KTS)*RKH(KTS)+RHOK
1483 RSS(M,KTS)=-RKCT(M,KTS)*DTOZ(KTS)+SPECIES(M,KTS)*RHOK
1485 !---INTERMEDIATE LEVELS------------------------------------------------
1488 CF=-DTOZL*RKH(K-1)/CM(K-1)
1490 CM(K)=-CR(K-1)*CF+(RKH(K-1)+RKH(K))*DTOZL+RHOK
1492 RSS(M,K)=-RSS(M,K-1)*CF &
1493 +(RKCT(M,K-1)-RKCT(M,K))*DTOZL+SPECIES(M,K)*RHOK
1496 !---BOTTOM LEVEL-------------------------------------------------------
1497 DTOZS=DTDIF/(ZHK(LMH)-ZHK(LMH+1))
1500 CF=-DTOZS*RKHH/CM(LMH-1)
1506 CMSB=-CMB+(RKHH+RKSS)*DTOZS+RHOK
1507 RSSB=-RSS(M,LMH-1)*CF+RKCT(M,LMH-1)*DTOZS+SPECIES(M,LMH)*RHOK
1508 SPECIES(M,LMH)=(DTOZS*RKSS*SZ0(M)+RSSB)/CMSB
1510 !---BACKSUBSTITUTION---------------------------------------------------
1514 SPECIES(M,K)=(-CR(K)*SPECIES(M,K+1)+RSS(M,K))*RCML
1517 !----------------------------------------------------------------------
1519 END SUBROUTINE VDIFH
1521 !----------------------------------------------------------------------
1522 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1523 !---------------------------------------------------------------------
1524 SUBROUTINE VDIFX(DTDIF,LMH,RKHS,CT &
1525 ,DUST1,DUST2,RKH,Z,RHO &
1526 ,IDS,IDE,JDS,JDE,KDS,KDE &
1527 ,IMS,IME,JMS,JME,KMS,KME &
1528 ,ITS,ITE,JTS,JTE,KTS,KTE)
1529 ! ***************************************************************
1531 ! * VERTICAL DIFFUSION OF MASS VARIABLES *
1533 ! ***************************************************************
1534 !---------------------------------------------------------------------
1538 !---------------------------------------------------------------------
1539 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
1540 ,IMS,IME,JMS,JME,KMS,KME &
1541 ,ITS,ITE,JTS,JTE,KTS,KTE
1543 INTEGER,INTENT(IN) :: LMH
1545 REAL,INTENT(IN) :: CT,DTDIF,RKHS
1547 REAL,DIMENSION(KTS:KTE-1),INTENT(IN) :: RKH
1548 REAL,DIMENSION(KTS:KTE),INTENT(IN) :: RHO
1549 REAL,DIMENSION(KTS:KTE+1),INTENT(IN) :: Z
1550 REAL,DIMENSION(KTS:KTE),INTENT(INOUT) :: DUST1,DUST2
1552 !----------------------------------------------------------------------
1554 !*** LOCAL VARIABLES
1558 REAL :: CF,CMB,CMDB,CTHF,DTOZL,DTOZS &
1559 ,RCML,RKHH,RSD1B,RSD2B
1561 REAL,DIMENSION(KTS:KTE-1) :: CM,CR,DTOZ,RKCT,RSD1,RSD2
1563 !----------------------------------------------------------------------
1564 !**********************************************************************
1565 !----------------------------------------------------------------------
1569 DTOZ(K)=DTDIF/(Z(K)-Z(K+1))
1570 CR(K)=-DTOZ(K)*RKH(K)
1571 RKCT(K)=RKH(K)*(Z(K)-Z(K+2))*CTHF
1574 CM(KTS)=DTOZ(KTS)*RKH(KTS)+RHO(KTS)
1575 !----------------------------------------------------------------------
1576 RSD1(KTS)=DUST1(KTS)*RHO(KTS)
1577 RSD2(KTS)=DUST2(KTS)*RHO(KTS)
1578 !----------------------------------------------------------------------
1581 CF=-DTOZL*RKH(K-1)/CM(K-1)
1582 CM(K)=-CR(K-1)*CF+(RKH(K-1)+RKH(K))*DTOZL+RHO(K)
1583 RSD1(K)=-RSD1(K-1)*CF+DUST1(K)*RHO(K)
1584 RSD2(K)=-RSD2(K-1)*CF+DUST2(K)*RHO(K)
1587 DTOZS=DTDIF/(Z(LMH)-Z(LMH+1))
1590 CF=-DTOZS*RKHH/CM(LMH-1)
1593 CMDB=-CMB+RKHH*DTOZS+RHO(LMH)
1595 RSD1B=-RSD1(LMH-1)*CF+DUST1(LMH)*RHO(LMH)
1596 RSD2B=-RSD2(LMH-1)*CF+DUST2(LMH)*RHO(LMH)
1597 !----------------------------------------------------------------------
1598 DUST1(LMH)=RSD1B/CMDB
1599 DUST2(LMH)=RSD2B/CMDB
1600 !----------------------------------------------------------------------
1603 DUST1(K)=(-CR(K)*DUST1(K+1)+RSD1(K))*RCML
1604 DUST2(K)=(-CR(K)*DUST2(K+1)+RSD2(K))*RCML
1606 !----------------------------------------------------------------------
1608 END SUBROUTINE VDIFX
1610 !---------------------------------------------------------------------
1611 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1612 !---------------------------------------------------------------------
1613 SUBROUTINE VDIFV(LMH,DTDIF,UZ0,VZ0,RKMS,U,V,RKM,Z,RHO &
1614 & ,IDS,IDE,JDS,JDE,KDS,KDE &
1615 & ,IMS,IME,JMS,JME,KMS,KME &
1616 ,ITS,ITE,JTS,JTE,KTS,KTE,I,J)
1617 ! ***************************************************************
1619 ! * VERTICAL DIFFUSION OF VELOCITY COMPONENTS *
1621 ! ***************************************************************
1622 !---------------------------------------------------------------------
1626 !---------------------------------------------------------------------
1627 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
1628 & ,IMS,IME,JMS,JME,KMS,KME &
1629 & ,ITS,ITE,JTS,JTE,KTS,KTE,I,J
1631 INTEGER,INTENT(IN) :: LMH
1633 REAL,INTENT(IN) :: RKMS,DTDIF,UZ0,VZ0
1635 REAL,DIMENSION(KTS:KTE-1),INTENT(IN) :: RKM
1636 REAL,DIMENSION(KTS:KTE),INTENT(IN) :: RHO
1637 REAL,DIMENSION(KTS:KTE+1),INTENT(IN) :: Z
1639 REAL,DIMENSION(KTS:KTE),INTENT(INOUT) :: U,V
1640 !----------------------------------------------------------------------
1642 !*** LOCAL VARIABLES
1646 REAL :: CF,DTOZAK,DTOZL,DTOZS,RCML,RCMVB,RHOK,RKMH
1648 REAL,DIMENSION(KTS:KTE-1) :: CM,CR,DTOZ,RSU,RSV
1649 !----------------------------------------------------------------------
1650 !**********************************************************************
1651 !----------------------------------------------------------------------
1653 DTOZ(K)=DTDIF/(Z(K)-Z(K+1))
1654 CR(K)=-DTOZ(K)*RKM(K)
1658 CM(1)=DTOZ(1)*RKM(1)+RHOK
1661 !----------------------------------------------------------------------
1664 CF=-DTOZL*RKM(K-1)/CM(K-1)
1666 CM(K)=-CR(K-1)*CF+(RKM(K-1)+RKM(K))*DTOZL+RHOK
1667 RSU(K)=-RSU(K-1)*CF+U(K)*RHOK
1668 RSV(K)=-RSV(K-1)*CF+V(K)*RHOK
1670 !----------------------------------------------------------------------
1671 DTOZS=DTDIF/(Z(LMH)-Z(LMH+1))
1674 CF=-DTOZS*RKMH/CM(LMH-1)
1676 RCMVB=1./((RKMH+RKMS)*DTOZS-CR(LMH-1)*CF+RHOK)
1678 !----------------------------------------------------------------------
1679 U(LMH)=(DTOZAK*UZ0-RSU(LMH-1)*CF+U(LMH)*RHOK)*RCMVB
1680 V(LMH)=(DTOZAK*VZ0-RSV(LMH-1)*CF+V(LMH)*RHOK)*RCMVB
1681 !----------------------------------------------------------------------
1684 U(K)=(-CR(K)*U(K+1)+RSU(K))*RCML
1685 V(K)=(-CR(K)*V(K+1)+RSV(K))*RCML
1687 !----------------------------------------------------------------------
1689 END SUBROUTINE VDIFV
1691 !-----------------------------------------------------------------------
1693 !=======================================================================
1694 SUBROUTINE MYJPBLINIT(RUBLTEN,RVBLTEN,RTHBLTEN,RQVBLTEN, &
1695 & TKE_MYJ,EXCH_H,RESTART,ALLOWED_TO_READ, &
1696 & IDS,IDE,JDS,JDE,KDS,KDE, &
1697 & IMS,IME,JMS,JME,KMS,KME, &
1698 & ITS,ITE,JTS,JTE,KTS,KTE )
1699 !-----------------------------------------------------------------------
1701 !-----------------------------------------------------------------------
1702 LOGICAL,INTENT(IN) :: ALLOWED_TO_READ,RESTART
1703 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE, &
1704 & IMS,IME,JMS,JME,KMS,KME, &
1705 & ITS,ITE,JTS,JTE,KTS,KTE
1707 REAL,DIMENSION(IMS:IME,KMS:KME,JMS:JME),INTENT(OUT) :: EXCH_H, &
1713 INTEGER :: I,J,K,ITF,JTF,KTF
1714 !-----------------------------------------------------------------------
1715 !-----------------------------------------------------------------------
1721 IF(.NOT.RESTART)THEN
1725 TKE_MYJ(I,K,J)=EPSQ2
1736 END SUBROUTINE MYJPBLINIT
1737 !-----------------------------------------------------------------------
1739 END MODULE MODULE_BL_MYJPBL
1741 !-----------------------------------------------------------------------