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