1 | !> @file diffusion_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 |
---|
6 | ! terms of the GNU General Public License as published by the Free Software |
---|
7 | ! Foundation, either version 3 of the License, or (at your option) any later |
---|
8 | ! version. |
---|
9 | ! |
---|
10 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
11 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
12 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
13 | ! |
---|
14 | ! You should have received a copy of the GNU General Public License along with |
---|
15 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
16 | ! |
---|
17 | ! Copyright 1997-2017 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: diffusion_e.f90 2119 2017-01-17 16:51:50Z scharf $ |
---|
27 | ! |
---|
28 | ! 2118 2017-01-17 16:38:49Z raasch |
---|
29 | ! OpenACC version of subroutine removed |
---|
30 | ! |
---|
31 | ! 2037 2016-10-26 11:15:40Z knoop |
---|
32 | ! Anelastic approximation implemented |
---|
33 | ! |
---|
34 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
35 | ! Forced header and separation lines into 80 columns |
---|
36 | ! |
---|
37 | ! 1873 2016-04-18 14:50:06Z maronga |
---|
38 | ! Module renamed (removed _mod) |
---|
39 | ! |
---|
40 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
41 | ! Module renamed |
---|
42 | ! Adapted for modularization of microphysics |
---|
43 | ! |
---|
44 | ! 1831 2016-04-07 13:15:51Z hoffmann |
---|
45 | ! turbulence renamed collision_turbulence |
---|
46 | ! |
---|
47 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
48 | ! Code annotations made doxygen readable |
---|
49 | ! |
---|
50 | ! 1374 2014-04-25 12:55:07Z raasch |
---|
51 | ! missing variables added to ONLY list |
---|
52 | ! rif removed from acc-present-list |
---|
53 | ! |
---|
54 | ! 1340 2014-03-25 19:45:13Z kanani |
---|
55 | ! REAL constants defined as wp-kind |
---|
56 | ! |
---|
57 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
58 | ! ONLY-attribute added to USE-statements, |
---|
59 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
60 | ! kinds are defined in new module kinds, |
---|
61 | ! revision history before 2012 removed, |
---|
62 | ! comment fields (!:) to be used for variable explanations added to |
---|
63 | ! all variable declaration statements |
---|
64 | ! |
---|
65 | ! 1257 2013-11-08 15:18:40Z raasch |
---|
66 | ! openacc loop and loop vector clauses removed |
---|
67 | ! |
---|
68 | ! 1179 2013-06-14 05:57:58Z raasch |
---|
69 | ! use_reference renamed use_single_reference_value |
---|
70 | ! |
---|
71 | ! 1171 2013-05-30 11:27:45Z raasch |
---|
72 | ! use_reference-case activated in accelerator version |
---|
73 | ! |
---|
74 | ! 1128 2013-04-12 06:19:32Z raasch |
---|
75 | ! loop index bounds in accelerator version replaced by i_left, i_right, j_south, |
---|
76 | ! j_north |
---|
77 | ! |
---|
78 | ! 1065 2012-11-22 17:42:36Z hoffmann |
---|
79 | ! Enabled the claculation of diss in case of turbulence = .TRUE. (parameterized |
---|
80 | ! effects of turbulence on autoconversion and accretion in two-moments cloud |
---|
81 | ! physics scheme). |
---|
82 | ! |
---|
83 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
84 | ! code put under GPL (PALM 3.9) |
---|
85 | ! |
---|
86 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
87 | ! accelerator version (*_acc) added, |
---|
88 | ! adjustment of mixing length to the Prandtl mixing length at first grid point |
---|
89 | ! above ground removed |
---|
90 | ! |
---|
91 | ! 1010 2012-09-20 07:59:54Z raasch |
---|
92 | ! cpp switch __nopointer added for pointer free version |
---|
93 | ! |
---|
94 | ! 1001 2012-09-13 14:08:46Z raasch |
---|
95 | ! most arrays comunicated by module instead of parameter list |
---|
96 | ! |
---|
97 | ! 825 2012-02-19 03:03:44Z raasch |
---|
98 | ! wang_collision_kernel renamed wang_kernel |
---|
99 | ! |
---|
100 | ! Revision 1.1 1997/09/19 07:40:24 raasch |
---|
101 | ! Initial revision |
---|
102 | ! |
---|
103 | ! |
---|
104 | ! Description: |
---|
105 | ! ------------ |
---|
106 | !> Diffusion- and dissipation terms for the TKE |
---|
107 | !------------------------------------------------------------------------------! |
---|
108 | MODULE diffusion_e_mod |
---|
109 | |
---|
110 | |
---|
111 | PRIVATE |
---|
112 | PUBLIC diffusion_e |
---|
113 | |
---|
114 | |
---|
115 | INTERFACE diffusion_e |
---|
116 | MODULE PROCEDURE diffusion_e |
---|
117 | MODULE PROCEDURE diffusion_e_ij |
---|
118 | END INTERFACE diffusion_e |
---|
119 | |
---|
120 | CONTAINS |
---|
121 | |
---|
122 | |
---|
123 | !------------------------------------------------------------------------------! |
---|
124 | ! Description: |
---|
125 | ! ------------ |
---|
126 | !> Call for all grid points |
---|
127 | !------------------------------------------------------------------------------! |
---|
128 | SUBROUTINE diffusion_e( var, var_reference ) |
---|
129 | |
---|
130 | USE arrays_3d, & |
---|
131 | ONLY: dd2zu, ddzu, ddzw, diss, e, km, l_grid, tend, zu, zw, & |
---|
132 | drho_air, rho_air_zw |
---|
133 | |
---|
134 | USE control_parameters, & |
---|
135 | ONLY: atmos_ocean_sign, g, use_single_reference_value, & |
---|
136 | wall_adjustment, wall_adjustment_factor |
---|
137 | |
---|
138 | USE grid_variables, & |
---|
139 | ONLY: ddx2, ddy2 |
---|
140 | |
---|
141 | USE indices, & |
---|
142 | ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzb_s_inner,& |
---|
143 | nzt |
---|
144 | |
---|
145 | USE kinds |
---|
146 | |
---|
147 | USE microphysics_mod, & |
---|
148 | ONLY: collision_turbulence |
---|
149 | |
---|
150 | USE particle_attributes, & |
---|
151 | ONLY: use_sgs_for_particles, wang_kernel |
---|
152 | |
---|
153 | IMPLICIT NONE |
---|
154 | |
---|
155 | INTEGER(iwp) :: i !< |
---|
156 | INTEGER(iwp) :: j !< |
---|
157 | INTEGER(iwp) :: k !< |
---|
158 | REAL(wp) :: dvar_dz !< |
---|
159 | REAL(wp) :: l_stable !< |
---|
160 | REAL(wp) :: var_reference !< |
---|
161 | |
---|
162 | #if defined( __nopointer ) |
---|
163 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: var !< |
---|
164 | #else |
---|
165 | REAL(wp), DIMENSION(:,:,:), POINTER :: var !< |
---|
166 | #endif |
---|
167 | REAL(wp), DIMENSION(nzb+1:nzt,nys:nyn) :: dissipation !< |
---|
168 | REAL(wp), DIMENSION(nzb+1:nzt,nys:nyn) :: l !< |
---|
169 | REAL(wp), DIMENSION(nzb+1:nzt,nys:nyn) :: ll !< |
---|
170 | |
---|
171 | |
---|
172 | ! |
---|
173 | !-- This if clause must be outside the k-loop because otherwise |
---|
174 | !-- runtime errors occur with -C hopt on NEC |
---|
175 | IF ( use_single_reference_value ) THEN |
---|
176 | |
---|
177 | DO i = nxl, nxr |
---|
178 | DO j = nys, nyn |
---|
179 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
180 | ! |
---|
181 | !-- Calculate the mixing length (for dissipation) |
---|
182 | dvar_dz = atmos_ocean_sign * & |
---|
183 | ( var(k+1,j,i) - var(k-1,j,i) ) * dd2zu(k) |
---|
184 | IF ( dvar_dz > 0.0_wp ) THEN |
---|
185 | l_stable = 0.76_wp * SQRT( e(k,j,i) ) / & |
---|
186 | SQRT( g / var_reference * dvar_dz ) + 1E-5_wp |
---|
187 | ELSE |
---|
188 | l_stable = l_grid(k) |
---|
189 | ENDIF |
---|
190 | ! |
---|
191 | !-- Adjustment of the mixing length |
---|
192 | IF ( wall_adjustment ) THEN |
---|
193 | l(k,j) = MIN( wall_adjustment_factor * & |
---|
194 | ( zu(k) - zw(nzb_s_inner(j,i)) ), & |
---|
195 | l_grid(k), l_stable ) |
---|
196 | ll(k,j) = MIN( wall_adjustment_factor * & |
---|
197 | ( zu(k) - zw(nzb_s_inner(j,i)) ), & |
---|
198 | l_grid(k) ) |
---|
199 | ELSE |
---|
200 | l(k,j) = MIN( l_grid(k), l_stable ) |
---|
201 | ll(k,j) = l_grid(k) |
---|
202 | ENDIF |
---|
203 | |
---|
204 | ENDDO |
---|
205 | ENDDO |
---|
206 | |
---|
207 | ! |
---|
208 | !-- Calculate the tendency terms |
---|
209 | DO j = nys, nyn |
---|
210 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
211 | |
---|
212 | dissipation(k,j) = ( 0.19_wp + 0.74_wp * l(k,j) / ll(k,j) ) * & |
---|
213 | e(k,j,i) * SQRT( e(k,j,i) ) / l(k,j) |
---|
214 | |
---|
215 | tend(k,j,i) = tend(k,j,i) & |
---|
216 | + ( & |
---|
217 | ( km(k,j,i)+km(k,j,i+1) ) * ( e(k,j,i+1)-e(k,j,i) ) & |
---|
218 | - ( km(k,j,i)+km(k,j,i-1) ) * ( e(k,j,i)-e(k,j,i-1) ) & |
---|
219 | ) * ddx2 & |
---|
220 | + ( & |
---|
221 | ( km(k,j,i)+km(k,j+1,i) ) * ( e(k,j+1,i)-e(k,j,i) ) & |
---|
222 | - ( km(k,j,i)+km(k,j-1,i) ) * ( e(k,j,i)-e(k,j-1,i) ) & |
---|
223 | ) * ddy2 & |
---|
224 | + ( & |
---|
225 | ( km(k,j,i)+km(k+1,j,i) ) * ( e(k+1,j,i)-e(k,j,i) ) * ddzu(k+1) & |
---|
226 | * rho_air_zw(k) & |
---|
227 | - ( km(k,j,i)+km(k-1,j,i) ) * ( e(k,j,i)-e(k-1,j,i) ) * ddzu(k) & |
---|
228 | * rho_air_zw(k-1) & |
---|
229 | ) * ddzw(k) * drho_air(k) & |
---|
230 | - dissipation(k,j) |
---|
231 | |
---|
232 | ENDDO |
---|
233 | ENDDO |
---|
234 | |
---|
235 | ! |
---|
236 | !-- Store dissipation if needed for calculating the sgs particle |
---|
237 | !-- velocities |
---|
238 | IF ( use_sgs_for_particles .OR. wang_kernel .OR. & |
---|
239 | collision_turbulence ) THEN |
---|
240 | DO j = nys, nyn |
---|
241 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
242 | diss(k,j,i) = dissipation(k,j) |
---|
243 | ENDDO |
---|
244 | ENDDO |
---|
245 | ENDIF |
---|
246 | |
---|
247 | ENDDO |
---|
248 | |
---|
249 | ELSE |
---|
250 | |
---|
251 | DO i = nxl, nxr |
---|
252 | DO j = nys, nyn |
---|
253 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
254 | ! |
---|
255 | !-- Calculate the mixing length (for dissipation) |
---|
256 | dvar_dz = atmos_ocean_sign * & |
---|
257 | ( var(k+1,j,i) - var(k-1,j,i) ) * dd2zu(k) |
---|
258 | IF ( dvar_dz > 0.0_wp ) THEN |
---|
259 | l_stable = 0.76_wp * SQRT( e(k,j,i) ) / & |
---|
260 | SQRT( g / var(k,j,i) * dvar_dz ) + 1E-5_wp |
---|
261 | ELSE |
---|
262 | l_stable = l_grid(k) |
---|
263 | ENDIF |
---|
264 | ! |
---|
265 | !-- Adjustment of the mixing length |
---|
266 | IF ( wall_adjustment ) THEN |
---|
267 | l(k,j) = MIN( wall_adjustment_factor * & |
---|
268 | ( zu(k) - zw(nzb_s_inner(j,i)) ), & |
---|
269 | l_grid(k), l_stable ) |
---|
270 | ll(k,j) = MIN( wall_adjustment_factor * & |
---|
271 | ( zu(k) - zw(nzb_s_inner(j,i)) ), & |
---|
272 | l_grid(k) ) |
---|
273 | ELSE |
---|
274 | l(k,j) = MIN( l_grid(k), l_stable ) |
---|
275 | ll(k,j) = l_grid(k) |
---|
276 | ENDIF |
---|
277 | |
---|
278 | ENDDO |
---|
279 | ENDDO |
---|
280 | |
---|
281 | ! |
---|
282 | !-- Calculate the tendency terms |
---|
283 | DO j = nys, nyn |
---|
284 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
285 | |
---|
286 | dissipation(k,j) = ( 0.19_wp + 0.74_wp * l(k,j) / ll(k,j) ) * & |
---|
287 | e(k,j,i) * SQRT( e(k,j,i) ) / l(k,j) |
---|
288 | |
---|
289 | tend(k,j,i) = tend(k,j,i) & |
---|
290 | + ( & |
---|
291 | ( km(k,j,i)+km(k,j,i+1) ) * ( e(k,j,i+1)-e(k,j,i) ) & |
---|
292 | - ( km(k,j,i)+km(k,j,i-1) ) * ( e(k,j,i)-e(k,j,i-1) ) & |
---|
293 | ) * ddx2 & |
---|
294 | + ( & |
---|
295 | ( km(k,j,i)+km(k,j+1,i) ) * ( e(k,j+1,i)-e(k,j,i) ) & |
---|
296 | - ( km(k,j,i)+km(k,j-1,i) ) * ( e(k,j,i)-e(k,j-1,i) ) & |
---|
297 | ) * ddy2 & |
---|
298 | + ( & |
---|
299 | ( km(k,j,i)+km(k+1,j,i) ) * ( e(k+1,j,i)-e(k,j,i) ) * ddzu(k+1) & |
---|
300 | * rho_air_zw(k) & |
---|
301 | - ( km(k,j,i)+km(k-1,j,i) ) * ( e(k,j,i)-e(k-1,j,i) ) * ddzu(k) & |
---|
302 | * rho_air_zw(k-1) & |
---|
303 | ) * ddzw(k) * drho_air(k) & |
---|
304 | - dissipation(k,j) |
---|
305 | |
---|
306 | ENDDO |
---|
307 | ENDDO |
---|
308 | |
---|
309 | ! |
---|
310 | !-- Store dissipation if needed for calculating the sgs particle |
---|
311 | !-- velocities |
---|
312 | IF ( use_sgs_for_particles .OR. wang_kernel .OR. & |
---|
313 | collision_turbulence ) THEN |
---|
314 | DO j = nys, nyn |
---|
315 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
316 | diss(k,j,i) = dissipation(k,j) |
---|
317 | ENDDO |
---|
318 | ENDDO |
---|
319 | ENDIF |
---|
320 | |
---|
321 | ENDDO |
---|
322 | |
---|
323 | ENDIF |
---|
324 | |
---|
325 | ! |
---|
326 | !-- Boundary condition for dissipation |
---|
327 | IF ( use_sgs_for_particles .OR. wang_kernel .OR. & |
---|
328 | collision_turbulence ) THEN |
---|
329 | DO i = nxl, nxr |
---|
330 | DO j = nys, nyn |
---|
331 | diss(nzb_s_inner(j,i),j,i) = diss(nzb_s_inner(j,i)+1,j,i) |
---|
332 | ENDDO |
---|
333 | ENDDO |
---|
334 | ENDIF |
---|
335 | |
---|
336 | END SUBROUTINE diffusion_e |
---|
337 | |
---|
338 | |
---|
339 | !------------------------------------------------------------------------------! |
---|
340 | ! Description: |
---|
341 | ! ------------ |
---|
342 | !> Call for grid point i,j |
---|
343 | !------------------------------------------------------------------------------! |
---|
344 | SUBROUTINE diffusion_e_ij( i, j, var, var_reference ) |
---|
345 | |
---|
346 | USE arrays_3d, & |
---|
347 | ONLY: dd2zu, ddzu, ddzw, diss, e, km, l_grid, tend, zu, zw, & |
---|
348 | drho_air, rho_air_zw |
---|
349 | |
---|
350 | USE control_parameters, & |
---|
351 | ONLY: atmos_ocean_sign, g, use_single_reference_value, & |
---|
352 | wall_adjustment, wall_adjustment_factor |
---|
353 | |
---|
354 | USE grid_variables, & |
---|
355 | ONLY: ddx2, ddy2 |
---|
356 | |
---|
357 | USE indices, & |
---|
358 | ONLY: nxlg, nxrg, nyng, nysg, nzb, nzb_s_inner, nzt |
---|
359 | |
---|
360 | USE kinds |
---|
361 | |
---|
362 | USE microphysics_mod, & |
---|
363 | ONLY: collision_turbulence |
---|
364 | |
---|
365 | USE particle_attributes, & |
---|
366 | ONLY: use_sgs_for_particles, wang_kernel |
---|
367 | |
---|
368 | IMPLICIT NONE |
---|
369 | |
---|
370 | INTEGER(iwp) :: i !< |
---|
371 | INTEGER(iwp) :: j !< |
---|
372 | INTEGER(iwp) :: k !< |
---|
373 | REAL(wp) :: dvar_dz !< |
---|
374 | REAL(wp) :: l_stable !< |
---|
375 | REAL(wp) :: var_reference !< |
---|
376 | |
---|
377 | #if defined( __nopointer ) |
---|
378 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: var !< |
---|
379 | #else |
---|
380 | REAL(wp), DIMENSION(:,:,:), POINTER :: var !< |
---|
381 | #endif |
---|
382 | REAL(wp), DIMENSION(nzb+1:nzt) :: dissipation !< |
---|
383 | REAL(wp), DIMENSION(nzb+1:nzt) :: l !< |
---|
384 | REAL(wp), DIMENSION(nzb+1:nzt) :: ll !< |
---|
385 | |
---|
386 | |
---|
387 | ! |
---|
388 | !-- Calculate the mixing length (for dissipation) |
---|
389 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
390 | dvar_dz = atmos_ocean_sign * & |
---|
391 | ( var(k+1,j,i) - var(k-1,j,i) ) * dd2zu(k) |
---|
392 | IF ( dvar_dz > 0.0_wp ) THEN |
---|
393 | IF ( use_single_reference_value ) THEN |
---|
394 | l_stable = 0.76_wp * SQRT( e(k,j,i) ) / & |
---|
395 | SQRT( g / var_reference * dvar_dz ) + 1E-5_wp |
---|
396 | ELSE |
---|
397 | l_stable = 0.76_wp * SQRT( e(k,j,i) ) / & |
---|
398 | SQRT( g / var(k,j,i) * dvar_dz ) + 1E-5_wp |
---|
399 | ENDIF |
---|
400 | ELSE |
---|
401 | l_stable = l_grid(k) |
---|
402 | ENDIF |
---|
403 | ! |
---|
404 | !-- Adjustment of the mixing length |
---|
405 | IF ( wall_adjustment ) THEN |
---|
406 | l(k) = MIN( wall_adjustment_factor * & |
---|
407 | ( zu(k) - zw(nzb_s_inner(j,i)) ), l_grid(k), & |
---|
408 | l_stable ) |
---|
409 | ll(k) = MIN( wall_adjustment_factor * & |
---|
410 | ( zu(k) - zw(nzb_s_inner(j,i)) ), l_grid(k) ) |
---|
411 | ELSE |
---|
412 | l(k) = MIN( l_grid(k), l_stable ) |
---|
413 | ll(k) = l_grid(k) |
---|
414 | ENDIF |
---|
415 | ! |
---|
416 | !-- Calculate the tendency term |
---|
417 | dissipation(k) = ( 0.19_wp + 0.74_wp * l(k) / ll(k) ) * e(k,j,i) * & |
---|
418 | SQRT( e(k,j,i) ) / l(k) |
---|
419 | |
---|
420 | tend(k,j,i) = tend(k,j,i) & |
---|
421 | + ( & |
---|
422 | ( km(k,j,i)+km(k,j,i+1) ) * ( e(k,j,i+1)-e(k,j,i) ) & |
---|
423 | - ( km(k,j,i)+km(k,j,i-1) ) * ( e(k,j,i)-e(k,j,i-1) ) & |
---|
424 | ) * ddx2 & |
---|
425 | + ( & |
---|
426 | ( km(k,j,i)+km(k,j+1,i) ) * ( e(k,j+1,i)-e(k,j,i) ) & |
---|
427 | - ( km(k,j,i)+km(k,j-1,i) ) * ( e(k,j,i)-e(k,j-1,i) ) & |
---|
428 | ) * ddy2 & |
---|
429 | + ( & |
---|
430 | ( km(k,j,i)+km(k+1,j,i) ) * ( e(k+1,j,i)-e(k,j,i) ) * ddzu(k+1) & |
---|
431 | * rho_air_zw(k) & |
---|
432 | - ( km(k,j,i)+km(k-1,j,i) ) * ( e(k,j,i)-e(k-1,j,i) ) * ddzu(k) & |
---|
433 | * rho_air_zw(k-1) & |
---|
434 | ) * ddzw(k) * drho_air(k) & |
---|
435 | - dissipation(k) |
---|
436 | |
---|
437 | ENDDO |
---|
438 | |
---|
439 | ! |
---|
440 | !-- Store dissipation if needed for calculating the sgs particle velocities |
---|
441 | IF ( use_sgs_for_particles .OR. wang_kernel .OR. & |
---|
442 | collision_turbulence ) THEN |
---|
443 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
444 | diss(k,j,i) = dissipation(k) |
---|
445 | ENDDO |
---|
446 | ! |
---|
447 | !-- Boundary condition for dissipation |
---|
448 | diss(nzb_s_inner(j,i),j,i) = diss(nzb_s_inner(j,i)+1,j,i) |
---|
449 | ENDIF |
---|
450 | |
---|
451 | END SUBROUTINE diffusion_e_ij |
---|
452 | |
---|
453 | END MODULE diffusion_e_mod |
---|