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