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