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