1 !-----------------------------------------------------------------------
3 MODULE MODULE_BL_QNSEPBL
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
31 !-----------------------------------------------------------------------
32 !*** QNSE MODEL CONSTANTS
33 !-----------------------------------------------------------------------
35 REAL,PARAMETER :: EPSQ2L=0.01
36 REAL,PARAMETER :: C0=0.55,CEPS=C0**3,BLCKDR=0.0063,CN=0.75 &
37 & ,AM1=8.0,AM2=2.3,AM3=35.0,AH1=1.4,AH2=-0.01 &
38 & ,AH3=1.29,AH4=2.44,AH5=19.8 &
39 & ,ARIMIN=0.127,BM1=2.88,BM2=16.0,BH1=3.6,BH2=16.0 &
40 & ,BH3=720.0,EPSKM=1.E-3
42 REAL,PARAMETER :: CAPA=R_D/CP
43 REAL,PARAMETER :: RLIVWV=XLS/XLV,ELOCP=2.72E6/CP
44 REAL,PARAMETER :: EPS1=1.E-12,EPS2=0.
45 REAL,PARAMETER :: EPSL=0.32,EPSRU=1.E-7,EPSRS=1.E-7 &
47 REAL,PARAMETER :: EPSA=1.E-8,EPSIT=1.E-4,EPSU2=1.E-4,EPSUST=0.07 &
49 REAL,PARAMETER :: ALPH=0.30,BETA=1./273.,EL0MAX=1000.,EL0MIN=1. &
50 & ,ELFC=0.23*0.5,GAM1=0.2222222222222222222 &
52 REAL,PARAMETER :: A1=0.659888514560862645 &
53 & ,A2x=0.6574209922667784586 &
54 & ,B1=11.87799326209552761 &
55 & ,B2=7.226971804046074028 &
56 & ,C1=0.000830955950095854396
57 REAL,PARAMETER :: A2S=17.2693882,A3S=273.16,A4S=35.86
58 REAL,PARAMETER :: ELZ0=0.,ESQ=5.0,EXCM=0.001 &
59 & ,FHNEU=0.8,GLKBR=10.,GLKBS=30. &
60 & ,QVISC=2.1E-5,RFC=0.191,RIC=0.505,SMALL=0.35 &
61 & ,SQPR=0.84,SQSC=0.84,SQVISC=258.2,TVISC=2.1E-5 &
62 & ,USTC=0.7,USTR=0.225,VISC=1.5E-5 &
63 & ,WOLD=0.15,WWST=1.2,ZTMAX=1.,ZTFC=1.,ZTMIN=-5.
65 REAL,PARAMETER :: SEAFC=0.98,PQ0SEA=PQ0*SEAFC
67 REAL,PARAMETER :: BTG=BETA*G,CZIV=SMALL*GLKBS &
68 ! & ,EP_1=R_V/R_D-1.,ESQHF=0.5*5.0,GRRS=GLKBR/GLKBS &
69 & ,ESQHF=0.5*5.0,GRRS=GLKBR/GLKBS &
70 & ,RB1=1./B1,RTVISC=1./TVISC,RVISC=1./VISC &
73 REAL,PARAMETER :: ADNH= 9.*A1*A2x*A2x*(12.*A1+3.*B2)*BTG*BTG &
74 & ,ADNM=18.*A1*A1*A2x*(B2-3.*A2x)*BTG &
75 & ,ANMH=-9.*A1*A2x*A2x*BTG*BTG &
76 & ,ANMM=-3.*A1*A2x*(3.*A2x+3.*B2*C1+18.*A1*C1-B2) &
78 & ,BDNH= 3.*A2x*(7.*A1+B2)*BTG &
80 & ,BEQH= A2x*B1*BTG+3.*A2x*(7.*A1+B2)*BTG &
81 & ,BEQM=-A1*B1*(1.-3.*C1)+6.*A1*A1 &
83 & ,BNMM=A1*(1.-3.*C1) &
84 & ,BSHH=9.*A1*A2x*A2x*BTG &
85 & ,BSHM=18.*A1*A1*A2x*C1 &
86 & ,BSMH=-3.*A1*A2x*(3.*A2x+3.*B2*C1+12.*A1*C1-B2) &
89 & ,CESM=A1*(1.-3.*C1) &
91 & ,ELFCS=VKARMAN*BTG &
92 & ,FZQ1=RTVISC*QVISC*ZQRZT &
93 & ,FZQ2=RTVISC*QVISC*ZQRZT &
94 & ,FZT1=RVISC *TVISC*SQPR &
95 & ,FZT2=CZIV*GRRS*TVISC*SQPR &
98 & ,RFAC=RIC/(FHNEU*RFC*RFC) &
105 !-----------------------------------------------------------------------
106 !*** FREE TERM IN THE EQUILIBRIUM EQUATION FOR (L/Q)**2
107 !-----------------------------------------------------------------------
109 REAL,PARAMETER :: AEQH=9.*A1*A2x*A2x*B1*BTG*BTG &
110 & +9.*A1*A2x*A2x*(12.*A1+3.*B2)*BTG*BTG &
111 & ,AEQM=3.*A1*A2x*B1*(3.*A2x+3.*B2*C1+18.*A1*C1-B2)&
112 & *BTG+18.*A1*A1*A2x*(B2-3.*A2x)*BTG
114 !-----------------------------------------------------------------------
115 !*** FORBIDDEN TURBULENCE AREA
116 !-----------------------------------------------------------------------
118 REAL,PARAMETER :: REQU=-AEQH/AEQM &
119 & ,EPSGH=1.E-9,EPSGM=REQU*EPSGH
121 !-----------------------------------------------------------------------
122 !*** NEAR ISOTROPY FOR SHEAR TURBULENCE, WW/Q2 LOWER LIMIT
123 !-----------------------------------------------------------------------
125 REAL,PARAMETER :: UBRYL=(18.*REQU*A1*A1*A2x*B2*C1*BTG &
126 & +9.*A1*A2x*A2x*B2*BTG*BTG) &
127 & /(REQU*ADNM+ADNH) &
128 & ,UBRY=(1.+EPSRS)*UBRYL,UBRY3=3.*UBRY
130 REAL,PARAMETER :: AUBH=27.*A1*A2x*A2x*B2*BTG*BTG-ADNH*UBRY3 &
131 & ,AUBM=54.*A1*A1*A2x*B2*C1*BTG -ADNM*UBRY3 &
132 & ,BUBH=(9.*A1*A2x+3.*A2x*B2)*BTG-BDNH*UBRY3 &
133 & ,BUBM=18.*A1*A1*C1 -BDNM*UBRY3 &
137 !-----------------------------------------------------------------------
141 !----------------------------------------------------------------------
142 SUBROUTINE QNSEPBL(DT,STEPBL,HT,DZ &
143 & ,PMID,PINT,TH,T,EXNER,QV,CWM,U,V,RHO &
144 & ,TSK,QSFC,CHKLOWQ,THZ0,QZ0,UZ0,VZ0,CORF &
145 & ,LOWLYR,XLAND,SICE,SNOW &
146 & ,TKE,EXCH_H,EXCH_M,USTAR,ZNT,EL_MYJ,PBLH,KPBL,CT &
147 & ,AKHS,AKMS,ELFLX,HFX & !JP HFX
149 & ,RUBLTEN,RVBLTEN,RTHBLTEN,RQVBLTEN,RQCBLTEN &
150 & ,IDS,IDE,JDS,JDE,KDS,KDE &
151 & ,IMS,IME,JMS,JME,KMS,KME &
152 & ,ITS,ITE,JTS,JTE,KTS,KTE)
153 !----------------------------------------------------------------------
157 !----------------------------------------------------------------------
158 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
159 & ,IMS,IME,JMS,JME,KMS,KME &
160 & ,ITS,ITE,JTS,JTE,KTS,KTE
162 INTEGER,INTENT(IN) :: STEPBL
164 INTEGER,DIMENSION(IMS:IME,JMS:JME),INTENT(IN) :: LOWLYR
166 INTEGER,DIMENSION(IMS:IME,JMS:JME),INTENT(OUT) :: KPBL
168 REAL,INTENT(IN) :: DT
170 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(IN) :: HT,SICE,SNOW &
173 REAL,DIMENSION(IMS:IME,KMS:KME,JMS:JME),INTENT(IN) :: CWM,DZ &
179 REAL,DIMENSION(IMS:IME,KMS:KME,JMS:JME),INTENT(IN),OPTIONAL :: &
183 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(OUT) :: PBLH
185 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(INOUT) :: AKHS,AKMS
187 REAL,DIMENSION(IMS:IME,KMS:KME,JMS:JME) &
188 & ,INTENT(OUT) :: EL_MYJ
189 REAL,DIMENSION(IMS:IME,KMS:KME,JMS:JME) &
190 & ,INTENT(INOUT) :: RQCBLTEN,RQVBLTEN &
194 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(INOUT) :: CT,QSFC,QZ0 &
198 REAL,DIMENSION(IMS:IME,KMS:KME,JMS:JME) &
199 & ,INTENT(INOUT) :: EXCH_H,EXCH_M,TKE
201 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(IN) :: CHKLOWQ,ELFLX,CORF
203 !----------------------------------------------------------------------
207 INTEGER :: I,J,K,KFLIP,LLOW,LMH,LMXL
209 INTEGER,DIMENSION(ITS:ITE,JTS:JTE) :: LPBL
211 REAL :: AKHS_DENS,AKMS_DENS,APEX,DCDT,DELTAZ,DQDT,DTDIF,DTDT &
212 & ,DTTURBL,DUDT,DVDT,EXNSFC,PSFC,PTOP,QFC1,QLOW,QOLD &
213 & ,RATIOMX,RDTTURBL,RG,RWMSK,SEAMASK,THNEW,THOLD,TX &
214 & ,ULOW,VLOW,WMSK,RLOW
216 REAL,DIMENSION(KTS:KTE) :: CWMK,PK,Q2K,QK,THEK,TK,UK,VK,&
219 REAL,DIMENSION(KTS:KTE-1) :: AKHK,AKMK,EL,RI,GH,S2
221 REAL,DIMENSION(KTS:KTE+1) :: ZHK
223 REAL,DIMENSION(ITS:ITE,JTS:JTE) :: THSK
225 REAL,DIMENSION(KTS:KTE,ITS:ITE) :: RHOK
227 REAL,DIMENSION(ITS:ITE,KTS:KTE,JTS:JTE) :: APE,THE
229 REAL,DIMENSION(ITS:ITE,KTS:KTE-1,JTS:JTE) :: AKH,AKM
231 REAL,DIMENSION(ITS:ITE,KTS:KTE+1,JTS:JTE) :: ZINT
235 INTEGER :: IMD,JMD,PRINT_DIAG
238 !----------------------------------------------------------------------
239 !**********************************************************************
240 !----------------------------------------------------------------------
247 !*** MAKE PREPARATIONS
249 !----------------------------------------------------------------------
273 ZINT(I,KTE+1,J)=HT(I,J) ! Z at bottom of lowest sigma layer
276 !!!!!! UNCOMMENT THESE LINES IF USING ETA COORDINATES
278 !!!!!! ZINT(I,KTE+1,J)=1.E-4 ! Z of bottom of lowest eta layer
279 !!!!!! ZHK(KTE+1)=1.E-4 ! Z of bottom of lowest eta layer
288 ZINT(I,K,J)=ZINT(I,K+1,J)+DZ(I,KFLIP,J)
292 THE(I,K,J)=(CWM(I,K,J)*(-ELOCP/TX)+1.)*TH(I,K,J)
297 EL_MYJ(its:ite,:,jts:jte) = 0.
299 !----------------------------------------------------------------------
300 setup_integration: DO J=JTS,JTE
301 !----------------------------------------------------------------------
305 !*** LOWEST LAYER ABOVE GROUND MUST BE FLIPPED
307 LMH=KTE-LOWLYR(I,J)+1
309 PTOP=PINT(I,KTE+1,J) ! KTE+1=KME
310 PSFC=PINT(I,LOWLYR(I,J),J)
312 !*** CONVERT LAND MASK (1 FOR SEA; 0 FOR LAND)
314 SEAMASK=XLAND(I,J)-1.
316 !*** FILL 1-D VERTICAL ARRAYS
317 !*** AND FLIP DIRECTION SINCE MYJ SCHEME
318 !*** COUNTS DOWNWARD FROM THE DOMAIN'S TOP
323 THEK(K)=THE(I,KFLIP,J)
324 RATIOMX=QV(I,KFLIP,J)
325 QK(K)=RATIOMX/(1.+RATIOMX)
326 CWMK(K)=CWM(I,KFLIP,J)
327 PK(K)=PMID(I,KFLIP,J)
331 !*** TKE=0.5*(q**2) ==> q**2=2.*TKE
333 Q2K(K)=2.*TKE(I,KFLIP,J)
335 !**** buoyancy flux of mass flux shallow convection scheme
337 IF ( PRESENT (WTHV_MF) .AND. PRESENT (LM_BL89) ) THEN
338 WTHV_MFK(K)=WTHV_MF(I,KFLIP,J)
339 LM_BL89K(K)=LM_BL89(I,KFLIP,J)
345 !*** COMPUTE THE HEIGHTS OF THE LAYER INTERFACES
350 ZHK(KTE+1)=HT(I,J) ! Z at bottom of lowest sigma layer
353 ! IF(I==IMD.AND.J==JMD)THEN
358 ! IF(I==227.AND.J==363)PRINT_DIAG=2
361 !----------------------------------------------------------------------
363 !*** FIND THE MIXING LENGTH
365 CALL MIXLEN(LMH,UK,VK,TK,THEK,QK,CWMK &
366 & ,Q2K,ZHK,USTAR(I,J),CORF(I,J),S2,GH,RI,EL &
367 & ,PBLH(I,J),LPBL(I,J),LMXL,CT(I,J),LM_BL89K &
368 & ,IDS,IDE,JDS,JDE,KDS,KDE &
369 & ,IMS,IME,JMS,JME,KMS,KME &
370 & ,ITS,ITE,JTS,JTE,KTS,KTE)
372 !----------------------------------------------------------------------
373 !*** THE MODEL LAYER (COUNTING UPWARD) CONTAINING THE TOP OF THE PBL
374 !----------------------------------------------------------------------
376 KPBL(I,J)=KTE-LPBL(I,J)+1
378 !----------------------------------------------------------------------
380 !*** FIND THE QNSE EXCHANGE COEFFICIENTS
382 CALL DIFCOF(LMH,EL,RI,Q2K,ZHK,AKMK,AKHK &
383 & ,IDS,IDE,JDS,JDE,KDS,KDE &
384 & ,IMS,IME,JMS,JME,KMS,KME &
385 & ,ITS,ITE,JTS,JTE,KTS,KTE,PRINT_DIAG) ! debug
387 !----------------------------------------------------------------------
388 !*** COUNTING DOWNWARD FROM THE TOP, THE EXCHANGE COEFFICIENTS AKH
389 !*** ARE DEFINED ON THE BOTTOMS OF THE LAYERS KTS TO KTE-1. COUNTING
390 !*** COUNTING UPWARD FROM THE BOTTOM, THOSE SAME COEFFICIENTS EXCH_H
391 !*** ARE DEFINED ON THE TOPS OF THE LAYERS KTS TO KTE-1.
397 DELTAZ=0.5*(ZHK(KFLIP)-ZHK(KFLIP+2))
398 EXCH_H(I,K+1,J)=AKHK(KFLIP)*DELTAZ
399 EXCH_M(I,K+1,J)=AKMK(KFLIP)*DELTAZ
402 !----------------------------------------------------------------------
404 !*** SOLVE FOR THE PRODUCTION/DISSIPATION OF
405 !*** THE TURBULENT KINETIC ENERGY
408 CALL PRODQ2(LMH,DTTURBL,USTAR(I,J),S2,RI,Q2K,EL,ZHK,AKMK,AKHK &
409 & ,WTHV_MFK,IDS,IDE,JDS,JDE,KDS,KDE &
410 & ,IMS,IME,JMS,JME,KMS,KME &
411 & ,ITS,ITE,JTS,JTE,KTS,KTE)
413 !----------------------------------------------------------------------
415 !*** CARRY OUT THE VERTICAL DIFFUSION OF
416 !*** TURBULENT KINETIC ENERGY
419 CALL VDIFQ(LMH,DTDIF,Q2K,EL,ZHK &
420 & ,IDS,IDE,JDS,JDE,KDS,KDE &
421 & ,IMS,IME,JMS,JME,KMS,KME &
422 & ,ITS,ITE,JTS,JTE,KTS,KTE)
424 !*** SAVE THE NEW TKE AND MIXING LENGTH.
428 Q2K(KFLIP)=AMAX1(Q2K(KFLIP),EPSQ2L)
429 TKE(I,K,J)=0.5*Q2K(KFLIP)
430 IF(KFLIP/=KTE)EL_MYJ(I,K,J)=EL(KFLIP) ! EL IS NOT DEFINED AT KTE
435 !----------------------------------------------------------------------
436 ENDDO setup_integration
437 !----------------------------------------------------------------------
439 !*** CONVERT SURFACE SENSIBLE TEMPERATURE TO POTENTIAL TEMPERATURE.
444 PSFC=PINT(I,LOWLYR(I,J),J)
445 RLOW=PSFC/(R_D*T(I,1,J))
448 THSK(I,J)=HFX(I,J)/(AKHS(I,J)*RLOW*CP)+TH(I,1,J)
455 !----------------------------------------------------------------------
457 !----------------------------------------------------------------------
458 main_integration: DO J=JTS,JTE
459 !----------------------------------------------------------------------
463 !*** FILL 1-D VERTICAL ARRAYS
464 !*** AND FLIP DIRECTION SINCE MYJ SCHEME
465 !*** COUNTS DOWNWARD FROM THE DOMAIN'S TOP
469 THEK(K)=THE(I,KFLIP,J)
470 RATIOMX=QV(I,KFLIP,J)
471 QK(K)=RATIOMX/(1.+RATIOMX)
472 CWMK(K)=CWM(I,KFLIP,J)
474 RHOK(K,I)=PMID(I,KFLIP,J)/(R_D*T(I,KFLIP,J)* &
475 & (1.+P608*QK(K)-CWMK(K)))
478 !*** COUNTING DOWNWARD FROM THE TOP, THE EXCHANGE COEFFICIENTS AKH
479 !*** ARE DEFINED ON THE BOTTOMS OF THE LAYERS KTS TO KTE-1. THESE COEFFICIENTS
480 !*** ARE ALSO MULTIPLIED BY THE DENSITY AT THE BOTTOM INTERFACE LEVEL.
483 AKHK(K)=AKH(I,K,J)*0.5*(RHOK(K,I)+RHOK(K+1,I))
486 ZHK(KTE+1)=ZINT(I,KTE+1,J)
488 SEAMASK=XLAND(I,J)-1.
489 THZ0(I,J)=(1.-SEAMASK)*THSK(I,J)+SEAMASK*THZ0(I,J)
492 AKHS_DENS=AKHS(I,J)*RHOK(KTE+1-LLOW,I)
495 QFC1=XLV*CHKLOWQ(I,J)*AKHS_DENS
497 IF(SNOW(I,J)>0..OR.SICE(I,J)>0.5)THEN
503 QSFC(I,J)=QLOW+ELFLX(I,J)/QFC1
507 PSFC=PINT(I,LOWLYR(I,J),J)
508 EXNSFC=(1.E5/PSFC)**CAPA
509 QSFC(I,J)=PQ0SEA/PSFC &
510 & *EXP(A2*(THSK(I,J)-A3*EXNSFC)/(THSK(I,J)-A4*EXNSFC))
513 QZ0 (I,J)=(1.-SEAMASK)*QSFC(I,J)+SEAMASK*QZ0 (I,J)
515 !*** LOWEST LAYER ABOVE GROUND MUST BE FLIPPED
517 LMH=KTE-LOWLYR(I,J)+1
519 !----------------------------------------------------------------------
520 !*** CARRY OUT THE VERTICAL DIFFUSION OF
521 !*** TEMPERATURE AND WATER VAPOR
522 !----------------------------------------------------------------------
524 CALL VDIFH(DTDIF,LMH,THZ0(I,J),QZ0(I,J) &
525 & ,AKHS_DENS,CHKLOWQ(I,J),CT(I,J) &
526 & ,THEK,QK,CWMK,AKHK,ZHK,RHOK(KTS,I) &
527 & ,IDS,IDE,JDS,JDE,KDS,KDE &
528 & ,IMS,IME,JMS,JME,KMS,KME &
529 & ,ITS,ITE,JTS,JTE,KTS,KTE,I,J)
530 !----------------------------------------------------------------------
532 !*** COMPUTE PRIMARY VARIABLE TENDENCIES
537 THNEW=THEK(KFLIP)+CWMK(KFLIP)*ELOCP*APE(I,K,J)
538 DTDT=(THNEW-THOLD)*RDTTURBL
539 QOLD=QV(I,K,J)/(1.+QV(I,K,J))
540 DQDT=(QK(KFLIP)-QOLD)*RDTTURBL
541 DCDT=(CWMK(KFLIP)-CWM(I,K,J))*RDTTURBL
543 RTHBLTEN(I,K,J)=DTDT + RTHBLTEN(I,K,J)
544 RQVBLTEN(I,K,J)=DQDT/(1.-QK(KFLIP))**2 + RQVBLTEN(I,K,J)
545 RQCBLTEN(I,K,J)=DCDT + RQCBLTEN(I,K,J)
549 ! IF(I==IMD.AND.J==JMD)THEN
554 ! IF(I==227.AND.J==363)PRINT_DIAG=0
557 PSFC=.01*PINT(I,LOWLYR(I,J),J)
558 ZSL_DIAG=0.5*DZ(I,1,J)
561 ! IF(PRINT_DIAG==1)THEN
563 ! write(6,"(a, 2i5, 2i3, 2f8.2, f6.2, 2f8.2)") &
564 ! '{turb4 i,j, Kpbl, Kmxl, Psfc, Zsfc, Zsl, Zpbl, Zmxl = ' &
565 ! , i, j, KPBL(i,j), KTE-LMXL+1, PSFC, ZHK(LMH+1), ZSL_diag &
566 ! , PBLH(i,j), ZHK(LMXL)-ZHK(LMH+1)
567 ! write(6,"(a, 2f7.2, f7.3, 3e11.4)") &
568 ! '{turb4 tsk, thsk, qz0, q**2_0, akhs, exch_0 = ' &
569 ! , tsk(i,j)-273.15, thsk(i,j), 1000.*qz0(i,j) &
570 ! , 2.*tke_myj(i,1,j), akhs(i,j), akhs(i,j)*ZSL_diag
572 ! '{turb5 k, Pmid, Pint_1, Tc, TH, DTH, GH, S2, EL, Q**2, Akh, EXCH_h, Dz, Dp'
574 ! KFLIP=KTE-K !-- Includes the KFLIP-1 in earlier versions
575 ! write(6,"(a,i3, 2f8.2, 2f8.3, 3e12.4, 4e11.4, f7.2, f6.2)") &
576 ! '{turb5 ', k, .01*pmid(i,k,j),.01*pint(i,k,j), T(i,k,j)-273.15 &
577 ! , th(i,k,j), DTTURBL*rthblten(i,k,j), GH(KFLIP), S2(KFLIP) &
578 ! , el_myj(i,KFLIP,j), 2.*tke_myj(i,k+1,j), akh(i,KFLIP,j) &
579 ! , exch_h(i,k,j), dz(i,k,j), .01*(pint(i,k,j)-pint(i,k+1,j))
582 ! ELSEIF(PRINT_DIAG==2)THEN
584 ! write(6,"(a, 2i5, 2i3, 2f8.2, f6.2, 2f8.2)") &
585 ! '}turb4 i,j, Kpbl, Kmxl, Psfc, Zsfc, Zsl, Zpbl, Zmxl = ' &
586 ! , i, j, KPBL(i,j), KTE-LMXL+1, PSFC, ZHK(LMH+1), ZSL_diag &
587 ! , PBLH(i,j), ZHK(LMXL)-ZHK(LMH+1)
588 ! write(6,"(a, 2f7.2, f7.3, 3e11.4)") &
589 ! '}turb4 tsk, thsk, qz0, q**2_0, akhs, exch_0 = ' &
590 ! , tsk(i,j)-273.15, thsk(i,j), 1000.*qz0(i,j) &
591 ! , 2.*tke_myj(i,1,j), akhs(i,j), akhs(i,j)*ZSL_diag
593 ! '}turb5 k, Pmid, Pint_1, Tc, TH, DTH, GH, S2, EL, Q**2, Akh, EXCH_h, Dz, Dp'
595 ! KFLIP=KTE-K !-- Includes the KFLIP-1 in earlier versions
596 ! write(6,"(a,i3, 2f8.2, 2f8.3, 3e12.4, 4e11.4, f7.2, f6.2)") &
597 ! '}turb5 ', k, .01*pmid(i,k,j),.01*pint(i,k,j), T(i,k,j)-273.15 &
598 ! , th(i,k,j), DTTURBL*rthblten(i,k,j), GH(KFLIP), S2(KFLIP) &
599 ! , el_myj(i,KFLIP,j), 2.*tke_myj(i,k+1,j), akh(i,KFLIP,j) &
600 ! , exch_h(i,k,j), dz(i,k,j), .01*(pint(i,k,j)-pint(i,k+1,j))
605 !----------------------------------------------------------------------
607 !----------------------------------------------------------------------
610 !*** FILL 1-D VERTICAL ARRAYS
611 !*** AND FLIP DIRECTION SINCE MYJ SCHEME
612 !*** COUNTS DOWNWARD FROM THE DOMAIN'S TOP
616 AKMK(K)=AKMK(K)*(RHOK(K,I)+RHOK(K+1,I))*0.5
620 AKMS_DENS=AKMS(I,J)*RHOK(KTE+1-LLOW,I)
628 ZHK(KTE+1)=ZINT(I,KTE+1,J)
630 !----------------------------------------------------------------------
631 !*** CARRY OUT THE VERTICAL DIFFUSION OF
632 !*** VELOCITY COMPONENTS
633 !----------------------------------------------------------------------
635 CALL VDIFV(LMH,DTDIF,UZ0(I,J),VZ0(I,J) &
636 & ,AKMS_DENS,UK,VK,AKMK,ZHK,RHOK(KTS,I) &
637 & ,IDS,IDE,JDS,JDE,KDS,KDE &
638 & ,IMS,IME,JMS,JME,KMS,KME &
639 & ,ITS,ITE,JTS,JTE,KTS,KTE,I,J)
641 !----------------------------------------------------------------------
643 !*** COMPUTE PRIMARY VARIABLE TENDENCIES
647 DUDT=(UK(KFLIP)-U(I,K,J))*RDTTURBL
648 DVDT=(VK(KFLIP)-V(I,K,J))*RDTTURBL
649 RUBLTEN(I,K,J)=DUDT + RUBLTEN(I,K,J)
650 RVBLTEN(I,K,J)=DVDT + RVBLTEN(I,K,J)
654 !----------------------------------------------------------------------
656 ENDDO main_integration
658 !----------------------------------------------------------------------
660 END SUBROUTINE QNSEPBL
662 !----------------------------------------------------------------------
663 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
664 !----------------------------------------------------------------------
666 !----------------------------------------------------------------------
667 ! ******************************************************************
669 ! * LEVEL 2.5 MIXING LENGTH *
671 ! ******************************************************************
673 &(LMH,U,V,T,THE,Q,CWM,Q2,Z,USTAR,CORF &
674 &,S2,GH,RI,EL,PBLH,LPBL,LMXL,CT,LM_BL89 &
675 &,IDS,IDE,JDS,JDE,KDS,KDE &
676 &,IMS,IME,JMS,JME,KMS,KME &
677 &,ITS,ITE,JTS,JTE,KTS,KTE)
678 !----------------------------------------------------------------------
682 !----------------------------------------------------------------------
683 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
684 & ,IMS,IME,JMS,JME,KMS,KME &
685 & ,ITS,ITE,JTS,JTE,KTS,KTE
687 INTEGER,INTENT(IN) :: LMH
689 INTEGER,INTENT(OUT) :: LMXL,LPBL
691 REAL,DIMENSION(KTS:KTE),INTENT(IN) :: CWM,Q,Q2,T,THE,U,V,LM_BL89
693 REAL,DIMENSION(KTS:KTE+1),INTENT(IN) :: Z
695 REAL,INTENT(OUT) :: PBLH
697 REAL,DIMENSION(KTS:KTE-1),INTENT(OUT) :: EL,RI,GH,S2
699 REAL,INTENT(INOUT) :: CT
701 REAL,INTENT(IN) :: CORF,USTAR
702 !----------------------------------------------------------------------
708 REAL :: A,ADEN,B,BDEN,AUBR,BUBR,BLMX,EL0,ELOQ2X,GHL,S2L &
709 & ,QOL2ST,QOL2UN,QDZL,RDZ,SQ,SREL,SZQ,TEM,THM,VKRMZ,RLAMBDA &
712 REAL,DIMENSION(KTS:KTE) :: Q1,EN2
714 REAL,DIMENSION(KTS:KTE-1) :: DTH,ELM,REL
716 !----------------------------------------------------------------------
717 !**********************************************************************
718 !--------------FIND THE HEIGHT OF THE PBL-------------------------------
722 IF(Q2(K)<=EPSQ2L*FH)THEN
730 !--------------THE HEIGHT OF THE PBL------------------------------------
732 110 PBLH=Z(LPBL)-Z(LMH+1)
734 !-----------------------------------------------------------------------
740 DTH(K)=THE(K)-THE(K+1)
744 IF(DTH(K)>0..AND.DTH(K+1)<=0.)THEN
751 !----------------------------------------------------------------------
752 !*** COMPUTE LOCAL GRADIENT RICHARDSON NUMBER
753 !----------------------------------------------------------------------
756 S2L=((U(K)-U(K+1))**2+(V(K)-V(K+1))**2)*RDZ*RDZ ! S**2
760 TEM=(T(K)+T(K+1))*0.5
761 THM=(THE(K)+THE(K+1))*0.5
764 B=(ELOCP/TEM-1.-P608)*THM
766 GHL=(DTH(K)*((Q(K)+Q(K+1)+CWM(K)+CWM(K+1))*(0.5*P608)+1.) &
767 & +(Q(K)-Q(K+1)+CWM(K)-CWM(K+1))*A &
768 & +(CWM(K)-CWM(K+1))*B)*RDZ ! dTheta/dz
770 IF(ABS(GHL)<=EPSGH)GHL=EPSGH
772 EN2(K)=GHL*G/THM ! N**2
778 !----------------------------------------------------------------------
779 !*** FIND MAXIMUM MIXING LENGTHS AND THE LEVEL OF THE PBL TOP
780 !----------------------------------------------------------------------
789 IF(S2L/GHL<=REQU)THEN
793 AUBR=(AUBM*S2L+AUBH*GHL)*GHL
794 BUBR= BUBM*S2L+BUBH*GHL
795 QOL2ST=(-0.5*BUBR+SQRT(BUBR*BUBR*0.25-AUBR*CUBR))*RCUBR
797 ELM(K)=MAX(SQRT(ELOQ2X*Q2(K)),EPSL)
800 ADEN=(ADNM*S2L+ADNH*GHL)*GHL
801 BDEN= BDNM*S2L+BDNH*GHL
802 QOL2UN=-0.5*BDEN+SQRT(BDEN*BDEN*0.25-ADEN)
803 ELOQ2X=1./(QOL2UN+EPSRU) ! repsr1/qol2un
804 ELM(K)=MAX(SQRT(ELOQ2X*Q2(K)),EPSL)
808 IF(ELM(LMH-1)==EPSL)LMXL=LMH
810 !----------------------------------------------------------------------
811 !*** THE HEIGHT OF THE MIXED LAYER
812 !----------------------------------------------------------------------
814 BLMX=Z(LMXL)-Z(LMH+1)
816 !----------------------------------------------------------------------
820 !----------------------------------------------------------------------
825 QDZL=(Q1(K)+Q1(K+1))*(Z(K+1)-Z(K+2))
826 SZQ=(Z(K+1)+Z(K+2)-Z(LMH+1)-Z(LMH+1))*QDZL+SZQ
830 !----------------------------------------------------------------------
831 !*** COMPUTATION OF ASYMPTOTIC L IN BLACKADAR FORMULA
832 !----------------------------------------------------------------------
834 EL0=MIN(ALPH*SZQ*0.5/SQ,EL0MAX)
837 !----------------------------------------------------------------------
838 !*** ABOVE THE PBL TOP
839 !----------------------------------------------------------------------
844 EL(K)=MIN((Z(K)-Z(K+2))*ELFC,ELM(K))
848 !----------------------------------------------------------------------
850 !----------------------------------------------------------------------
854 VKRMZ=(Z(K+1)-Z(LMH+1))*VKARMAN
855 EL(K)=MIN(VKRMZ/(VKRMZ/EL0+1.),ELM(K))
861 SREL=MIN(((REL(K-1)+REL(K+1))*0.5+REL(K))*0.5,REL(K))
862 EL(K)=MAX(SREL*ELM(K),EPSL)
865 !----------------------------------------------------------------------
866 !*** MIXING LENGTH FOR THE QNSE MODEL IN STABLE CASE
867 !----------------------------------------------------------------------
870 RLAMBDA=F/(BLCKDR*USTAR)
872 IF(EN2(K)>=0.0)THEN ! Stable case
873 VKRMZ=(Z(K+1)-Z(LMH+1))*VKARMAN
875 RLN=SQRT(2.*EN2(K)/Q2(K))/CN
876 ! EL(K)=MIN(1./(RLB+RLN),ELM(K))
881 !----------------------------------------------------------------------
882 END SUBROUTINE MIXLEN
883 !----------------------------------------------------------------------
884 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
885 !----------------------------------------------------------------------
887 !----------------------------------------------------------------------
888 ! ******************************************************************
890 ! * LEVEL 2.5 Q2 PRODUCTION/DISSIPATION *
892 ! ******************************************************************
894 &(LMH,DTTURBL,USTAR,S2,RI,Q2,EL,Z,AKM,AKH,WTHV_MF &
895 &,IDS,IDE,JDS,JDE,KDS,KDE &
896 &,IMS,IME,JMS,JME,KMS,KME &
897 &,ITS,ITE,JTS,JTE,KTS,KTE)
898 !----------------------------------------------------------------------
902 !----------------------------------------------------------------------
903 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
904 & ,IMS,IME,JMS,JME,KMS,KME &
905 & ,ITS,ITE,JTS,JTE,KTS,KTE
907 INTEGER,INTENT(IN) :: LMH
909 REAL,INTENT(IN) :: DTTURBL,USTAR
911 REAL,DIMENSION(KTS:KTE-1),INTENT(IN) :: S2,RI,AKM,AKH,EL
913 REAL,DIMENSION(KTS:KTE+1),INTENT(IN) :: Z
916 REAL,DIMENSION(KTS:KTE),INTENT(IN) :: WTHV_MF
918 REAL,DIMENSION(KTS:KTE),INTENT(INOUT) :: Q2
920 !----------------------------------------------------------------------
926 REAL :: S2L,Q2L,DELTAZ,AKML,AKHL,EN2,PR,BPR,DIS,RC02
928 !----------------------------------------------------------------------
929 !**********************************************************************
930 !----------------------------------------------------------------------
933 main_integration: DO K=1,LMH-1
936 DELTAZ=0.5*(Z(K)-Z(K+2))
941 !*** TURBULENCE PRODUCTION TERM
945 !*** BUOYANCY PRODUCTION
951 DIS=CEPS*(0.5*Q2L)**1.5/EL(K)
953 Q2L=Q2L+2.0*(PR-BPR-DIS)*DTTURBL
954 Q2(K)=AMAX1(Q2L,EPSQ2L)
955 !----------------------------------------------------------------------
956 !*** END OF PRODUCTION/DISSIPATION LOOP
957 !----------------------------------------------------------------------
959 ENDDO main_integration
961 !----------------------------------------------------------------------
962 !*** LOWER BOUNDARY CONDITION FOR Q2
963 !----------------------------------------------------------------------
965 Q2(LMH)=AMAX1(RC02*USTAR*USTAR,EPSQ2L)
966 !----------------------------------------------------------------------
968 END SUBROUTINE PRODQ2
970 !----------------------------------------------------------------------
971 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
972 !----------------------------------------------------------------------
974 ! ******************************************************************
976 ! * DIFFUSION COEFFICIENTS KM, KH BASED ON THE QNSE THEORY *
978 ! ******************************************************************
979 &(LMH,EL,RI,Q2,Z,AKM,AKH &
980 &,IDS,IDE,JDS,JDE,KDS,KDE &
981 &,IMS,IME,JMS,JME,KMS,KME &
982 &,ITS,ITE,JTS,JTE,KTS,KTE,PRINT_DIAG) ! debug
983 !----------------------------------------------------------------------
987 !----------------------------------------------------------------------
988 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
989 & ,IMS,IME,JMS,JME,KMS,KME &
990 & ,ITS,ITE,JTS,JTE,KTS,KTE
992 INTEGER,INTENT(IN) :: LMH
994 REAL,DIMENSION(KTS:KTE),INTENT(IN) :: Q2
995 REAL,DIMENSION(KTS:KTE-1),INTENT(IN) :: EL,RI
996 REAL,DIMENSION(KTS:KTE+1),INTENT(IN) :: Z
998 REAL,DIMENSION(KTS:KTE-1),INTENT(OUT) :: AKH,AKM
999 !----------------------------------------------------------------------
1001 !*** LOCAL VARIABLES
1005 REAL :: AK0,ALPHAM,ALPHAH,RIL,RIL2,ARIL,ARIL2,ARIL4,ELL,Q1L,RDZ &
1008 !*** Begin debugging
1009 INTEGER,INTENT(IN) :: PRINT_DIAG
1013 !----------------------------------------------------------------------
1014 !**********************************************************************
1015 !----------------------------------------------------------------------
1019 Q1L=SQRT(0.5*Q2(K)) !Note that Q1L is SQRT(TKE)
1021 AK0=C0*ELL*Q1L !KM in neutral case
1023 !----------------------------------------------------------------------
1024 !*** STABILITY FUNCTIONS ALPHAM AND ALPHAH
1025 !----------------------------------------------------------------------
1030 ARIL=MIN(ABS(RIL),2.*ARIMIN)
1033 ALPHAM=1.0+BM1*ARIL+BM2*ARIL2
1034 ALPHAH=AH1+BH1*ARIL+BH2*ARIL2+BH3*ARIL4
1040 ALPHAM=(1.0+AM1*RIL2)/(1.0+AM2*RIL+AM3*RIL2)
1041 ALPHAH=(AH1+AH2*RIL+AH3*RIL2)/(1.0+AH4*RIL+AH5*RIL2)
1044 !-----------------------------------------------------------------------
1045 !*** END OF STABILITY FUNCTIONS COMPUTATIONS
1046 !-----------------------------------------------------------------------
1048 !----------------------------------------------------------------------
1049 !*** DIFFUSION COEFFICIENTS
1050 !----------------------------------------------------------------------
1052 RDZ=2./(Z(K)-Z(K+2))
1055 AKM(K)=MAX(AK0DZ*ALPHAM,AKMIN)
1056 AKH(K)=MAX(AK0DZ*ALPHAH,AKMIN)
1057 !----------------------------------------------------------------------
1059 !----------------------------------------------------------------------
1061 END SUBROUTINE DIFCOF
1063 !----------------------------------------------------------------------
1064 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1065 !----------------------------------------------------------------------
1067 ! ******************************************************************
1069 ! * VERTICAL DIFFUSION OF Q2 (TKE) *
1071 ! ******************************************************************
1072 &(LMH,DTDIF,Q2,EL,Z &
1073 &,IDS,IDE,JDS,JDE,KDS,KDE &
1074 &,IMS,IME,JMS,JME,KMS,KME &
1075 &,ITS,ITE,JTS,JTE,KTS,KTE)
1076 !----------------------------------------------------------------------
1080 !----------------------------------------------------------------------
1081 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
1082 & ,IMS,IME,JMS,JME,KMS,KME &
1083 & ,ITS,ITE,JTS,JTE,KTS,KTE
1085 INTEGER,INTENT(IN) :: LMH
1087 REAL,INTENT(IN) :: DTDIF
1089 REAL,DIMENSION(KTS:KTE-1),INTENT(IN) :: EL
1090 REAL,DIMENSION(KTS:KTE+1),INTENT(IN) :: Z
1092 REAL,DIMENSION(KTS:KTE),INTENT(INOUT) :: Q2
1093 !----------------------------------------------------------------------
1095 !*** LOCAL VARIABLES
1099 REAL :: ADEN,AKQS,BDEN,BESH,BESM,CDEN,CF,DTOZS,ELL,ELOQ2,ELOQ4 &
1100 & ,ELQDZ,ESH,ESM,ESQHF,GHL,GML,Q1L,RDEN,RDZ
1102 REAL,DIMENSION(KTS:KTE-2) :: AKQ,CM,CR,DTOZ,RSQ2
1103 !----------------------------------------------------------------------
1104 !**********************************************************************
1105 !----------------------------------------------------------------------
1107 !*** VERTICAL TURBULENT DIFFUSION
1109 !----------------------------------------------------------------------
1113 DTOZ(K)=(DTDIF+DTDIF)/(Z(K)-Z(K+2))
1114 AKQ(K)=SQRT((Q2(K)+Q2(K+1))*0.5)*(EL(K)+EL(K+1))*ESQHF &
1116 CR(K)=-DTOZ(K)*AKQ(K)
1119 CM(1)=DTOZ(1)*AKQ(1)+1.
1123 CF=-DTOZ(K)*AKQ(K-1)/CM(K-1)
1124 CM(K)=-CR(K-1)*CF+(AKQ(K-1)+AKQ(K))*DTOZ(K)+1.
1125 RSQ2(K)=-RSQ2(K-1)*CF+Q2(K)
1128 DTOZS=(DTDIF+DTDIF)/(Z(LMH-1)-Z(LMH+1))
1129 AKQS=SQRT((Q2(LMH-1)+Q2(LMH))*0.5)*(EL(LMH-1)+ELZ0)*ESQHF &
1130 & /(Z(LMH)-Z(LMH+1))
1132 CF=-DTOZS*AKQ(LMH-2)/CM(LMH-2)
1134 Q2(LMH-1)=(DTOZS*AKQS*Q2(LMH)-RSQ2(LMH-2)*CF+Q2(LMH-1)) &
1135 & /((AKQ(LMH-2)+AKQS)*DTOZS-CR(LMH-2)*CF+1.)
1138 Q2(K)=(-CR(K)*Q2(K+1)+RSQ2(K))/CM(K)
1140 !----------------------------------------------------------------------
1142 END SUBROUTINE VDIFQ
1144 !----------------------------------------------------------------------
1145 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1146 !---------------------------------------------------------------------
1147 SUBROUTINE VDIFH(DTDIF,LMH,THZ0,QZ0,RKHS,CHKLOWQ,CT &
1148 & ,THE,Q,CWM,RKH,Z,RHO &
1149 & ,IDS,IDE,JDS,JDE,KDS,KDE &
1150 & ,IMS,IME,JMS,JME,KMS,KME &
1151 & ,ITS,ITE,JTS,JTE,KTS,KTE,I,J)
1152 ! ***************************************************************
1154 ! * VERTICAL DIFFUSION OF MASS VARIABLES *
1156 ! ***************************************************************
1157 !---------------------------------------------------------------------
1161 !---------------------------------------------------------------------
1162 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
1163 & ,IMS,IME,JMS,JME,KMS,KME &
1164 & ,ITS,ITE,JTS,JTE,KTS,KTE,I,J
1166 INTEGER,INTENT(IN) :: LMH
1168 REAL,INTENT(IN) :: CHKLOWQ,CT,DTDIF,QZ0,RKHS,THZ0
1170 REAL,DIMENSION(KTS:KTE-1),INTENT(IN) :: RKH
1171 REAL,DIMENSION(KTS:KTE),INTENT(IN) :: RHO
1172 REAL,DIMENSION(KTS:KTE+1),INTENT(IN) :: Z
1173 REAL,DIMENSION(KTS:KTE),INTENT(INOUT) :: CWM,Q,THE
1175 !----------------------------------------------------------------------
1177 !*** LOCAL VARIABLES
1181 REAL :: CF,CMB,CMCB,CMQB,CMTB,CTHF,DTOZL,DTOZS &
1182 & ,RCML,RKHH,RKQS,RSCB,RSQB,RSTB
1184 REAL,DIMENSION(KTS:KTE-1) :: CM,CR,DTOZ,RKCT,RSC,RSQ,RST
1186 !----------------------------------------------------------------------
1187 !**********************************************************************
1188 !----------------------------------------------------------------------
1192 DTOZ(K)=DTDIF/(Z(K)-Z(K+1))
1193 CR(K)=-DTOZ(K)*RKH(K)
1194 RKCT(K)=RKH(K)*(Z(K)-Z(K+2))*CTHF
1197 CM(KTS)=DTOZ(KTS)*RKH(KTS)+RHO(KTS)
1198 !----------------------------------------------------------------------
1199 RST(KTS)=-RKCT(KTS)*DTOZ(KTS) &
1200 & +THE(KTS)*RHO(KTS)
1201 RSQ(KTS)=Q(KTS) *RHO(KTS)
1202 RSC(KTS)=CWM(KTS)*RHO(KTS)
1203 !----------------------------------------------------------------------
1206 CF=-DTOZL*RKH(K-1)/CM(K-1)
1207 CM(K)=-CR(K-1)*CF+(RKH(K-1)+RKH(K))*DTOZL+RHO(K)
1208 RST(K)=-RST(K-1)*CF+(RKCT(K-1)-RKCT(K))*DTOZL+THE(K)*RHO(K)
1209 RSQ(K)=-RSQ(K-1)*CF+Q(K) *RHO(K)
1210 RSC(K)=-RSC(K-1)*CF+CWM(K)*RHO(K)
1213 DTOZS=DTDIF/(Z(LMH)-Z(LMH+1))
1216 CF=-DTOZS*RKHH/CM(LMH-1)
1220 CMTB=-CMB+(RKHH+RKHS)*DTOZS+RHO(LMH)
1221 CMQB=-CMB+(RKHH+RKQS)*DTOZS+RHO(LMH)
1222 CMCB=-CMB+(RKHH )*DTOZS+RHO(LMH)
1224 RSTB=-RST(LMH-1)*CF+RKCT(LMH-1)*DTOZS+THE(LMH)*RHO(LMH)
1225 RSQB=-RSQ(LMH-1)*CF+Q(LMH) *RHO(LMH)
1226 RSCB=-RSC(LMH-1)*CF+CWM(LMH)*RHO(LMH)
1227 !----------------------------------------------------------------------
1228 THE(LMH)=(DTOZS*RKHS*THZ0+RSTB)/CMTB
1229 Q(LMH) =(DTOZS*RKQS*QZ0 +RSQB)/CMQB
1230 CWM(LMH)=( RSCB)/CMCB
1231 !----------------------------------------------------------------------
1234 THE(K)=(-CR(K)*THE(K+1)+RST(K))*RCML
1235 Q(K) =(-CR(K)* Q(K+1)+RSQ(K))*RCML
1236 CWM(K)=(-CR(K)*CWM(K+1)+RSC(K))*RCML
1238 !----------------------------------------------------------------------
1240 END SUBROUTINE VDIFH
1242 !---------------------------------------------------------------------
1243 !XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1244 !---------------------------------------------------------------------
1245 SUBROUTINE VDIFV(LMH,DTDIF,UZ0,VZ0,RKMS,U,V,RKM,Z,RHO &
1246 & ,IDS,IDE,JDS,JDE,KDS,KDE &
1247 & ,IMS,IME,JMS,JME,KMS,KME &
1248 ,ITS,ITE,JTS,JTE,KTS,KTE,I,J)
1249 ! ***************************************************************
1251 ! * VERTICAL DIFFUSION OF VELOCITY COMPONENTS *
1253 ! ***************************************************************
1254 !---------------------------------------------------------------------
1258 !---------------------------------------------------------------------
1259 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
1260 & ,IMS,IME,JMS,JME,KMS,KME &
1261 & ,ITS,ITE,JTS,JTE,KTS,KTE,I,J
1263 INTEGER,INTENT(IN) :: LMH
1265 REAL,INTENT(IN) :: RKMS,DTDIF,UZ0,VZ0
1267 REAL,DIMENSION(KTS:KTE-1),INTENT(IN) :: RKM
1268 REAL,DIMENSION(KTS:KTE),INTENT(IN) :: RHO
1269 REAL,DIMENSION(KTS:KTE+1),INTENT(IN) :: Z
1271 REAL,DIMENSION(KTS:KTE),INTENT(INOUT) :: U,V
1272 !----------------------------------------------------------------------
1274 !*** LOCAL VARIABLES
1278 REAL :: CF,DTOZAK,DTOZL,DTOZS,RCML,RCMVB,RHOK,RKMH
1280 REAL,DIMENSION(KTS:KTE-1) :: CM,CR,DTOZ,RSU,RSV
1281 !----------------------------------------------------------------------
1282 !**********************************************************************
1283 !----------------------------------------------------------------------
1285 DTOZ(K)=DTDIF/(Z(K)-Z(K+1))
1286 CR(K)=-DTOZ(K)*RKM(K)
1290 CM(1)=DTOZ(1)*RKM(1)+RHOK
1293 !----------------------------------------------------------------------
1296 CF=-DTOZL*RKM(K-1)/CM(K-1)
1298 CM(K)=-CR(K-1)*CF+(RKM(K-1)+RKM(K))*DTOZL+RHOK
1299 RSU(K)=-RSU(K-1)*CF+U(K)*RHOK
1300 RSV(K)=-RSV(K-1)*CF+V(K)*RHOK
1302 !----------------------------------------------------------------------
1303 DTOZS=DTDIF/(Z(LMH)-Z(LMH+1))
1306 CF=-DTOZS*RKMH/CM(LMH-1)
1308 RCMVB=1./((RKMH+RKMS)*DTOZS-CR(LMH-1)*CF+RHOK)
1310 !----------------------------------------------------------------------
1311 U(LMH)=(DTOZAK*UZ0-RSU(LMH-1)*CF+U(LMH)*RHOK)*RCMVB
1312 V(LMH)=(DTOZAK*VZ0-RSV(LMH-1)*CF+V(LMH)*RHOK)*RCMVB
1313 !----------------------------------------------------------------------
1316 U(K)=(-CR(K)*U(K+1)+RSU(K))*RCML
1317 V(K)=(-CR(K)*V(K+1)+RSV(K))*RCML
1319 !----------------------------------------------------------------------
1321 END SUBROUTINE VDIFV
1323 !-----------------------------------------------------------------------
1325 !=======================================================================
1326 SUBROUTINE QNSEPBLINIT(RUBLTEN,RVBLTEN,RTHBLTEN,RQVBLTEN, &
1327 & TKE,EXCH_H,RESTART,ALLOWED_TO_READ, &
1328 & IDS,IDE,JDS,JDE,KDS,KDE, &
1329 & IMS,IME,JMS,JME,KMS,KME, &
1330 & ITS,ITE,JTS,JTE,KTS,KTE )
1331 !-----------------------------------------------------------------------
1333 !-----------------------------------------------------------------------
1334 LOGICAL,INTENT(IN) :: ALLOWED_TO_READ,RESTART
1335 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE, &
1336 & IMS,IME,JMS,JME,KMS,KME, &
1337 & ITS,ITE,JTS,JTE,KTS,KTE
1339 REAL,DIMENSION(IMS:IME,KMS:KME,JMS:JME),INTENT(OUT) :: EXCH_H, &
1345 INTEGER :: I,J,K,ITF,JTF,KTF
1346 !-----------------------------------------------------------------------
1347 !-----------------------------------------------------------------------
1353 IF(.NOT.RESTART)THEN
1368 END SUBROUTINE QNSEPBLINIT
1369 !-----------------------------------------------------------------------
1371 END MODULE MODULE_BL_QNSEPBL
1373 !-----------------------------------------------------------------------