UPP  001
 All Data Structures Files Functions Pages
MIXLEN.f
1  SUBROUTINE mixlen(EL0,EL)
2 !
3 ! CALCULATES LAYER-AVERAGED BLACKADAR'S MIXING LENGTH, AND PBL TOP
4 ! AS CPBLT*(ASYMPTOTIC EL); AND THEN EL, ACCOUNT TAKEN OF STABILITY,
5 ! PBL TOP AND VERTICAL GRID DISTANCE RESTRICTIONS (SEE BELOW)
6 !
7 ! SET FROM EXISTING CODES BY L. LOBOCKI, JUNE 5, 1992
8 ! MODIFIED BY FEDOR MESINGER, OCTOBER 13, NOVEMBER 19
9 ! MODIFIED BY JIM TUCCILLO FOR MPI IMPLEMENTATION
10 ! 01-10-25 H CHUANG - MODIFIED TO PROCESS HYBRID MODEL OUTPUT
11 ! 02-06-19 MIKE BALDWIN - WRF VERSION
12 ! 21-03-11 B Cui - change local arrays to dimension (im,jsta:jend)
13 !
14 !
15 ! INPUT:
16 ! ------
17 !
18 ! ZINT (IM,jsta_2l:jend_2u,LP1) - ETA INTERFACES HEIGHT FIELD
19 ! T (IM,jsta_2l:jend_2u,LM) - TEMPERATURE
20 ! PMID (IM,jsta_2l:jend_2u,LM) - PRESSURE IN LAYERS
21 ! Q2 (IM,jsta_2l:jend_2u,LM) - TURBULENCE KINETIC ENERGY * 2
22 ! HGT (IM,jsta_2l:jend_2u) - SURFACE ELEVATION ARRAY
23 ! HTM (IM,jsta_2l:jend_2u,LM) - HEIGHT TOPOGRAPHY MASK ARRAY
24 ! EL0 (IM,JM) - ARRAY OF ASYMPTOTIC VALUES FOR MIXING LENGTH
25 !
26 ! OUTPUT:
27 ! -------
28 !
29 ! EL (IM,jsta_2l:jend_2u,LM) - FIELD OF RESULTING MASTER LENGTH SCALES
30 !
31 !
32 ! SCRATCH AREAS:
33 ! --------------
34 !
35 ! VKRMZ(IM,JM)
36 !
37 ! RELEVANT CONSTANTS:
38 ! -------------------
39 !
40 ! VON KARMAN CONSTANT:
41  use vrbls3d, only: zint, pmid, t, q2
42  use masks, only: lmh, htm
43  use params_mod, only: epsq2, capa
44  use ctlblk_mod, only: jsta, jend, jsta_m, jend_m, im, jm, jsta_2l, jend_2u,&
45  lm, lm1, spval
46 
47 !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
48  implicit none
49 !
50  real,PARAMETER :: vkrm=0.4
51 ! CONSTANTS NEEDED FOR THE EL(BL,ST,ZI) SCHEME:
52  real,PARAMETER :: frg=4.*9.8,drdrff=0.54,cpblt=10., &
53  csh=0.23*0.5, epsn2=1.e-7
54 !
55 ! ------------------------------------------------------------------
56 !
57  real,intent(in) :: el0(im,jsta_2l:jend_2u)
58  real,intent(out) :: el(im,jsta_2l:jend_2u,lm)
59  real hgt(im,jsta:jend),ape(im,jsta_m:jend_m,2)
60 !
61  integer i,j,l
62  real zl,vkrmz,ensq,q2kl,elst,ziag,elvgd
63 
64 !***********************************************************************
65 !
66 !$omp parallel do
67  DO l=1,lm
68  DO j=jsta,jend
69  DO i=1,im
70  el(i,j,l)=0.
71  ENDDO
72  ENDDO
73  ENDDO
74  DO j=jsta,jend
75  DO i=1,im
76  hgt(i,j)=zint(i,j,nint(lmh(i,j))+1)
77  ENDDO
78  ENDDO
79 !
80 !---THE AVERAGE EL SCHEME---------------------------(FM, AUGUST 19 MEMO)
81 ! FIRST GET EL IN THE LAYERS
82 !
83 !$omp parallel do private(i,j,l,vkrmz,zl)
84  DO l=1,lm
85  DO j=jsta,jend
86  DO i=1,im
87  IF(hgt(i,j)<spval)THEN
88  zl = 0.5*(zint(i,j,l)+zint(i,j,l+1))
89  vkrmz = (zl-hgt(i,j))*vkrm
90  el(i,j,l) = el0(i,j)*vkrmz/(el0(i,j)+vkrmz)
91  ELSE
92  el(i,j,l) = spval
93  ENDIF
94  ENDDO
95  ENDDO
96  ENDDO
97 !***
98 !*** GET NOW THE INTERFACE EL BY TWO-POINT AVERAGING OF LAYER VALUES
99 !***
100  DO l=1,lm1
101 !$omp parallel do private(i,j)
102  DO j=jsta,jend
103  DO i=1,im
104  IF(hgt(i,j)<spval)THEN
105  el(i,j,l) = 0.5*(el(i,j,l)+el(i,j,l+1))*htm(i,j,l+1)
106  ELSE
107  el(i,j,l) = spval
108  ENDIF
109  ENDDO
110  ENDDO
111  ENDDO
112 !
113 !$omp parallel do private(i,j)
114  DO j=jsta,jend
115  DO i=1,im
116  IF(hgt(i,j)<spval)THEN
117  el(i,j,lm) = 0.0
118  ELSE
119  el(i,j,lm) = spval
120  ENDIF
121  ENDDO
122  ENDDO
123 !---STABILITY, PBL TOP, AND VERTICAL GRID DISTANCE RESTRICTIONS:--------
124 ! COMPUTE EL STABLE AND
125 ! * USE THE SMALLER OF EL BLACKADAR, EL STABLE IF WITHIN PBL;
126 ! * USE THE SMALLEST OF EL STABLE, ELVGD, AND VKRMZ IF ABOVE PBL
127 ! (ASSUME PBL TOP IS AT CPBLT*EL0(K));
128 !$omp parallel do private(i,j)
129  DO j=jsta_m,jend_m
130  DO i=1,im
131  ape(i,j,1) = (1.e5/pmid(i,j,1))**capa
132  ENDDO
133  ENDDO
134 !
135  DO l=1,lm1
136 !$omp parallel do private(i,j,elst,elvgd,ensq,q2kl,ziag)
137  DO j=jsta_m,jend_m
138  DO i=2,im-1
139  IF(t(i,j,l)<spval)THEN
140  ape(i,j,2) = (1.e5/pmid(i,j,l+1))**capa
141  ensq = htm(i,j,l+1)* &
142  frg*(t(i,j,l)*ape(i,j,1)-t(i,j,l+1)*ape(i,j,2))/ &
143  ((t(i,j,l)*ape(i,j,1)+t(i,j,l+1)*ape(i,j,2))* &
144  (zint(i,j,l)-zint(i,j,l+2))+epsn2)
145  ensq = amax1(ensq,epsn2)
146  q2kl = amax1(epsq2,q2(i,j,l))
147  elst = drdrff*sqrt(q2kl/ensq)
148 !WAS ELST = DRDRFF*SQRT(Q2(I,J,L)/ENSQ)
149  ziag = zint(i,j,l+1)-hgt(i,j)
150 !
151  IF(ziag < cpblt*el0(i,j))THEN
152  el(i,j,l) = amin1(el(i,j,l),elst)
153  ELSE
154  elvgd = csh*(zint(i,j,l)-zint(i,j,l+2))
155  el(i,j,l) = amin1(elst,elvgd,vkrm*ziag)
156  ENDIF
157  ape(i,j,1) = ape(i,j,2)
158  ELSE
159  el(i,j,l) = spval
160  ENDIF
161  ENDDO
162  ENDDO
163  ENDDO
164 !
165  RETURN
166  END
167 
Definition: MASKS_mod.f:1