2 MODULE MODULE_BL_MYJURB
4 !-----------------------------------------------------------------------
6 USE MODULE_MODEL_CONSTANTS
8 !-----------------------------------------------------------------------
10 ! REFERENCES: Janjic (2002), NCEP Office Note 437
11 ! Mellor and Yamada (1982), Rev. Geophys. Space Phys.
14 ! MYJ UPDATES THE TURBULENT KINETIC ENERGY WITH THE PRODUCTION/
15 ! DISSIPATION TERM AND THE VERTICAL DIFFUSION TERM
16 ! (USING AN IMPLICIT FORMULATION) FROM MELLOR-YAMADA
17 ! LEVEL 2.5 AS EXTENDED BY JANJIC. EXCHANGE COEFFICIENTS FOR
18 ! THE SURFACE AND FOR ALL LAYER INTERFACES ARE COMPUTED FROM
19 ! MONIN-OBUKHOV THEORY.
20 ! THE TURBULENT VERTICAL EXCHANGE IS THEN EXECUTED.
22 !-----------------------------------------------------------------------
24 INTEGER :: ITRMX=5 ! Iteration count for mixing length computation
26 ! REAL,PARAMETER :: G=9.81,PI=3.1415926,R_D=287.04,R_V=461.6 &
28 REAL,PARAMETER :: PI=3.1415926,VKARMAN=0.4
29 ! REAL,PARAMETER :: CP=7.*R_D/2.
30 REAL,PARAMETER :: CAPA=R_D/CP
31 REAL,PARAMETER :: RLIVWV=XLS/XLV,ELOCP=2.72E6/CP
32 REAL,PARAMETER :: EPS1=1.E-12,EPS2=0.
33 REAL,PARAMETER :: EPSL=0.32,EPSRU=1.E-7,EPSRS=1.E-7 &
35 REAL,PARAMETER :: EPSA=1.E-8,EPSIT=1.E-4,EPSU2=1.E-4,EPSUST=0.07 &
37 REAL,PARAMETER :: ALPH=0.30,BETA=1./273.,EL0MAX=1000.,EL0MIN=1. &
38 & ,ELFC=0.23*0.5,GAM1=0.2222222222222222222 &
40 REAL,PARAMETER :: A1=0.659888514560862645 &
41 & ,A2x=0.6574209922667784586 &
42 & ,B1=11.87799326209552761 &
43 & ,B2=7.226971804046074028 &
44 & ,C1=0.000830955950095854396
45 REAL,PARAMETER :: A2S=17.2693882,A3S=273.16,A4S=35.86
46 REAL,PARAMETER :: ELZ0=0.,ESQ=5.0,EXCM=0.001 &
47 & ,FHNEU=0.8,GLKBR=10.,GLKBS=30. &
48 & ,QVISC=2.1E-5,RFC=0.191,RIC=0.505,SMALL=0.35 &
49 & ,SQPR=0.84,SQSC=0.84,SQVISC=258.2,TVISC=2.1E-5 &
50 & ,USTC=0.7,USTR=0.225,VISC=1.5E-5 &
51 & ,WOLD=0.15,WWST=1.2,ZTMAX=1.,ZTFC=1.,ZTMIN=-5.
53 REAL,PARAMETER :: SEAFC=0.98,PQ0SEA=PQ0*SEAFC
55 REAL,PARAMETER :: BTG=BETA*G,CZIV=SMALL*GLKBS &
56 ! & ,EP_1=R_V/R_D-1.,ESQHF=0.5*5.0,GRRS=GLKBR/GLKBS &
57 & ,ESQHF=0.5*5.0,GRRS=GLKBR/GLKBS &
58 & ,RB1=1./B1,RTVISC=1./TVISC,RVISC=1./VISC &
61 REAL,PARAMETER :: ADNH= 9.*A1*A2x*A2x*(12.*A1+3.*B2)*BTG*BTG &
62 & ,ADNM=18.*A1*A1*A2x*(B2-3.*A2x)*BTG &
63 & ,ANMH=-9.*A1*A2x*A2x*BTG*BTG &
64 & ,ANMM=-3.*A1*A2x*(3.*A2x+3.*B2*C1+18.*A1*C1-B2) &
66 & ,BDNH= 3.*A2x*(7.*A1+B2)*BTG &
68 & ,BEQH= A2x*B1*BTG+3.*A2x*(7.*A1+B2)*BTG &
69 & ,BEQM=-A1*B1*(1.-3.*C1)+6.*A1*A1 &
71 & ,BNMM=A1*(1.-3.*C1) &
72 & ,BSHH=9.*A1*A2x*A2x*BTG &
73 & ,BSHM=18.*A1*A1*A2x*C1 &
74 & ,BSMH=-3.*A1*A2x*(3.*A2x+3.*B2*C1+12.*A1*C1-B2) &
77 & ,CESM=A1*(1.-3.*C1) &
79 & ,ELFCS=VKARMAN*BTG &
80 & ,FZQ1=RTVISC*QVISC*ZQRZT &
81 & ,FZQ2=RTVISC*QVISC*ZQRZT &
82 & ,FZT1=RVISC *TVISC*SQPR &
83 & ,FZT2=CZIV*GRRS*TVISC*SQPR &
86 & ,RFAC=RIC/(FHNEU*RFC*RFC) &
93 !-----------------------------------------------------------------------
94 !*** FREE TERM IN THE EQUILIBRIUM EQUATION FOR (L/Q)**2
95 !-----------------------------------------------------------------------
97 REAL,PARAMETER :: AEQH=9.*A1*A2x*A2x*B1*BTG*BTG &
98 & +9.*A1*A2x*A2x*(12.*A1+3.*B2)*BTG*BTG &
99 & ,AEQM=3.*A1*A2x*B1*(3.*A2x+3.*B2*C1+18.*A1*C1-B2)&
100 & *BTG+18.*A1*A1*A2x*(B2-3.*A2x)*BTG
102 !-----------------------------------------------------------------------
103 !*** FORBIDDEN TURBULENCE AREA
104 !-----------------------------------------------------------------------
106 REAL,PARAMETER :: REQU=-AEQH/AEQM &
107 & ,EPSGH=1.E-9,EPSGM=REQU*EPSGH
109 !-----------------------------------------------------------------------
110 !*** NEAR ISOTROPY FOR SHEAR TURBULENCE, WW/Q2 LOWER LIMIT
111 !-----------------------------------------------------------------------
113 REAL,PARAMETER :: UBRYL=(18.*REQU*A1*A1*A2x*B2*C1*BTG &
114 & +9.*A1*A2x*A2x*B2*BTG*BTG) &
115 & /(REQU*ADNM+ADNH) &
116 & ,UBRY=(1.+EPSRS)*UBRYL,UBRY3=3.*UBRY
118 REAL,PARAMETER :: AUBH=27.*A1*A2x*A2x*B2*BTG*BTG-ADNH*UBRY3 &
119 & ,AUBM=54.*A1*A1*A2x*B2*C1*BTG -ADNM*UBRY3 &
120 & ,BUBH=(9.*A1*A2x+3.*A2x*B2)*BTG-BDNH*UBRY3 &
121 & ,BUBM=18.*A1*A1*C1 -BDNM*UBRY3 &
125 !-----------------------------------------------------------------------
129 !----------------------------------------------------------------------
130 SUBROUTINE MYJURB(IDIFF,FLAG_BEP,DT,STEPBL,HT,DZ &
131 & ,PMID,PINT,TH,T,EXNER,QV,CWM,U,V,RHO &
132 & ,TSK,QSFC,CHKLOWQ,THZ0,QZ0,UZ0,VZ0 &
133 & ,LOWLYR,XLAND,SICE,SNOW &
134 & ,TKE_MYJ,EXCH_H,EXCH_M,USTAR,ZNT,EL_MYJ,PBLH,KPBL,CT &
136 & ,RUBLTEN,RVBLTEN,RTHBLTEN,RQVBLTEN,RQCBLTEN &
137 ! Variables added for multi-layer UCM
139 & ,A_U_BEP,A_V_BEP,A_T_BEP,A_Q_BEP &
140 & ,A_E_BEP,B_U_BEP,B_V_BEP &
141 & ,B_T_BEP,B_Q_BEP,B_E_BEP,DLG_BEP &
142 & ,DL_U_BEP,SF_BEP,VL_BEP &
143 ! Multi-layer UCM end
144 & ,IDS,IDE,JDS,JDE,KDS,KDE &
145 & ,IMS,IME,JMS,JME,KMS,KME &
146 & ,ITS,ITE,JTS,JTE,KTS,KTE)
147 !----------------------------------------------------------------------
151 !----------------------------------------------------------------------
152 INTEGER,INTENT(IN) :: IDIFF
153 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
154 & ,IMS,IME,JMS,JME,KMS,KME &
155 & ,ITS,ITE,JTS,JTE,KTS,KTE
157 INTEGER,INTENT(IN) :: STEPBL
159 INTEGER,DIMENSION(IMS:IME,JMS:JME),INTENT(IN) :: LOWLYR
161 INTEGER,DIMENSION(IMS:IME,JMS:JME),INTENT(OUT) :: KPBL
163 REAL,INTENT(IN) :: DT
165 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(IN) :: HT,SICE,SNOW &
168 REAL,DIMENSION(IMS:IME,KMS:KME,JMS:JME),INTENT(IN) :: CWM,DZ &
174 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(OUT) :: PBLH
176 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(INOUT) :: AKHS,AKMS
178 REAL,DIMENSION(IMS:IME,KMS:KME,JMS:JME) &
179 & ,INTENT(OUT) :: EL_MYJ &
180 & ,RQCBLTEN,RQVBLTEN &
183 ! Variables added for multi-layer UCM
184 REAL,DIMENSION(IMS:IME,KMS:KME,JMS:JME),INTENT(IN) :: A_U_BEP &
192 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(IN) :: FRC_URB2D
193 REAL,DIMENSION(IMS:IME,KMS:KME,JMS:JME) &
194 & ,INTENT(INOUT) :: EXCH_H,EXCH_M,TKE_MYJ
197 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(INOUT) :: CT,QSFC,QZ0 &
201 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(IN) :: CHKLOWQ,ELFLX
202 LOGICAL, INTENT(IN ) :: FLAG_BEP
204 !----------------------------------------------------------------------
208 INTEGER :: I,J,K,KFLIP,LLOW,LMH,LMXL
209 ! Variables added for multi-layer UCM
210 REAL,DIMENSION(KTS:KTE) :: A_U,A_V,A_T,A_E,B_U,B_V,B_T,B_E !Vertically flipped fields
211 REAL,DIMENSION(KTS:KTE) :: A_Q,B_Q,VLK,DL_U,B_E_FACE,DZ_KFLIP !Vertically flipped fields
212 REAL,DIMENSION(KTS:KTE) :: SFK !Vertically flipped SF,VL
218 INTEGER,DIMENSION(ITS:ITE,JTS:JTE) :: LPBL
220 REAL :: AKHS_DENS,AKMS_DENS,APEX,DCDT,DELTAZ,DQDT,DTDIF,DTDT &
221 & ,DTTURBL,DUDT,DVDT,EXNSFC,PSFC,PTOP,QFC1,QLOW,QOLD &
222 & ,RATIOMX,RDTTURBL,RG,RWMSK,SEAMASK,THNEW,THOLD,TX &
225 REAL,DIMENSION(KTS:KTE) :: CWMK,PK,Q2K,QK,THEK,TK,UK,VK
227 REAL,DIMENSION(KTS:KTE-1) :: AKHK,AKMK,EL,GH,GM
229 REAL,DIMENSION(KTS:KTE+1) :: ZHK
231 REAL,DIMENSION(ITS:ITE,JTS:JTE) :: THSK
233 REAL,DIMENSION(KTS:KTE,ITS:ITE) :: RHOK
235 REAL,DIMENSION(ITS:ITE,KTS:KTE,JTS:JTE) :: APE,THE
237 REAL,DIMENSION(ITS:ITE,KTS:KTE-1,JTS:JTE) :: AKH,AKM
239 REAL,DIMENSION(ITS:ITE,KTS:KTE+1,JTS:JTE) :: ZINT
243 INTEGER :: IMD,JMD,PRINT_DIAG
246 !----------------------------------------------------------------------
247 !**********************************************************************
248 !----------------------------------------------------------------------
255 !*** MAKE PREPARATIONS
258 !----------------------------------------------------------------------
282 ZINT(I,KTE+1,J)=HT(I,J) ! Z at bottom of lowest sigma layer
285 !!!!!! UNCOMMENT THESE LINES IF USING ETA COORDINATES
287 !!!!!! ZINT(I,KTE+1,J)=1.E-4 ! Z of bottom of lowest eta layer
288 !!!!!! ZHK(KTE+1)=1.E-4 ! Z of bottom of lowest eta layer
297 ZINT(I,K,J)=ZINT(I,K+1,J)+DZ(I,KFLIP,J)
301 THE(I,K,J)=(CWM(I,K,J)*(-ELOCP/TX)+1.)*TH(I,K,J)
305 EL_MYJ(its:ite,:,jts:jte) = 0.
307 !----------------------------------------------------------------------
308 setup_integration: DO J=JTS,JTE
309 !----------------------------------------------------------------------
313 !*** LOWEST LAYER ABOVE GROUND MUST BE FLIPPED
315 LMH=KTE-LOWLYR(I,J)+1
317 PTOP=PINT(I,KTE+1,J) ! KTE+1=KME
318 PSFC=PINT(I,LOWLYR(I,J),J)
320 !*** CONVERT LAND MASK (1 FOR SEA; 0 FOR LAND)
322 SEAMASK=XLAND(I,J)-1.
324 !*** FILL 1-D VERTICAL ARRAYS
325 !*** AND FLIP DIRECTION SINCE MYJ SCHEME
326 !*** COUNTS DOWNWARD FROM THE DOMAIN'S TOP
331 THEK(K)=THE(I,KFLIP,J)
332 RATIOMX=QV(I,KFLIP,J)
333 QK(K)=RATIOMX/(1.+RATIOMX)
334 CWMK(K)=CWM(I,KFLIP,J)
335 PK(K)=PMID(I,KFLIP,J)
339 DZ_KFLIP(K)=DZ(I,KFLIP,J)
344 !*** TKE=0.5*(q**2) ==> q**2=2.*TKE
346 Q2K(K)=2.*TKE_MYJ(I,KFLIP,J)
348 !*** COMPUTE THE HEIGHTS OF THE LAYER INTERFACES
353 ZHK(KTE+1)=HT(I,J) ! Z at bottom of lowest sigma layer
358 B_E(K)=B_E_BEP(I,KFLIP,J)
359 A_E(K)=A_E_BEP(I,KFLIP,J)
360 SFK(K)=SF_BEP(I,KFLIP,J)
361 VLK(K)=VL_BEP(I,KFLIP,J)
363 DL_U(K)=DL_U_BEP(I,KFLIP,J)
376 ! Multi-layer UCM - caculate B_E at grid faces
382 ELSEIF ( K == KTS ) THEN
385 SLOPE=(B_E(K-1)-B_E(K))/0.5/(DZ_KFLIP(K-1)+DZ_KFLIP(K))
386 ICEPT=B_E(K)-SLOPE*(ZHK(K)-0.5*DZ_KFLIP(K))
387 B_E_FACE(K)=2.*(SLOPE*ZHK(K)+ICEPT) !*2 accounts for Q2K=2.*TKE_MYJ
393 ! IF(I==IMD.AND.J==JMD)THEN
398 ! IF(I==227.AND.J==363)PRINT_DIAG=2
401 !----------------------------------------------------------------------
403 !*** FIND THE MIXING LENGTH
405 CALL MIXLEN(LMH,UK,VK,TK,THEK,QK,CWMK &
406 & ,Q2K,ZHK,GM,GH,EL &
407 & ,PBLH(I,J),LPBL(I,J),LMXL,CT(I,J) &
411 & ,IDS,IDE,JDS,JDE,KDS,KDE &
412 & ,IMS,IME,JMS,JME,KMS,KME &
413 & ,ITS,ITE,JTS,JTE,KTS,KTE)
415 !----------------------------------------------------------------------
417 !*** SOLVE FOR THE PRODUCTION/DISSIPATION OF
418 !*** THE TURBULENT KINETIC ENERGY
421 CALL PRODQ2(LMH,DTTURBL,USTAR(I,J),GM,GH,EL,Q2K &
422 & ,IDS,IDE,JDS,JDE,KDS,KDE &
423 & ,IMS,IME,JMS,JME,KMS,KME &
424 & ,ITS,ITE,JTS,JTE,KTS,KTE)
428 Q2K(LMH)=Q2K(LMH)*(1-FRC_URB2D(I,J))+(B_E_FACE(LMH)* &
429 & 0.5*EL(LMH-1)/11.788/2.)**(2./3.)
433 !----------------------------------------------------------------------
434 !*** THE MODEL LAYER (COUNTING UPWARD) CONTAINING THE TOP OF THE PBL
435 !----------------------------------------------------------------------
437 KPBL(I,J)=KTE-LPBL(I,J)+1
439 !----------------------------------------------------------------------
441 !*** FIND THE EXCHANGE COEFFICIENTS IN THE FREE ATMOSPHERE
443 CALL DIFCOF(LMH,LMXL,GM,GH,EL,TK,Q2K,ZHK,AKMK,AKHK &
444 & ,IDS,IDE,JDS,JDE,KDS,KDE &
445 & ,IMS,IME,JMS,JME,KMS,KME &
446 & ,ITS,ITE,JTS,JTE,KTS,KTE,PRINT_DIAG) ! debug
448 !*** COUNTING DOWNWARD FROM THE TOP, THE EXCHANGE COEFFICIENTS AKH
449 !*** ARE DEFINED ON THE BOTTOMS OF THE LAYERS KTS TO KTE-1. COUNTING
450 !*** COUNTING UPWARD FROM THE BOTTOM, THOSE SAME COEFFICIENTS EXCH_H
451 !*** ARE DEFINED ON THE TOPS OF THE LAYERS KTS TO KTE-1.
457 DELTAZ=0.5*(ZHK(KFLIP)-ZHK(KFLIP+2))
459 EXCH_H(I,K+1,J)=AKHK(KFLIP)*DELTAZ
460 EXCH_M(I,K+1,J)=AKMK(KFLIP)*DELTAZ
463 !----------------------------------------------------------------------
465 !*** CARRY OUT THE VERTICAL DIFFUSION OF
466 !*** TURBULENT KINETIC ENERGY
470 CALL VDIFQ(LMH,DTDIF,Q2K,EL,ZHK &
472 & ,A_E,B_E_FACE,SFK,VLK &
474 & ,IDS,IDE,JDS,JDE,KDS,KDE &
475 & ,IMS,IME,JMS,JME,KMS,KME &
476 & ,ITS,ITE,JTS,JTE,KTS,KTE)
478 !*** SAVE THE NEW TKE AND MIXING LENGTH.
482 Q2K(KFLIP)=AMAX1(Q2K(KFLIP),EPSQ2)
483 TKE_MYJ(I,K,J)=0.5*Q2K(KFLIP)
484 IF(KFLIP/=KTE)EL_MYJ(I,K,J)=EL(KFLIP) ! EL IS NOT DEFINED AT KTE (ground surface)
489 !----------------------------------------------------------------------
490 ENDDO setup_integration
491 !----------------------------------------------------------------------
492 ! Multi-layer UCM - if idiff=1 then integration in PBL driver
496 !*** CONVERT SURFACE SENSIBLE TEMPERATURE TO POTENTIAL TEMPERATURE.
500 PSFC=PINT(I,LOWLYR(I,J),J)
501 THSK(I,J)=TSK(I,J)*(1.E5/PSFC)**CAPA
505 !----------------------------------------------------------------------
507 !----------------------------------------------------------------------
508 main_integration: DO J=JTS,JTE
509 !----------------------------------------------------------------------
513 !*** FILL 1-D VERTICAL ARRAYS
514 !*** AND FLIP DIRECTION SINCE MYJ SCHEME
515 !*** COUNTS DOWNWARD FROM THE DOMAIN'S TOP
519 THEK(K)=THE(I,KFLIP,J)
520 RATIOMX=QV(I,KFLIP,J) !mixing ratio
521 QK(K)=RATIOMX/(1.+RATIOMX) !specific humidity
522 CWMK(K)=CWM(I,KFLIP,J)
524 RHOK(K,I)=PMID(I,KFLIP,J)/(R_D*T(I,KFLIP,J)* &
525 & (1.+P608*QK(K)-CWMK(K)))
534 A_Q(K)=A_Q_BEP(I,KFLIP,J)
535 B_Q(K)=B_Q_BEP(I,KFLIP,J)
536 A_T(K)=A_T_BEP(I,KFLIP,J)
537 B_T(K)=B_T_BEP(I,KFLIP,J)
538 SFK(K)=SF_BEP(I,KFLIP,J)
539 VLK(K)=VL_BEP(I,KFLIP,J)
553 !*** COUNTING DOWNWARD FROM THE TOP, THE EXCHANGE COEFFICIENTS AKH
554 !*** ARE DEFINED ON THE BOTTOMS OF THE LAYERS KTS TO KTE-1. THESE COEFFICIENTS
555 !*** ARE ALSO MULTIPLIED BY THE DENSITY AT THE BOTTOM INTERFACE LEVEL.
558 AKHK(K)=AKH(I,K,J)*0.5*(RHOK(K,I)+RHOK(K+1,I))
561 ZHK(KTE+1)=ZINT(I,KTE+1,J)
563 SEAMASK=XLAND(I,J)-1.
564 THZ0(I,J)=(1.-SEAMASK)*THSK(I,J)+SEAMASK*THZ0(I,J)
567 AKHS_DENS=AKHS(I,J)*RHOK(KTE+1-LLOW,I)
570 QFC1=XLV*CHKLOWQ(I,J)*AKHS_DENS
572 IF(SNOW(I,J)>0..OR.SICE(I,J)>0.5)THEN
578 QSFC(I,J)=QLOW+ELFLX(I,J)/QFC1
582 PSFC=PINT(I,LOWLYR(I,J),J)
583 EXNSFC=(1.E5/PSFC)**CAPA
584 QSFC(I,J)=PQ0SEA/PSFC &
585 & *EXP(A2*(THSK(I,J)-A3*EXNSFC)/(THSK(I,J)-A4*EXNSFC))
588 QZ0 (I,J)=(1.-SEAMASK)*QSFC(I,J)+SEAMASK*QZ0 (I,J)
590 !*** LOWEST LAYER ABOVE GROUND MUST BE FLIPPED
592 LMH=KTE-LOWLYR(I,J)+1
594 !----------------------------------------------------------------------
595 !*** CARRY OUT THE VERTICAL DIFFUSION OF
596 !*** TEMPERATURE AND WATER VAPOR
597 !----------------------------------------------------------------------
600 CALL VDIFH(DTDIF,LMH,THZ0(I,J),QZ0(I,J) &
601 & ,AKHS_DENS,CHKLOWQ(I,J),CT(I,J) &
602 & ,THEK,QK,CWMK,AKHK,ZHK,RHOK(KTS,I) &
604 & ,A_T,B_T,A_Q,B_Q,SFK,VLK &
606 & ,IDS,IDE,JDS,JDE,KDS,KDE &
607 & ,IMS,IME,JMS,JME,KMS,KME &
608 & ,ITS,ITE,JTS,JTE,KTS,KTE,I,J)
609 !----------------------------------------------------------------------
611 !*** COMPUTE PRIMARY VARIABLE TENDENCIES
616 THNEW=THEK(KFLIP)+CWMK(KFLIP)*ELOCP*APE(I,K,J)
617 DTDT=(THNEW-THOLD)*RDTTURBL
618 QOLD=QV(I,K,J)/(1.+QV(I,K,J))
619 DQDT=(QK(KFLIP)-QOLD)*RDTTURBL
620 DCDT=(CWMK(KFLIP)-CWM(I,K,J))*RDTTURBL
623 RQVBLTEN(I,K,J)=DQDT/(1.-QK(KFLIP))**2
629 ! IF(I==IMD.AND.J==JMD)THEN
634 ! IF(I==227.AND.J==363)PRINT_DIAG=0
637 PSFC=.01*PINT(I,LOWLYR(I,J),J)
638 ZSL_DIAG=0.5*DZ(I,1,J)
641 ! IF(PRINT_DIAG==1)THEN
643 ! write(6,"(a, 2i5, 2i3, 2f8.2, f6.2, 2f8.2)") &
644 ! '{turb4 i,j, Kpbl, Kmxl, Psfc, Zsfc, Zsl, Zpbl, Zmxl = ' &
645 ! , i, j, KPBL(i,j), KTE-LMXL+1, PSFC, ZHK(LMH+1), ZSL_diag &
646 ! , PBLH(i,j), ZHK(LMXL)-ZHK(LMH+1)
647 ! write(6,"(a, 2f7.2, f7.3, 3e11.4)") &
648 ! '{turb4 tsk, thsk, qz0, q**2_0, akhs, exch_0 = ' &
649 ! , tsk(i,j)-273.15, thsk(i,j), 1000.*qz0(i,j) &
650 ! , 2.*tke_myj(i,1,j), akhs(i,j), akhs(i,j)*ZSL_diag
652 ! '{turb5 k, Pmid, Pint_1, Tc, TH, DTH, GH, GM, EL, Q**2, Akh, EXCH_h, Dz, Dp'
654 ! KFLIP=KTE-K !-- Includes the KFLIP-1 in earlier versions
655 ! write(6,"(a,i3, 2f8.2, 2f8.3, 3e12.4, 4e11.4, f7.2, f6.2)") &
656 ! '{turb5 ', k, .01*pmid(i,k,j),.01*pint(i,k,j), T(i,k,j)-273.15 &
657 ! , th(i,k,j), DTTURBL*rthblten(i,k,j), GH(KFLIP), GM(KFLIP) &
658 ! , el_myj(i,KFLIP,j), 2.*tke_myj(i,k+1,j), akh(i,KFLIP,j) &
659 ! , exch_h(i,k,j), dz(i,k,j), .01*(pint(i,k,j)-pint(i,k+1,j))
662 ! ELSEIF(PRINT_DIAG==2)THEN
664 ! write(6,"(a, 2i5, 2i3, 2f8.2, f6.2, 2f8.2)") &
665 ! '}turb4 i,j, Kpbl, Kmxl, Psfc, Zsfc, Zsl, Zpbl, Zmxl = ' &
666 ! , i, j, KPBL(i,j), KTE-LMXL+1, PSFC, ZHK(LMH+1), ZSL_diag &
667 ! , PBLH(i,j), ZHK(LMXL)-ZHK(LMH+1)
668 ! write(6,"(a, 2f7.2, f7.3, 3e11.4)") &
669 ! '}turb4 tsk, thsk, qz0, q**2_0, akhs, exch_0 = ' &
670 ! , tsk(i,j)-273.15, thsk(i,j), 1000.*qz0(i,j) &
671 ! , 2.*tke_myj(i,1,j), akhs(i,j), akhs(i,j)*ZSL_diag
673 ! '}turb5 k, Pmid, Pint_1, Tc, TH, DTH, GH, GM, EL, Q**2, Akh, EXCH_h, Dz, Dp'
675 ! KFLIP=KTE-K !-- Includes the KFLIP-1 in earlier versions
676 ! write(6,"(a,i3, 2f8.2, 2f8.3, 3e12.4, 4e11.4, f7.2, f6.2)") &
677 ! '}turb5 ', k, .01*pmid(i,k,j),.01*pint(i,k,j), T(i,k,j)-273.15 &
678 ! , th(i,k,j), DTTURBL*rthblten(i,k,j), GH(KFLIP), GM(KFLIP) &
679 ! , el_myj(i,KFLIP,j), 2.*tke_myj(i,k+1,j), akh(i,KFLIP,j) &
680 ! , exch_h(i,k,j), dz(i,k,j), .01*(pint(i,k,j)-pint(i,k+1,j))
685 !----------------------------------------------------------------------
687 !----------------------------------------------------------------------
690 !*** FILL 1-D VERTICAL ARRAYS
691 !*** AND FLIP DIRECTION SINCE MYJ SCHEME
692 !*** COUNTS DOWNWARD FROM THE DOMAIN'S TOP
697 AKMK(K)=AKMK(K)*(RHOK(K,I)+RHOK(K+1,I))*0.5
701 AKMS_DENS=AKMS(I,J)*RHOK(KTE+1-LLOW,I)
716 A_U(K)=A_U_BEP(I,KFLIP,J)
717 A_V(K)=A_V_BEP(I,KFLIP,J)
718 B_U(K)=B_U_BEP(I,KFLIP,J)
719 B_V(K)=B_V_BEP(I,KFLIP,J)
720 SFK(K)=SF_BEP(I,KFLIP,J)
721 VLK(K)=VL_BEP(I,KFLIP,J)
735 ZHK(KTE+1)=ZINT(I,KTE+1,J)
737 !----------------------------------------------------------------------
738 !*** CARRY OUT THE VERTICAL DIFFUSION OF
739 !*** VELOCITY COMPONENTS
740 !----------------------------------------------------------------------
742 CALL VDIFV(LMH,DTDIF,UZ0(I,J),VZ0(I,J) &
743 & ,AKMS_DENS,UK,VK,AKMK,ZHK,RHOK(KTS,I) &
745 & ,A_U,A_V,B_U,B_V,SFK,VLK &
747 & ,IDS,IDE,JDS,JDE,KDS,KDE &
748 & ,IMS,IME,JMS,JME,KMS,KME &
749 & ,ITS,ITE,JTS,JTE,KTS,KTE,I,J)
751 !----------------------------------------------------------------------
753 !*** COMPUTE PRIMARY VARIABLE TENDENCIES
757 DUDT=(UK(KFLIP)-U(I,K,J))*RDTTURBL
758 DVDT=(VK(KFLIP)-V(I,K,J))*RDTTURBL
764 !----------------------------------------------------------------------
766 ENDDO main_integration
769 !----------------------------------------------------------------------
771 END SUBROUTINE MYJURB
773 !----------------------------------------------------------------------
774 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
775 !----------------------------------------------------------------------
777 !----------------------------------------------------------------------
778 ! ******************************************************************
780 ! * LEVEL 2.5 MIXING LENGTH *
782 ! ******************************************************************
784 &(LMH,U,V,T,THE,Q,CWM,Q2,Z,GM,GH,EL,PBLH,LPBL,LMXL,CT &
788 &,IDS,IDE,JDS,JDE,KDS,KDE &
789 &,IMS,IME,JMS,JME,KMS,KME &
790 &,ITS,ITE,JTS,JTE,KTS,KTE)
791 !----------------------------------------------------------------------
795 !----------------------------------------------------------------------
796 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
797 & ,IMS,IME,JMS,JME,KMS,KME &
798 & ,ITS,ITE,JTS,JTE,KTS,KTE
800 INTEGER,INTENT(IN) :: LMH
802 INTEGER,INTENT(OUT) :: LMXL,LPBL
804 REAL,DIMENSION(KTS:KTE),INTENT(IN) :: CWM,Q,Q2,T,THE,U,V
806 REAL,DIMENSION(KTS:KTE),INTENT(IN) :: DL_U
809 REAL,DIMENSION(KTS:KTE+1),INTENT(IN) :: Z
811 REAL,INTENT(OUT) :: PBLH
813 REAL,DIMENSION(KTS:KTE-1),INTENT(OUT) :: EL,GH,GM
815 REAL,INTENT(INOUT) :: CT
816 !----------------------------------------------------------------------
822 REAL :: A,ADEN,B,BDEN,AUBR,BUBR,BLMX,EL0,ELOQ2X,GHL,GML &
823 & ,QOL2ST,QOL2UN,QDZL,RDZ,SQ,SREL,SZQ,TEM,THM,VKRMZ
825 REAL,DIMENSION(KTS:KTE) :: Q1
827 REAL,DIMENSION(KTS:KTE-1) :: DTH,ELM,REL
829 !----------------------------------------------------------------------
830 !**********************************************************************
831 !--------------FIND THE HEIGHT OF THE PBL-------------------------------
835 IF(Q2(K)<=EPSQ2*FH)THEN
843 !--------------THE HEIGHT OF THE PBL------------------------------------
845 110 PBLH=Z(LPBL+1)-Z(LMH+1)
847 !-----------------------------------------------------------------------
853 DTH(K)=THE(K)-THE(K+1)
857 IF(DTH(K)>0..AND.DTH(K+1)<=0.)THEN
864 !----------------------------------------------------------------------
867 GML=((U(K)-U(K+1))**2+(V(K)-V(K+1))**2)*RDZ*RDZ
870 TEM=(T(K)+T(K+1))*0.5
871 THM=(THE(K)+THE(K+1))*0.5
874 B=(ELOCP/TEM-1.-P608)*THM
876 GHL=(DTH(K)*((Q(K)+Q(K+1)+CWM(K)+CWM(K+1))*(0.5*P608)+1.) &
877 & +(Q(K)-Q(K+1)+CWM(K)-CWM(K+1))*A &
878 & +(CWM(K)-CWM(K+1))*B)*RDZ
880 IF(ABS(GHL)<=EPSGH)GHL=EPSGH
884 !----------------------------------------------------------------------
885 !*** FIND MAXIMUM MIXING LENGTHS AND THE LEVEL OF THE PBL TOP
886 !----------------------------------------------------------------------
895 IF(GML/GHL<=REQU)THEN
899 AUBR=(AUBM*GML+AUBH*GHL)*GHL
900 BUBR= BUBM*GML+BUBH*GHL
901 QOL2ST=(-0.5*BUBR+SQRT(BUBR*BUBR*0.25-AUBR*CUBR))*RCUBR
903 ELM(K)=MAX(SQRT(ELOQ2X*Q2(K)),EPSL)
906 ADEN=(ADNM*GML+ADNH*GHL)*GHL
907 BDEN= BDNM*GML+BDNH*GHL
908 QOL2UN=-0.5*BDEN+SQRT(BDEN*BDEN*0.25-ADEN)
909 ELOQ2X=1./(QOL2UN+EPSRU) ! repsr1/qol2un
910 ELM(K)=MAX(SQRT(ELOQ2X*Q2(K)),EPSL)
914 IF(ELM(LMH-1)==EPSL)LMXL=LMH
916 !----------------------------------------------------------------------
917 !*** THE HEIGHT OF THE MIXED LAYER
918 !----------------------------------------------------------------------
920 BLMX=Z(LMXL)-Z(LMH+1)
922 !----------------------------------------------------------------------
926 !----------------------------------------------------------------------
931 QDZL=(Q1(K)+Q1(K+1))*(Z(K+1)-Z(K+2))
932 SZQ=(Z(K+1)+Z(K+2)-Z(LMH+1)-Z(LMH+1))*QDZL+SZQ
936 !----------------------------------------------------------------------
937 !*** COMPUTATION OF ASYMPTOTIC L IN BLACKADAR FORMULA
938 !----------------------------------------------------------------------
940 EL0=MIN(ALPH*SZQ*0.5/SQ,EL0MAX)
943 !----------------------------------------------------------------------
944 !*** ABOVE THE PBL TOP
945 !----------------------------------------------------------------------
950 EL(K)=MIN((Z(K)-Z(K+2))*ELFC,ELM(K))
954 !----------------------------------------------------------------------
956 !----------------------------------------------------------------------
960 VKRMZ=(Z(K+1)-Z(LMH+1))*VKARMAN
962 IF (DL_U(K).GT.0.0) THEN
963 EL(K)=MIN(VKRMZ/(VKRMZ/EL0+1.),ELM(K))
964 EL(K)=1./(1./EL(K)+1./DL_U(K))
966 EL(K)=MIN(VKRMZ/(VKRMZ/EL0+1.),ELM(K))
974 SREL=MIN(((REL(K-1)+REL(K+1))*0.5+REL(K))*0.5,REL(K))
975 EL(K)=MAX(SREL*ELM(K),EPSL)
978 !----------------------------------------------------------------------
979 END SUBROUTINE MIXLEN
980 !----------------------------------------------------------------------
981 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
982 !----------------------------------------------------------------------
984 !----------------------------------------------------------------------
985 ! ******************************************************************
987 ! * LEVEL 2.5 Q2 PRODUCTION/DISSIPATION *
989 ! ******************************************************************
991 &(LMH,DTTURBL,USTAR,GM,GH,EL,Q2 &
992 &,IDS,IDE,JDS,JDE,KDS,KDE &
993 &,IMS,IME,JMS,JME,KMS,KME &
994 &,ITS,ITE,JTS,JTE,KTS,KTE)
995 !----------------------------------------------------------------------
999 !----------------------------------------------------------------------
1000 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
1001 & ,IMS,IME,JMS,JME,KMS,KME &
1002 & ,ITS,ITE,JTS,JTE,KTS,KTE
1004 INTEGER,INTENT(IN) :: LMH
1006 REAL,INTENT(IN) :: DTTURBL,USTAR
1008 REAL,DIMENSION(KTS:KTE-1),INTENT(IN) :: GH,GM
1009 REAL,DIMENSION(KTS:KTE-1),INTENT(INOUT) :: EL
1011 REAL,DIMENSION(KTS:KTE),INTENT(INOUT) :: Q2
1012 !----------------------------------------------------------------------
1014 !*** LOCAL VARIABLES
1018 REAL :: ADEN,AEQU,ANUM,ARHS,BDEN,BEQU,BNUM,BRHS,CDEN,CRHS &
1019 & ,DLOQ1,ELOQ11,ELOQ12,ELOQ13,ELOQ21,ELOQ22,ELOQ31,ELOQ32 &
1020 & ,ELOQ41,ELOQ42,ELOQ51,ELOQ52,ELOQN,EQOL2,GHL,GML &
1021 & ,RDEN1,RDEN2,RHS2,RHSP1,RHSP2,RHST2
1023 !----------------------------------------------------------------------
1024 !**********************************************************************
1025 !----------------------------------------------------------------------
1027 main_integration: DO K=1,LMH-1
1031 !----------------------------------------------------------------------
1032 !*** COEFFICIENTS OF THE EQUILIBRIUM EQUATION
1033 !----------------------------------------------------------------------
1035 AEQU=(AEQM*GML+AEQH*GHL)*GHL
1036 BEQU= BEQM*GML+BEQH*GHL
1038 !----------------------------------------------------------------------
1039 !*** EQUILIBRIUM SOLUTION FOR L/Q
1040 !----------------------------------------------------------------------
1042 EQOL2=-0.5*BEQU+SQRT(BEQU*BEQU*0.25-AEQU)
1044 !----------------------------------------------------------------------
1045 !*** IS THERE PRODUCTION/DISSIPATION ?
1046 !----------------------------------------------------------------------
1048 IF((GML+GHL*GHL<=EPSTRB) &
1049 & .OR.(GHL>=EPSGH.AND.GML/GHL<=REQU) &
1050 & .OR.(EQOL2<=EPS2))THEN
1052 !----------------------------------------------------------------------
1054 !----------------------------------------------------------------------
1058 !----------------------------------------------------------------------
1062 !----------------------------------------------------------------------
1064 !----------------------------------------------------------------------
1065 !----------------------------------------------------------------------
1066 !*** COEFFICIENTS OF THE TERMS IN THE NUMERATOR
1067 !----------------------------------------------------------------------
1069 ANUM=(ANMM*GML+ANMH*GHL)*GHL
1070 BNUM= BNMM*GML+BNMH*GHL
1072 !----------------------------------------------------------------------
1073 !*** COEFFICIENTS OF THE TERMS IN THE DENOMINATOR
1074 !----------------------------------------------------------------------
1076 ADEN=(ADNM*GML+ADNH*GHL)*GHL
1077 BDEN= BDNM*GML+BDNH*GHL
1080 !----------------------------------------------------------------------
1081 !*** COEFFICIENTS OF THE NUMERATOR OF THE LINEARIZED EQ.
1082 !----------------------------------------------------------------------
1084 ARHS=-(ANUM*BDEN-BNUM*ADEN)*2.
1088 !----------------------------------------------------------------------
1089 !*** INITIAL VALUE OF L/Q
1090 !----------------------------------------------------------------------
1092 DLOQ1=EL(K)/SQRT(Q2(K))
1094 !----------------------------------------------------------------------
1095 !*** FIRST ITERATION FOR L/Q, RHS=0
1096 !----------------------------------------------------------------------
1100 ELOQ31=ELOQ21*ELOQ11
1101 ELOQ41=ELOQ21*ELOQ21
1102 ELOQ51=ELOQ21*ELOQ31
1104 !----------------------------------------------------------------------
1106 !----------------------------------------------------------------------
1108 RDEN1=1./(ADEN*ELOQ41+BDEN*ELOQ21+CDEN)
1110 !----------------------------------------------------------------------
1112 !----------------------------------------------------------------------
1114 RHSP1=(ARHS*ELOQ51+BRHS*ELOQ31+CRHS*ELOQ11)*RDEN1*RDEN1
1116 !----------------------------------------------------------------------
1117 !*** FIRST-GUESS SOLUTION
1118 !----------------------------------------------------------------------
1120 ELOQ12=ELOQ11+(DLOQ1-ELOQ11)*EXP(RHSP1*DTTURBL)
1121 ELOQ12=MAX(ELOQ12,EPS1)
1123 !----------------------------------------------------------------------
1124 !*** SECOND ITERATION FOR L/Q
1125 !----------------------------------------------------------------------
1127 ELOQ22=ELOQ12*ELOQ12
1128 ELOQ32=ELOQ22*ELOQ12
1129 ELOQ42=ELOQ22*ELOQ22
1130 ELOQ52=ELOQ22*ELOQ32
1132 !----------------------------------------------------------------------
1134 !----------------------------------------------------------------------
1136 RDEN2=1./(ADEN*ELOQ42+BDEN*ELOQ22+CDEN)
1137 RHS2 =-(ANUM*ELOQ42+BNUM*ELOQ22)*RDEN2+RB1
1138 RHSP2= (ARHS*ELOQ52+BRHS*ELOQ32+CRHS*ELOQ12)*RDEN2*RDEN2
1141 !----------------------------------------------------------------------
1142 !*** CORRECTED SOLUTION
1143 !----------------------------------------------------------------------
1145 ELOQ13=ELOQ12-RHST2+(RHST2+DLOQ1-ELOQ12)*EXP(RHSP2*DTTURBL)
1146 ELOQ13=AMAX1(ELOQ13,EPS1)
1148 !----------------------------------------------------------------------
1149 !*** TWO ITERATIONS IS ENOUGH IN MOST CASES ...
1150 !----------------------------------------------------------------------
1155 Q2(K)=EL(K)*EL(K)/(ELOQN*ELOQN)
1156 Q2(K)=AMAX1(Q2(K),EPSQ2)
1157 IF(Q2(K)==EPSQ2)THEN
1165 !----------------------------------------------------------------------
1166 !*** END OF TURBULENT BRANCH
1167 !----------------------------------------------------------------------
1170 !----------------------------------------------------------------------
1171 !*** END OF PRODUCTION/DISSIPATION LOOP
1172 !----------------------------------------------------------------------
1174 ENDDO main_integration
1176 !----------------------------------------------------------------------
1177 !*** LOWER BOUNDARY CONDITION FOR Q2
1178 !----------------------------------------------------------------------
1180 Q2(LMH)=AMAX1(B1**(2./3.)*USTAR*USTAR,EPSQ2)
1181 !----------------------------------------------------------------------
1183 END SUBROUTINE PRODQ2
1185 !----------------------------------------------------------------------
1186 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1187 !----------------------------------------------------------------------
1189 ! ******************************************************************
1191 ! * LEVEL 2.5 DIFFUSION COEFFICIENTS *
1193 ! ******************************************************************
1194 &(LMH,LMXL,GM,GH,EL,T,Q2,Z,AKM,AKH &
1195 &,IDS,IDE,JDS,JDE,KDS,KDE &
1196 &,IMS,IME,JMS,JME,KMS,KME &
1197 &,ITS,ITE,JTS,JTE,KTS,KTE,PRINT_DIAG) ! debug
1198 !----------------------------------------------------------------------
1202 !----------------------------------------------------------------------
1203 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
1204 & ,IMS,IME,JMS,JME,KMS,KME &
1205 & ,ITS,ITE,JTS,JTE,KTS,KTE
1207 INTEGER,INTENT(IN) :: LMH,LMXL
1209 REAL,DIMENSION(KTS:KTE),INTENT(IN) :: Q2,T
1210 REAL,DIMENSION(KTS:KTE-1),INTENT(IN) :: EL,GH,GM
1211 REAL,DIMENSION(KTS:KTE+1),INTENT(IN) :: Z
1213 REAL,DIMENSION(KTS:KTE-1),INTENT(OUT) :: AKH,AKM
1214 !----------------------------------------------------------------------
1216 !*** LOCAL VARIABLES
1220 REAL :: ADEN,AKMIN,BDEN,BESH,BESM,CDEN,D2T,ELL,ELOQ2,ELOQ4,ELQDZ &
1221 & ,ESH,ESM,GHL,GML,Q1L,RDEN,RDZ
1223 !*** Begin debugging
1224 INTEGER,INTENT(IN) :: PRINT_DIAG
1228 !----------------------------------------------------------------------
1229 !**********************************************************************
1230 !----------------------------------------------------------------------
1241 !----------------------------------------------------------------------
1242 !*** COEFFICIENTS OF THE TERMS IN THE DENOMINATOR
1243 !----------------------------------------------------------------------
1245 ADEN=(ADNM*GML+ADNH*GHL)*GHL
1246 BDEN= BDNM*GML+BDNH*GHL
1249 !----------------------------------------------------------------------
1250 !*** COEFFICIENTS FOR THE SM DETERMINANT
1251 !----------------------------------------------------------------------
1255 !----------------------------------------------------------------------
1256 !*** COEFFICIENTS FOR THE SH DETERMINANT
1257 !----------------------------------------------------------------------
1259 BESH=BSHM*GML+BSHH*GHL
1261 !----------------------------------------------------------------------
1263 !----------------------------------------------------------------------
1265 RDEN=1./(ADEN*ELOQ4+BDEN*ELOQ2+CDEN)
1267 !----------------------------------------------------------------------
1269 !----------------------------------------------------------------------
1271 ESM=(BESM*ELOQ2+CESM)*RDEN
1272 ESH=(BESH*ELOQ2+CESH)*RDEN
1274 !----------------------------------------------------------------------
1275 !*** DIFFUSION COEFFICIENTS
1276 !----------------------------------------------------------------------
1278 RDZ=2./(Z(K)-Z(K+2))
1283 !----------------------------------------------------------------------
1285 !----------------------------------------------------------------------
1287 !----------------------------------------------------------------------
1289 !----------------------------------------------------------------------
1296 ! D2T=T(K-1)-2.*T(K)+T(K+1)
1297 ! IF(D2T<D2Tmin)THEN
1305 ! RDZ=2./(Z(K)-Z(K+2))
1307 ! AKM(K)=MAX(AKM(K),AKMIN)
1308 ! AKH(K)=MAX(AKH(K),AKMIN)
1311 !*** Begin debugging
1312 ! IF(PRINT_DIAG>0)THEN
1313 ! write(6,"(a,3i3)") '{turb1 lmxl,lmh,kinv=',lmxl,lmh,kinv
1314 ! write(6,"(a,3i3)") '}turb1 lmxl,lmh,kinv=',lmxl,lmh,kinv
1315 ! IF(PRINT_DIAG==1)THEN
1317 ! '{turb3 k, t, d2t, rdz, z(k), z(k+2), akmin, akh '
1320 ! '}turb3 k, t, d2t, rdz, z(k), z(k+2), akmin, akh '
1322 ! DO K=LMH-1,KINV-1,-1
1323 ! D2T=T(K-1)-2.*T(K)+T(K+1)
1324 ! RDZ=2./(Z(K)-Z(K+2))
1326 ! IF(PRINT_DIAG==1)THEN
1327 ! write(6,"(a,i3,f8.3,2e12.5,2f9.2,2e12.5)") '{turb3 ' &
1328 ! ,k,t(k)-273.15,d2t,rdz,z(k),z(k+2),akmin,akh(k)
1330 ! write(6,"(a,i3,f8.3,2e12.5,2f9.2,2e12.5)") '}turb3 ' &
1331 ! ,k,t(k)-273.15,d2t,rdz,z(k),z(k+2),akmin,akh(k)
1334 ! ENDIF !- IF (print_diag > 0) THEN
1335 ! ENDIF !- IF(KINV<LMH)THEN
1339 !----------------------------------------------------------------------
1341 END SUBROUTINE DIFCOF
1343 !----------------------------------------------------------------------
1344 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1345 !----------------------------------------------------------------------
1347 ! ******************************************************************
1349 ! * VERTICAL DIFFUSION OF Q2 (TKE) *
1351 ! ******************************************************************
1352 &(LMH,DTDIF,Q2,EL,Z &
1356 &,IDS,IDE,JDS,JDE,KDS,KDE &
1357 &,IMS,IME,JMS,JME,KMS,KME &
1358 &,ITS,ITE,JTS,JTE,KTS,KTE)
1359 !----------------------------------------------------------------------
1363 !----------------------------------------------------------------------
1364 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
1365 & ,IMS,IME,JMS,JME,KMS,KME &
1366 & ,ITS,ITE,JTS,JTE,KTS,KTE
1368 INTEGER,INTENT(IN) :: LMH
1370 REAL,INTENT(IN) :: DTDIF
1372 REAL,DIMENSION(KTS:KTE-1),INTENT(IN) :: EL
1373 REAL,DIMENSION(KTS:KTE+1),INTENT(IN) :: Z
1375 REAL,DIMENSION(KTS:KTE),INTENT(INOUT) :: Q2
1377 REAL,DIMENSION(KTS:KTE),INTENT(IN) :: A_E,B_E,VLK
1378 REAL,DIMENSION(KTS:KTE),INTENT(IN) :: SFK
1380 !----------------------------------------------------------------------
1382 !*** LOCAL VARIABLES
1386 REAL :: ADEN,AKQS,BDEN,BESH,BESM,CDEN,CF,DTOZS,ELL,ELOQ2,ELOQ4 &
1387 & ,ELQDZ,ESH,ESM,ESQHF,GHL,GML,Q1L,RDEN,RDZ
1389 REAL,DIMENSION(KTS:KTE-2) :: AKQ,CM,CR,DTOZ,RSQ2
1390 !----------------------------------------------------------------------
1391 !**********************************************************************
1392 !----------------------------------------------------------------------
1394 !*** VERTICAL TURBULENT DIFFUSION
1396 !----------------------------------------------------------------------
1400 DTOZ(K)=(DTDIF+DTDIF)/(Z(K)-Z(K+2))/VLK(K) !Bep
1401 AKQ(K)=SFK(K)*SQRT((Q2(K)+Q2(K+1))*0.5)*(EL(K)+EL(K+1))*ESQHF &
1402 & /(Z(K+1)-Z(K+2)) !Bep
1403 CR(K)=-DTOZ(K)*AKQ(K)
1406 CM(1)=DTOZ(1)*AKQ(1)+1.
1407 RSQ2(1)=Q2(1)+DTDIF*B_E(1) !Bep
1410 CF=-DTOZ(K)*AKQ(K-1)/CM(K-1)
1411 CM(K)=-CR(K-1)*CF+(AKQ(K-1)+AKQ(K))*DTOZ(K)+1.
1412 CM(K)=-CR(K-1)*CF+(AKQ(K-1)+AKQ(K))*DTOZ(K)+1.
1413 RSQ2(K)=-RSQ2(K-1)*CF+Q2(K)+DTDIF*B_E(K) !Bep
1416 DTOZS=(DTDIF+DTDIF)/(Z(LMH-1)-Z(LMH+1))/VLK(K)
1417 AKQS=SFK(K)*SQRT((Q2(LMH-1)+Q2(LMH))*0.5)*(EL(LMH-1)+ELZ0)*ESQHF&
1418 & /(Z(LMH)-Z(LMH+1))
1420 CF=-DTOZS*AKQ(LMH-2)/CM(LMH-2)
1422 Q2(LMH-1)=(DTOZS*AKQS*Q2(LMH)-RSQ2(LMH-2)*CF+Q2(LMH-1)&
1423 & +DTDIF*B_E(LMH-1)) & !Bep
1424 & /((AKQ(LMH-2)+AKQS)*DTOZS-CR(LMH-2)*CF+1.)
1427 Q2(K)=(-CR(K)*Q2(K+1)+RSQ2(K))/CM(K)
1429 !----------------------------------------------------------------------
1431 END SUBROUTINE VDIFQ
1433 !----------------------------------------------------------------------
1434 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1435 !---------------------------------------------------------------------
1436 SUBROUTINE VDIFH(DTDIF,LMH,THZ0,QZ0,RKHS,CHKLOWQ,CT &
1437 & ,THE,Q,CWM,RKH_IN,Z,RHO &
1439 & ,A_T,B_T,A_Q,B_Q,SFK,VLK &
1441 & ,IDS,IDE,JDS,JDE,KDS,KDE &
1442 & ,IMS,IME,JMS,JME,KMS,KME &
1443 & ,ITS,ITE,JTS,JTE,KTS,KTE,I,J)
1444 ! ***************************************************************
1446 ! * VERTICAL DIFFUSION OF MASS VARIABLES *
1448 ! ***************************************************************
1449 !---------------------------------------------------------------------
1453 !---------------------------------------------------------------------
1454 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
1455 & ,IMS,IME,JMS,JME,KMS,KME &
1456 & ,ITS,ITE,JTS,JTE,KTS,KTE,I,J
1458 INTEGER,INTENT(IN) :: LMH
1460 REAL,INTENT(IN) :: CHKLOWQ,CT,DTDIF,QZ0,RKHS,THZ0
1462 REAL,DIMENSION(KTS:KTE-1),INTENT(IN) :: RKH_IN
1463 REAL,DIMENSION(KTS:KTE),INTENT(IN) :: RHO
1464 REAL,DIMENSION(KTS:KTE+1),INTENT(IN) :: Z
1465 REAL,DIMENSION(KTS:KTE),INTENT(INOUT) :: CWM,Q,THE
1466 ! Variables added for Bep
1467 REAL,DIMENSION(KTS:KTE),INTENT(IN) :: A_T,B_T,A_Q,B_Q,VLK
1468 REAL,DIMENSION(KTS:KTE),INTENT(IN) :: SFK
1471 !----------------------------------------------------------------------
1473 !*** LOCAL VARIABLES
1477 REAL :: CF,CMB,CMCB,CMQB,CMTB,CTHF,DTOZL,DTOZS &
1478 & ,RCML,RKHH,RKQS,RSCB,RSQB,RSTB
1479 ! Variables added for Bep
1480 REAL :: CF_T,CF_Q,RCML_T,RCML_Q,CMB_T,CMB_Q
1483 REAL,DIMENSION(KTS:KTE-1) :: CM,CR,DTOZ,RKCT,RSC,RSQ,RST
1484 ! Variables added for Bep
1485 REAL,DIMENSION(KTS:KTE-1) :: CM_T,CM_Q
1486 REAL,DIMENSION(KTS:KTE-1) :: RKH
1489 !----------------------------------------------------------------------
1490 !**********************************************************************
1491 !----------------------------------------------------------------------
1495 RKH(K)=RKH_IN(K)*SFK(K) !Bep
1496 DTOZ(K)=DTDIF/(Z(K)-Z(K+1))/VLK(K) !Bep
1497 CR(K)=-DTOZ(K)*RKH(K)
1498 RKCT(K)=RKH(K)*(Z(K)-Z(K+2))*CTHF
1501 CM(KTS)=DTOZ(KTS)*RKH(KTS)+RHO(KTS)
1502 CM_T(KTS)=DTOZ(KTS)*RKH(KTS)+RHO(KTS)*(1.-DTDIF*A_T(KTS)) !Bep
1503 CM_Q(KTS)=DTOZ(KTS)*RKH(KTS)+RHO(KTS)*(1.-DTDIF*A_Q(KTS)) !Bep
1504 !----------------------------------------------------------------------
1505 RST(KTS) = -RKCT(KTS)*DTOZ(KTS)+&
1506 &RHO(KTS)*(THE(KTS)+DTDIF*B_T(KTS)) !Bep
1507 RSQ(KTS) = RHO(KTS)*( Q(KTS)+DTDIF*B_Q(KTS)) !Bep
1508 RSC(KTS) = RHO(KTS)* CWM(KTS)
1509 !----------------------------------------------------------------------
1512 CF = -DTOZL*RKH(K-1)/CM(K-1)
1513 CF_T = -DTOZL*RKH(K-1)/CM_T(K-1) !Bep
1514 CF_Q = -DTOZL*RKH(K-1)/CM_Q(K-1) !Bep
1515 CM(K) = -CR(K-1)*CF+ (RKH(K-1)+RKH(K))*DTOZL+RHO(K)
1516 CM_T(K)= -CR(K-1)*CF_T+(RKH(K-1)+RKH(K))*DTOZL+RHO(K)*&
1518 CM_Q(K)= -CR(K-1)*CF_Q+(RKH(K-1)+RKH(K))*DTOZL+RHO(K)*&
1519 &(1.-DTDIF*A_Q(K)) !Bep
1520 RST(K)=-RST(K-1)*CF_T+(RKCT(K-1)-RKCT(K))*DTOZL+RHO(K)*&
1521 &(THE(K)+DTDIF*B_T(K)) !Bep
1522 RSQ(K)=-RSQ(K-1)*CF_Q+RHO(K)*( Q(K)+DTDIF*B_Q(K)) !Bep
1523 RSC(K)=-RSC(K-1)*CF+CWM(K)*RHO(K)
1526 DTOZS=DTDIF/(Z(LMH)-Z(LMH+1))/VLK(LMH) !Bep
1529 CF=-DTOZS*RKHH/CM(LMH-1)
1530 CF_T=-DTOZS*RKHH/CM_T(LMH-1) !Bep
1531 CF_Q=-DTOZS*RKHH/CM_Q(LMH-1) !Bep
1535 CMB_T=CR(LMH-1)*CF_T
1536 CMB_Q=CR(LMH-1)*CF_Q
1537 CMTB=-CMB_T+RKHH*DTOZS+RHO(LMH)*(1.-DTDIF*A_T(LMH)) !Bep
1538 CMQB=-CMB_Q+RKHH*DTOZS+RHO(LMH)*(1.-DTDIF*A_Q(LMH)) !Bep
1539 CMCB=-CMB+(RKHH )*DTOZS+RHO(LMH)
1541 RSTB=-RST(LMH-1)*CF_T+RHO(LMH)*(THE(LMH)+DTDIF*B_T(LMH))+&
1542 &RKCT(LMH-1)*DTOZS !Bep
1543 RSQB=-RSQ(LMH-1)*CF_Q+RHO(LMH)*( Q(LMH)+DTDIF*B_Q(LMH)) !Bep
1544 RSCB=-RSC(LMH-1)*CF+CWM(LMH)*RHO(LMH)
1545 !----------------------------------------------------------------------
1549 !----------------------------------------------------------------------
1552 RCML_T=1./CM_T(K) !Bep
1553 RCML_Q=1./CM_Q(K) !Bep
1554 THE(K)=(-CR(K)*THE(K+1)+RST(K))*RCML_T
1555 Q(K) =(-CR(K)* Q(K+1)+RSQ(K))*RCML_Q
1556 CWM(K)=(-CR(K)*CWM(K+1)+RSC(K))*RCML
1558 !----------------------------------------------------------------------
1562 END SUBROUTINE VDIFH
1564 !----------------------------------------------------------------------
1565 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1566 !---------------------------------------------------------------------
1567 SUBROUTINE VDIFX(DTDIF,LMH,RKHS,CT &
1568 ,DUST1,DUST2,RKH,Z,RHO &
1569 ,IDS,IDE,JDS,JDE,KDS,KDE &
1570 ,IMS,IME,JMS,JME,KMS,KME &
1571 ,ITS,ITE,JTS,JTE,KTS,KTE)
1572 ! ***************************************************************
1574 ! * VERTICAL DIFFUSION OF MASS VARIABLES *
1576 ! ***************************************************************
1577 !---------------------------------------------------------------------
1581 !---------------------------------------------------------------------
1582 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
1583 ,IMS,IME,JMS,JME,KMS,KME &
1584 ,ITS,ITE,JTS,JTE,KTS,KTE
1586 INTEGER,INTENT(IN) :: LMH
1588 REAL,INTENT(IN) :: CT,DTDIF,RKHS
1590 REAL,DIMENSION(KTS:KTE-1),INTENT(IN) :: RKH
1591 REAL,DIMENSION(KTS:KTE),INTENT(IN) :: RHO
1592 REAL,DIMENSION(KTS:KTE+1),INTENT(IN) :: Z
1593 REAL,DIMENSION(KTS:KTE),INTENT(INOUT) :: DUST1,DUST2
1595 !----------------------------------------------------------------------
1597 !*** LOCAL VARIABLES
1601 REAL :: CF,CMB,CMDB,CTHF,DTOZL,DTOZS &
1602 ,RCML,RKHH,RSD1B,RSD2B
1604 REAL,DIMENSION(KTS:KTE-1) :: CM,CR,DTOZ,RKCT,RSD1,RSD2
1606 !----------------------------------------------------------------------
1607 !**********************************************************************
1608 !----------------------------------------------------------------------
1612 DTOZ(K)=DTDIF/(Z(K)-Z(K+1))
1613 CR(K)=-DTOZ(K)*RKH(K)
1614 RKCT(K)=RKH(K)*(Z(K)-Z(K+2))*CTHF
1617 CM(KTS)=DTOZ(KTS)*RKH(KTS)+RHO(KTS)
1618 !----------------------------------------------------------------------
1619 RSD1(KTS)=DUST1(KTS)*RHO(KTS)
1620 RSD2(KTS)=DUST2(KTS)*RHO(KTS)
1621 !----------------------------------------------------------------------
1624 CF=-DTOZL*RKH(K-1)/CM(K-1)
1625 CM(K)=-CR(K-1)*CF+(RKH(K-1)+RKH(K))*DTOZL+RHO(K)
1626 RSD1(K)=-RSD1(K-1)*CF+DUST1(K)*RHO(K)
1627 RSD2(K)=-RSD2(K-1)*CF+DUST2(K)*RHO(K)
1630 DTOZS=DTDIF/(Z(LMH)-Z(LMH+1))
1633 CF=-DTOZS*RKHH/CM(LMH-1)
1636 CMDB=-CMB+RKHH*DTOZS+RHO(LMH)
1638 RSD1B=-RSD1(LMH-1)*CF+DUST1(LMH)*RHO(LMH)
1639 RSD2B=-RSD2(LMH-1)*CF+DUST2(LMH)*RHO(LMH)
1640 !----------------------------------------------------------------------
1641 DUST1(LMH)=RSD1B/CMDB
1642 DUST2(LMH)=RSD2B/CMDB
1643 !----------------------------------------------------------------------
1646 DUST1(K)=(-CR(K)*DUST1(K+1)+RSD1(K))*RCML
1647 DUST2(K)=(-CR(K)*DUST2(K+1)+RSD2(K))*RCML
1649 !----------------------------------------------------------------------
1651 END SUBROUTINE VDIFX
1653 !---------------------------------------------------------------------
1654 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1655 !---------------------------------------------------------------------
1656 SUBROUTINE VDIFV(LMH,DTDIF,UZ0,VZ0,RKMS,U,V,RKM_IN,Z,RHO &
1657 ! Variables added for Bep
1658 & ,A_UK,A_VK,B_UK,B_VK,SFK,VLK &
1660 & ,IDS,IDE,JDS,JDE,KDS,KDE &
1661 & ,IMS,IME,JMS,JME,KMS,KME &
1662 ,ITS,ITE,JTS,JTE,KTS,KTE,I,J)
1663 ! ***************************************************************
1665 ! * VERTICAL DIFFUSION OF VELOCITY COMPONENTS *
1667 ! ***************************************************************
1668 !---------------------------------------------------------------------
1672 !---------------------------------------------------------------------
1673 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
1674 & ,IMS,IME,JMS,JME,KMS,KME &
1675 & ,ITS,ITE,JTS,JTE,KTS,KTE,I,J
1677 INTEGER,INTENT(IN) :: LMH
1679 REAL,INTENT(IN) :: RKMS,DTDIF,UZ0,VZ0
1681 REAL,DIMENSION(KTS:KTE-1),INTENT(IN) :: RKM_IN !Bep
1682 REAL,DIMENSION(KTS:KTE),INTENT(IN) :: RHO
1683 REAL,DIMENSION(KTS:KTE+1),INTENT(IN) :: Z
1685 REAL,DIMENSION(KTS:KTE),INTENT(INOUT) :: U,V
1686 REAL,DIMENSION(KTS:KTE),INTENT(IN) :: A_UK,A_VK,B_UK,B_VK,VLK !Bep
1687 REAL,DIMENSION(KTS:KTE),INTENT(IN) :: SFK !Bep
1688 !----------------------------------------------------------------------
1690 !*** LOCAL VARIABLES
1694 REAL :: CFU,RCMLU,RCMVBU
1695 REAL :: CFV,RCMLV,RCMVBV
1696 REAL :: DTOZAK,DTOZL,DTOZS,RHOK,RKMH
1698 REAL,DIMENSION(KTS:KTE-1) :: CMU,CMV,CR,DTOZ,RSU,RSV
1699 REAL,DIMENSION(KTS:KTE-1) :: RKM !Bep
1700 !----------------------------------------------------------------------
1701 !**********************************************************************
1702 !----------------------------------------------------------------------
1704 RKM(K)=RKM_IN(K)*SFK(K)
1705 DTOZ(K)=DTDIF/(Z(K)-Z(K+1))/VLK(K)
1706 CR(K)=-DTOZ(K)*RKM(K) !alpha, gamma
1710 CMU(1)=DTOZ(1)*RKM(1)+RHOK*(1.-DTDIF*A_UK(1)) !Bep change beta
1711 CMV(1)=DTOZ(1)*RKM(1)+RHOK*(1.-DTDIF*A_VK(1)) !Bep change beta
1712 RSU(1)=RHOK*(U(1)+DTDIF*B_UK(1)) !Bep change W
1713 RSV(1)=RHOK*(V(1)+DTDIF*B_VK(1)) !Bep change W
1714 !----------------------------------------------------------------------
1717 CFU=-DTOZL*RKM(K-1)/CMU(K-1)
1718 CFV=-DTOZL*RKM(K-1)/CMV(K-1)
1720 CMU(K)=-CR(K-1)*CFU+(RKM(K-1)+RKM(K))&
1721 &*DTOZL+RHOK*(1.-DTDIF*A_UK(K)) !Bep
1722 CMV(K)=-CR(K-1)*CFV+(RKM(K-1)+RKM(K))&
1723 &*DTOZL+RHOK*(1.-DTDIF*A_VK(K)) !Bep
1724 RSU(K)=-RSU(K-1)*CFU+RHOK*(U(K)+DTDIF*B_UK(K)) !Bep
1725 RSV(K)=-RSV(K-1)*CFV+RHOK*(V(K)+DTDIF*B_VK(K)) !Bep
1727 !----------------------------------------------------------------------
1728 ! Bep: change lower BC from value UZ0 at LMH+1 to flux derived BC: Z(LMH+1)=0.
1729 DTOZS=DTDIF/(Z(LMH)-Z(LMH+1))/VLK(LMH) !Bep
1730 RKMH=RKM(LMH-1) !Bep
1732 CFU=-DTOZS*RKMH/CMU(LMH-1)
1733 CFV=-DTOZS*RKMH/CMV(LMH-1)
1735 RCMVBU=1./(RKMH*DTOZS-CR(LMH-1)*CFU+RHOK*(1.-DTDIF*A_UK(LMH))) !Bep
1736 RCMVBV=1./(RKMH*DTOZS-CR(LMH-1)*CFV+RHOK*(1.-DTDIF*A_VK(LMH))) !Bep
1738 !----------------------------------------------------------------------
1739 U(LMH)=(-RSU(LMH-1)*CFU+RHOK*(U(LMH)+DTDIF*B_UK(LMH)))*RCMVBU !Bep
1740 V(LMH)=(-RSV(LMH-1)*CFV+RHOK*(V(LMH)+DTDIF*B_VK(LMH)))*RCMVBV !Bep
1741 !----------------------------------------------------------------------
1743 RCMLU=1./CMU(K) !Bep
1744 RCMLV=1./CMV(K) !Bep
1745 U(K)=(-CR(K)*U(K+1)+RSU(K))*RCMLU !Bep
1746 V(K)=(-CR(K)*V(K+1)+RSV(K))*RCMLV !Bep
1748 !----------------------------------------------------------------------
1751 END SUBROUTINE VDIFV
1753 !-----------------------------------------------------------------------
1754 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1755 !=======================================================================
1756 SUBROUTINE MYJURBINIT(RUBLTEN,RVBLTEN,RTHBLTEN,RQVBLTEN, &
1757 & TKE_MYJ,EXCH_H,RESTART,ALLOWED_TO_READ, &
1758 & IDS,IDE,JDS,JDE,KDS,KDE, &
1759 & IMS,IME,JMS,JME,KMS,KME, &
1760 & ITS,ITE,JTS,JTE,KTS,KTE )
1761 !-----------------------------------------------------------------------
1763 !-----------------------------------------------------------------------
1764 LOGICAL,INTENT(IN) :: ALLOWED_TO_READ,RESTART
1765 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE, &
1766 & IMS,IME,JMS,JME,KMS,KME, &
1767 & ITS,ITE,JTS,JTE,KTS,KTE
1769 REAL,DIMENSION(IMS:IME,KMS:KME,JMS:JME),INTENT(OUT) :: EXCH_H, &
1775 INTEGER :: I,J,K,ITF,JTF,KTF
1776 !-----------------------------------------------------------------------
1777 !-----------------------------------------------------------------------
1783 IF(.NOT.RESTART)THEN
1787 TKE_MYJ(I,K,J)=EPSQ2
1798 END SUBROUTINE MYJURBINIT
1799 !-----------------------------------------------------------------------
1801 END MODULE MODULE_BL_MYJURB
1803 !-----------------------------------------------------------------------