1 | !> @file production_e.f90 |
---|
2 | !--------------------------------------------------------------------------------! |
---|
3 | ! This file is part of PALM. |
---|
4 | ! |
---|
5 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
6 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
7 | ! either version 3 of the License, or (at your option) any later version. |
---|
8 | ! |
---|
9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
10 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
11 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
12 | ! |
---|
13 | ! You should have received a copy of the GNU General Public License along with |
---|
14 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
15 | ! |
---|
16 | ! Copyright 1997-2014 Leibniz Universitaet Hannover |
---|
17 | !--------------------------------------------------------------------------------! |
---|
18 | ! |
---|
19 | ! Current revisions: |
---|
20 | ! ----------------- |
---|
21 | ! |
---|
22 | ! |
---|
23 | ! Former revisions: |
---|
24 | ! ----------------- |
---|
25 | ! $Id: production_e.f90 1683 2015-10-07 23:57:51Z knoop $ |
---|
26 | ! |
---|
27 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
28 | ! Code annotations made doxygen readable |
---|
29 | ! |
---|
30 | ! 1374 2014-04-25 12:55:07Z raasch |
---|
31 | ! nzb_s_outer removed from acc-present-list |
---|
32 | ! |
---|
33 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
34 | ! REAL constants provided with KIND-attribute |
---|
35 | ! |
---|
36 | ! 1342 2014-03-26 17:04:47Z kanani |
---|
37 | ! REAL constants defined as wp-kind |
---|
38 | ! |
---|
39 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
40 | ! ONLY-attribute added to USE-statements, |
---|
41 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
42 | ! kinds are defined in new module kinds, |
---|
43 | ! old module precision_kind is removed, |
---|
44 | ! revision history before 2012 removed, |
---|
45 | ! comment fields (!:) to be used for variable explanations added to |
---|
46 | ! all variable declaration statements |
---|
47 | ! |
---|
48 | ! 1257 2013-11-08 15:18:40Z raasch |
---|
49 | ! openacc loop and loop vector clauses removed, declare create moved after |
---|
50 | ! the FORTRAN declaration statement |
---|
51 | ! |
---|
52 | ! 1179 2013-06-14 05:57:58Z raasch |
---|
53 | ! use_reference renamed use_single_reference_value |
---|
54 | ! |
---|
55 | ! 1128 2013-04-12 06:19:32Z raasch |
---|
56 | ! loop index bounds in accelerator version replaced by i_left, i_right, j_south, |
---|
57 | ! j_north |
---|
58 | ! |
---|
59 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
60 | ! code put under GPL (PALM 3.9) |
---|
61 | ! |
---|
62 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
63 | ! accelerator version (*_acc) added |
---|
64 | ! |
---|
65 | ! 1007 2012-09-19 14:30:36Z franke |
---|
66 | ! Bugfix: calculation of buoyancy production has to consider the liquid water |
---|
67 | ! mixing ratio in case of cloud droplets |
---|
68 | ! |
---|
69 | ! 940 2012-07-09 14:31:00Z raasch |
---|
70 | ! TKE production by buoyancy can be switched off in case of runs with pure |
---|
71 | ! neutral stratification |
---|
72 | ! |
---|
73 | ! Revision 1.1 1997/09/19 07:45:35 raasch |
---|
74 | ! Initial revision |
---|
75 | ! |
---|
76 | ! |
---|
77 | ! Description: |
---|
78 | ! ------------ |
---|
79 | !> Production terms (shear + buoyancy) of the TKE. |
---|
80 | !> @warning The case with prandtl_layer = F and use_surface_fluxes = T is |
---|
81 | !> not considered well! |
---|
82 | !------------------------------------------------------------------------------! |
---|
83 | MODULE production_e_mod |
---|
84 | |
---|
85 | |
---|
86 | USE wall_fluxes_mod, & |
---|
87 | ONLY: wall_fluxes_e, wall_fluxes_e_acc |
---|
88 | |
---|
89 | USE kinds |
---|
90 | |
---|
91 | PRIVATE |
---|
92 | PUBLIC production_e, production_e_acc, production_e_init |
---|
93 | |
---|
94 | LOGICAL, SAVE :: first_call = .TRUE. !< |
---|
95 | |
---|
96 | REAL(wp), DIMENSION(:,:), ALLOCATABLE, SAVE :: u_0 !< |
---|
97 | REAL(wp), DIMENSION(:,:), ALLOCATABLE, SAVE :: v_0 !< |
---|
98 | |
---|
99 | INTERFACE production_e |
---|
100 | MODULE PROCEDURE production_e |
---|
101 | MODULE PROCEDURE production_e_ij |
---|
102 | END INTERFACE production_e |
---|
103 | |
---|
104 | INTERFACE production_e_acc |
---|
105 | MODULE PROCEDURE production_e_acc |
---|
106 | END INTERFACE production_e_acc |
---|
107 | |
---|
108 | INTERFACE production_e_init |
---|
109 | MODULE PROCEDURE production_e_init |
---|
110 | END INTERFACE production_e_init |
---|
111 | |
---|
112 | CONTAINS |
---|
113 | |
---|
114 | |
---|
115 | !------------------------------------------------------------------------------! |
---|
116 | ! Description: |
---|
117 | ! ------------ |
---|
118 | !> Call for all grid points |
---|
119 | !------------------------------------------------------------------------------! |
---|
120 | SUBROUTINE production_e |
---|
121 | |
---|
122 | USE arrays_3d, & |
---|
123 | ONLY: ddzw, dd2zu, kh, km, pt, q, ql, qsws, qswst, rho, shf, & |
---|
124 | tend, tswst, u, v, vpt, w |
---|
125 | |
---|
126 | USE cloud_parameters, & |
---|
127 | ONLY: l_d_cp, l_d_r, pt_d_t, t_d_pt |
---|
128 | |
---|
129 | USE control_parameters, & |
---|
130 | ONLY: cloud_droplets, cloud_physics, g, humidity, kappa, neutral, & |
---|
131 | ocean, prandtl_layer, pt_reference, rho_reference, & |
---|
132 | use_single_reference_value, use_surface_fluxes, & |
---|
133 | use_top_fluxes |
---|
134 | |
---|
135 | USE grid_variables, & |
---|
136 | ONLY: ddx, dx, ddy, dy, wall_e_x, wall_e_y |
---|
137 | |
---|
138 | USE indices, & |
---|
139 | ONLY: nxl, nxr, nys, nyn, nzb, nzb_diff_s_inner, & |
---|
140 | nzb_diff_s_outer, nzb_s_inner, nzt, nzt_diff |
---|
141 | |
---|
142 | IMPLICIT NONE |
---|
143 | |
---|
144 | INTEGER(iwp) :: i !< |
---|
145 | INTEGER(iwp) :: j !< |
---|
146 | INTEGER(iwp) :: k !< |
---|
147 | |
---|
148 | REAL(wp) :: def !< |
---|
149 | REAL(wp) :: dudx !< |
---|
150 | REAL(wp) :: dudy !< |
---|
151 | REAL(wp) :: dudz !< |
---|
152 | REAL(wp) :: dvdx !< |
---|
153 | REAL(wp) :: dvdy !< |
---|
154 | REAL(wp) :: dvdz !< |
---|
155 | REAL(wp) :: dwdx !< |
---|
156 | REAL(wp) :: dwdy !< |
---|
157 | REAL(wp) :: dwdz !< |
---|
158 | REAL(wp) :: k1 !< |
---|
159 | REAL(wp) :: k2 !< |
---|
160 | REAL(wp) :: km_neutral !< |
---|
161 | REAL(wp) :: theta !< |
---|
162 | REAL(wp) :: temp !< |
---|
163 | |
---|
164 | ! REAL(wp), DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: usvs, vsus, wsus, wsvs |
---|
165 | REAL(wp), DIMENSION(nzb:nzt+1) :: usvs !< |
---|
166 | REAL(wp), DIMENSION(nzb:nzt+1) :: vsus !< |
---|
167 | REAL(wp), DIMENSION(nzb:nzt+1) :: wsus !< |
---|
168 | REAL(wp), DIMENSION(nzb:nzt+1) :: wsvs !< |
---|
169 | |
---|
170 | ! |
---|
171 | !-- First calculate horizontal momentum flux u'v', w'v', v'u', w'u' at |
---|
172 | !-- vertical walls, if neccessary |
---|
173 | !-- So far, results are slightly different from the ij-Version. |
---|
174 | !-- Therefore, ij-Version is called further below within the ij-loops. |
---|
175 | ! IF ( topography /= 'flat' ) THEN |
---|
176 | ! CALL wall_fluxes_e( usvs, 1.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, wall_e_y ) |
---|
177 | ! CALL wall_fluxes_e( wsvs, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, wall_e_y ) |
---|
178 | ! CALL wall_fluxes_e( vsus, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp, wall_e_x ) |
---|
179 | ! CALL wall_fluxes_e( wsus, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, wall_e_x ) |
---|
180 | ! ENDIF |
---|
181 | |
---|
182 | |
---|
183 | DO i = nxl, nxr |
---|
184 | |
---|
185 | ! |
---|
186 | !-- Calculate TKE production by shear |
---|
187 | DO j = nys, nyn |
---|
188 | DO k = nzb_diff_s_outer(j,i), nzt |
---|
189 | |
---|
190 | dudx = ( u(k,j,i+1) - u(k,j,i) ) * ddx |
---|
191 | dudy = 0.25_wp * ( u(k,j+1,i) + u(k,j+1,i+1) - & |
---|
192 | u(k,j-1,i) - u(k,j-1,i+1) ) * ddy |
---|
193 | dudz = 0.5_wp * ( u(k+1,j,i) + u(k+1,j,i+1) - & |
---|
194 | u(k-1,j,i) - u(k-1,j,i+1) ) * dd2zu(k) |
---|
195 | |
---|
196 | dvdx = 0.25_wp * ( v(k,j,i+1) + v(k,j+1,i+1) - & |
---|
197 | v(k,j,i-1) - v(k,j+1,i-1) ) * ddx |
---|
198 | dvdy = ( v(k,j+1,i) - v(k,j,i) ) * ddy |
---|
199 | dvdz = 0.5_wp * ( v(k+1,j,i) + v(k+1,j+1,i) - & |
---|
200 | v(k-1,j,i) - v(k-1,j+1,i) ) * dd2zu(k) |
---|
201 | |
---|
202 | dwdx = 0.25_wp * ( w(k,j,i+1) + w(k-1,j,i+1) - & |
---|
203 | w(k,j,i-1) - w(k-1,j,i-1) ) * ddx |
---|
204 | dwdy = 0.25_wp * ( w(k,j+1,i) + w(k-1,j+1,i) - & |
---|
205 | w(k,j-1,i) - w(k-1,j-1,i) ) * ddy |
---|
206 | dwdz = ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
207 | |
---|
208 | def = 2.0_wp * ( dudx**2 + dvdy**2 + dwdz**2 ) + & |
---|
209 | dudy**2 + dvdx**2 + dwdx**2 + dwdy**2 + dudz**2 + & |
---|
210 | dvdz**2 + 2.0_wp * ( dvdx*dudy + dwdx*dudz + dwdy*dvdz ) |
---|
211 | |
---|
212 | IF ( def < 0.0_wp ) def = 0.0_wp |
---|
213 | |
---|
214 | tend(k,j,i) = tend(k,j,i) + km(k,j,i) * def |
---|
215 | |
---|
216 | ENDDO |
---|
217 | ENDDO |
---|
218 | |
---|
219 | IF ( prandtl_layer ) THEN |
---|
220 | |
---|
221 | ! |
---|
222 | !-- Position beneath wall |
---|
223 | !-- (2) - Will allways be executed. |
---|
224 | !-- 'bottom and wall: use u_0,v_0 and wall functions' |
---|
225 | DO j = nys, nyn |
---|
226 | |
---|
227 | IF ( ( wall_e_x(j,i) /= 0.0_wp ) .OR. ( wall_e_y(j,i) /= 0.0_wp ) ) & |
---|
228 | THEN |
---|
229 | |
---|
230 | k = nzb_diff_s_inner(j,i) - 1 |
---|
231 | dudx = ( u(k,j,i+1) - u(k,j,i) ) * ddx |
---|
232 | dudz = 0.5_wp * ( u(k+1,j,i) + u(k+1,j,i+1) - & |
---|
233 | u_0(j,i) - u_0(j,i+1) ) * dd2zu(k) |
---|
234 | dvdy = ( v(k,j+1,i) - v(k,j,i) ) * ddy |
---|
235 | dvdz = 0.5_wp * ( v(k+1,j,i) + v(k+1,j+1,i) - & |
---|
236 | v_0(j,i) - v_0(j+1,i) ) * dd2zu(k) |
---|
237 | dwdz = ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
238 | |
---|
239 | IF ( wall_e_y(j,i) /= 0.0_wp ) THEN |
---|
240 | ! |
---|
241 | !-- Inconsistency removed: as the thermal stratification is |
---|
242 | !-- not taken into account for the evaluation of the wall |
---|
243 | !-- fluxes at vertical walls, the eddy viscosity km must not |
---|
244 | !-- be used for the evaluation of the velocity gradients dudy |
---|
245 | !-- and dwdy |
---|
246 | !-- Note: The validity of the new method has not yet been |
---|
247 | !-- shown, as so far no suitable data for a validation |
---|
248 | !-- has been available |
---|
249 | CALL wall_fluxes_e( i, j, k, nzb_diff_s_outer(j,i)-2, & |
---|
250 | usvs, 1.0_wp, 0.0_wp, 0.0_wp, 0.0_wp ) |
---|
251 | CALL wall_fluxes_e( i, j, k, nzb_diff_s_outer(j,i)-2, & |
---|
252 | wsvs, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp ) |
---|
253 | km_neutral = kappa * ( usvs(k)**2 + wsvs(k)**2 )**0.25_wp * & |
---|
254 | 0.5_wp * dy |
---|
255 | IF ( km_neutral > 0.0_wp ) THEN |
---|
256 | dudy = - wall_e_y(j,i) * usvs(k) / km_neutral |
---|
257 | dwdy = - wall_e_y(j,i) * wsvs(k) / km_neutral |
---|
258 | ELSE |
---|
259 | dudy = 0.0_wp |
---|
260 | dwdy = 0.0_wp |
---|
261 | ENDIF |
---|
262 | ELSE |
---|
263 | dudy = 0.25_wp * ( u(k,j+1,i) + u(k,j+1,i+1) - & |
---|
264 | u(k,j-1,i) - u(k,j-1,i+1) ) * ddy |
---|
265 | dwdy = 0.25_wp * ( w(k,j+1,i) + w(k-1,j+1,i) - & |
---|
266 | w(k,j-1,i) - w(k-1,j-1,i) ) * ddy |
---|
267 | ENDIF |
---|
268 | |
---|
269 | IF ( wall_e_x(j,i) /= 0.0_wp ) THEN |
---|
270 | ! |
---|
271 | !-- Inconsistency removed: as the thermal stratification is |
---|
272 | !-- not taken into account for the evaluation of the wall |
---|
273 | !-- fluxes at vertical walls, the eddy viscosity km must not |
---|
274 | !-- be used for the evaluation of the velocity gradients dvdx |
---|
275 | !-- and dwdx |
---|
276 | !-- Note: The validity of the new method has not yet been |
---|
277 | !-- shown, as so far no suitable data for a validation |
---|
278 | !-- has been available |
---|
279 | CALL wall_fluxes_e( i, j, k, nzb_diff_s_outer(j,i)-2, & |
---|
280 | vsus, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp ) |
---|
281 | CALL wall_fluxes_e( i, j, k, nzb_diff_s_outer(j,i)-2, & |
---|
282 | wsus, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp ) |
---|
283 | km_neutral = kappa * ( vsus(k)**2 + wsus(k)**2 )**0.25_wp * & |
---|
284 | 0.5_wp * dx |
---|
285 | IF ( km_neutral > 0.0_wp ) THEN |
---|
286 | dvdx = - wall_e_x(j,i) * vsus(k) / km_neutral |
---|
287 | dwdx = - wall_e_x(j,i) * wsus(k) / km_neutral |
---|
288 | ELSE |
---|
289 | dvdx = 0.0_wp |
---|
290 | dwdx = 0.0_wp |
---|
291 | ENDIF |
---|
292 | ELSE |
---|
293 | dvdx = 0.25_wp * ( v(k,j,i+1) + v(k,j+1,i+1) - & |
---|
294 | v(k,j,i-1) - v(k,j+1,i-1) ) * ddx |
---|
295 | dwdx = 0.25_wp * ( w(k,j,i+1) + w(k-1,j,i+1) - & |
---|
296 | w(k,j,i-1) - w(k-1,j,i-1) ) * ddx |
---|
297 | ENDIF |
---|
298 | |
---|
299 | def = 2.0_wp * ( dudx**2 + dvdy**2 + dwdz**2 ) + & |
---|
300 | dudy**2 + dvdx**2 + dwdx**2 + dwdy**2 + dudz**2 + & |
---|
301 | dvdz**2 + 2.0_wp * ( dvdx*dudy + dwdx*dudz + dwdy*dvdz ) |
---|
302 | |
---|
303 | IF ( def < 0.0_wp ) def = 0.0_wp |
---|
304 | |
---|
305 | tend(k,j,i) = tend(k,j,i) + km(k,j,i) * def |
---|
306 | |
---|
307 | |
---|
308 | ! |
---|
309 | !-- (3) - will be executed only, if there is at least one level |
---|
310 | !-- between (2) and (4), i.e. the topography must have a |
---|
311 | !-- minimum height of 2 dz. Wall fluxes for this case have |
---|
312 | !-- already been calculated for (2). |
---|
313 | !-- 'wall only: use wall functions' |
---|
314 | |
---|
315 | DO k = nzb_diff_s_inner(j,i), nzb_diff_s_outer(j,i)-2 |
---|
316 | |
---|
317 | dudx = ( u(k,j,i+1) - u(k,j,i) ) * ddx |
---|
318 | dudz = 0.5_wp * ( u(k+1,j,i) + u(k+1,j,i+1) - & |
---|
319 | u(k-1,j,i) - u(k-1,j,i+1) ) * dd2zu(k) |
---|
320 | dvdy = ( v(k,j+1,i) - v(k,j,i) ) * ddy |
---|
321 | dvdz = 0.5_wp * ( v(k+1,j,i) + v(k+1,j+1,i) - & |
---|
322 | v(k-1,j,i) - v(k-1,j+1,i) ) * dd2zu(k) |
---|
323 | dwdz = ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
324 | |
---|
325 | IF ( wall_e_y(j,i) /= 0.0_wp ) THEN |
---|
326 | ! |
---|
327 | !-- Inconsistency removed: as the thermal stratification |
---|
328 | !-- is not taken into account for the evaluation of the |
---|
329 | !-- wall fluxes at vertical walls, the eddy viscosity km |
---|
330 | !-- must not be used for the evaluation of the velocity |
---|
331 | !-- gradients dudy and dwdy |
---|
332 | !-- Note: The validity of the new method has not yet |
---|
333 | !-- been shown, as so far no suitable data for a |
---|
334 | !-- validation has been available |
---|
335 | km_neutral = kappa * ( usvs(k)**2 + & |
---|
336 | wsvs(k)**2 )**0.25_wp * 0.5_wp * dy |
---|
337 | IF ( km_neutral > 0.0_wp ) THEN |
---|
338 | dudy = - wall_e_y(j,i) * usvs(k) / km_neutral |
---|
339 | dwdy = - wall_e_y(j,i) * wsvs(k) / km_neutral |
---|
340 | ELSE |
---|
341 | dudy = 0.0_wp |
---|
342 | dwdy = 0.0_wp |
---|
343 | ENDIF |
---|
344 | ELSE |
---|
345 | dudy = 0.25_wp * ( u(k,j+1,i) + u(k,j+1,i+1) - & |
---|
346 | u(k,j-1,i) - u(k,j-1,i+1) ) * ddy |
---|
347 | dwdy = 0.25_wp * ( w(k,j+1,i) + w(k-1,j+1,i) - & |
---|
348 | w(k,j-1,i) - w(k-1,j-1,i) ) * ddy |
---|
349 | ENDIF |
---|
350 | |
---|
351 | IF ( wall_e_x(j,i) /= 0.0_wp ) THEN |
---|
352 | ! |
---|
353 | !-- Inconsistency removed: as the thermal stratification |
---|
354 | !-- is not taken into account for the evaluation of the |
---|
355 | !-- wall fluxes at vertical walls, the eddy viscosity km |
---|
356 | !-- must not be used for the evaluation of the velocity |
---|
357 | !-- gradients dvdx and dwdx |
---|
358 | !-- Note: The validity of the new method has not yet |
---|
359 | !-- been shown, as so far no suitable data for a |
---|
360 | !-- validation has been available |
---|
361 | km_neutral = kappa * ( vsus(k)**2 + & |
---|
362 | wsus(k)**2 )**0.25_wp * 0.5_wp * dx |
---|
363 | IF ( km_neutral > 0.0_wp ) THEN |
---|
364 | dvdx = - wall_e_x(j,i) * vsus(k) / km_neutral |
---|
365 | dwdx = - wall_e_x(j,i) * wsus(k) / km_neutral |
---|
366 | ELSE |
---|
367 | dvdx = 0.0_wp |
---|
368 | dwdx = 0.0_wp |
---|
369 | ENDIF |
---|
370 | ELSE |
---|
371 | dvdx = 0.25_wp * ( v(k,j,i+1) + v(k,j+1,i+1) - & |
---|
372 | v(k,j,i-1) - v(k,j+1,i-1) ) * ddx |
---|
373 | dwdx = 0.25_wp * ( w(k,j,i+1) + w(k-1,j,i+1) - & |
---|
374 | w(k,j,i-1) - w(k-1,j,i-1) ) * ddx |
---|
375 | ENDIF |
---|
376 | |
---|
377 | def = 2.0_wp * ( dudx**2 + dvdy**2 + dwdz**2 ) + & |
---|
378 | dudy**2 + dvdx**2 + dwdx**2 + dwdy**2 + dudz**2 + & |
---|
379 | dvdz**2 + 2.0_wp * ( dvdx*dudy + dwdx*dudz + dwdy*dvdz ) |
---|
380 | |
---|
381 | IF ( def < 0.0_wp ) def = 0.0_wp |
---|
382 | |
---|
383 | tend(k,j,i) = tend(k,j,i) + km(k,j,i) * def |
---|
384 | |
---|
385 | ENDDO |
---|
386 | |
---|
387 | ENDIF |
---|
388 | |
---|
389 | ENDDO |
---|
390 | |
---|
391 | ! |
---|
392 | !-- (4) - will allways be executed. |
---|
393 | !-- 'special case: free atmosphere' (as for case (0)) |
---|
394 | DO j = nys, nyn |
---|
395 | |
---|
396 | IF ( ( wall_e_x(j,i) /= 0.0_wp ) .OR. ( wall_e_y(j,i) /= 0.0_wp ) ) & |
---|
397 | THEN |
---|
398 | |
---|
399 | k = nzb_diff_s_outer(j,i)-1 |
---|
400 | |
---|
401 | dudx = ( u(k,j,i+1) - u(k,j,i) ) * ddx |
---|
402 | dudy = 0.25_wp * ( u(k,j+1,i) + u(k,j+1,i+1) - & |
---|
403 | u(k,j-1,i) - u(k,j-1,i+1) ) * ddy |
---|
404 | dudz = 0.5_wp * ( u(k+1,j,i) + u(k+1,j,i+1) - & |
---|
405 | u(k-1,j,i) - u(k-1,j,i+1) ) * dd2zu(k) |
---|
406 | |
---|
407 | dvdx = 0.25_wp * ( v(k,j,i+1) + v(k,j+1,i+1) - & |
---|
408 | v(k,j,i-1) - v(k,j+1,i-1) ) * ddx |
---|
409 | dvdy = ( v(k,j+1,i) - v(k,j,i) ) * ddy |
---|
410 | dvdz = 0.5_wp * ( v(k+1,j,i) + v(k+1,j+1,i) - & |
---|
411 | v(k-1,j,i) - v(k-1,j+1,i) ) * dd2zu(k) |
---|
412 | |
---|
413 | dwdx = 0.25_wp * ( w(k,j,i+1) + w(k-1,j,i+1) - & |
---|
414 | w(k,j,i-1) - w(k-1,j,i-1) ) * ddx |
---|
415 | dwdy = 0.25_wp * ( w(k,j+1,i) + w(k-1,j+1,i) - & |
---|
416 | w(k,j-1,i) - w(k-1,j-1,i) ) * ddy |
---|
417 | dwdz = ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
418 | |
---|
419 | def = 2.0_wp * ( dudx**2 + dvdy**2 + dwdz**2 ) + & |
---|
420 | dudy**2 + dvdx**2 + dwdx**2 + dwdy**2 + dudz**2 + & |
---|
421 | dvdz**2 + 2.0_wp * ( dvdx*dudy + dwdx*dudz + dwdy*dvdz ) |
---|
422 | |
---|
423 | IF ( def < 0.0_wp ) def = 0.0_wp |
---|
424 | |
---|
425 | tend(k,j,i) = tend(k,j,i) + km(k,j,i) * def |
---|
426 | |
---|
427 | ENDIF |
---|
428 | |
---|
429 | ENDDO |
---|
430 | |
---|
431 | ! |
---|
432 | !-- Position without adjacent wall |
---|
433 | !-- (1) - will allways be executed. |
---|
434 | !-- 'bottom only: use u_0,v_0' |
---|
435 | DO j = nys, nyn |
---|
436 | |
---|
437 | IF ( ( wall_e_x(j,i) == 0.0_wp ) .AND. ( wall_e_y(j,i) == 0.0_wp ) ) & |
---|
438 | THEN |
---|
439 | |
---|
440 | k = nzb_diff_s_inner(j,i)-1 |
---|
441 | |
---|
442 | dudx = ( u(k,j,i+1) - u(k,j,i) ) * ddx |
---|
443 | dudy = 0.25_wp * ( u(k,j+1,i) + u(k,j+1,i+1) - & |
---|
444 | u(k,j-1,i) - u(k,j-1,i+1) ) * ddy |
---|
445 | dudz = 0.5_wp * ( u(k+1,j,i) + u(k+1,j,i+1) - & |
---|
446 | u_0(j,i) - u_0(j,i+1) ) * dd2zu(k) |
---|
447 | |
---|
448 | dvdx = 0.25_wp * ( v(k,j,i+1) + v(k,j+1,i+1) - & |
---|
449 | v(k,j,i-1) - v(k,j+1,i-1) ) * ddx |
---|
450 | dvdy = ( v(k,j+1,i) - v(k,j,i) ) * ddy |
---|
451 | dvdz = 0.5_wp * ( v(k+1,j,i) + v(k+1,j+1,i) - & |
---|
452 | v_0(j,i) - v_0(j+1,i) ) * dd2zu(k) |
---|
453 | |
---|
454 | dwdx = 0.25_wp * ( w(k,j,i+1) + w(k-1,j,i+1) - & |
---|
455 | w(k,j,i-1) - w(k-1,j,i-1) ) * ddx |
---|
456 | dwdy = 0.25_wp * ( w(k,j+1,i) + w(k-1,j+1,i) - & |
---|
457 | w(k,j-1,i) - w(k-1,j-1,i) ) * ddy |
---|
458 | dwdz = ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
459 | |
---|
460 | def = 2.0_wp * ( dudx**2 + dvdy**2 + dwdz**2 ) + & |
---|
461 | dudy**2 + dvdx**2 + dwdx**2 + dwdy**2 + dudz**2 + & |
---|
462 | dvdz**2 + 2.0_wp * ( dvdx*dudy + dwdx*dudz + dwdy*dvdz ) |
---|
463 | |
---|
464 | IF ( def < 0.0_wp ) def = 0.0_wp |
---|
465 | |
---|
466 | tend(k,j,i) = tend(k,j,i) + km(k,j,i) * def |
---|
467 | |
---|
468 | ENDIF |
---|
469 | |
---|
470 | ENDDO |
---|
471 | |
---|
472 | ELSEIF ( use_surface_fluxes ) THEN |
---|
473 | |
---|
474 | DO j = nys, nyn |
---|
475 | |
---|
476 | k = nzb_diff_s_outer(j,i)-1 |
---|
477 | |
---|
478 | dudx = ( u(k,j,i+1) - u(k,j,i) ) * ddx |
---|
479 | dudy = 0.25_wp * ( u(k,j+1,i) + u(k,j+1,i+1) - & |
---|
480 | u(k,j-1,i) - u(k,j-1,i+1) ) * ddy |
---|
481 | dudz = 0.5_wp * ( u(k+1,j,i) + u(k+1,j,i+1) - & |
---|
482 | u(k-1,j,i) - u(k-1,j,i+1) ) * dd2zu(k) |
---|
483 | |
---|
484 | dvdx = 0.25_wp * ( v(k,j,i+1) + v(k,j+1,i+1) - & |
---|
485 | v(k,j,i-1) - v(k,j+1,i-1) ) * ddx |
---|
486 | dvdy = ( v(k,j+1,i) - v(k,j,i) ) * ddy |
---|
487 | dvdz = 0.5_wp * ( v(k+1,j,i) + v(k+1,j+1,i) - & |
---|
488 | v(k-1,j,i) - v(k-1,j+1,i) ) * dd2zu(k) |
---|
489 | |
---|
490 | dwdx = 0.25_wp * ( w(k,j,i+1) + w(k-1,j,i+1) - & |
---|
491 | w(k,j,i-1) - w(k-1,j,i-1) ) * ddx |
---|
492 | dwdy = 0.25_wp * ( w(k,j+1,i) + w(k-1,j+1,i) - & |
---|
493 | w(k,j-1,i) - w(k-1,j-1,i) ) * ddy |
---|
494 | dwdz = ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
495 | |
---|
496 | def = 2.0_wp * ( dudx**2 + dvdy**2 + dwdz**2 ) + & |
---|
497 | dudy**2 + dvdx**2 + dwdx**2 + dwdy**2 + dudz**2 + & |
---|
498 | dvdz**2 + 2.0_wp * ( dvdx*dudy + dwdx*dudz + dwdy*dvdz ) |
---|
499 | |
---|
500 | IF ( def < 0.0_wp ) def = 0.0_wp |
---|
501 | |
---|
502 | tend(k,j,i) = tend(k,j,i) + km(k,j,i) * def |
---|
503 | |
---|
504 | ENDDO |
---|
505 | |
---|
506 | ENDIF |
---|
507 | |
---|
508 | ! |
---|
509 | !-- If required, calculate TKE production by buoyancy |
---|
510 | IF ( .NOT. neutral ) THEN |
---|
511 | |
---|
512 | IF ( .NOT. humidity ) THEN |
---|
513 | |
---|
514 | IF ( use_single_reference_value ) THEN |
---|
515 | |
---|
516 | IF ( ocean ) THEN |
---|
517 | ! |
---|
518 | !-- So far in the ocean no special treatment of density flux |
---|
519 | !-- in the bottom and top surface layer |
---|
520 | DO j = nys, nyn |
---|
521 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
522 | tend(k,j,i) = tend(k,j,i) + & |
---|
523 | kh(k,j,i) * g / rho_reference * & |
---|
524 | ( rho(k+1,j,i) - rho(k-1,j,i) ) * & |
---|
525 | dd2zu(k) |
---|
526 | ENDDO |
---|
527 | ENDDO |
---|
528 | |
---|
529 | ELSE |
---|
530 | |
---|
531 | DO j = nys, nyn |
---|
532 | DO k = nzb_diff_s_inner(j,i), nzt_diff |
---|
533 | tend(k,j,i) = tend(k,j,i) - & |
---|
534 | kh(k,j,i) * g / pt_reference * & |
---|
535 | ( pt(k+1,j,i) - pt(k-1,j,i) ) * & |
---|
536 | dd2zu(k) |
---|
537 | ENDDO |
---|
538 | |
---|
539 | IF ( use_surface_fluxes ) THEN |
---|
540 | k = nzb_diff_s_inner(j,i)-1 |
---|
541 | tend(k,j,i) = tend(k,j,i) + g / pt_reference * & |
---|
542 | shf(j,i) |
---|
543 | ENDIF |
---|
544 | |
---|
545 | IF ( use_top_fluxes ) THEN |
---|
546 | k = nzt |
---|
547 | tend(k,j,i) = tend(k,j,i) + g / pt_reference * & |
---|
548 | tswst(j,i) |
---|
549 | ENDIF |
---|
550 | ENDDO |
---|
551 | |
---|
552 | ENDIF |
---|
553 | |
---|
554 | ELSE |
---|
555 | |
---|
556 | IF ( ocean ) THEN |
---|
557 | ! |
---|
558 | !-- So far in the ocean no special treatment of density flux |
---|
559 | !-- in the bottom and top surface layer |
---|
560 | DO j = nys, nyn |
---|
561 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
562 | tend(k,j,i) = tend(k,j,i) + & |
---|
563 | kh(k,j,i) * g / rho(k,j,i) * & |
---|
564 | ( rho(k+1,j,i) - rho(k-1,j,i) ) * & |
---|
565 | dd2zu(k) |
---|
566 | ENDDO |
---|
567 | ENDDO |
---|
568 | |
---|
569 | ELSE |
---|
570 | |
---|
571 | DO j = nys, nyn |
---|
572 | DO k = nzb_diff_s_inner(j,i), nzt_diff |
---|
573 | tend(k,j,i) = tend(k,j,i) - & |
---|
574 | kh(k,j,i) * g / pt(k,j,i) * & |
---|
575 | ( pt(k+1,j,i) - pt(k-1,j,i) ) * & |
---|
576 | dd2zu(k) |
---|
577 | ENDDO |
---|
578 | |
---|
579 | IF ( use_surface_fluxes ) THEN |
---|
580 | k = nzb_diff_s_inner(j,i)-1 |
---|
581 | tend(k,j,i) = tend(k,j,i) + g / pt(k,j,i) * & |
---|
582 | shf(j,i) |
---|
583 | ENDIF |
---|
584 | |
---|
585 | IF ( use_top_fluxes ) THEN |
---|
586 | k = nzt |
---|
587 | tend(k,j,i) = tend(k,j,i) + g / pt(k,j,i) * & |
---|
588 | tswst(j,i) |
---|
589 | ENDIF |
---|
590 | ENDDO |
---|
591 | |
---|
592 | ENDIF |
---|
593 | |
---|
594 | ENDIF |
---|
595 | |
---|
596 | ELSE |
---|
597 | |
---|
598 | DO j = nys, nyn |
---|
599 | |
---|
600 | DO k = nzb_diff_s_inner(j,i), nzt_diff |
---|
601 | |
---|
602 | IF ( .NOT. cloud_physics .AND. .NOT. cloud_droplets ) THEN |
---|
603 | k1 = 1.0_wp + 0.61_wp * q(k,j,i) |
---|
604 | k2 = 0.61_wp * pt(k,j,i) |
---|
605 | tend(k,j,i) = tend(k,j,i) - kh(k,j,i) * & |
---|
606 | g / vpt(k,j,i) * & |
---|
607 | ( k1 * ( pt(k+1,j,i)-pt(k-1,j,i) ) + & |
---|
608 | k2 * ( q(k+1,j,i) - q(k-1,j,i) ) & |
---|
609 | ) * dd2zu(k) |
---|
610 | ELSE IF ( cloud_physics ) THEN |
---|
611 | IF ( ql(k,j,i) == 0.0_wp ) THEN |
---|
612 | k1 = 1.0_wp + 0.61_wp * q(k,j,i) |
---|
613 | k2 = 0.61_wp * pt(k,j,i) |
---|
614 | ELSE |
---|
615 | theta = pt(k,j,i) + pt_d_t(k) * l_d_cp * ql(k,j,i) |
---|
616 | temp = theta * t_d_pt(k) |
---|
617 | k1 = ( 1.0_wp - q(k,j,i) + 1.61_wp * & |
---|
618 | ( q(k,j,i) - ql(k,j,i) ) * & |
---|
619 | ( 1.0_wp + 0.622_wp * l_d_r / temp ) ) / & |
---|
620 | ( 1.0_wp + 0.622_wp * l_d_r * l_d_cp * & |
---|
621 | ( q(k,j,i) - ql(k,j,i) ) / ( temp * temp ) ) |
---|
622 | k2 = theta * ( l_d_cp / temp * k1 - 1.0_wp ) |
---|
623 | ENDIF |
---|
624 | tend(k,j,i) = tend(k,j,i) - kh(k,j,i) * & |
---|
625 | g / vpt(k,j,i) * & |
---|
626 | ( k1 * ( pt(k+1,j,i)-pt(k-1,j,i) ) + & |
---|
627 | k2 * ( q(k+1,j,i) - q(k-1,j,i) ) & |
---|
628 | ) * dd2zu(k) |
---|
629 | ELSE IF ( cloud_droplets ) THEN |
---|
630 | k1 = 1.0_wp + 0.61_wp * q(k,j,i) - ql(k,j,i) |
---|
631 | k2 = 0.61_wp * pt(k,j,i) |
---|
632 | tend(k,j,i) = tend(k,j,i) - & |
---|
633 | kh(k,j,i) * g / vpt(k,j,i) * & |
---|
634 | ( k1 * ( pt(k+1,j,i)- pt(k-1,j,i) ) + & |
---|
635 | k2 * ( q(k+1,j,i) - q(k-1,j,i) ) - & |
---|
636 | pt(k,j,i) * ( ql(k+1,j,i) - & |
---|
637 | ql(k-1,j,i) ) ) * dd2zu(k) |
---|
638 | ENDIF |
---|
639 | |
---|
640 | ENDDO |
---|
641 | |
---|
642 | ENDDO |
---|
643 | |
---|
644 | IF ( use_surface_fluxes ) THEN |
---|
645 | |
---|
646 | DO j = nys, nyn |
---|
647 | |
---|
648 | k = nzb_diff_s_inner(j,i)-1 |
---|
649 | |
---|
650 | IF ( .NOT. cloud_physics .AND. .NOT. cloud_droplets ) THEN |
---|
651 | k1 = 1.0_wp + 0.61_wp * q(k,j,i) |
---|
652 | k2 = 0.61_wp * pt(k,j,i) |
---|
653 | ELSE IF ( cloud_physics ) THEN |
---|
654 | IF ( ql(k,j,i) == 0.0_wp ) THEN |
---|
655 | k1 = 1.0_wp + 0.61_wp * q(k,j,i) |
---|
656 | k2 = 0.61_wp * pt(k,j,i) |
---|
657 | ELSE |
---|
658 | theta = pt(k,j,i) + pt_d_t(k) * l_d_cp * ql(k,j,i) |
---|
659 | temp = theta * t_d_pt(k) |
---|
660 | k1 = ( 1.0_wp - q(k,j,i) + 1.61_wp * & |
---|
661 | ( q(k,j,i) - ql(k,j,i) ) * & |
---|
662 | ( 1.0_wp + 0.622_wp * l_d_r / temp ) ) / & |
---|
663 | ( 1.0_wp + 0.622_wp * l_d_r * l_d_cp * & |
---|
664 | ( q(k,j,i) - ql(k,j,i) ) / ( temp * temp ) ) |
---|
665 | k2 = theta * ( l_d_cp / temp * k1 - 1.0_wp ) |
---|
666 | ENDIF |
---|
667 | ELSE IF ( cloud_droplets ) THEN |
---|
668 | k1 = 1.0_wp + 0.61_wp * q(k,j,i) - ql(k,j,i) |
---|
669 | k2 = 0.61_wp * pt(k,j,i) |
---|
670 | ENDIF |
---|
671 | |
---|
672 | tend(k,j,i) = tend(k,j,i) + g / vpt(k,j,i) * & |
---|
673 | ( k1* shf(j,i) + k2 * qsws(j,i) ) |
---|
674 | ENDDO |
---|
675 | |
---|
676 | ENDIF |
---|
677 | |
---|
678 | IF ( use_top_fluxes ) THEN |
---|
679 | |
---|
680 | DO j = nys, nyn |
---|
681 | |
---|
682 | k = nzt |
---|
683 | |
---|
684 | IF ( .NOT. cloud_physics .AND. .NOT. cloud_droplets ) THEN |
---|
685 | k1 = 1.0_wp + 0.61_wp * q(k,j,i) |
---|
686 | k2 = 0.61_wp * pt(k,j,i) |
---|
687 | ELSE IF ( cloud_physics ) THEN |
---|
688 | IF ( ql(k,j,i) == 0.0_wp ) THEN |
---|
689 | k1 = 1.0_wp + 0.61_wp * q(k,j,i) |
---|
690 | k2 = 0.61_wp * pt(k,j,i) |
---|
691 | ELSE |
---|
692 | theta = pt(k,j,i) + pt_d_t(k) * l_d_cp * ql(k,j,i) |
---|
693 | temp = theta * t_d_pt(k) |
---|
694 | k1 = ( 1.0_wp - q(k,j,i) + 1.61_wp * & |
---|
695 | ( q(k,j,i) - ql(k,j,i) ) * & |
---|
696 | ( 1.0_wp + 0.622_wp * l_d_r / temp ) ) / & |
---|
697 | ( 1.0_wp + 0.622_wp * l_d_r * l_d_cp * & |
---|
698 | ( q(k,j,i) - ql(k,j,i) ) / ( temp * temp ) ) |
---|
699 | k2 = theta * ( l_d_cp / temp * k1 - 1.0_wp ) |
---|
700 | ENDIF |
---|
701 | ELSE IF ( cloud_droplets ) THEN |
---|
702 | k1 = 1.0_wp + 0.61_wp * q(k,j,i) - ql(k,j,i) |
---|
703 | k2 = 0.61_wp * pt(k,j,i) |
---|
704 | ENDIF |
---|
705 | |
---|
706 | tend(k,j,i) = tend(k,j,i) + g / vpt(k,j,i) * & |
---|
707 | ( k1* tswst(j,i) + k2 * qswst(j,i) ) |
---|
708 | ENDDO |
---|
709 | |
---|
710 | ENDIF |
---|
711 | |
---|
712 | ENDIF |
---|
713 | |
---|
714 | ENDIF |
---|
715 | |
---|
716 | ENDDO |
---|
717 | |
---|
718 | END SUBROUTINE production_e |
---|
719 | |
---|
720 | |
---|
721 | !------------------------------------------------------------------------------! |
---|
722 | ! Description: |
---|
723 | ! ------------ |
---|
724 | !> Call for all grid points - accelerator version |
---|
725 | !------------------------------------------------------------------------------! |
---|
726 | SUBROUTINE production_e_acc |
---|
727 | |
---|
728 | USE arrays_3d, & |
---|
729 | ONLY: ddzw, dd2zu, kh, km, pt, q, ql, qsws, qswst, rho, shf, & |
---|
730 | tend, tswst, u, v, vpt, w |
---|
731 | |
---|
732 | USE cloud_parameters, & |
---|
733 | ONLY: l_d_cp, l_d_r, pt_d_t, t_d_pt |
---|
734 | |
---|
735 | USE control_parameters, & |
---|
736 | ONLY: cloud_droplets, cloud_physics, g, humidity, kappa, neutral, & |
---|
737 | ocean, prandtl_layer, pt_reference, rho_reference, & |
---|
738 | topography, use_single_reference_value, use_surface_fluxes, & |
---|
739 | use_top_fluxes |
---|
740 | |
---|
741 | USE grid_variables, & |
---|
742 | ONLY: ddx, dx, ddy, dy, wall_e_x, wall_e_y |
---|
743 | |
---|
744 | USE indices, & |
---|
745 | ONLY: i_left, i_right, j_north, j_south, nxl, nxr, nys, nyn, nzb, & |
---|
746 | nzb_diff_s_inner, nzb_diff_s_outer, nzb_s_inner, nzt, & |
---|
747 | nzt_diff |
---|
748 | |
---|
749 | IMPLICIT NONE |
---|
750 | |
---|
751 | INTEGER(iwp) :: i !< |
---|
752 | INTEGER(iwp) :: j !< |
---|
753 | INTEGER(iwp) :: k !< |
---|
754 | |
---|
755 | REAL(wp) :: def !< |
---|
756 | REAL(wp) :: dudx !< |
---|
757 | REAL(wp) :: dudy !< |
---|
758 | REAL(wp) :: dudz !< |
---|
759 | REAL(wp) :: dvdx !< |
---|
760 | REAL(wp) :: dvdy !< |
---|
761 | REAL(wp) :: dvdz !< |
---|
762 | REAL(wp) :: dwdx !< |
---|
763 | REAL(wp) :: dwdy !< |
---|
764 | REAL(wp) :: dwdz !< |
---|
765 | REAL(wp) :: k1 !< |
---|
766 | REAL(wp) :: k2 !< |
---|
767 | REAL(wp) :: km_neutral !< |
---|
768 | REAL(wp) :: theta !< |
---|
769 | REAL(wp) :: temp !< |
---|
770 | |
---|
771 | REAL(wp), DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: usvs !< |
---|
772 | REAL(wp), DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: vsus !< |
---|
773 | REAL(wp), DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: wsus !< |
---|
774 | REAL(wp), DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: wsvs !< |
---|
775 | !$acc declare create ( usvs, vsus, wsus, wsvs ) |
---|
776 | |
---|
777 | ! |
---|
778 | !-- First calculate horizontal momentum flux u'v', w'v', v'u', w'u' at |
---|
779 | !-- vertical walls, if neccessary |
---|
780 | !-- CAUTION: results are slightly different from the ij-version!! |
---|
781 | !-- ij-version should be called further below within the ij-loops!! |
---|
782 | IF ( topography /= 'flat' ) THEN |
---|
783 | CALL wall_fluxes_e_acc( usvs, 1.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, wall_e_y ) |
---|
784 | CALL wall_fluxes_e_acc( wsvs, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, wall_e_y ) |
---|
785 | CALL wall_fluxes_e_acc( vsus, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp, wall_e_x ) |
---|
786 | CALL wall_fluxes_e_acc( wsus, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, wall_e_x ) |
---|
787 | ENDIF |
---|
788 | |
---|
789 | |
---|
790 | ! |
---|
791 | !-- Calculate TKE production by shear |
---|
792 | !$acc kernels present( ddzw, dd2zu, kh, km, nzb_diff_s_inner, nzb_diff_s_outer ) & |
---|
793 | !$acc present( nzb_s_inner, pt, q, ql, qsws, qswst, rho ) & |
---|
794 | !$acc present( shf, tend, tswst, u, v, vpt, w, wall_e_x, wall_e_y ) & |
---|
795 | !$acc copyin( u_0, v_0 ) |
---|
796 | DO i = i_left, i_right |
---|
797 | DO j = j_south, j_north |
---|
798 | DO k = 1, nzt |
---|
799 | |
---|
800 | IF ( k >= nzb_diff_s_outer(j,i) ) THEN |
---|
801 | |
---|
802 | dudx = ( u(k,j,i+1) - u(k,j,i) ) * ddx |
---|
803 | dudy = 0.25_wp * ( u(k,j+1,i) + u(k,j+1,i+1) - & |
---|
804 | u(k,j-1,i) - u(k,j-1,i+1) ) * ddy |
---|
805 | dudz = 0.5_wp * ( u(k+1,j,i) + u(k+1,j,i+1) - & |
---|
806 | u(k-1,j,i) - u(k-1,j,i+1) ) * dd2zu(k) |
---|
807 | |
---|
808 | dvdx = 0.25_wp * ( v(k,j,i+1) + v(k,j+1,i+1) - & |
---|
809 | v(k,j,i-1) - v(k,j+1,i-1) ) * ddx |
---|
810 | dvdy = ( v(k,j+1,i) - v(k,j,i) ) * ddy |
---|
811 | dvdz = 0.5_wp * ( v(k+1,j,i) + v(k+1,j+1,i) - & |
---|
812 | v(k-1,j,i) - v(k-1,j+1,i) ) * dd2zu(k) |
---|
813 | |
---|
814 | dwdx = 0.25_wp * ( w(k,j,i+1) + w(k-1,j,i+1) - & |
---|
815 | w(k,j,i-1) - w(k-1,j,i-1) ) * ddx |
---|
816 | dwdy = 0.25_wp * ( w(k,j+1,i) + w(k-1,j+1,i) - & |
---|
817 | w(k,j-1,i) - w(k-1,j-1,i) ) * ddy |
---|
818 | dwdz = ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
819 | |
---|
820 | def = 2.0_wp * ( dudx**2 + dvdy**2 + dwdz**2 ) + & |
---|
821 | dudy**2 + dvdx**2 + dwdx**2 + dwdy**2 + dudz**2 + & |
---|
822 | dvdz**2 + 2.0_wp * ( dvdx*dudy + dwdx*dudz + dwdy*dvdz ) |
---|
823 | |
---|
824 | IF ( def < 0.0_wp ) def = 0.0_wp |
---|
825 | |
---|
826 | tend(k,j,i) = tend(k,j,i) + km(k,j,i) * def |
---|
827 | |
---|
828 | ENDIF |
---|
829 | |
---|
830 | ENDDO |
---|
831 | ENDDO |
---|
832 | ENDDO |
---|
833 | |
---|
834 | IF ( prandtl_layer ) THEN |
---|
835 | |
---|
836 | ! |
---|
837 | !-- Position beneath wall |
---|
838 | !-- (2) - Will allways be executed. |
---|
839 | !-- 'bottom and wall: use u_0,v_0 and wall functions' |
---|
840 | DO i = i_left, i_right |
---|
841 | DO j = j_south, j_north |
---|
842 | DO k = 1, nzt |
---|
843 | |
---|
844 | IF ( ( wall_e_x(j,i) /= 0.0_wp ).OR.( wall_e_y(j,i) /= 0.0_wp ) ) & |
---|
845 | THEN |
---|
846 | |
---|
847 | IF ( k == nzb_diff_s_inner(j,i) - 1 ) THEN |
---|
848 | dudx = ( u(k,j,i+1) - u(k,j,i) ) * ddx |
---|
849 | dudz = 0.5_wp * ( u(k+1,j,i) + u(k+1,j,i+1) - & |
---|
850 | u_0(j,i) - u_0(j,i+1) ) * dd2zu(k) |
---|
851 | dvdy = ( v(k,j+1,i) - v(k,j,i) ) * ddy |
---|
852 | dvdz = 0.5_wp * ( v(k+1,j,i) + v(k+1,j+1,i) - & |
---|
853 | v_0(j,i) - v_0(j+1,i) ) * dd2zu(k) |
---|
854 | dwdz = ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
855 | |
---|
856 | IF ( wall_e_y(j,i) /= 0.0_wp ) THEN |
---|
857 | ! |
---|
858 | !-- Inconsistency removed: as the thermal stratification is |
---|
859 | !-- not taken into account for the evaluation of the wall |
---|
860 | !-- fluxes at vertical walls, the eddy viscosity km must not |
---|
861 | !-- be used for the evaluation of the velocity gradients dudy |
---|
862 | !-- and dwdy |
---|
863 | !-- Note: The validity of the new method has not yet been |
---|
864 | !-- shown, as so far no suitable data for a validation |
---|
865 | !-- has been available |
---|
866 | ! CALL wall_fluxes_e( i, j, k, nzb_diff_s_outer(j,i)-2, & |
---|
867 | ! usvs, 1.0_wp, 0.0_wp, 0.0_wp, 0.0_wp ) |
---|
868 | ! CALL wall_fluxes_e( i, j, k, nzb_diff_s_outer(j,i)-2, & |
---|
869 | ! wsvs, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp ) |
---|
870 | km_neutral = kappa * & |
---|
871 | ( usvs(k,j,i)**2 + wsvs(k,j,i)**2 )**0.25_wp * & |
---|
872 | 0.5_wp * dy |
---|
873 | IF ( km_neutral > 0.0_wp ) THEN |
---|
874 | dudy = - wall_e_y(j,i) * usvs(k,j,i) / km_neutral |
---|
875 | dwdy = - wall_e_y(j,i) * wsvs(k,j,i) / km_neutral |
---|
876 | ELSE |
---|
877 | dudy = 0.0_wp |
---|
878 | dwdy = 0.0_wp |
---|
879 | ENDIF |
---|
880 | ELSE |
---|
881 | dudy = 0.25_wp * ( u(k,j+1,i) + u(k,j+1,i+1) - & |
---|
882 | u(k,j-1,i) - u(k,j-1,i+1) ) * ddy |
---|
883 | dwdy = 0.25_wp * ( w(k,j+1,i) + w(k-1,j+1,i) - & |
---|
884 | w(k,j-1,i) - w(k-1,j-1,i) ) * ddy |
---|
885 | ENDIF |
---|
886 | |
---|
887 | IF ( wall_e_x(j,i) /= 0.0_wp ) THEN |
---|
888 | ! |
---|
889 | !-- Inconsistency removed: as the thermal stratification is |
---|
890 | !-- not taken into account for the evaluation of the wall |
---|
891 | !-- fluxes at vertical walls, the eddy viscosity km must not |
---|
892 | !-- be used for the evaluation of the velocity gradients dvdx |
---|
893 | !-- and dwdx |
---|
894 | !-- Note: The validity of the new method has not yet been |
---|
895 | !-- shown, as so far no suitable data for a validation |
---|
896 | !-- has been available |
---|
897 | ! CALL wall_fluxes_e( i, j, k, nzb_diff_s_outer(j,i)-2, & |
---|
898 | ! vsus, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp ) |
---|
899 | ! CALL wall_fluxes_e( i, j, k, nzb_diff_s_outer(j,i)-2, & |
---|
900 | ! wsus, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp ) |
---|
901 | km_neutral = kappa * & |
---|
902 | ( vsus(k,j,i)**2 + wsus(k,j,i)**2 )**0.25_wp * & |
---|
903 | 0.5_wp * dx |
---|
904 | IF ( km_neutral > 0.0_wp ) THEN |
---|
905 | dvdx = - wall_e_x(j,i) * vsus(k,j,i) / km_neutral |
---|
906 | dwdx = - wall_e_x(j,i) * wsus(k,j,i) / km_neutral |
---|
907 | ELSE |
---|
908 | dvdx = 0.0_wp |
---|
909 | dwdx = 0.0_wp |
---|
910 | ENDIF |
---|
911 | ELSE |
---|
912 | dvdx = 0.25_wp * ( v(k,j,i+1) + v(k,j+1,i+1) - & |
---|
913 | v(k,j,i-1) - v(k,j+1,i-1) ) * ddx |
---|
914 | dwdx = 0.25_wp * ( w(k,j,i+1) + w(k-1,j,i+1) - & |
---|
915 | w(k,j,i-1) - w(k-1,j,i-1) ) * ddx |
---|
916 | ENDIF |
---|
917 | |
---|
918 | def = 2.0_wp * ( dudx**2 + dvdy**2 + dwdz**2 ) + & |
---|
919 | dudy**2 + dvdx**2 + dwdx**2 + dwdy**2 + dudz**2 + & |
---|
920 | dvdz**2 + 2.0_wp * ( dvdx*dudy + dwdx*dudz + dwdy*dvdz ) |
---|
921 | |
---|
922 | IF ( def < 0.0_wp ) def = 0.0_wp |
---|
923 | |
---|
924 | tend(k,j,i) = tend(k,j,i) + km(k,j,i) * def |
---|
925 | |
---|
926 | ENDIF |
---|
927 | ! |
---|
928 | !-- (3) - will be executed only, if there is at least one level |
---|
929 | !-- between (2) and (4), i.e. the topography must have a |
---|
930 | !-- minimum height of 2 dz. Wall fluxes for this case have |
---|
931 | !-- already been calculated for (2). |
---|
932 | !-- 'wall only: use wall functions' |
---|
933 | |
---|
934 | IF ( k >= nzb_diff_s_inner(j,i) .AND. & |
---|
935 | k <= nzb_diff_s_outer(j,i)-2 ) THEN |
---|
936 | |
---|
937 | dudx = ( u(k,j,i+1) - u(k,j,i) ) * ddx |
---|
938 | dudz = 0.5_wp * ( u(k+1,j,i) + u(k+1,j,i+1) - & |
---|
939 | u(k-1,j,i) - u(k-1,j,i+1) ) * dd2zu(k) |
---|
940 | dvdy = ( v(k,j+1,i) - v(k,j,i) ) * ddy |
---|
941 | dvdz = 0.5_wp * ( v(k+1,j,i) + v(k+1,j+1,i) - & |
---|
942 | v(k-1,j,i) - v(k-1,j+1,i) ) * dd2zu(k) |
---|
943 | dwdz = ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
944 | |
---|
945 | IF ( wall_e_y(j,i) /= 0.0_wp ) THEN |
---|
946 | ! |
---|
947 | !-- Inconsistency removed: as the thermal stratification |
---|
948 | !-- is not taken into account for the evaluation of the |
---|
949 | !-- wall fluxes at vertical walls, the eddy viscosity km |
---|
950 | !-- must not be used for the evaluation of the velocity |
---|
951 | !-- gradients dudy and dwdy |
---|
952 | !-- Note: The validity of the new method has not yet |
---|
953 | !-- been shown, as so far no suitable data for a |
---|
954 | !-- validation has been available |
---|
955 | km_neutral = kappa * ( usvs(k,j,i)**2 + & |
---|
956 | wsvs(k,j,i)**2 )**0.25_wp * 0.5_wp * dy |
---|
957 | IF ( km_neutral > 0.0_wp ) THEN |
---|
958 | dudy = - wall_e_y(j,i) * usvs(k,j,i) / km_neutral |
---|
959 | dwdy = - wall_e_y(j,i) * wsvs(k,j,i) / km_neutral |
---|
960 | ELSE |
---|
961 | dudy = 0.0_wp |
---|
962 | dwdy = 0.0_wp |
---|
963 | ENDIF |
---|
964 | ELSE |
---|
965 | dudy = 0.25_wp * ( u(k,j+1,i) + u(k,j+1,i+1) - & |
---|
966 | u(k,j-1,i) - u(k,j-1,i+1) ) * ddy |
---|
967 | dwdy = 0.25_wp * ( w(k,j+1,i) + w(k-1,j+1,i) - & |
---|
968 | w(k,j-1,i) - w(k-1,j-1,i) ) * ddy |
---|
969 | ENDIF |
---|
970 | |
---|
971 | IF ( wall_e_x(j,i) /= 0.0_wp ) THEN |
---|
972 | ! |
---|
973 | !-- Inconsistency removed: as the thermal stratification |
---|
974 | !-- is not taken into account for the evaluation of the |
---|
975 | !-- wall fluxes at vertical walls, the eddy viscosity km |
---|
976 | !-- must not be used for the evaluation of the velocity |
---|
977 | !-- gradients dvdx and dwdx |
---|
978 | !-- Note: The validity of the new method has not yet |
---|
979 | !-- been shown, as so far no suitable data for a |
---|
980 | !-- validation has been available |
---|
981 | km_neutral = kappa * ( vsus(k,j,i)**2 + & |
---|
982 | wsus(k,j,i)**2 )**0.25_wp * 0.5_wp * dx |
---|
983 | IF ( km_neutral > 0.0_wp ) THEN |
---|
984 | dvdx = - wall_e_x(j,i) * vsus(k,j,i) / km_neutral |
---|
985 | dwdx = - wall_e_x(j,i) * wsus(k,j,i) / km_neutral |
---|
986 | ELSE |
---|
987 | dvdx = 0.0_wp |
---|
988 | dwdx = 0.0_wp |
---|
989 | ENDIF |
---|
990 | ELSE |
---|
991 | dvdx = 0.25_wp * ( v(k,j,i+1) + v(k,j+1,i+1) - & |
---|
992 | v(k,j,i-1) - v(k,j+1,i-1) ) * ddx |
---|
993 | dwdx = 0.25_wp * ( w(k,j,i+1) + w(k-1,j,i+1) - & |
---|
994 | w(k,j,i-1) - w(k-1,j,i-1) ) * ddx |
---|
995 | ENDIF |
---|
996 | |
---|
997 | def = 2.0_wp * ( dudx**2 + dvdy**2 + dwdz**2 ) + & |
---|
998 | dudy**2 + dvdx**2 + dwdx**2 + dwdy**2 + dudz**2 + & |
---|
999 | dvdz**2 + 2.0_wp * ( dvdx*dudy + dwdx*dudz + dwdy*dvdz ) |
---|
1000 | |
---|
1001 | IF ( def < 0.0_wp ) def = 0.0_wp |
---|
1002 | |
---|
1003 | tend(k,j,i) = tend(k,j,i) + km(k,j,i) * def |
---|
1004 | |
---|
1005 | ENDIF |
---|
1006 | |
---|
1007 | ! |
---|
1008 | !-- (4) - will allways be executed. |
---|
1009 | !-- 'special case: free atmosphere' (as for case (0)) |
---|
1010 | IF ( k == nzb_diff_s_outer(j,i)-1 ) THEN |
---|
1011 | |
---|
1012 | dudx = ( u(k,j,i+1) - u(k,j,i) ) * ddx |
---|
1013 | dudy = 0.25_wp * ( u(k,j+1,i) + u(k,j+1,i+1) - & |
---|
1014 | u(k,j-1,i) - u(k,j-1,i+1) ) * ddy |
---|
1015 | dudz = 0.5_wp * ( u(k+1,j,i) + u(k+1,j,i+1) - & |
---|
1016 | u(k-1,j,i) - u(k-1,j,i+1) ) * dd2zu(k) |
---|
1017 | |
---|
1018 | dvdx = 0.25_wp * ( v(k,j,i+1) + v(k,j+1,i+1) - & |
---|
1019 | v(k,j,i-1) - v(k,j+1,i-1) ) * ddx |
---|
1020 | dvdy = ( v(k,j+1,i) - v(k,j,i) ) * ddy |
---|
1021 | dvdz = 0.5_wp * ( v(k+1,j,i) + v(k+1,j+1,i) - & |
---|
1022 | v(k-1,j,i) - v(k-1,j+1,i) ) * dd2zu(k) |
---|
1023 | |
---|
1024 | dwdx = 0.25_wp * ( w(k,j,i+1) + w(k-1,j,i+1) - & |
---|
1025 | w(k,j,i-1) - w(k-1,j,i-1) ) * ddx |
---|
1026 | dwdy = 0.25_wp * ( w(k,j+1,i) + w(k-1,j+1,i) - & |
---|
1027 | w(k,j-1,i) - w(k-1,j-1,i) ) * ddy |
---|
1028 | dwdz = ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
1029 | |
---|
1030 | def = 2.0_wp * ( dudx**2 + dvdy**2 + dwdz**2 ) + & |
---|
1031 | dudy**2 + dvdx**2 + dwdx**2 + dwdy**2 + dudz**2 + & |
---|
1032 | dvdz**2 + 2.0_wp * ( dvdx*dudy + dwdx*dudz + dwdy*dvdz ) |
---|
1033 | |
---|
1034 | IF ( def < 0.0_wp ) def = 0.0_wp |
---|
1035 | |
---|
1036 | tend(k,j,i) = tend(k,j,i) + km(k,j,i) * def |
---|
1037 | |
---|
1038 | ENDIF |
---|
1039 | |
---|
1040 | ENDIF |
---|
1041 | |
---|
1042 | ENDDO |
---|
1043 | ENDDO |
---|
1044 | ENDDO |
---|
1045 | |
---|
1046 | ! |
---|
1047 | !-- Position without adjacent wall |
---|
1048 | !-- (1) - will allways be executed. |
---|
1049 | !-- 'bottom only: use u_0,v_0' |
---|
1050 | DO i = i_left, i_right |
---|
1051 | DO j = j_south, j_north |
---|
1052 | DO k = 1, nzt |
---|
1053 | |
---|
1054 | IF ( ( wall_e_x(j,i) == 0.0_wp ) .AND. ( wall_e_y(j,i) == 0.0_wp ) ) & |
---|
1055 | THEN |
---|
1056 | |
---|
1057 | IF ( k == nzb_diff_s_inner(j,i)-1 ) THEN |
---|
1058 | |
---|
1059 | dudx = ( u(k,j,i+1) - u(k,j,i) ) * ddx |
---|
1060 | dudy = 0.25_wp * ( u(k,j+1,i) + u(k,j+1,i+1) - & |
---|
1061 | u(k,j-1,i) - u(k,j-1,i+1) ) * ddy |
---|
1062 | dudz = 0.5_wp * ( u(k+1,j,i) + u(k+1,j,i+1) - & |
---|
1063 | u_0(j,i) - u_0(j,i+1) ) * dd2zu(k) |
---|
1064 | |
---|
1065 | dvdx = 0.25_wp * ( v(k,j,i+1) + v(k,j+1,i+1) - & |
---|
1066 | v(k,j,i-1) - v(k,j+1,i-1) ) * ddx |
---|
1067 | dvdy = ( v(k,j+1,i) - v(k,j,i) ) * ddy |
---|
1068 | dvdz = 0.5_wp * ( v(k+1,j,i) + v(k+1,j+1,i) - & |
---|
1069 | v_0(j,i) - v_0(j+1,i) ) * dd2zu(k) |
---|
1070 | |
---|
1071 | dwdx = 0.25_wp * ( w(k,j,i+1) + w(k-1,j,i+1) - & |
---|
1072 | w(k,j,i-1) - w(k-1,j,i-1) ) * ddx |
---|
1073 | dwdy = 0.25_wp * ( w(k,j+1,i) + w(k-1,j+1,i) - & |
---|
1074 | w(k,j-1,i) - w(k-1,j-1,i) ) * ddy |
---|
1075 | dwdz = ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
1076 | |
---|
1077 | def = 2.0_wp * ( dudx**2 + dvdy**2 + dwdz**2 ) + & |
---|
1078 | dudy**2 + dvdx**2 + dwdx**2 + dwdy**2 + dudz**2 + & |
---|
1079 | dvdz**2 + 2.0_wp * ( dvdx*dudy + dwdx*dudz + dwdy*dvdz ) |
---|
1080 | |
---|
1081 | IF ( def < 0.0_wp ) def = 0.0_wp |
---|
1082 | |
---|
1083 | tend(k,j,i) = tend(k,j,i) + km(k,j,i) * def |
---|
1084 | |
---|
1085 | ENDIF |
---|
1086 | |
---|
1087 | ENDIF |
---|
1088 | |
---|
1089 | ENDDO |
---|
1090 | ENDDO |
---|
1091 | ENDDO |
---|
1092 | |
---|
1093 | ELSEIF ( use_surface_fluxes ) THEN |
---|
1094 | |
---|
1095 | DO i = i_left, i_right |
---|
1096 | DO j = j_south, j_north |
---|
1097 | DO k = 1, nzt |
---|
1098 | |
---|
1099 | IF ( k == nzb_diff_s_outer(j,i)-1 ) THEN |
---|
1100 | |
---|
1101 | dudx = ( u(k,j,i+1) - u(k,j,i) ) * ddx |
---|
1102 | dudy = 0.25_wp * ( u(k,j+1,i) + u(k,j+1,i+1) - & |
---|
1103 | u(k,j-1,i) - u(k,j-1,i+1) ) * ddy |
---|
1104 | dudz = 0.5_wp * ( u(k+1,j,i) + u(k+1,j,i+1) - & |
---|
1105 | u(k-1,j,i) - u(k-1,j,i+1) ) * dd2zu(k) |
---|
1106 | |
---|
1107 | dvdx = 0.25_wp * ( v(k,j,i+1) + v(k,j+1,i+1) - & |
---|
1108 | v(k,j,i-1) - v(k,j+1,i-1) ) * ddx |
---|
1109 | dvdy = ( v(k,j+1,i) - v(k,j,i) ) * ddy |
---|
1110 | dvdz = 0.5_wp * ( v(k+1,j,i) + v(k+1,j+1,i) - & |
---|
1111 | v(k-1,j,i) - v(k-1,j+1,i) ) * dd2zu(k) |
---|
1112 | |
---|
1113 | dwdx = 0.25_wp * ( w(k,j,i+1) + w(k-1,j,i+1) - & |
---|
1114 | w(k,j,i-1) - w(k-1,j,i-1) ) * ddx |
---|
1115 | dwdy = 0.25_wp * ( w(k,j+1,i) + w(k-1,j+1,i) - & |
---|
1116 | w(k,j-1,i) - w(k-1,j-1,i) ) * ddy |
---|
1117 | dwdz = ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
1118 | |
---|
1119 | def = 2.0_wp * ( dudx**2 + dvdy**2 + dwdz**2 ) + & |
---|
1120 | dudy**2 + dvdx**2 + dwdx**2 + dwdy**2 + dudz**2 + & |
---|
1121 | dvdz**2 + 2.0_wp * ( dvdx*dudy + dwdx*dudz + dwdy*dvdz ) |
---|
1122 | |
---|
1123 | IF ( def < 0.0_wp ) def = 0.0_wp |
---|
1124 | |
---|
1125 | tend(k,j,i) = tend(k,j,i) + km(k,j,i) * def |
---|
1126 | |
---|
1127 | ENDIF |
---|
1128 | |
---|
1129 | ENDDO |
---|
1130 | ENDDO |
---|
1131 | ENDDO |
---|
1132 | |
---|
1133 | ENDIF |
---|
1134 | |
---|
1135 | ! |
---|
1136 | !-- If required, calculate TKE production by buoyancy |
---|
1137 | IF ( .NOT. neutral ) THEN |
---|
1138 | |
---|
1139 | IF ( .NOT. humidity ) THEN |
---|
1140 | |
---|
1141 | IF ( use_single_reference_value ) THEN |
---|
1142 | |
---|
1143 | IF ( ocean ) THEN |
---|
1144 | ! |
---|
1145 | !-- So far in the ocean no special treatment of density flux |
---|
1146 | !-- in the bottom and top surface layer |
---|
1147 | DO i = i_left, i_right |
---|
1148 | DO j = j_south, j_north |
---|
1149 | DO k = 1, nzt |
---|
1150 | IF ( k > nzb_s_inner(j,i) ) THEN |
---|
1151 | tend(k,j,i) = tend(k,j,i) + & |
---|
1152 | kh(k,j,i) * g / rho_reference * & |
---|
1153 | ( rho(k+1,j,i) - rho(k-1,j,i) ) * & |
---|
1154 | dd2zu(k) |
---|
1155 | ENDIF |
---|
1156 | ENDDO |
---|
1157 | ENDDO |
---|
1158 | ENDDO |
---|
1159 | |
---|
1160 | ELSE |
---|
1161 | |
---|
1162 | DO i = i_left, i_right |
---|
1163 | DO j = j_south, j_north |
---|
1164 | DO k = 1, nzt_diff |
---|
1165 | IF ( k >= nzb_diff_s_inner(j,i) ) THEN |
---|
1166 | tend(k,j,i) = tend(k,j,i) - & |
---|
1167 | kh(k,j,i) * g / pt_reference * & |
---|
1168 | ( pt(k+1,j,i) - pt(k-1,j,i) ) * & |
---|
1169 | dd2zu(k) |
---|
1170 | ENDIF |
---|
1171 | |
---|
1172 | IF ( k == nzb_diff_s_inner(j,i)-1 .AND. & |
---|
1173 | use_surface_fluxes ) THEN |
---|
1174 | tend(k,j,i) = tend(k,j,i) + g / pt_reference * & |
---|
1175 | shf(j,i) |
---|
1176 | ENDIF |
---|
1177 | |
---|
1178 | IF ( k == nzt .AND. use_top_fluxes ) THEN |
---|
1179 | tend(k,j,i) = tend(k,j,i) + g / pt_reference * & |
---|
1180 | tswst(j,i) |
---|
1181 | ENDIF |
---|
1182 | ENDDO |
---|
1183 | ENDDO |
---|
1184 | ENDDO |
---|
1185 | |
---|
1186 | ENDIF |
---|
1187 | |
---|
1188 | ELSE |
---|
1189 | |
---|
1190 | IF ( ocean ) THEN |
---|
1191 | ! |
---|
1192 | !-- So far in the ocean no special treatment of density flux |
---|
1193 | !-- in the bottom and top surface layer |
---|
1194 | DO i = i_left, i_right |
---|
1195 | DO j = j_south, j_north |
---|
1196 | DO k = 1, nzt |
---|
1197 | IF ( k > nzb_s_inner(j,i) ) THEN |
---|
1198 | tend(k,j,i) = tend(k,j,i) + & |
---|
1199 | kh(k,j,i) * g / rho(k,j,i) * & |
---|
1200 | ( rho(k+1,j,i) - rho(k-1,j,i) ) * & |
---|
1201 | dd2zu(k) |
---|
1202 | ENDIF |
---|
1203 | ENDDO |
---|
1204 | ENDDO |
---|
1205 | ENDDO |
---|
1206 | |
---|
1207 | ELSE |
---|
1208 | |
---|
1209 | DO i = i_left, i_right |
---|
1210 | DO j = j_south, j_north |
---|
1211 | DO k = 1, nzt_diff |
---|
1212 | IF( k >= nzb_diff_s_inner(j,i) ) THEN |
---|
1213 | tend(k,j,i) = tend(k,j,i) - & |
---|
1214 | kh(k,j,i) * g / pt(k,j,i) * & |
---|
1215 | ( pt(k+1,j,i) - pt(k-1,j,i) ) * & |
---|
1216 | dd2zu(k) |
---|
1217 | ENDIF |
---|
1218 | |
---|
1219 | IF ( k == nzb_diff_s_inner(j,i)-1 .AND. & |
---|
1220 | use_surface_fluxes ) THEN |
---|
1221 | tend(k,j,i) = tend(k,j,i) + g / pt(k,j,i) * & |
---|
1222 | shf(j,i) |
---|
1223 | ENDIF |
---|
1224 | |
---|
1225 | IF ( k == nzt .AND. use_top_fluxes ) THEN |
---|
1226 | tend(k,j,i) = tend(k,j,i) + g / pt(k,j,i) * & |
---|
1227 | tswst(j,i) |
---|
1228 | ENDIF |
---|
1229 | ENDDO |
---|
1230 | ENDDO |
---|
1231 | ENDDO |
---|
1232 | |
---|
1233 | ENDIF |
---|
1234 | |
---|
1235 | ENDIF |
---|
1236 | |
---|
1237 | ELSE |
---|
1238 | ! |
---|
1239 | !++ This part gives the PGI compiler problems in the previous loop |
---|
1240 | !++ even without any acc statements???? |
---|
1241 | ! STOP '+++ production_e problems with acc-directives' |
---|
1242 | ! !acc loop |
---|
1243 | ! DO i = nxl, nxr |
---|
1244 | ! DO j = nys, nyn |
---|
1245 | ! !acc loop vector |
---|
1246 | ! DO k = 1, nzt_diff |
---|
1247 | ! |
---|
1248 | ! IF ( k >= nzb_diff_s_inner(j,i) ) THEN |
---|
1249 | ! |
---|
1250 | ! IF ( .NOT. cloud_physics .AND. .NOT. cloud_droplets ) THEN |
---|
1251 | ! k1 = 1.0_wp + 0.61_wp * q(k,j,i) |
---|
1252 | ! k2 = 0.61_wp * pt(k,j,i) |
---|
1253 | ! tend(k,j,i) = tend(k,j,i) - kh(k,j,i) * & |
---|
1254 | ! g / vpt(k,j,i) * & |
---|
1255 | ! ( k1 * ( pt(k+1,j,i)-pt(k-1,j,i) ) + & |
---|
1256 | ! k2 * ( q(k+1,j,i) - q(k-1,j,i) ) & |
---|
1257 | ! ) * dd2zu(k) |
---|
1258 | ! ELSE IF ( cloud_physics ) THEN |
---|
1259 | ! IF ( ql(k,j,i) == 0.0_wp ) THEN |
---|
1260 | ! k1 = 1.0_wp + 0.61_wp * q(k,j,i) |
---|
1261 | ! k2 = 0.61_wp * pt(k,j,i) |
---|
1262 | ! ELSE |
---|
1263 | ! theta = pt(k,j,i) + pt_d_t(k) * l_d_cp * ql(k,j,i) |
---|
1264 | ! temp = theta * t_d_pt(k) |
---|
1265 | ! k1 = ( 1.0_wp - q(k,j,i) + 1.61_wp * & |
---|
1266 | ! ( q(k,j,i) - ql(k,j,i) ) * & |
---|
1267 | ! ( 1.0_wp + 0.622_wp * l_d_r / temp ) ) / & |
---|
1268 | ! ( 1.0_wp + 0.622_wp * l_d_r * l_d_cp * & |
---|
1269 | ! ( q(k,j,i) - ql(k,j,i) ) / ( temp * temp ) ) |
---|
1270 | ! k2 = theta * ( l_d_cp / temp * k1 - 1.0_wp ) |
---|
1271 | ! ENDIF |
---|
1272 | ! tend(k,j,i) = tend(k,j,i) - kh(k,j,i) * & |
---|
1273 | ! g / vpt(k,j,i) * & |
---|
1274 | ! ( k1 * ( pt(k+1,j,i)-pt(k-1,j,i) ) + & |
---|
1275 | ! k2 * ( q(k+1,j,i) - q(k-1,j,i) ) & |
---|
1276 | ! ) * dd2zu(k) |
---|
1277 | ! ELSE IF ( cloud_droplets ) THEN |
---|
1278 | ! k1 = 1.0_wp + 0.61_wp * q(k,j,i) - ql(k,j,i) |
---|
1279 | ! k2 = 0.61_wp * pt(k,j,i) |
---|
1280 | ! tend(k,j,i) = tend(k,j,i) - & |
---|
1281 | ! kh(k,j,i) * g / vpt(k,j,i) * & |
---|
1282 | ! ( k1 * ( pt(k+1,j,i)- pt(k-1,j,i) ) + & |
---|
1283 | ! k2 * ( q(k+1,j,i) - q(k-1,j,i) ) - & |
---|
1284 | ! pt(k,j,i) * ( ql(k+1,j,i) - & |
---|
1285 | ! ql(k-1,j,i) ) ) * dd2zu(k) |
---|
1286 | ! ENDIF |
---|
1287 | ! |
---|
1288 | ! ENDIF |
---|
1289 | ! |
---|
1290 | ! ENDDO |
---|
1291 | ! ENDDO |
---|
1292 | ! ENDDO |
---|
1293 | ! |
---|
1294 | |
---|
1295 | !!++ Next two loops are probably very inefficiently parallellized |
---|
1296 | !!++ and will require better optimization |
---|
1297 | ! IF ( use_surface_fluxes ) THEN |
---|
1298 | ! |
---|
1299 | ! !acc loop |
---|
1300 | ! DO i = nxl, nxr |
---|
1301 | ! DO j = nys, nyn |
---|
1302 | ! !acc loop vector |
---|
1303 | ! DO k = 1, nzt_diff |
---|
1304 | ! |
---|
1305 | ! IF ( k == nzb_diff_s_inner(j,i)-1 ) THEN |
---|
1306 | ! |
---|
1307 | ! IF ( .NOT. cloud_physics .AND. .NOT. cloud_droplets ) THEN |
---|
1308 | ! k1 = 1.0_wp + 0.61_wp * q(k,j,i) |
---|
1309 | ! k2 = 0.61_wp * pt(k,j,i) |
---|
1310 | ! ELSE IF ( cloud_physics ) THEN |
---|
1311 | ! IF ( ql(k,j,i) == 0.0_wp ) THEN |
---|
1312 | ! k1 = 1.0_wp + 0.61_wp * q(k,j,i) |
---|
1313 | ! k2 = 0.61_wp * pt(k,j,i) |
---|
1314 | ! ELSE |
---|
1315 | ! theta = pt(k,j,i) + pt_d_t(k) * l_d_cp * ql(k,j,i) |
---|
1316 | ! temp = theta * t_d_pt(k) |
---|
1317 | ! k1 = ( 1.0_wp - q(k,j,i) + 1.61_wp * & |
---|
1318 | ! ( q(k,j,i) - ql(k,j,i) ) * & |
---|
1319 | ! ( 1.0_wp + 0.622_wp * l_d_r / temp ) ) /& |
---|
1320 | ! ( 1.0_wp + 0.622_wp * l_d_r * l_d_cp * & |
---|
1321 | ! ( q(k,j,i) - ql(k,j,i) ) / ( temp * temp ) ) |
---|
1322 | ! k2 = theta * ( l_d_cp / temp * k1 - 1.0_wp ) |
---|
1323 | ! ENDIF |
---|
1324 | ! ELSE IF ( cloud_droplets ) THEN |
---|
1325 | ! k1 = 1.0_wp + 0.61_wp * q(k,j,i) - ql(k,j,i) |
---|
1326 | ! k2 = 0.61_wp * pt(k,j,i) |
---|
1327 | ! ENDIF |
---|
1328 | ! |
---|
1329 | ! tend(k,j,i) = tend(k,j,i) + g / vpt(k,j,i) * & |
---|
1330 | ! ( k1* shf(j,i) + k2 * qsws(j,i) ) |
---|
1331 | ! ENDIF |
---|
1332 | ! |
---|
1333 | ! ENDDO |
---|
1334 | ! ENDDO |
---|
1335 | ! ENDDO |
---|
1336 | ! |
---|
1337 | ! ENDIF |
---|
1338 | ! |
---|
1339 | ! IF ( use_top_fluxes ) THEN |
---|
1340 | ! |
---|
1341 | ! !acc loop |
---|
1342 | ! DO i = nxl, nxr |
---|
1343 | ! DO j = nys, nyn |
---|
1344 | ! !acc loop vector |
---|
1345 | ! DO k = 1, nzt |
---|
1346 | ! IF ( k == nzt ) THEN |
---|
1347 | ! |
---|
1348 | ! IF ( .NOT. cloud_physics .AND. .NOT. cloud_droplets ) THEN |
---|
1349 | ! k1 = 1.0_wp + 0.61_wp * q(k,j,i) |
---|
1350 | ! k2 = 0.61_wp * pt(k,j,i) |
---|
1351 | ! ELSE IF ( cloud_physics ) THEN |
---|
1352 | ! IF ( ql(k,j,i) == 0.0_wp ) THEN |
---|
1353 | ! k1 = 1.0_wp + 0.61_wp * q(k,j,i) |
---|
1354 | ! k2 = 0.61_wp * pt(k,j,i) |
---|
1355 | ! ELSE |
---|
1356 | ! theta = pt(k,j,i) + pt_d_t(k) * l_d_cp * ql(k,j,i) |
---|
1357 | ! temp = theta * t_d_pt(k) |
---|
1358 | ! k1 = ( 1.0_wp - q(k,j,i) + 1.61_wp * & |
---|
1359 | ! ( q(k,j,i) - ql(k,j,i) ) * & |
---|
1360 | ! ( 1.0_wp + 0.622_wp * l_d_r / temp ) ) /& |
---|
1361 | ! ( 1.0_wp + 0.622_wp * l_d_r * l_d_cp * & |
---|
1362 | ! ( q(k,j,i) - ql(k,j,i) ) / ( temp * temp ) ) |
---|
1363 | ! k2 = theta * ( l_d_cp / temp * k1 - 1.0_wp ) |
---|
1364 | ! ENDIF |
---|
1365 | ! ELSE IF ( cloud_droplets ) THEN |
---|
1366 | ! k1 = 1.0_wp + 0.61_wp * q(k,j,i) - ql(k,j,i) |
---|
1367 | ! k2 = 0.61_wp * pt(k,j,i) |
---|
1368 | ! ENDIF |
---|
1369 | ! |
---|
1370 | ! tend(k,j,i) = tend(k,j,i) + g / vpt(k,j,i) * & |
---|
1371 | ! ( k1* tswst(j,i) + k2 * qswst(j,i) ) |
---|
1372 | ! |
---|
1373 | ! ENDIF |
---|
1374 | ! |
---|
1375 | ! ENDDO |
---|
1376 | ! ENDDO |
---|
1377 | ! ENDDO |
---|
1378 | ! |
---|
1379 | ! ENDIF |
---|
1380 | |
---|
1381 | ENDIF |
---|
1382 | |
---|
1383 | ENDIF |
---|
1384 | !$acc end kernels |
---|
1385 | |
---|
1386 | END SUBROUTINE production_e_acc |
---|
1387 | |
---|
1388 | |
---|
1389 | !------------------------------------------------------------------------------! |
---|
1390 | ! Description: |
---|
1391 | ! ------------ |
---|
1392 | !> Call for grid point i,j |
---|
1393 | !------------------------------------------------------------------------------! |
---|
1394 | SUBROUTINE production_e_ij( i, j ) |
---|
1395 | |
---|
1396 | USE arrays_3d, & |
---|
1397 | ONLY: ddzw, dd2zu, kh, km, pt, q, ql, qsws, qswst, rho, shf, & |
---|
1398 | tend, tswst, u, v, vpt, w |
---|
1399 | |
---|
1400 | USE cloud_parameters, & |
---|
1401 | ONLY: l_d_cp, l_d_r, pt_d_t, t_d_pt |
---|
1402 | |
---|
1403 | USE control_parameters, & |
---|
1404 | ONLY: cloud_droplets, cloud_physics, g, humidity, kappa, neutral, & |
---|
1405 | ocean, prandtl_layer, pt_reference, rho_reference, & |
---|
1406 | use_single_reference_value, use_surface_fluxes, & |
---|
1407 | use_top_fluxes |
---|
1408 | |
---|
1409 | USE grid_variables, & |
---|
1410 | ONLY: ddx, dx, ddy, dy, wall_e_x, wall_e_y |
---|
1411 | |
---|
1412 | USE indices, & |
---|
1413 | ONLY: nxl, nxr, nys, nyn, nzb, nzb_diff_s_inner, & |
---|
1414 | nzb_diff_s_outer, nzb_s_inner, nzt, nzt_diff |
---|
1415 | |
---|
1416 | IMPLICIT NONE |
---|
1417 | |
---|
1418 | INTEGER(iwp) :: i !< |
---|
1419 | INTEGER(iwp) :: j !< |
---|
1420 | INTEGER(iwp) :: k !< |
---|
1421 | |
---|
1422 | REAL(wp) :: def !< |
---|
1423 | REAL(wp) :: dudx !< |
---|
1424 | REAL(wp) :: dudy !< |
---|
1425 | REAL(wp) :: dudz !< |
---|
1426 | REAL(wp) :: dvdx !< |
---|
1427 | REAL(wp) :: dvdy !< |
---|
1428 | REAL(wp) :: dvdz !< |
---|
1429 | REAL(wp) :: dwdx !< |
---|
1430 | REAL(wp) :: dwdy !< |
---|
1431 | REAL(wp) :: dwdz !< |
---|
1432 | REAL(wp) :: k1 !< |
---|
1433 | REAL(wp) :: k2 !< |
---|
1434 | REAL(wp) :: km_neutral !< |
---|
1435 | REAL(wp) :: theta !< |
---|
1436 | REAL(wp) :: temp !< |
---|
1437 | |
---|
1438 | REAL(wp), DIMENSION(nzb:nzt+1) :: usvs !< |
---|
1439 | REAL(wp), DIMENSION(nzb:nzt+1) :: vsus !< |
---|
1440 | REAL(wp), DIMENSION(nzb:nzt+1) :: wsus !< |
---|
1441 | REAL(wp), DIMENSION(nzb:nzt+1) :: wsvs !< |
---|
1442 | |
---|
1443 | ! |
---|
1444 | !-- Calculate TKE production by shear |
---|
1445 | DO k = nzb_diff_s_outer(j,i), nzt |
---|
1446 | |
---|
1447 | dudx = ( u(k,j,i+1) - u(k,j,i) ) * ddx |
---|
1448 | dudy = 0.25_wp * ( u(k,j+1,i) + u(k,j+1,i+1) - & |
---|
1449 | u(k,j-1,i) - u(k,j-1,i+1) ) * ddy |
---|
1450 | dudz = 0.5_wp * ( u(k+1,j,i) + u(k+1,j,i+1) - & |
---|
1451 | u(k-1,j,i) - u(k-1,j,i+1) ) * dd2zu(k) |
---|
1452 | |
---|
1453 | dvdx = 0.25_wp * ( v(k,j,i+1) + v(k,j+1,i+1) - & |
---|
1454 | v(k,j,i-1) - v(k,j+1,i-1) ) * ddx |
---|
1455 | dvdy = ( v(k,j+1,i) - v(k,j,i) ) * ddy |
---|
1456 | dvdz = 0.5_wp * ( v(k+1,j,i) + v(k+1,j+1,i) - & |
---|
1457 | v(k-1,j,i) - v(k-1,j+1,i) ) * dd2zu(k) |
---|
1458 | |
---|
1459 | dwdx = 0.25_wp * ( w(k,j,i+1) + w(k-1,j,i+1) - & |
---|
1460 | w(k,j,i-1) - w(k-1,j,i-1) ) * ddx |
---|
1461 | dwdy = 0.25_wp * ( w(k,j+1,i) + w(k-1,j+1,i) - & |
---|
1462 | w(k,j-1,i) - w(k-1,j-1,i) ) * ddy |
---|
1463 | dwdz = ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
1464 | |
---|
1465 | def = 2.0_wp * ( dudx**2 + dvdy**2 + dwdz**2 ) & |
---|
1466 | + dudy**2 + dvdx**2 + dwdx**2 + dwdy**2 + dudz**2 + dvdz**2 & |
---|
1467 | + 2.0_wp * ( dvdx*dudy + dwdx*dudz + dwdy*dvdz ) |
---|
1468 | |
---|
1469 | IF ( def < 0.0_wp ) def = 0.0_wp |
---|
1470 | |
---|
1471 | tend(k,j,i) = tend(k,j,i) + km(k,j,i) * def |
---|
1472 | |
---|
1473 | ENDDO |
---|
1474 | |
---|
1475 | IF ( prandtl_layer ) THEN |
---|
1476 | |
---|
1477 | IF ( ( wall_e_x(j,i) /= 0.0_wp ) .OR. ( wall_e_y(j,i) /= 0.0_wp ) ) THEN |
---|
1478 | |
---|
1479 | ! |
---|
1480 | !-- Position beneath wall |
---|
1481 | !-- (2) - Will allways be executed. |
---|
1482 | !-- 'bottom and wall: use u_0,v_0 and wall functions' |
---|
1483 | k = nzb_diff_s_inner(j,i)-1 |
---|
1484 | |
---|
1485 | dudx = ( u(k,j,i+1) - u(k,j,i) ) * ddx |
---|
1486 | dudz = 0.5_wp * ( u(k+1,j,i) + u(k+1,j,i+1) - & |
---|
1487 | u_0(j,i) - u_0(j,i+1) ) * dd2zu(k) |
---|
1488 | dvdy = ( v(k,j+1,i) - v(k,j,i) ) * ddy |
---|
1489 | dvdz = 0.5_wp * ( v(k+1,j,i) + v(k+1,j+1,i) - & |
---|
1490 | v_0(j,i) - v_0(j+1,i) ) * dd2zu(k) |
---|
1491 | dwdz = ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
1492 | |
---|
1493 | IF ( wall_e_y(j,i) /= 0.0_wp ) THEN |
---|
1494 | ! |
---|
1495 | !-- Inconsistency removed: as the thermal stratification |
---|
1496 | !-- is not taken into account for the evaluation of the |
---|
1497 | !-- wall fluxes at vertical walls, the eddy viscosity km |
---|
1498 | !-- must not be used for the evaluation of the velocity |
---|
1499 | !-- gradients dudy and dwdy |
---|
1500 | !-- Note: The validity of the new method has not yet |
---|
1501 | !-- been shown, as so far no suitable data for a |
---|
1502 | !-- validation has been available |
---|
1503 | CALL wall_fluxes_e( i, j, k, nzb_diff_s_outer(j,i)-2, & |
---|
1504 | usvs, 1.0_wp, 0.0_wp, 0.0_wp, 0.0_wp ) |
---|
1505 | CALL wall_fluxes_e( i, j, k, nzb_diff_s_outer(j,i)-2, & |
---|
1506 | wsvs, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp ) |
---|
1507 | km_neutral = kappa * ( usvs(k)**2 + wsvs(k)**2 )**0.25_wp * & |
---|
1508 | 0.5_wp * dy |
---|
1509 | IF ( km_neutral > 0.0_wp ) THEN |
---|
1510 | dudy = - wall_e_y(j,i) * usvs(k) / km_neutral |
---|
1511 | dwdy = - wall_e_y(j,i) * wsvs(k) / km_neutral |
---|
1512 | ELSE |
---|
1513 | dudy = 0.0_wp |
---|
1514 | dwdy = 0.0_wp |
---|
1515 | ENDIF |
---|
1516 | ELSE |
---|
1517 | dudy = 0.25_wp * ( u(k,j+1,i) + u(k,j+1,i+1) - & |
---|
1518 | u(k,j-1,i) - u(k,j-1,i+1) ) * ddy |
---|
1519 | dwdy = 0.25_wp * ( w(k,j+1,i) + w(k-1,j+1,i) - & |
---|
1520 | w(k,j-1,i) - w(k-1,j-1,i) ) * ddy |
---|
1521 | ENDIF |
---|
1522 | |
---|
1523 | IF ( wall_e_x(j,i) /= 0.0_wp ) THEN |
---|
1524 | ! |
---|
1525 | !-- Inconsistency removed: as the thermal stratification |
---|
1526 | !-- is not taken into account for the evaluation of the |
---|
1527 | !-- wall fluxes at vertical walls, the eddy viscosity km |
---|
1528 | !-- must not be used for the evaluation of the velocity |
---|
1529 | !-- gradients dvdx and dwdx |
---|
1530 | !-- Note: The validity of the new method has not yet |
---|
1531 | !-- been shown, as so far no suitable data for a |
---|
1532 | !-- validation has been available |
---|
1533 | CALL wall_fluxes_e( i, j, k, nzb_diff_s_outer(j,i)-2, & |
---|
1534 | vsus, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp ) |
---|
1535 | CALL wall_fluxes_e( i, j, k, nzb_diff_s_outer(j,i)-2, & |
---|
1536 | wsus, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp ) |
---|
1537 | km_neutral = kappa * ( vsus(k)**2 + wsus(k)**2 )**0.25_wp * & |
---|
1538 | 0.5_wp * dx |
---|
1539 | IF ( km_neutral > 0.0_wp ) THEN |
---|
1540 | dvdx = - wall_e_x(j,i) * vsus(k) / km_neutral |
---|
1541 | dwdx = - wall_e_x(j,i) * wsus(k) / km_neutral |
---|
1542 | ELSE |
---|
1543 | dvdx = 0.0_wp |
---|
1544 | dwdx = 0.0_wp |
---|
1545 | ENDIF |
---|
1546 | ELSE |
---|
1547 | dvdx = 0.25_wp * ( v(k,j,i+1) + v(k,j+1,i+1) - & |
---|
1548 | v(k,j,i-1) - v(k,j+1,i-1) ) * ddx |
---|
1549 | dwdx = 0.25_wp * ( w(k,j,i+1) + w(k-1,j,i+1) - & |
---|
1550 | w(k,j,i-1) - w(k-1,j,i-1) ) * ddx |
---|
1551 | ENDIF |
---|
1552 | |
---|
1553 | def = 2.0_wp * ( dudx**2 + dvdy**2 + dwdz**2 ) + & |
---|
1554 | dudy**2 + dvdx**2 + dwdx**2 + dwdy**2 + dudz**2 + & |
---|
1555 | dvdz**2 + 2.0_wp * ( dvdx*dudy + dwdx*dudz + dwdy*dvdz ) |
---|
1556 | |
---|
1557 | IF ( def < 0.0_wp ) def = 0.0_wp |
---|
1558 | |
---|
1559 | tend(k,j,i) = tend(k,j,i) + km(k,j,i) * def |
---|
1560 | |
---|
1561 | ! |
---|
1562 | !-- (3) - will be executed only, if there is at least one level |
---|
1563 | !-- between (2) and (4), i.e. the topography must have a |
---|
1564 | !-- minimum height of 2 dz. Wall fluxes for this case have |
---|
1565 | !-- already been calculated for (2). |
---|
1566 | !-- 'wall only: use wall functions' |
---|
1567 | DO k = nzb_diff_s_inner(j,i), nzb_diff_s_outer(j,i)-2 |
---|
1568 | |
---|
1569 | dudx = ( u(k,j,i+1) - u(k,j,i) ) * ddx |
---|
1570 | dudz = 0.5_wp * ( u(k+1,j,i) + u(k+1,j,i+1) - & |
---|
1571 | u(k-1,j,i) - u(k-1,j,i+1) ) * dd2zu(k) |
---|
1572 | dvdy = ( v(k,j+1,i) - v(k,j,i) ) * ddy |
---|
1573 | dvdz = 0.5_wp * ( v(k+1,j,i) + v(k+1,j+1,i) - & |
---|
1574 | v(k-1,j,i) - v(k-1,j+1,i) ) * dd2zu(k) |
---|
1575 | dwdz = ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
1576 | |
---|
1577 | IF ( wall_e_y(j,i) /= 0.0_wp ) THEN |
---|
1578 | ! |
---|
1579 | !-- Inconsistency removed: as the thermal stratification |
---|
1580 | !-- is not taken into account for the evaluation of the |
---|
1581 | !-- wall fluxes at vertical walls, the eddy viscosity km |
---|
1582 | !-- must not be used for the evaluation of the velocity |
---|
1583 | !-- gradients dudy and dwdy |
---|
1584 | !-- Note: The validity of the new method has not yet |
---|
1585 | !-- been shown, as so far no suitable data for a |
---|
1586 | !-- validation has been available |
---|
1587 | km_neutral = kappa * ( usvs(k)**2 + & |
---|
1588 | wsvs(k)**2 )**0.25_wp * 0.5_wp * dy |
---|
1589 | IF ( km_neutral > 0.0_wp ) THEN |
---|
1590 | dudy = - wall_e_y(j,i) * usvs(k) / km_neutral |
---|
1591 | dwdy = - wall_e_y(j,i) * wsvs(k) / km_neutral |
---|
1592 | ELSE |
---|
1593 | dudy = 0.0_wp |
---|
1594 | dwdy = 0.0_wp |
---|
1595 | ENDIF |
---|
1596 | ELSE |
---|
1597 | dudy = 0.25_wp * ( u(k,j+1,i) + u(k,j+1,i+1) - & |
---|
1598 | u(k,j-1,i) - u(k,j-1,i+1) ) * ddy |
---|
1599 | dwdy = 0.25_wp * ( w(k,j+1,i) + w(k-1,j+1,i) - & |
---|
1600 | w(k,j-1,i) - w(k-1,j-1,i) ) * ddy |
---|
1601 | ENDIF |
---|
1602 | |
---|
1603 | IF ( wall_e_x(j,i) /= 0.0_wp ) THEN |
---|
1604 | ! |
---|
1605 | !-- Inconsistency removed: as the thermal stratification |
---|
1606 | !-- is not taken into account for the evaluation of the |
---|
1607 | !-- wall fluxes at vertical walls, the eddy viscosity km |
---|
1608 | !-- must not be used for the evaluation of the velocity |
---|
1609 | !-- gradients dvdx and dwdx |
---|
1610 | !-- Note: The validity of the new method has not yet |
---|
1611 | !-- been shown, as so far no suitable data for a |
---|
1612 | !-- validation has been available |
---|
1613 | km_neutral = kappa * ( vsus(k)**2 + & |
---|
1614 | wsus(k)**2 )**0.25_wp * 0.5_wp * dx |
---|
1615 | IF ( km_neutral > 0.0_wp ) THEN |
---|
1616 | dvdx = - wall_e_x(j,i) * vsus(k) / km_neutral |
---|
1617 | dwdx = - wall_e_x(j,i) * wsus(k) / km_neutral |
---|
1618 | ELSE |
---|
1619 | dvdx = 0.0_wp |
---|
1620 | dwdx = 0.0_wp |
---|
1621 | ENDIF |
---|
1622 | ELSE |
---|
1623 | dvdx = 0.25_wp * ( v(k,j,i+1) + v(k,j+1,i+1) - & |
---|
1624 | v(k,j,i-1) - v(k,j+1,i-1) ) * ddx |
---|
1625 | dwdx = 0.25_wp * ( w(k,j,i+1) + w(k-1,j,i+1) - & |
---|
1626 | w(k,j,i-1) - w(k-1,j,i-1) ) * ddx |
---|
1627 | ENDIF |
---|
1628 | |
---|
1629 | def = 2.0_wp * ( dudx**2 + dvdy**2 + dwdz**2 ) + & |
---|
1630 | dudy**2 + dvdx**2 + dwdx**2 + dwdy**2 + dudz**2 + & |
---|
1631 | dvdz**2 + 2.0_wp * ( dvdx*dudy + dwdx*dudz + dwdy*dvdz ) |
---|
1632 | |
---|
1633 | IF ( def < 0.0_wp ) def = 0.0_wp |
---|
1634 | |
---|
1635 | tend(k,j,i) = tend(k,j,i) + km(k,j,i) * def |
---|
1636 | |
---|
1637 | ENDDO |
---|
1638 | |
---|
1639 | ! |
---|
1640 | !-- (4) - will allways be executed. |
---|
1641 | !-- 'special case: free atmosphere' (as for case (0)) |
---|
1642 | k = nzb_diff_s_outer(j,i)-1 |
---|
1643 | |
---|
1644 | dudx = ( u(k,j,i+1) - u(k,j,i) ) * ddx |
---|
1645 | dudy = 0.25_wp * ( u(k,j+1,i) + u(k,j+1,i+1) - & |
---|
1646 | u(k,j-1,i) - u(k,j-1,i+1) ) * ddy |
---|
1647 | dudz = 0.5_wp * ( u(k+1,j,i) + u(k+1,j,i+1) - & |
---|
1648 | u(k-1,j,i) - u(k-1,j,i+1) ) * dd2zu(k) |
---|
1649 | |
---|
1650 | dvdx = 0.25_wp * ( v(k,j,i+1) + v(k,j+1,i+1) - & |
---|
1651 | v(k,j,i-1) - v(k,j+1,i-1) ) * ddx |
---|
1652 | dvdy = ( v(k,j+1,i) - v(k,j,i) ) * ddy |
---|
1653 | dvdz = 0.5_wp * ( v(k+1,j,i) + v(k+1,j+1,i) - & |
---|
1654 | v(k-1,j,i) - v(k-1,j+1,i) ) * dd2zu(k) |
---|
1655 | |
---|
1656 | dwdx = 0.25_wp * ( w(k,j,i+1) + w(k-1,j,i+1) - & |
---|
1657 | w(k,j,i-1) - w(k-1,j,i-1) ) * ddx |
---|
1658 | dwdy = 0.25_wp * ( w(k,j+1,i) + w(k-1,j+1,i) - & |
---|
1659 | w(k,j-1,i) - w(k-1,j-1,i) ) * ddy |
---|
1660 | dwdz = ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
1661 | |
---|
1662 | def = 2.0_wp * ( dudx**2 + dvdy**2 + dwdz**2 ) + & |
---|
1663 | dudy**2 + dvdx**2 + dwdx**2 + dwdy**2 + dudz**2 + & |
---|
1664 | dvdz**2 + 2.0_wp * ( dvdx*dudy + dwdx*dudz + dwdy*dvdz ) |
---|
1665 | |
---|
1666 | IF ( def < 0.0_wp ) def = 0.0_wp |
---|
1667 | |
---|
1668 | tend(k,j,i) = tend(k,j,i) + km(k,j,i) * def |
---|
1669 | |
---|
1670 | ELSE |
---|
1671 | |
---|
1672 | ! |
---|
1673 | !-- Position without adjacent wall |
---|
1674 | !-- (1) - will allways be executed. |
---|
1675 | !-- 'bottom only: use u_0,v_0' |
---|
1676 | k = nzb_diff_s_inner(j,i)-1 |
---|
1677 | |
---|
1678 | dudx = ( u(k,j,i+1) - u(k,j,i) ) * ddx |
---|
1679 | dudy = 0.25_wp * ( u(k,j+1,i) + u(k,j+1,i+1) - & |
---|
1680 | u(k,j-1,i) - u(k,j-1,i+1) ) * ddy |
---|
1681 | dudz = 0.5_wp * ( u(k+1,j,i) + u(k+1,j,i+1) - & |
---|
1682 | u_0(j,i) - u_0(j,i+1) ) * dd2zu(k) |
---|
1683 | |
---|
1684 | dvdx = 0.25_wp * ( v(k,j,i+1) + v(k,j+1,i+1) - & |
---|
1685 | v(k,j,i-1) - v(k,j+1,i-1) ) * ddx |
---|
1686 | dvdy = ( v(k,j+1,i) - v(k,j,i) ) * ddy |
---|
1687 | dvdz = 0.5_wp * ( v(k+1,j,i) + v(k+1,j+1,i) - & |
---|
1688 | v_0(j,i) - v_0(j+1,i) ) * dd2zu(k) |
---|
1689 | |
---|
1690 | dwdx = 0.25_wp * ( w(k,j,i+1) + w(k-1,j,i+1) - & |
---|
1691 | w(k,j,i-1) - w(k-1,j,i-1) ) * ddx |
---|
1692 | dwdy = 0.25_wp * ( w(k,j+1,i) + w(k-1,j+1,i) - & |
---|
1693 | w(k,j-1,i) - w(k-1,j-1,i) ) * ddy |
---|
1694 | dwdz = ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
1695 | |
---|
1696 | def = 2.0_wp * ( dudx**2 + dvdy**2 + dwdz**2 ) & |
---|
1697 | + dudy**2 + dvdx**2 + dwdx**2 + dwdy**2 + dudz**2 + dvdz**2 & |
---|
1698 | + 2.0_wp * ( dvdx*dudy + dwdx*dudz + dwdy*dvdz ) |
---|
1699 | |
---|
1700 | IF ( def < 0.0_wp ) def = 0.0_wp |
---|
1701 | |
---|
1702 | tend(k,j,i) = tend(k,j,i) + km(k,j,i) * def |
---|
1703 | |
---|
1704 | ENDIF |
---|
1705 | |
---|
1706 | ELSEIF ( use_surface_fluxes ) THEN |
---|
1707 | |
---|
1708 | k = nzb_diff_s_outer(j,i)-1 |
---|
1709 | |
---|
1710 | dudx = ( u(k,j,i+1) - u(k,j,i) ) * ddx |
---|
1711 | dudy = 0.25_wp * ( u(k,j+1,i) + u(k,j+1,i+1) - & |
---|
1712 | u(k,j-1,i) - u(k,j-1,i+1) ) * ddy |
---|
1713 | dudz = 0.5_wp * ( u(k+1,j,i) + u(k+1,j,i+1) - & |
---|
1714 | u(k-1,j,i) - u(k-1,j,i+1) ) * dd2zu(k) |
---|
1715 | |
---|
1716 | dvdx = 0.25_wp * ( v(k,j,i+1) + v(k,j+1,i+1) - & |
---|
1717 | v(k,j,i-1) - v(k,j+1,i-1) ) * ddx |
---|
1718 | dvdy = ( v(k,j+1,i) - v(k,j,i) ) * ddy |
---|
1719 | dvdz = 0.5_wp * ( v(k+1,j,i) + v(k+1,j+1,i) - & |
---|
1720 | v(k-1,j,i) - v(k-1,j+1,i) ) * dd2zu(k) |
---|
1721 | |
---|
1722 | dwdx = 0.25_wp * ( w(k,j,i+1) + w(k-1,j,i+1) - & |
---|
1723 | w(k,j,i-1) - w(k-1,j,i-1) ) * ddx |
---|
1724 | dwdy = 0.25_wp * ( w(k,j+1,i) + w(k-1,j+1,i) - & |
---|
1725 | w(k,j-1,i) - w(k-1,j-1,i) ) * ddy |
---|
1726 | dwdz = ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
1727 | |
---|
1728 | def = 2.0_wp * ( dudx**2 + dvdy**2 + dwdz**2 ) + & |
---|
1729 | dudy**2 + dvdx**2 + dwdx**2 + dwdy**2 + dudz**2 + & |
---|
1730 | dvdz**2 + 2.0_wp * ( dvdx*dudy + dwdx*dudz + dwdy*dvdz ) |
---|
1731 | |
---|
1732 | IF ( def < 0.0_wp ) def = 0.0_wp |
---|
1733 | |
---|
1734 | tend(k,j,i) = tend(k,j,i) + km(k,j,i) * def |
---|
1735 | |
---|
1736 | ENDIF |
---|
1737 | |
---|
1738 | ! |
---|
1739 | !-- If required, calculate TKE production by buoyancy |
---|
1740 | IF ( .NOT. neutral ) THEN |
---|
1741 | |
---|
1742 | IF ( .NOT. humidity ) THEN |
---|
1743 | |
---|
1744 | IF ( use_single_reference_value ) THEN |
---|
1745 | |
---|
1746 | IF ( ocean ) THEN |
---|
1747 | ! |
---|
1748 | !-- So far in the ocean no special treatment of density flux in |
---|
1749 | !-- the bottom and top surface layer |
---|
1750 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
1751 | tend(k,j,i) = tend(k,j,i) + & |
---|
1752 | kh(k,j,i) * g / rho_reference * & |
---|
1753 | ( rho(k+1,j,i) - rho(k-1,j,i) ) * dd2zu(k) |
---|
1754 | ENDDO |
---|
1755 | |
---|
1756 | ELSE |
---|
1757 | |
---|
1758 | DO k = nzb_diff_s_inner(j,i), nzt_diff |
---|
1759 | tend(k,j,i) = tend(k,j,i) - & |
---|
1760 | kh(k,j,i) * g / pt_reference * & |
---|
1761 | ( pt(k+1,j,i) - pt(k-1,j,i) ) * dd2zu(k) |
---|
1762 | ENDDO |
---|
1763 | |
---|
1764 | IF ( use_surface_fluxes ) THEN |
---|
1765 | k = nzb_diff_s_inner(j,i)-1 |
---|
1766 | tend(k,j,i) = tend(k,j,i) + g / pt_reference * shf(j,i) |
---|
1767 | ENDIF |
---|
1768 | |
---|
1769 | IF ( use_top_fluxes ) THEN |
---|
1770 | k = nzt |
---|
1771 | tend(k,j,i) = tend(k,j,i) + g / pt_reference * tswst(j,i) |
---|
1772 | ENDIF |
---|
1773 | |
---|
1774 | ENDIF |
---|
1775 | |
---|
1776 | ELSE |
---|
1777 | |
---|
1778 | IF ( ocean ) THEN |
---|
1779 | ! |
---|
1780 | !-- So far in the ocean no special treatment of density flux in |
---|
1781 | !-- the bottom and top surface layer |
---|
1782 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
1783 | tend(k,j,i) = tend(k,j,i) + & |
---|
1784 | kh(k,j,i) * g / rho(k,j,i) * & |
---|
1785 | ( rho(k+1,j,i) - rho(k-1,j,i) ) * dd2zu(k) |
---|
1786 | ENDDO |
---|
1787 | |
---|
1788 | ELSE |
---|
1789 | |
---|
1790 | DO k = nzb_diff_s_inner(j,i), nzt_diff |
---|
1791 | tend(k,j,i) = tend(k,j,i) - & |
---|
1792 | kh(k,j,i) * g / pt(k,j,i) * & |
---|
1793 | ( pt(k+1,j,i) - pt(k-1,j,i) ) * dd2zu(k) |
---|
1794 | ENDDO |
---|
1795 | |
---|
1796 | IF ( use_surface_fluxes ) THEN |
---|
1797 | k = nzb_diff_s_inner(j,i)-1 |
---|
1798 | tend(k,j,i) = tend(k,j,i) + g / pt(k,j,i) * shf(j,i) |
---|
1799 | ENDIF |
---|
1800 | |
---|
1801 | IF ( use_top_fluxes ) THEN |
---|
1802 | k = nzt |
---|
1803 | tend(k,j,i) = tend(k,j,i) + g / pt(k,j,i) * tswst(j,i) |
---|
1804 | ENDIF |
---|
1805 | |
---|
1806 | ENDIF |
---|
1807 | |
---|
1808 | ENDIF |
---|
1809 | |
---|
1810 | ELSE |
---|
1811 | |
---|
1812 | DO k = nzb_diff_s_inner(j,i), nzt_diff |
---|
1813 | |
---|
1814 | IF ( .NOT. cloud_physics .AND. .NOT. cloud_droplets ) THEN |
---|
1815 | k1 = 1.0_wp + 0.61_wp * q(k,j,i) |
---|
1816 | k2 = 0.61_wp * pt(k,j,i) |
---|
1817 | tend(k,j,i) = tend(k,j,i) - kh(k,j,i) * g / vpt(k,j,i) * & |
---|
1818 | ( k1 * ( pt(k+1,j,i)-pt(k-1,j,i) ) + & |
---|
1819 | k2 * ( q(k+1,j,i) - q(k-1,j,i) ) & |
---|
1820 | ) * dd2zu(k) |
---|
1821 | ELSE IF ( cloud_physics ) THEN |
---|
1822 | IF ( ql(k,j,i) == 0.0_wp ) THEN |
---|
1823 | k1 = 1.0_wp + 0.61_wp * q(k,j,i) |
---|
1824 | k2 = 0.61_wp * pt(k,j,i) |
---|
1825 | ELSE |
---|
1826 | theta = pt(k,j,i) + pt_d_t(k) * l_d_cp * ql(k,j,i) |
---|
1827 | temp = theta * t_d_pt(k) |
---|
1828 | k1 = ( 1.0_wp - q(k,j,i) + 1.61_wp * & |
---|
1829 | ( q(k,j,i) - ql(k,j,i) ) * & |
---|
1830 | ( 1.0_wp + 0.622_wp * l_d_r / temp ) ) / & |
---|
1831 | ( 1.0_wp + 0.622_wp * l_d_r * l_d_cp * & |
---|
1832 | ( q(k,j,i) - ql(k,j,i) ) / ( temp * temp ) ) |
---|
1833 | k2 = theta * ( l_d_cp / temp * k1 - 1.0_wp ) |
---|
1834 | ENDIF |
---|
1835 | tend(k,j,i) = tend(k,j,i) - kh(k,j,i) * g / vpt(k,j,i) * & |
---|
1836 | ( k1 * ( pt(k+1,j,i)-pt(k-1,j,i) ) + & |
---|
1837 | k2 * ( q(k+1,j,i) - q(k-1,j,i) ) & |
---|
1838 | ) * dd2zu(k) |
---|
1839 | ELSE IF ( cloud_droplets ) THEN |
---|
1840 | k1 = 1.0_wp + 0.61_wp * q(k,j,i) - ql(k,j,i) |
---|
1841 | k2 = 0.61_wp * pt(k,j,i) |
---|
1842 | tend(k,j,i) = tend(k,j,i) - kh(k,j,i) * g / vpt(k,j,i) * & |
---|
1843 | ( k1 * ( pt(k+1,j,i)-pt(k-1,j,i) ) + & |
---|
1844 | k2 * ( q(k+1,j,i) - q(k-1,j,i) ) - & |
---|
1845 | pt(k,j,i) * ( ql(k+1,j,i) - & |
---|
1846 | ql(k-1,j,i) ) ) * dd2zu(k) |
---|
1847 | ENDIF |
---|
1848 | ENDDO |
---|
1849 | |
---|
1850 | IF ( use_surface_fluxes ) THEN |
---|
1851 | k = nzb_diff_s_inner(j,i)-1 |
---|
1852 | |
---|
1853 | IF ( .NOT. cloud_physics .AND. .NOT. cloud_droplets ) THEN |
---|
1854 | k1 = 1.0_wp + 0.61_wp * q(k,j,i) |
---|
1855 | k2 = 0.61_wp * pt(k,j,i) |
---|
1856 | ELSE IF ( cloud_physics ) THEN |
---|
1857 | IF ( ql(k,j,i) == 0.0_wp ) THEN |
---|
1858 | k1 = 1.0_wp + 0.61_wp * q(k,j,i) |
---|
1859 | k2 = 0.61_wp * pt(k,j,i) |
---|
1860 | ELSE |
---|
1861 | theta = pt(k,j,i) + pt_d_t(k) * l_d_cp * ql(k,j,i) |
---|
1862 | temp = theta * t_d_pt(k) |
---|
1863 | k1 = ( 1.0_wp - q(k,j,i) + 1.61_wp * & |
---|
1864 | ( q(k,j,i) - ql(k,j,i) ) * & |
---|
1865 | ( 1.0_wp + 0.622_wp * l_d_r / temp ) ) / & |
---|
1866 | ( 1.0_wp + 0.622_wp * l_d_r * l_d_cp * & |
---|
1867 | ( q(k,j,i) - ql(k,j,i) ) / ( temp * temp ) ) |
---|
1868 | k2 = theta * ( l_d_cp / temp * k1 - 1.0_wp ) |
---|
1869 | ENDIF |
---|
1870 | ELSE IF ( cloud_droplets ) THEN |
---|
1871 | k1 = 1.0_wp + 0.61_wp * q(k,j,i) - ql(k,j,i) |
---|
1872 | k2 = 0.61_wp * pt(k,j,i) |
---|
1873 | ENDIF |
---|
1874 | |
---|
1875 | tend(k,j,i) = tend(k,j,i) + g / vpt(k,j,i) * & |
---|
1876 | ( k1* shf(j,i) + k2 * qsws(j,i) ) |
---|
1877 | ENDIF |
---|
1878 | |
---|
1879 | IF ( use_top_fluxes ) THEN |
---|
1880 | k = nzt |
---|
1881 | |
---|
1882 | IF ( .NOT. cloud_physics .AND. .NOT. cloud_droplets ) THEN |
---|
1883 | k1 = 1.0_wp + 0.61_wp * q(k,j,i) |
---|
1884 | k2 = 0.61_wp * pt(k,j,i) |
---|
1885 | ELSE IF ( cloud_physics ) THEN |
---|
1886 | IF ( ql(k,j,i) == 0.0_wp ) THEN |
---|
1887 | k1 = 1.0_wp + 0.61_wp * q(k,j,i) |
---|
1888 | k2 = 0.61_wp * pt(k,j,i) |
---|
1889 | ELSE |
---|
1890 | theta = pt(k,j,i) + pt_d_t(k) * l_d_cp * ql(k,j,i) |
---|
1891 | temp = theta * t_d_pt(k) |
---|
1892 | k1 = ( 1.0_wp - q(k,j,i) + 1.61_wp * & |
---|
1893 | ( q(k,j,i) - ql(k,j,i) ) * & |
---|
1894 | ( 1.0_wp + 0.622_wp * l_d_r / temp ) ) / & |
---|
1895 | ( 1.0_wp + 0.622_wp * l_d_r * l_d_cp * & |
---|
1896 | ( q(k,j,i) - ql(k,j,i) ) / ( temp * temp ) ) |
---|
1897 | k2 = theta * ( l_d_cp / temp * k1 - 1.0_wp ) |
---|
1898 | ENDIF |
---|
1899 | ELSE IF ( cloud_droplets ) THEN |
---|
1900 | k1 = 1.0_wp + 0.61_wp * q(k,j,i) - ql(k,j,i) |
---|
1901 | k2 = 0.61_wp * pt(k,j,i) |
---|
1902 | ENDIF |
---|
1903 | |
---|
1904 | tend(k,j,i) = tend(k,j,i) + g / vpt(k,j,i) * & |
---|
1905 | ( k1* tswst(j,i) + k2 * qswst(j,i) ) |
---|
1906 | ENDIF |
---|
1907 | |
---|
1908 | ENDIF |
---|
1909 | |
---|
1910 | ENDIF |
---|
1911 | |
---|
1912 | END SUBROUTINE production_e_ij |
---|
1913 | |
---|
1914 | |
---|
1915 | !------------------------------------------------------------------------------! |
---|
1916 | ! Description: |
---|
1917 | ! ------------ |
---|
1918 | !> @todo Missing subroutine description. |
---|
1919 | !------------------------------------------------------------------------------! |
---|
1920 | SUBROUTINE production_e_init |
---|
1921 | |
---|
1922 | USE arrays_3d, & |
---|
1923 | ONLY: kh, km, u, us, usws, v, vsws, zu |
---|
1924 | |
---|
1925 | USE control_parameters, & |
---|
1926 | ONLY: kappa, prandtl_layer |
---|
1927 | |
---|
1928 | USE indices, & |
---|
1929 | ONLY: nxl, nxlg, nxr, nxrg, nys, nysg, nyn, nyng, nzb_u_inner, & |
---|
1930 | nzb_v_inner |
---|
1931 | |
---|
1932 | IMPLICIT NONE |
---|
1933 | |
---|
1934 | INTEGER(iwp) :: i !< |
---|
1935 | INTEGER(iwp) :: j !< |
---|
1936 | INTEGER(iwp) :: ku !< |
---|
1937 | INTEGER(iwp) :: kv !< |
---|
1938 | |
---|
1939 | IF ( prandtl_layer ) THEN |
---|
1940 | |
---|
1941 | IF ( first_call ) THEN |
---|
1942 | ALLOCATE( u_0(nysg:nyng,nxlg:nxrg), v_0(nysg:nyng,nxlg:nxrg) ) |
---|
1943 | u_0 = 0.0_wp ! just to avoid access of uninitialized memory |
---|
1944 | v_0 = 0.0_wp ! within exchange_horiz_2d |
---|
1945 | first_call = .FALSE. |
---|
1946 | ENDIF |
---|
1947 | |
---|
1948 | ! |
---|
1949 | !-- Calculate a virtual velocity at the surface in a way that the |
---|
1950 | !-- vertical velocity gradient at k = 1 (u(k+1)-u_0) matches the |
---|
1951 | !-- Prandtl law (-w'u'/km). This gradient is used in the TKE shear |
---|
1952 | !-- production term at k=1 (see production_e_ij). |
---|
1953 | !-- The velocity gradient has to be limited in case of too small km |
---|
1954 | !-- (otherwise the timestep may be significantly reduced by large |
---|
1955 | !-- surface winds). |
---|
1956 | !-- Upper bounds are nxr+1 and nyn+1 because otherwise these values are |
---|
1957 | !-- not available in case of non-cyclic boundary conditions. |
---|
1958 | !-- WARNING: the exact analytical solution would require the determination |
---|
1959 | !-- of the eddy diffusivity by km = u* * kappa * zp / phi_m. |
---|
1960 | !$OMP PARALLEL DO PRIVATE( ku, kv ) |
---|
1961 | DO i = nxl, nxr+1 |
---|
1962 | DO j = nys, nyn+1 |
---|
1963 | |
---|
1964 | ku = nzb_u_inner(j,i)+1 |
---|
1965 | kv = nzb_v_inner(j,i)+1 |
---|
1966 | |
---|
1967 | u_0(j,i) = u(ku+1,j,i) + usws(j,i) * ( zu(ku+1) - zu(ku-1) ) / & |
---|
1968 | ( 0.5_wp * ( km(ku,j,i) + km(ku,j,i-1) ) + & |
---|
1969 | 1.0E-20_wp ) |
---|
1970 | ! ( us(j,i) * kappa * zu(1) ) |
---|
1971 | v_0(j,i) = v(kv+1,j,i) + vsws(j,i) * ( zu(kv+1) - zu(kv-1) ) / & |
---|
1972 | ( 0.5_wp * ( km(kv,j,i) + km(kv,j-1,i) ) + & |
---|
1973 | 1.0E-20_wp ) |
---|
1974 | ! ( us(j,i) * kappa * zu(1) ) |
---|
1975 | |
---|
1976 | IF ( ABS( u(ku+1,j,i) - u_0(j,i) ) > & |
---|
1977 | ABS( u(ku+1,j,i) - u(ku-1,j,i) ) ) u_0(j,i) = u(ku-1,j,i) |
---|
1978 | IF ( ABS( v(kv+1,j,i) - v_0(j,i) ) > & |
---|
1979 | ABS( v(kv+1,j,i) - v(kv-1,j,i) ) ) v_0(j,i) = v(kv-1,j,i) |
---|
1980 | |
---|
1981 | ENDDO |
---|
1982 | ENDDO |
---|
1983 | |
---|
1984 | CALL exchange_horiz_2d( u_0 ) |
---|
1985 | CALL exchange_horiz_2d( v_0 ) |
---|
1986 | |
---|
1987 | ENDIF |
---|
1988 | |
---|
1989 | END SUBROUTINE production_e_init |
---|
1990 | |
---|
1991 | END MODULE production_e_mod |
---|