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