PHYEX 0.9.5
PHYsique EXternalisée
Loading...
Searching...
No Matches
mode_compute_bl89_ml.F90
Go to the documentation of this file.
2IMPLICIT NONE
3CONTAINS
4! ######spl
5 SUBROUTINE compute_bl89_ml(D, CST, CSTURB,PDZZ2D, &
6 PTKEM_DEP,PG_O_THVREF,PVPT,KK,OUPORDN,OFLUX,PSHEAR,PLWORK)
7
8 USE yomhook , ONLY : lhook, dr_hook, jphook
9
10!$ACDC singlecolumn
11
12! ###################################################################
13!!
14!! COMPUTE_BL89_ML routine to:
15!! 1/ compute upward or downward mixing length with BL89 formulation
16!!
17!! AUTHOR
18!! ------
19!! J. PERGAUD
20!!
21!! MODIFICATIONS
22!! -------------
23!! Original 19/01/06
24!! S. Riette Jan 2012: support for both order of vertical levels and cleaning
25!! R.Honnert Oct 2016 : Update with AROME
26!! Q.Rodier 01/2019 : support RM17 mixing length as in bl89.f90
27! P. Wautelet 10/04/2019: replace ABORT and STOP calls by Print_msg
28! P. Wautelet 17/12/2021: bugfix: KK instead of JKK
29!!
30!-------------------------------------------------------------------------------
31!
32!* 0. DECLARATIONS
33!
34! ------------
35!
36!!!!!!!!!!!!
37!!!!!!!!!!!!
38!!!!!!!!!!!!!!!!!! WARNING !!
39!!!!!!!!!!!!
40!!!!!!!!!!!!
41!Any modification done to this routine must be copied in bl89.f90.
42!This routine was inlined in bl89 for numerical performance reasons
43!but algorithm must remain the same.
44!!!!!!!!!!!!
45!
47USE modd_cst, ONLY: cst_t
48USE modd_cturb, ONLY: csturb_t
49!
50USE mode_msg, ONLY: print_msg
51!
53USE modd_io, ONLY:nverb_fatal
54!
55IMPLICIT NONE
56!
57! 0.1 arguments
58!
59TYPE(dimphyex_t), INTENT(IN) :: D
60TYPE(cst_t), INTENT(IN) :: CST
61TYPE(csturb_t), INTENT(IN) :: CSTURB
62REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PDZZ2D ! height difference between two mass levels
63REAL, DIMENSION(D%NIJT), INTENT(IN) :: PTKEM_DEP ! TKE to consume
64REAL, DIMENSION(D%NIJT), INTENT(IN) :: PG_O_THVREF ! g/ThetaVRef at the departure point
65REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PVPT ! ThetaV on mass levels
66INTEGER, INTENT(IN) :: KK ! index of departure level
67LOGICAL, INTENT(IN) :: OUPORDN ! switch to compute upward (true) or
68 ! downward (false) mixing length
69LOGICAL, INTENT(IN) :: OFLUX ! Computation must be done from flux level
70REAL, DIMENSION(D%NIJT), INTENT(OUT) :: PLWORK ! Resulting mixing length
71REAL, DIMENSION(D%NIJT,D%NKT), INTENT(IN) :: PSHEAR ! vertical wind shear for RM17 mixing length
72
73! 0.2 Local variable
74!
75REAL, DIMENSION(D%NIJT) :: ZLWORK1,ZLWORK2 ! Temporary mixing length
76REAL, DIMENSION(D%NIJT) :: ZINTE,ZPOTE ! TKE and potential energy
77 ! between 2 levels
78REAL, DIMENSION(D%NIJT) :: ZVPT_DEP ! Thetav on departure point
79!
80REAL, DIMENSION(D%NIJT,D%NKT) :: ZDELTVPT,ZHLVPT
81 !Virtual Potential Temp at Half level and DeltaThv between
82 !2 mass levels
83
84INTEGER :: JKK !loop counters
85INTEGER :: JIJ, JK
86INTEGER :: IIJB,IIJE ! physical horizontal domain indices
87INTEGER :: IKT,IKB,IKA,IKE,IKL
88REAL :: ZTEST,ZTEST0,ZTESTM !test for vectorization
89!-------------------------------------------------------------------------------------
90!
91!* 1. INITIALISATION
92! --------------
93REAL(KIND=jphook) :: zhook_handle
94IF (lhook) CALL dr_hook('COMPUTE_BL89_ML',0,zhook_handle)
95!
96iije=d%NIJE
97iijb=d%NIJB
98ikt=d%NKT
99ikb=d%NKB
100ika=d%NKA
101ike=d%NKE
102ikl=d%NKL
103!
104CALL dzm_mf(d, pvpt, zdeltvpt)
105zdeltvpt(iijb:iije,ika)=0.
106!$mnh_expand_where(JIJ=IIJB:IIJE,JK=1:IKT)
107WHERE (abs(zdeltvpt(iijb:iije,1:ikt))<csturb%XLINF)
108 zdeltvpt(iijb:iije,1:ikt)=csturb%XLINF
109END WHERE
110!$mnh_end_expand_where(JIJ=IIJB:IIJE,JK=1:IKT)
111!
112CALL mzm_mf(d, pvpt, zhlvpt)
113!
114!We consider that gradient between mass levels KKB and KKB+KKL is the same as
115!the gradient between flux level KKB and mass level KKB
116!$mnh_expand_array(JIJ=IIJB:IIJE)
117zdeltvpt(iijb:iije,ikb)=pdzz2d(iijb:iije,ikb)*zdeltvpt(iijb:iije,ikb+ikl)/pdzz2d(iijb:iije,ikb+ikl)
118zhlvpt(iijb:iije,ikb)=pvpt(iijb:iije,ikb)-zdeltvpt(iijb:iije,ikb)*0.5
119!$mnh_end_expand_array(JIJ=IIJB:IIJE)
120!
121!
122!
123!* 2. CALCULATION OF THE UPWARD MIXING LENGTH
124! ---------------------------------------
125!
126
127IF (oupordn.EQV..true.) THEN
128 !$mnh_expand_array(JIJ=IIJB:IIJE)
129 zinte(iijb:iije)=ptkem_dep(iijb:iije)
130 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
131 plwork=0.
132 ztestm=1.
133 IF(oflux)THEN
134 !$mnh_expand_array(JIJ=IIJB:IIJE)
135 zvpt_dep(iijb:iije)=zhlvpt(iijb:iije,kk) ! departure point is on flux level
136 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
137 !We must compute what happens between flux level KK and mass level KK
138 DO jij=iijb,iije
139 ztest0=0.5+sign(0.5,zinte(jij)) ! test if there's energy to consume
140 ! Energy consumed if parcel cross the entire layer
141 zpote(jij) = ztest0*(pg_o_thvref(jij) * &
142 (0.5*(zhlvpt(jij,kk)+ pvpt(jij,kk)) - zvpt_dep(jij)) + &
143 csturb%XRM17*pshear(jij,kk)*sqrt(abs(ptkem_dep(jij)))) * &
144 pdzz2d(jij,kk)*0.5
145 ! Test if it rests some energy to consume
146 ztest =0.5+sign(0.5,zinte(jij)-zpote(jij))
147 ! Length travelled by parcel if it rests energy to consume
148 zlwork1(jij)=pdzz2d(jij,kk)*0.5
149 ! Lenght travelled by parcel to nullify energy
150 zlwork2(jij)= ( - pg_o_thvref(jij) * &
151 ( zhlvpt(jij,kk) - zvpt_dep(jij) ) &
152 - csturb%XRM17*pshear(jij,kk)*sqrt(abs(ptkem_dep(jij))) &
153 + sqrt(abs( &
154 (csturb%XRM17*pshear(jij,kk)*sqrt(abs(ptkem_dep(jij))) + &
155 pg_o_thvref(jij) * (zhlvpt(jij,kk) - zvpt_dep(jij)) )**2 &
156 + 2. * zinte(jij) * pg_o_thvref(jij) &
157 * zdeltvpt(jij,kk) / pdzz2d(jij,kk) )) ) / &
158 ( pg_o_thvref(jij) * zdeltvpt(jij,kk) / pdzz2d(jij,kk) )
159 ! Effective length travelled by parcel
160 plwork(jij)=plwork(jij)+ztest0*(ztest*zlwork1(jij)+ &
161 (1-ztest)*zlwork2(jij))
162 ! Rest of energy to consume
163 zinte(jij) = zinte(jij) - zpote(jij)
164 ENDDO
165 ELSE
166 !$mnh_expand_array(JIJ=IIJB:IIJE)
167 zvpt_dep(iijb:iije)=pvpt(iijb:iije,kk) ! departure point is on mass level
168 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
169 ENDIF
170
171 DO jkk=kk+ikl,ike,ikl
172 IF(ztestm > 0.) THEN
173 ztestm=0
174 DO jij=iijb,iije
175 ztest0=0.5+sign(0.5,zinte(jij))
176 zpote(jij) = ztest0*(pg_o_thvref(jij) * &
177 (zhlvpt(jij,jkk) - zvpt_dep(jij)) &
178 + csturb%XRM17*pshear(jij,jkk)*sqrt(abs(ptkem_dep(jij))))* pdzz2d(jij,jkk)
179 ztest =0.5+sign(0.5,zinte(jij)-zpote(jij))
180 ztestm=ztestm+ztest0
181 zlwork1(jij)=pdzz2d(jij,jkk)
182 !ZLWORK2 jump of the last reached level
183 zlwork2(jij)= ( - pg_o_thvref(jij) * &
184 ( pvpt(jij,jkk-ikl) - zvpt_dep(jij) ) &
185 - csturb%XRM17*pshear(jij,jkk)*sqrt(abs(ptkem_dep(jij))) &
186 + sqrt(abs( &
187 (csturb%XRM17*pshear(jij,jkk)*sqrt(abs(ptkem_dep(jij))) + &
188 pg_o_thvref(jij) * (pvpt(jij,jkk-ikl) - zvpt_dep(jij)) )**2 &
189 + 2. * zinte(jij) * pg_o_thvref(jij) &
190 * zdeltvpt(jij,jkk) / pdzz2d(jij,jkk) )) ) / &
191 ( pg_o_thvref(jij) * zdeltvpt(jij,jkk) / pdzz2d(jij,jkk) )
192 !
193 plwork(jij)=plwork(jij)+ztest0*(ztest*zlwork1(jij)+ &
194 (1-ztest)*zlwork2(jij))
195 zinte(jij) = zinte(jij) - zpote(jij)
196 END DO
197 ENDIF
198 END DO
199ENDIF
200!!
201!* 2. CALCULATION OF THE DOWNWARD MIXING LENGTH
202! ---------------------------------------
203!
204
205IF (oupordn.EQV..false.) THEN
206 !$mnh_expand_array(JIJ=IIJB:IIJE)
207 zinte(iijb:iije)=ptkem_dep(iijb:iije)
208 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
209 plwork=0.
210 ztestm=1.
211 IF(oflux) THEN
212 CALL print_msg(nverb_fatal,'GEN','COMPUTE_BL89_ML','OFLUX option not coded for downward mixing length')
213 ELSE
214 !$mnh_expand_array(JIJ=IIJB:IIJE)
215 zvpt_dep(iijb:iije)=pvpt(iijb:iije,kk) ! departure point is on mass level
216 !$mnh_end_expand_array(JIJ=IIJB:IIJE)
217 ENDIF
218
219 DO jkk=kk,ikb,-ikl
220 IF(ztestm > 0.) THEN
221 ztestm=0
222 DO jij=iijb,iije
223 ztest0=0.5+sign(0.5,zinte(jij))
224 zpote(jij) = ztest0*(-pg_o_thvref(jij) * &
225 (zhlvpt(jij,jkk) - zvpt_dep(jij)) &
226 + csturb%XRM17*pshear(jij,jkk)*sqrt(abs(ptkem_dep(jij))))* pdzz2d(jij,jkk)
227 ztest =0.5+sign(0.5,zinte(jij)-zpote(jij))
228 ztestm=ztestm+ztest0
229 zlwork1(jij)=pdzz2d(jij,jkk)
230 zlwork2(jij)= ( + pg_o_thvref(jij) * &
231 ( pvpt(jij,jkk) - zvpt_dep(jij) ) &
232 -csturb%XRM17*pshear(jij,jkk)*sqrt(abs(ptkem_dep(jij))) &
233 + sqrt(abs( &
234 (csturb%XRM17*pshear(jij,jkk)*sqrt(abs(ptkem_dep(jij))) - &
235 pg_o_thvref(jij) * (pvpt(jij,jkk) - zvpt_dep(jij)) )**2 &
236 + 2. * zinte(jij) * pg_o_thvref(jij) &
237 * zdeltvpt(jij,jkk) / pdzz2d(jij,jkk) )) ) / &
238 ( pg_o_thvref(jij) * zdeltvpt(jij,jkk) / pdzz2d(jij,jkk) )
239 !
240 plwork(jij)=plwork(jij)+ztest0*(ztest*zlwork1(jij)+ &
241 (1-ztest)*zlwork2(jij))
242 zinte(jij) = zinte(jij) - zpote(jij)
243 END DO
244 ENDIF
245 END DO
246ENDIF
247
248IF (lhook) CALL dr_hook('COMPUTE_BL89_ML',1,zhook_handle)
249END SUBROUTINE compute_bl89_ml
250END MODULE mode_compute_bl89_ml
integer, parameter nverb_fatal
Definition modd_io.F90:6
subroutine compute_bl89_ml(d, cst, csturb, pdzz2d, ptkem_dep, pg_o_thvref, pvpt, kk, oupordn, oflux, pshear, plwork)
subroutine dzm_mf(d, pa, pdzm)
subroutine mzm_mf(d, pa, pmzm)