1 | !> @file diffusion_v_mod.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-2016 Leibniz Universitaet Hannover |
---|
17 | !--------------------------------------------------------------------------------! |
---|
18 | ! |
---|
19 | ! Current revisions: |
---|
20 | ! ----------------- |
---|
21 | ! |
---|
22 | ! |
---|
23 | ! Former revisions: |
---|
24 | ! ----------------- |
---|
25 | ! $Id: diffusion_v_mod.f90 1851 2016-04-08 13:32:50Z hoffmann $ |
---|
26 | ! |
---|
27 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
28 | ! Module renamed |
---|
29 | ! |
---|
30 | ! |
---|
31 | ! 1740 2016-01-13 08:19:40Z raasch |
---|
32 | ! unnecessary calculations of kmzm and kmzp in wall bounded parts removed |
---|
33 | ! |
---|
34 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
35 | ! Code annotations made doxygen readable |
---|
36 | ! |
---|
37 | ! 1340 2014-03-25 19:45:13Z kanani |
---|
38 | ! REAL constants defined as wp-kind |
---|
39 | ! |
---|
40 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
41 | ! ONLY-attribute added to USE-statements, |
---|
42 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
43 | ! kinds are defined in new module kinds, |
---|
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 | ! 1128 2013-04-12 06:19:32Z raasch |
---|
53 | ! loop index bounds in accelerator version replaced by i_left, i_right, j_south, |
---|
54 | ! j_north |
---|
55 | ! |
---|
56 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
57 | ! code put under GPL (PALM 3.9) |
---|
58 | ! |
---|
59 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
60 | ! accelerator version (*_acc) added |
---|
61 | ! |
---|
62 | ! 1001 2012-09-13 14:08:46Z raasch |
---|
63 | ! arrays comunicated by module instead of parameter list |
---|
64 | ! |
---|
65 | ! 978 2012-08-09 08:28:32Z fricke |
---|
66 | ! outflow damping layer removed |
---|
67 | ! kmxm_x/_y and kmxp_x/_y change to kmxm and kmxp |
---|
68 | ! |
---|
69 | ! Revision 1.1 1997/09/12 06:24:01 raasch |
---|
70 | ! Initial revision |
---|
71 | ! |
---|
72 | ! |
---|
73 | ! Description: |
---|
74 | ! ------------ |
---|
75 | !> Diffusion term of the v-component |
---|
76 | !------------------------------------------------------------------------------! |
---|
77 | MODULE diffusion_v_mod |
---|
78 | |
---|
79 | |
---|
80 | USE wall_fluxes_mod |
---|
81 | |
---|
82 | PRIVATE |
---|
83 | PUBLIC diffusion_v, diffusion_v_acc |
---|
84 | |
---|
85 | INTERFACE diffusion_v |
---|
86 | MODULE PROCEDURE diffusion_v |
---|
87 | MODULE PROCEDURE diffusion_v_ij |
---|
88 | END INTERFACE diffusion_v |
---|
89 | |
---|
90 | INTERFACE diffusion_v_acc |
---|
91 | MODULE PROCEDURE diffusion_v_acc |
---|
92 | END INTERFACE diffusion_v_acc |
---|
93 | |
---|
94 | CONTAINS |
---|
95 | |
---|
96 | |
---|
97 | !------------------------------------------------------------------------------! |
---|
98 | ! Description: |
---|
99 | ! ------------ |
---|
100 | !> Call for all grid points |
---|
101 | !------------------------------------------------------------------------------! |
---|
102 | SUBROUTINE diffusion_v |
---|
103 | |
---|
104 | USE arrays_3d, & |
---|
105 | ONLY: ddzu, ddzw, km, tend, u, v, vsws, vswst, w |
---|
106 | |
---|
107 | USE control_parameters, & |
---|
108 | ONLY: constant_top_momentumflux, topography, use_surface_fluxes, & |
---|
109 | use_top_fluxes |
---|
110 | |
---|
111 | USE grid_variables, & |
---|
112 | ONLY: ddx, ddy, ddy2, fxm, fxp, wall_v |
---|
113 | |
---|
114 | USE indices, & |
---|
115 | ONLY: nxl, nxr, nyn, nys, nysv, nzb, nzb_diff_v, nzb_v_inner, & |
---|
116 | nzb_v_outer, nzt, nzt_diff |
---|
117 | |
---|
118 | USE kinds |
---|
119 | |
---|
120 | IMPLICIT NONE |
---|
121 | |
---|
122 | INTEGER(iwp) :: i !< |
---|
123 | INTEGER(iwp) :: j !< |
---|
124 | INTEGER(iwp) :: k !< |
---|
125 | REAL(wp) :: kmxm !< |
---|
126 | REAL(wp) :: kmxp !< |
---|
127 | REAL(wp) :: kmzm !< |
---|
128 | REAL(wp) :: kmzp !< |
---|
129 | |
---|
130 | REAL(wp), DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: vsus !< |
---|
131 | |
---|
132 | ! |
---|
133 | !-- First calculate horizontal momentum flux v'u' at vertical walls, |
---|
134 | !-- if neccessary |
---|
135 | IF ( topography /= 'flat' ) THEN |
---|
136 | CALL wall_fluxes( vsus, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp, nzb_v_inner, & |
---|
137 | nzb_v_outer, wall_v ) |
---|
138 | ENDIF |
---|
139 | |
---|
140 | DO i = nxl, nxr |
---|
141 | DO j = nysv, nyn |
---|
142 | ! |
---|
143 | !-- Compute horizontal diffusion |
---|
144 | DO k = nzb_v_outer(j,i)+1, nzt |
---|
145 | ! |
---|
146 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
147 | kmxp = 0.25_wp * & |
---|
148 | ( km(k,j,i)+km(k,j,i+1)+km(k,j-1,i)+km(k,j-1,i+1) ) |
---|
149 | kmxm = 0.25_wp * & |
---|
150 | ( km(k,j,i)+km(k,j,i-1)+km(k,j-1,i)+km(k,j-1,i-1) ) |
---|
151 | |
---|
152 | tend(k,j,i) = tend(k,j,i) & |
---|
153 | & + ( kmxp * ( v(k,j,i+1) - v(k,j,i) ) * ddx & |
---|
154 | & + kmxp * ( u(k,j,i+1) - u(k,j-1,i+1) ) * ddy & |
---|
155 | & - kmxm * ( v(k,j,i) - v(k,j,i-1) ) * ddx & |
---|
156 | & - kmxm * ( u(k,j,i) - u(k,j-1,i) ) * ddy & |
---|
157 | & ) * ddx & |
---|
158 | & + 2.0_wp * ( & |
---|
159 | & km(k,j,i) * ( v(k,j+1,i) - v(k,j,i) ) & |
---|
160 | & - km(k,j-1,i) * ( v(k,j,i) - v(k,j-1,i) ) & |
---|
161 | & ) * ddy2 |
---|
162 | ENDDO |
---|
163 | |
---|
164 | ! |
---|
165 | !-- Wall functions at the left and right walls, respectively |
---|
166 | IF ( wall_v(j,i) /= 0.0_wp ) THEN |
---|
167 | |
---|
168 | DO k = nzb_v_inner(j,i)+1, nzb_v_outer(j,i) |
---|
169 | kmxp = 0.25_wp * & |
---|
170 | ( km(k,j,i)+km(k,j,i+1)+km(k,j-1,i)+km(k,j-1,i+1) ) |
---|
171 | kmxm = 0.25_wp * & |
---|
172 | ( km(k,j,i)+km(k,j,i-1)+km(k,j-1,i)+km(k,j-1,i-1) ) |
---|
173 | |
---|
174 | tend(k,j,i) = tend(k,j,i) & |
---|
175 | + 2.0_wp * ( & |
---|
176 | km(k,j,i) * ( v(k,j+1,i) - v(k,j,i) ) & |
---|
177 | - km(k,j-1,i) * ( v(k,j,i) - v(k,j-1,i) ) & |
---|
178 | ) * ddy2 & |
---|
179 | + ( fxp(j,i) * ( & |
---|
180 | kmxp * ( v(k,j,i+1) - v(k,j,i) ) * ddx & |
---|
181 | + kmxp * ( u(k,j,i+1) - u(k,j-1,i+1) ) * ddy & |
---|
182 | ) & |
---|
183 | - fxm(j,i) * ( & |
---|
184 | kmxm * ( v(k,j,i) - v(k,j,i-1) ) * ddx & |
---|
185 | + kmxm * ( u(k,j,i) - u(k,j-1,i) ) * ddy & |
---|
186 | ) & |
---|
187 | + wall_v(j,i) * vsus(k,j,i) & |
---|
188 | ) * ddx |
---|
189 | ENDDO |
---|
190 | ENDIF |
---|
191 | |
---|
192 | ! |
---|
193 | !-- Compute vertical diffusion. In case of simulating a Prandtl |
---|
194 | !-- layer, index k starts at nzb_v_inner+2. |
---|
195 | DO k = nzb_diff_v(j,i), nzt_diff |
---|
196 | ! |
---|
197 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
198 | kmzp = 0.25_wp * & |
---|
199 | ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
200 | kmzm = 0.25_wp * & |
---|
201 | ( km(k,j,i)+km(k-1,j,i)+km(k,j-1,i)+km(k-1,j-1,i) ) |
---|
202 | |
---|
203 | tend(k,j,i) = tend(k,j,i) & |
---|
204 | & + ( kmzp * ( ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
205 | & + ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
206 | & ) & |
---|
207 | & - kmzm * ( ( v(k,j,i) - v(k-1,j,i) ) * ddzu(k) & |
---|
208 | & + ( w(k-1,j,i) - w(k-1,j-1,i) ) * ddy & |
---|
209 | & ) & |
---|
210 | & ) * ddzw(k) |
---|
211 | ENDDO |
---|
212 | |
---|
213 | ! |
---|
214 | !-- Vertical diffusion at the first grid point above the surface, |
---|
215 | !-- if the momentum flux at the bottom is given by the Prandtl law |
---|
216 | !-- or if it is prescribed by the user. |
---|
217 | !-- Difference quotient of the momentum flux is not formed over |
---|
218 | !-- half of the grid spacing (2.0*ddzw(k)) any more, since the |
---|
219 | !-- comparison with other (LES) models showed that the values of |
---|
220 | !-- the momentum flux becomes too large in this case. |
---|
221 | !-- The term containing w(k-1,..) (see above equation) is removed here |
---|
222 | !-- because the vertical velocity is assumed to be zero at the surface. |
---|
223 | IF ( use_surface_fluxes ) THEN |
---|
224 | k = nzb_v_inner(j,i)+1 |
---|
225 | ! |
---|
226 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
227 | kmzp = 0.25_wp * & |
---|
228 | ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
229 | |
---|
230 | tend(k,j,i) = tend(k,j,i) & |
---|
231 | & + ( kmzp * ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
232 | & ) * ddzw(k) & |
---|
233 | & + ( kmzp * ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
234 | & + vsws(j,i) & |
---|
235 | & ) * ddzw(k) |
---|
236 | ENDIF |
---|
237 | |
---|
238 | ! |
---|
239 | !-- Vertical diffusion at the first gridpoint below the top boundary, |
---|
240 | !-- if the momentum flux at the top is prescribed by the user |
---|
241 | IF ( use_top_fluxes .AND. constant_top_momentumflux ) THEN |
---|
242 | k = nzt |
---|
243 | ! |
---|
244 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
245 | kmzm = 0.25_wp * & |
---|
246 | ( km(k,j,i)+km(k-1,j,i)+km(k,j-1,i)+km(k-1,j-1,i) ) |
---|
247 | |
---|
248 | tend(k,j,i) = tend(k,j,i) & |
---|
249 | & - ( kmzm * ( w(k-1,j,i) - w(k-1,j-1,i) ) * ddy & |
---|
250 | & ) * ddzw(k) & |
---|
251 | & + ( -vswst(j,i) & |
---|
252 | & - kmzm * ( v(k,j,i) - v(k-1,j,i) ) * ddzu(k) & |
---|
253 | & ) * ddzw(k) |
---|
254 | ENDIF |
---|
255 | |
---|
256 | ENDDO |
---|
257 | ENDDO |
---|
258 | |
---|
259 | END SUBROUTINE diffusion_v |
---|
260 | |
---|
261 | |
---|
262 | !------------------------------------------------------------------------------! |
---|
263 | ! Description: |
---|
264 | ! ------------ |
---|
265 | !> Call for all grid points - accelerator version |
---|
266 | !------------------------------------------------------------------------------! |
---|
267 | SUBROUTINE diffusion_v_acc |
---|
268 | |
---|
269 | USE arrays_3d, & |
---|
270 | ONLY: ddzu, ddzw, km, tend, u, v, vsws, vswst, w |
---|
271 | |
---|
272 | USE control_parameters, & |
---|
273 | ONLY: constant_top_momentumflux, topography, use_surface_fluxes, & |
---|
274 | use_top_fluxes |
---|
275 | |
---|
276 | USE grid_variables, & |
---|
277 | ONLY: ddx, ddy, ddy2, fxm, fxp, wall_v |
---|
278 | |
---|
279 | USE indices, & |
---|
280 | ONLY: i_left, i_right, j_north, j_south, nxl, nxr, nyn, nys, nzb, & |
---|
281 | nzb_diff_v, nzb_v_inner, nzb_v_outer, nzt, nzt_diff |
---|
282 | |
---|
283 | USE kinds |
---|
284 | |
---|
285 | IMPLICIT NONE |
---|
286 | |
---|
287 | INTEGER(iwp) :: i !< |
---|
288 | INTEGER(iwp) :: j !< |
---|
289 | INTEGER(iwp) :: k !< |
---|
290 | REAL(wp) :: kmxm !< |
---|
291 | REAL(wp) :: kmxp !< |
---|
292 | REAL(wp) :: kmzm !< |
---|
293 | REAL(wp) :: kmzp !< |
---|
294 | |
---|
295 | REAL(wp), DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: vsus !< |
---|
296 | !$acc declare create ( vsus ) |
---|
297 | |
---|
298 | ! |
---|
299 | !-- First calculate horizontal momentum flux v'u' at vertical walls, |
---|
300 | !-- if neccessary |
---|
301 | IF ( topography /= 'flat' ) THEN |
---|
302 | CALL wall_fluxes_acc( vsus, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp, & |
---|
303 | nzb_v_inner, nzb_v_outer, wall_v ) |
---|
304 | ENDIF |
---|
305 | |
---|
306 | !$acc kernels present ( u, v, w, km, tend, vsws, vswst ) & |
---|
307 | !$acc present ( ddzu, ddzw, fxm, fxp, wall_v ) & |
---|
308 | !$acc present ( nzb_v_inner, nzb_v_outer, nzb_diff_v ) |
---|
309 | DO i = i_left, i_right |
---|
310 | DO j = j_south, j_north |
---|
311 | ! |
---|
312 | !-- Compute horizontal diffusion |
---|
313 | DO k = 1, nzt |
---|
314 | IF ( k > nzb_v_outer(j,i) ) THEN |
---|
315 | ! |
---|
316 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
317 | kmxp = 0.25_wp * & |
---|
318 | ( km(k,j,i)+km(k,j,i+1)+km(k,j-1,i)+km(k,j-1,i+1) ) |
---|
319 | kmxm = 0.25_wp * & |
---|
320 | ( km(k,j,i)+km(k,j,i-1)+km(k,j-1,i)+km(k,j-1,i-1) ) |
---|
321 | |
---|
322 | tend(k,j,i) = tend(k,j,i) & |
---|
323 | & + ( kmxp * ( v(k,j,i+1) - v(k,j,i) ) * ddx & |
---|
324 | & + kmxp * ( u(k,j,i+1) - u(k,j-1,i+1) ) * ddy & |
---|
325 | & - kmxm * ( v(k,j,i) - v(k,j,i-1) ) * ddx & |
---|
326 | & - kmxm * ( u(k,j,i) - u(k,j-1,i) ) * ddy & |
---|
327 | & ) * ddx & |
---|
328 | & + 2.0_wp * ( & |
---|
329 | & km(k,j,i) * ( v(k,j+1,i) - v(k,j,i) ) & |
---|
330 | & - km(k,j-1,i) * ( v(k,j,i) - v(k,j-1,i) ) & |
---|
331 | & ) * ddy2 |
---|
332 | ENDIF |
---|
333 | ENDDO |
---|
334 | |
---|
335 | ! |
---|
336 | !-- Wall functions at the left and right walls, respectively |
---|
337 | DO k = 1, nzt |
---|
338 | IF( k > nzb_v_inner(j,i) .AND. k <= nzb_v_outer(j,i) .AND. & |
---|
339 | wall_v(j,i) /= 0.0_wp ) THEN |
---|
340 | |
---|
341 | kmxp = 0.25_wp * & |
---|
342 | ( km(k,j,i)+km(k,j,i+1)+km(k,j-1,i)+km(k,j-1,i+1) ) |
---|
343 | kmxm = 0.25_wp * & |
---|
344 | ( km(k,j,i)+km(k,j,i-1)+km(k,j-1,i)+km(k,j-1,i-1) ) |
---|
345 | |
---|
346 | tend(k,j,i) = tend(k,j,i) & |
---|
347 | + 2.0_wp * ( & |
---|
348 | km(k,j,i) * ( v(k,j+1,i) - v(k,j,i) ) & |
---|
349 | - km(k,j-1,i) * ( v(k,j,i) - v(k,j-1,i) ) & |
---|
350 | ) * ddy2 & |
---|
351 | + ( fxp(j,i) * ( & |
---|
352 | kmxp * ( v(k,j,i+1) - v(k,j,i) ) * ddx & |
---|
353 | + kmxp * ( u(k,j,i+1) - u(k,j-1,i+1) ) * ddy & |
---|
354 | ) & |
---|
355 | - fxm(j,i) * ( & |
---|
356 | kmxm * ( v(k,j,i) - v(k,j,i-1) ) * ddx & |
---|
357 | + kmxm * ( u(k,j,i) - u(k,j-1,i) ) * ddy & |
---|
358 | ) & |
---|
359 | + wall_v(j,i) * vsus(k,j,i) & |
---|
360 | ) * ddx |
---|
361 | ENDIF |
---|
362 | ENDDO |
---|
363 | |
---|
364 | ! |
---|
365 | !-- Compute vertical diffusion. In case of simulating a Prandtl |
---|
366 | !-- layer, index k starts at nzb_v_inner+2. |
---|
367 | DO k = 1, nzt_diff |
---|
368 | IF ( k >= nzb_diff_v(j,i) ) THEN |
---|
369 | ! |
---|
370 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
371 | kmzp = 0.25_wp * & |
---|
372 | ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
373 | kmzm = 0.25_wp * & |
---|
374 | ( km(k,j,i)+km(k-1,j,i)+km(k,j-1,i)+km(k-1,j-1,i) ) |
---|
375 | |
---|
376 | tend(k,j,i) = tend(k,j,i) & |
---|
377 | & + ( kmzp * ( ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1)& |
---|
378 | & + ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
379 | & ) & |
---|
380 | & - kmzm * ( ( v(k,j,i) - v(k-1,j,i) ) * ddzu(k)& |
---|
381 | & + ( w(k-1,j,i) - w(k-1,j-1,i) ) * ddy & |
---|
382 | & ) & |
---|
383 | & ) * ddzw(k) |
---|
384 | ENDIF |
---|
385 | ENDDO |
---|
386 | |
---|
387 | ENDDO |
---|
388 | ENDDO |
---|
389 | |
---|
390 | ! |
---|
391 | !-- Vertical diffusion at the first grid point above the surface, |
---|
392 | !-- if the momentum flux at the bottom is given by the Prandtl law |
---|
393 | !-- or if it is prescribed by the user. |
---|
394 | !-- Difference quotient of the momentum flux is not formed over |
---|
395 | !-- half of the grid spacing (2.0*ddzw(k)) any more, since the |
---|
396 | !-- comparison with other (LES) models showed that the values of |
---|
397 | !-- the momentum flux becomes too large in this case. |
---|
398 | !-- The term containing w(k-1,..) (see above equation) is removed here |
---|
399 | !-- because the vertical velocity is assumed to be zero at the surface. |
---|
400 | IF ( use_surface_fluxes ) THEN |
---|
401 | |
---|
402 | DO i = i_left, i_right |
---|
403 | DO j = j_south, j_north |
---|
404 | |
---|
405 | k = nzb_v_inner(j,i)+1 |
---|
406 | ! |
---|
407 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
408 | kmzp = 0.25_wp * & |
---|
409 | ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
410 | |
---|
411 | tend(k,j,i) = tend(k,j,i) & |
---|
412 | & + ( kmzp * ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
413 | & ) * ddzw(k) & |
---|
414 | & + ( kmzp * ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
415 | & + vsws(j,i) & |
---|
416 | & ) * ddzw(k) |
---|
417 | ENDDO |
---|
418 | ENDDO |
---|
419 | |
---|
420 | ENDIF |
---|
421 | |
---|
422 | ! |
---|
423 | !-- Vertical diffusion at the first gridpoint below the top boundary, |
---|
424 | !-- if the momentum flux at the top is prescribed by the user |
---|
425 | IF ( use_top_fluxes .AND. constant_top_momentumflux ) THEN |
---|
426 | |
---|
427 | k = nzt |
---|
428 | |
---|
429 | DO i = i_left, i_right |
---|
430 | DO j = j_south, j_north |
---|
431 | |
---|
432 | ! |
---|
433 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
434 | kmzm = 0.25_wp * & |
---|
435 | ( km(k,j,i)+km(k-1,j,i)+km(k,j-1,i)+km(k-1,j-1,i) ) |
---|
436 | |
---|
437 | tend(k,j,i) = tend(k,j,i) & |
---|
438 | & - ( kmzm * ( w(k-1,j,i) - w(k-1,j-1,i) ) * ddy & |
---|
439 | & ) * ddzw(k) & |
---|
440 | & + ( -vswst(j,i) & |
---|
441 | & - kmzm * ( v(k,j,i) - v(k-1,j,i) ) * ddzu(k) & |
---|
442 | & ) * ddzw(k) |
---|
443 | ENDDO |
---|
444 | ENDDO |
---|
445 | |
---|
446 | ENDIF |
---|
447 | !$acc end kernels |
---|
448 | |
---|
449 | END SUBROUTINE diffusion_v_acc |
---|
450 | |
---|
451 | |
---|
452 | !------------------------------------------------------------------------------! |
---|
453 | ! Description: |
---|
454 | ! ------------ |
---|
455 | !> Call for grid point i,j |
---|
456 | !------------------------------------------------------------------------------! |
---|
457 | SUBROUTINE diffusion_v_ij( i, j ) |
---|
458 | |
---|
459 | USE arrays_3d, & |
---|
460 | ONLY: ddzu, ddzw, km, tend, u, v, vsws, vswst, w |
---|
461 | |
---|
462 | USE control_parameters, & |
---|
463 | ONLY: constant_top_momentumflux, use_surface_fluxes, use_top_fluxes |
---|
464 | |
---|
465 | USE grid_variables, & |
---|
466 | ONLY: ddx, ddy, ddy2, fxm, fxp, wall_v |
---|
467 | |
---|
468 | USE indices, & |
---|
469 | ONLY: nzb, nzb_diff_v, nzb_v_inner, nzb_v_outer, nzt, nzt_diff |
---|
470 | |
---|
471 | USE kinds |
---|
472 | |
---|
473 | IMPLICIT NONE |
---|
474 | |
---|
475 | INTEGER(iwp) :: i !< |
---|
476 | INTEGER(iwp) :: j !< |
---|
477 | INTEGER(iwp) :: k !< |
---|
478 | REAL(wp) :: kmxm !< |
---|
479 | REAL(wp) :: kmxp !< |
---|
480 | REAL(wp) :: kmzm !< |
---|
481 | REAL(wp) :: kmzp !< |
---|
482 | |
---|
483 | REAL(wp), DIMENSION(nzb:nzt+1) :: vsus !< |
---|
484 | |
---|
485 | ! |
---|
486 | !-- Compute horizontal diffusion |
---|
487 | DO k = nzb_v_outer(j,i)+1, nzt |
---|
488 | ! |
---|
489 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
490 | kmxp = 0.25_wp * ( km(k,j,i)+km(k,j,i+1)+km(k,j-1,i)+km(k,j-1,i+1) ) |
---|
491 | kmxm = 0.25_wp * ( km(k,j,i)+km(k,j,i-1)+km(k,j-1,i)+km(k,j-1,i-1) ) |
---|
492 | |
---|
493 | tend(k,j,i) = tend(k,j,i) & |
---|
494 | & + ( kmxp * ( v(k,j,i+1) - v(k,j,i) ) * ddx & |
---|
495 | & + kmxp * ( u(k,j,i+1) - u(k,j-1,i+1) ) * ddy & |
---|
496 | & - kmxm * ( v(k,j,i) - v(k,j,i-1) ) * ddx & |
---|
497 | & - kmxm * ( u(k,j,i) - u(k,j-1,i) ) * ddy & |
---|
498 | & ) * ddx & |
---|
499 | & + 2.0_wp * ( & |
---|
500 | & km(k,j,i) * ( v(k,j+1,i) - v(k,j,i) ) & |
---|
501 | & - km(k,j-1,i) * ( v(k,j,i) - v(k,j-1,i) ) & |
---|
502 | & ) * ddy2 |
---|
503 | ENDDO |
---|
504 | |
---|
505 | ! |
---|
506 | !-- Wall functions at the left and right walls, respectively |
---|
507 | IF ( wall_v(j,i) /= 0.0_wp ) THEN |
---|
508 | |
---|
509 | ! |
---|
510 | !-- Calculate the horizontal momentum flux v'u' |
---|
511 | CALL wall_fluxes( i, j, nzb_v_inner(j,i)+1, nzb_v_outer(j,i), & |
---|
512 | vsus, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp ) |
---|
513 | |
---|
514 | DO k = nzb_v_inner(j,i)+1, nzb_v_outer(j,i) |
---|
515 | kmxp = 0.25_wp * & |
---|
516 | ( km(k,j,i)+km(k,j,i+1)+km(k,j-1,i)+km(k,j-1,i+1) ) |
---|
517 | kmxm = 0.25_wp * & |
---|
518 | ( km(k,j,i)+km(k,j,i-1)+km(k,j-1,i)+km(k,j-1,i-1) ) |
---|
519 | |
---|
520 | tend(k,j,i) = tend(k,j,i) & |
---|
521 | + 2.0_wp * ( & |
---|
522 | km(k,j,i) * ( v(k,j+1,i) - v(k,j,i) ) & |
---|
523 | - km(k,j-1,i) * ( v(k,j,i) - v(k,j-1,i) ) & |
---|
524 | ) * ddy2 & |
---|
525 | + ( fxp(j,i) * ( & |
---|
526 | kmxp * ( v(k,j,i+1) - v(k,j,i) ) * ddx & |
---|
527 | + kmxp * ( u(k,j,i+1) - u(k,j-1,i+1) ) * ddy & |
---|
528 | ) & |
---|
529 | - fxm(j,i) * ( & |
---|
530 | kmxm * ( v(k,j,i) - v(k,j,i-1) ) * ddx & |
---|
531 | + kmxm * ( u(k,j,i) - u(k,j-1,i) ) * ddy & |
---|
532 | ) & |
---|
533 | + wall_v(j,i) * vsus(k) & |
---|
534 | ) * ddx |
---|
535 | ENDDO |
---|
536 | ENDIF |
---|
537 | |
---|
538 | ! |
---|
539 | !-- Compute vertical diffusion. In case of simulating a Prandtl layer, |
---|
540 | !-- index k starts at nzb_v_inner+2. |
---|
541 | DO k = nzb_diff_v(j,i), nzt_diff |
---|
542 | ! |
---|
543 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
544 | kmzp = 0.25_wp * ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
545 | kmzm = 0.25_wp * ( km(k,j,i)+km(k-1,j,i)+km(k,j-1,i)+km(k-1,j-1,i) ) |
---|
546 | |
---|
547 | tend(k,j,i) = tend(k,j,i) & |
---|
548 | & + ( kmzp * ( ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
549 | & + ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
550 | & ) & |
---|
551 | & - kmzm * ( ( v(k,j,i) - v(k-1,j,i) ) * ddzu(k) & |
---|
552 | & + ( w(k-1,j,i) - w(k-1,j-1,i) ) * ddy & |
---|
553 | & ) & |
---|
554 | & ) * ddzw(k) |
---|
555 | ENDDO |
---|
556 | |
---|
557 | ! |
---|
558 | !-- Vertical diffusion at the first grid point above the surface, if the |
---|
559 | !-- momentum flux at the bottom is given by the Prandtl law or if it is |
---|
560 | !-- prescribed by the user. |
---|
561 | !-- Difference quotient of the momentum flux is not formed over half of |
---|
562 | !-- the grid spacing (2.0*ddzw(k)) any more, since the comparison with |
---|
563 | !-- other (LES) models showed that the values of the momentum flux becomes |
---|
564 | !-- too large in this case. |
---|
565 | !-- The term containing w(k-1,..) (see above equation) is removed here |
---|
566 | !-- because the vertical velocity is assumed to be zero at the surface. |
---|
567 | IF ( use_surface_fluxes ) THEN |
---|
568 | k = nzb_v_inner(j,i)+1 |
---|
569 | ! |
---|
570 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
571 | kmzp = 0.25_wp * ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
572 | |
---|
573 | tend(k,j,i) = tend(k,j,i) & |
---|
574 | & + ( kmzp * ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
575 | & ) * ddzw(k) & |
---|
576 | & + ( kmzp * ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
577 | & + vsws(j,i) & |
---|
578 | & ) * ddzw(k) |
---|
579 | ENDIF |
---|
580 | |
---|
581 | ! |
---|
582 | !-- Vertical diffusion at the first gridpoint below the top boundary, |
---|
583 | !-- if the momentum flux at the top is prescribed by the user |
---|
584 | IF ( use_top_fluxes .AND. constant_top_momentumflux ) THEN |
---|
585 | k = nzt |
---|
586 | ! |
---|
587 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
588 | kmzm = 0.25_wp * & |
---|
589 | ( km(k,j,i)+km(k-1,j,i)+km(k,j-1,i)+km(k-1,j-1,i) ) |
---|
590 | |
---|
591 | tend(k,j,i) = tend(k,j,i) & |
---|
592 | & - ( kmzm * ( w(k-1,j,i) - w(k-1,j-1,i) ) * ddy & |
---|
593 | & ) * ddzw(k) & |
---|
594 | & + ( -vswst(j,i) & |
---|
595 | & - kmzm * ( v(k,j,i) - v(k-1,j,i) ) * ddzu(k) & |
---|
596 | & ) * ddzw(k) |
---|
597 | ENDIF |
---|
598 | |
---|
599 | END SUBROUTINE diffusion_v_ij |
---|
600 | |
---|
601 | END MODULE diffusion_v_mod |
---|