1 | !> @file diffusion_w.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-2016 Leibniz Universitaet Hannover |
---|
17 | !--------------------------------------------------------------------------------! |
---|
18 | ! |
---|
19 | ! Current revisions: |
---|
20 | ! ----------------- |
---|
21 | ! |
---|
22 | ! |
---|
23 | ! Former revisions: |
---|
24 | ! ----------------- |
---|
25 | ! $Id: diffusion_w.f90 1874 2016-04-18 14:51:10Z suehring $ |
---|
26 | ! |
---|
27 | ! 1873 2016-04-18 14:50:06Z maronga |
---|
28 | ! Module renamed (removed _mod) |
---|
29 | ! |
---|
30 | ! |
---|
31 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
32 | ! Module renamed |
---|
33 | ! |
---|
34 | ! |
---|
35 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
36 | ! Code annotations made doxygen readable |
---|
37 | ! |
---|
38 | ! 1374 2014-04-25 12:55:07Z raasch |
---|
39 | ! vsws + vswst removed from acc-present-list |
---|
40 | ! |
---|
41 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
42 | ! REAL constants provided with KIND-attribute |
---|
43 | ! |
---|
44 | ! 1340 2014-03-25 19:45:13Z kanani |
---|
45 | ! REAL constants defined as wp-kind |
---|
46 | ! |
---|
47 | ! 1322 2014-03-20 16:38:49Z raasch |
---|
48 | ! REAL constants defined as wp-kind |
---|
49 | ! |
---|
50 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
51 | ! ONLY-attribute added to USE-statements, |
---|
52 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
53 | ! kinds are defined in new module kinds, |
---|
54 | ! revision history before 2012 removed, |
---|
55 | ! comment fields (!:) to be used for variable explanations added to |
---|
56 | ! all variable declaration statements |
---|
57 | ! |
---|
58 | ! 1257 2013-11-08 15:18:40Z raasch |
---|
59 | ! openacc loop and loop vector clauses removed, declare create moved after |
---|
60 | ! the FORTRAN declaration statement |
---|
61 | ! |
---|
62 | ! 1128 2013-04-12 06:19:32Z raasch |
---|
63 | ! loop index bounds in accelerator version replaced by i_left, i_right, j_south, |
---|
64 | ! j_north |
---|
65 | ! |
---|
66 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
67 | ! code put under GPL (PALM 3.9) |
---|
68 | ! |
---|
69 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
70 | ! accelerator version (*_acc) added |
---|
71 | ! |
---|
72 | ! 1001 2012-09-13 14:08:46Z raasch |
---|
73 | ! arrays comunicated by module instead of parameter list |
---|
74 | ! |
---|
75 | ! 978 2012-08-09 08:28:32Z fricke |
---|
76 | ! outflow damping layer removed |
---|
77 | ! kmxm_x/_z and kmxp_x/_z change to kmxm and kmxp |
---|
78 | ! kmym_y/_z and kmyp_y/_z change to kmym and kmyp |
---|
79 | ! |
---|
80 | ! Revision 1.1 1997/09/12 06:24:11 raasch |
---|
81 | ! Initial revision |
---|
82 | ! |
---|
83 | ! |
---|
84 | ! Description: |
---|
85 | ! ------------ |
---|
86 | !> Diffusion term of the w-component |
---|
87 | !------------------------------------------------------------------------------! |
---|
88 | MODULE diffusion_w_mod |
---|
89 | |
---|
90 | |
---|
91 | USE wall_fluxes_mod, & |
---|
92 | ONLY : wall_fluxes, wall_fluxes_acc |
---|
93 | |
---|
94 | PRIVATE |
---|
95 | PUBLIC diffusion_w, diffusion_w_acc |
---|
96 | |
---|
97 | INTERFACE diffusion_w |
---|
98 | MODULE PROCEDURE diffusion_w |
---|
99 | MODULE PROCEDURE diffusion_w_ij |
---|
100 | END INTERFACE diffusion_w |
---|
101 | |
---|
102 | INTERFACE diffusion_w_acc |
---|
103 | MODULE PROCEDURE diffusion_w_acc |
---|
104 | END INTERFACE diffusion_w_acc |
---|
105 | |
---|
106 | CONTAINS |
---|
107 | |
---|
108 | |
---|
109 | !------------------------------------------------------------------------------! |
---|
110 | ! Description: |
---|
111 | ! ------------ |
---|
112 | !> Call for all grid points |
---|
113 | !------------------------------------------------------------------------------! |
---|
114 | SUBROUTINE diffusion_w |
---|
115 | |
---|
116 | USE arrays_3d, & |
---|
117 | ONLY : ddzu, ddzw, km, tend, u, v, w |
---|
118 | |
---|
119 | USE control_parameters, & |
---|
120 | ONLY : topography |
---|
121 | |
---|
122 | USE grid_variables, & |
---|
123 | ONLY : ddx, ddy, fwxm, fwxp, fwym, fwyp, wall_w_x, wall_w_y |
---|
124 | |
---|
125 | USE indices, & |
---|
126 | ONLY : nxl, nxr, nyn, nys, nzb, nzb_w_inner, nzb_w_outer, nzt |
---|
127 | |
---|
128 | USE kinds |
---|
129 | |
---|
130 | IMPLICIT NONE |
---|
131 | |
---|
132 | INTEGER(iwp) :: i !< |
---|
133 | INTEGER(iwp) :: j !< |
---|
134 | INTEGER(iwp) :: k !< |
---|
135 | |
---|
136 | REAL(wp) :: kmxm !< |
---|
137 | REAL(wp) :: kmxp !< |
---|
138 | REAL(wp) :: kmym !< |
---|
139 | REAL(wp) :: kmyp !< |
---|
140 | |
---|
141 | REAL(wp), DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: wsus !< |
---|
142 | REAL(wp), DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: wsvs !< |
---|
143 | |
---|
144 | |
---|
145 | ! |
---|
146 | !-- First calculate horizontal momentum flux w'u' and/or w'v' at vertical |
---|
147 | !-- walls, if neccessary |
---|
148 | IF ( topography /= 'flat' ) THEN |
---|
149 | CALL wall_fluxes( wsus, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, nzb_w_inner, & |
---|
150 | nzb_w_outer, wall_w_x ) |
---|
151 | CALL wall_fluxes( wsvs, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, nzb_w_inner, & |
---|
152 | nzb_w_outer, wall_w_y ) |
---|
153 | ENDIF |
---|
154 | |
---|
155 | DO i = nxl, nxr |
---|
156 | DO j = nys, nyn |
---|
157 | DO k = nzb_w_outer(j,i)+1, nzt-1 |
---|
158 | ! |
---|
159 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
160 | kmxp = 0.25_wp * & |
---|
161 | ( km(k,j,i)+km(k,j,i+1)+km(k+1,j,i)+km(k+1,j,i+1) ) |
---|
162 | kmxm = 0.25_wp * & |
---|
163 | ( km(k,j,i)+km(k,j,i-1)+km(k+1,j,i)+km(k+1,j,i-1) ) |
---|
164 | kmyp = 0.25_wp * & |
---|
165 | ( km(k,j,i)+km(k+1,j,i)+km(k,j+1,i)+km(k+1,j+1,i) ) |
---|
166 | kmym = 0.25_wp * & |
---|
167 | ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
168 | |
---|
169 | tend(k,j,i) = tend(k,j,i) & |
---|
170 | & + ( kmxp * ( w(k,j,i+1) - w(k,j,i) ) * ddx & |
---|
171 | & + kmxp * ( u(k+1,j,i+1) - u(k,j,i+1) ) * ddzu(k+1) & |
---|
172 | & - kmxm * ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
173 | & - kmxm * ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
174 | & ) * ddx & |
---|
175 | & + ( kmyp * ( w(k,j+1,i) - w(k,j,i) ) * ddy & |
---|
176 | & + kmyp * ( v(k+1,j+1,i) - v(k,j+1,i) ) * ddzu(k+1) & |
---|
177 | & - kmym * ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
178 | & - kmym * ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
179 | & ) * ddy & |
---|
180 | & + 2.0_wp * ( & |
---|
181 | & km(k+1,j,i) * ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) & |
---|
182 | & - km(k,j,i) * ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) & |
---|
183 | & ) * ddzu(k+1) |
---|
184 | ENDDO |
---|
185 | |
---|
186 | ! |
---|
187 | !-- Wall functions at all vertical walls, where necessary |
---|
188 | IF ( wall_w_x(j,i) /= 0.0_wp .OR. wall_w_y(j,i) /= 0.0_wp ) THEN |
---|
189 | |
---|
190 | DO k = nzb_w_inner(j,i)+1, nzb_w_outer(j,i) |
---|
191 | ! |
---|
192 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
193 | kmxp = 0.25_wp * & |
---|
194 | ( km(k,j,i)+km(k,j,i+1)+km(k+1,j,i)+km(k+1,j,i+1) ) |
---|
195 | kmxm = 0.25_wp * & |
---|
196 | ( km(k,j,i)+km(k,j,i-1)+km(k+1,j,i)+km(k+1,j,i-1) ) |
---|
197 | kmyp = 0.25_wp * & |
---|
198 | ( km(k,j,i)+km(k+1,j,i)+km(k,j+1,i)+km(k+1,j+1,i) ) |
---|
199 | kmym = 0.25_wp * & |
---|
200 | ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
201 | |
---|
202 | tend(k,j,i) = tend(k,j,i) & |
---|
203 | + ( fwxp(j,i) * ( & |
---|
204 | kmxp * ( w(k,j,i+1) - w(k,j,i) ) * ddx & |
---|
205 | + kmxp * ( u(k+1,j,i+1) - u(k,j,i+1) ) * ddzu(k+1) & |
---|
206 | ) & |
---|
207 | - fwxm(j,i) * ( & |
---|
208 | kmxm * ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
209 | + kmxm * ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
210 | ) & |
---|
211 | + wall_w_x(j,i) * wsus(k,j,i) & |
---|
212 | ) * ddx & |
---|
213 | + ( fwyp(j,i) * ( & |
---|
214 | kmyp * ( w(k,j+1,i) - w(k,j,i) ) * ddy & |
---|
215 | + kmyp * ( v(k+1,j+1,i) - v(k,j+1,i) ) * ddzu(k+1) & |
---|
216 | ) & |
---|
217 | - fwym(j,i) * ( & |
---|
218 | kmym * ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
219 | + kmym * ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
220 | ) & |
---|
221 | + wall_w_y(j,i) * wsvs(k,j,i) & |
---|
222 | ) * ddy & |
---|
223 | + 2.0_wp * ( & |
---|
224 | km(k+1,j,i) * ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) & |
---|
225 | - km(k,j,i) * ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) & |
---|
226 | ) * ddzu(k+1) |
---|
227 | ENDDO |
---|
228 | ENDIF |
---|
229 | |
---|
230 | ENDDO |
---|
231 | ENDDO |
---|
232 | |
---|
233 | END SUBROUTINE diffusion_w |
---|
234 | |
---|
235 | |
---|
236 | !------------------------------------------------------------------------------! |
---|
237 | ! Description: |
---|
238 | ! ------------ |
---|
239 | !> Call for all grid points - accelerator version |
---|
240 | !------------------------------------------------------------------------------! |
---|
241 | SUBROUTINE diffusion_w_acc |
---|
242 | |
---|
243 | USE arrays_3d, & |
---|
244 | ONLY : ddzu, ddzw, km, tend, u, v, w |
---|
245 | |
---|
246 | USE control_parameters, & |
---|
247 | ONLY : topography |
---|
248 | |
---|
249 | USE grid_variables, & |
---|
250 | ONLY : ddx, ddy, fwxm, fwxp, fwym, fwyp, wall_w_x, wall_w_y |
---|
251 | |
---|
252 | USE indices, & |
---|
253 | ONLY : i_left, i_right, j_north, j_south, nxl, nxr, nyn, nys, nzb, & |
---|
254 | nzb_w_inner, nzb_w_outer, nzt |
---|
255 | |
---|
256 | USE kinds |
---|
257 | |
---|
258 | IMPLICIT NONE |
---|
259 | |
---|
260 | INTEGER(iwp) :: i !< |
---|
261 | INTEGER(iwp) :: j !< |
---|
262 | INTEGER(iwp) :: k !< |
---|
263 | |
---|
264 | REAL(wp) :: kmxm !< |
---|
265 | REAL(wp) :: kmxp !< |
---|
266 | REAL(wp) :: kmym !< |
---|
267 | REAL(wp) :: kmyp !< |
---|
268 | |
---|
269 | REAL(wp), DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: wsus !< |
---|
270 | REAL(wp), DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: wsvs !< |
---|
271 | !$acc declare create ( wsus, wsvs ) |
---|
272 | |
---|
273 | ! |
---|
274 | !-- First calculate horizontal momentum flux w'u' and/or w'v' at vertical |
---|
275 | !-- walls, if neccessary |
---|
276 | IF ( topography /= 'flat' ) THEN |
---|
277 | CALL wall_fluxes_acc( wsus, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, & |
---|
278 | nzb_w_inner, nzb_w_outer, wall_w_x ) |
---|
279 | CALL wall_fluxes_acc( wsvs, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, & |
---|
280 | nzb_w_inner, nzb_w_outer, wall_w_y ) |
---|
281 | ENDIF |
---|
282 | |
---|
283 | !$acc kernels present ( u, v, w, km, tend ) & |
---|
284 | !$acc present ( ddzu, ddzw, fwxm, fwxp, fwym, fwyp, wall_w_x, wall_w_y ) & |
---|
285 | !$acc present ( nzb_w_inner, nzb_w_outer ) |
---|
286 | DO i = i_left, i_right |
---|
287 | DO j = j_south, j_north |
---|
288 | DO k = 1, nzt |
---|
289 | IF ( k > nzb_w_outer(j,i) ) THEN |
---|
290 | ! |
---|
291 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
292 | kmxp = 0.25_wp * & |
---|
293 | ( km(k,j,i)+km(k,j,i+1)+km(k+1,j,i)+km(k+1,j,i+1) ) |
---|
294 | kmxm = 0.25_wp * & |
---|
295 | ( km(k,j,i)+km(k,j,i-1)+km(k+1,j,i)+km(k+1,j,i-1) ) |
---|
296 | kmyp = 0.25_wp * & |
---|
297 | ( km(k,j,i)+km(k+1,j,i)+km(k,j+1,i)+km(k+1,j+1,i) ) |
---|
298 | kmym = 0.25_wp * & |
---|
299 | ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
300 | |
---|
301 | tend(k,j,i) = tend(k,j,i) & |
---|
302 | & + ( kmxp * ( w(k,j,i+1) - w(k,j,i) ) * ddx & |
---|
303 | & + kmxp * ( u(k+1,j,i+1) - u(k,j,i+1) ) * ddzu(k+1) & |
---|
304 | & - kmxm * ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
305 | & - kmxm * ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
306 | & ) * ddx & |
---|
307 | & + ( kmyp * ( w(k,j+1,i) - w(k,j,i) ) * ddy & |
---|
308 | & + kmyp * ( v(k+1,j+1,i) - v(k,j+1,i) ) * ddzu(k+1) & |
---|
309 | & - kmym * ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
310 | & - kmym * ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
311 | & ) * ddy & |
---|
312 | & + 2.0_wp * ( & |
---|
313 | & km(k+1,j,i) * ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) & |
---|
314 | & - km(k,j,i) * ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) & |
---|
315 | & ) * ddzu(k+1) |
---|
316 | ENDIF |
---|
317 | ENDDO |
---|
318 | |
---|
319 | ! |
---|
320 | !-- Wall functions at all vertical walls, where necessary |
---|
321 | DO k = 1,nzt |
---|
322 | |
---|
323 | IF ( k > nzb_w_inner(j,i) .AND. k <= nzb_w_outer(j,i) .AND. & |
---|
324 | wall_w_x(j,i) /= 0.0_wp .AND. wall_w_y(j,i) /= 0.0_wp ) THEN |
---|
325 | ! |
---|
326 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
327 | kmxp = 0.25_wp * & |
---|
328 | ( km(k,j,i)+km(k,j,i+1)+km(k+1,j,i)+km(k+1,j,i+1) ) |
---|
329 | kmxm = 0.25_wp * & |
---|
330 | ( km(k,j,i)+km(k,j,i-1)+km(k+1,j,i)+km(k+1,j,i-1) ) |
---|
331 | kmyp = 0.25_wp * & |
---|
332 | ( km(k,j,i)+km(k+1,j,i)+km(k,j+1,i)+km(k+1,j+1,i) ) |
---|
333 | kmym = 0.25_wp * & |
---|
334 | ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
335 | |
---|
336 | tend(k,j,i) = tend(k,j,i) & |
---|
337 | + ( fwxp(j,i) * ( & |
---|
338 | kmxp * ( w(k,j,i+1) - w(k,j,i) ) * ddx & |
---|
339 | + kmxp * ( u(k+1,j,i+1) - u(k,j,i+1) ) * ddzu(k+1) & |
---|
340 | ) & |
---|
341 | - fwxm(j,i) * ( & |
---|
342 | kmxm * ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
343 | + kmxm * ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
344 | ) & |
---|
345 | + wall_w_x(j,i) * wsus(k,j,i) & |
---|
346 | ) * ddx & |
---|
347 | + ( fwyp(j,i) * ( & |
---|
348 | kmyp * ( w(k,j+1,i) - w(k,j,i) ) * ddy & |
---|
349 | + kmyp * ( v(k+1,j+1,i) - v(k,j+1,i) ) * ddzu(k+1) & |
---|
350 | ) & |
---|
351 | - fwym(j,i) * ( & |
---|
352 | kmym * ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
353 | + kmym * ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
354 | ) & |
---|
355 | + wall_w_y(j,i) * wsvs(k,j,i) & |
---|
356 | ) * ddy & |
---|
357 | + 2.0_wp * ( & |
---|
358 | km(k+1,j,i) * ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) & |
---|
359 | - km(k,j,i) * ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) & |
---|
360 | ) * ddzu(k+1) |
---|
361 | ENDIF |
---|
362 | ENDDO |
---|
363 | |
---|
364 | ENDDO |
---|
365 | ENDDO |
---|
366 | !$acc end kernels |
---|
367 | |
---|
368 | END SUBROUTINE diffusion_w_acc |
---|
369 | |
---|
370 | |
---|
371 | !------------------------------------------------------------------------------! |
---|
372 | ! Description: |
---|
373 | ! ------------ |
---|
374 | !> Call for grid point i,j |
---|
375 | !------------------------------------------------------------------------------! |
---|
376 | SUBROUTINE diffusion_w_ij( i, j ) |
---|
377 | |
---|
378 | USE arrays_3d, & |
---|
379 | ONLY : ddzu, ddzw, km, tend, u, v, w |
---|
380 | |
---|
381 | USE control_parameters, & |
---|
382 | ONLY : topography |
---|
383 | |
---|
384 | USE grid_variables, & |
---|
385 | ONLY : ddx, ddy, fwxm, fwxp, fwym, fwyp, wall_w_x, wall_w_y |
---|
386 | |
---|
387 | USE indices, & |
---|
388 | ONLY : nxl, nxr, nyn, nys, nzb, nzb_w_inner, nzb_w_outer, nzt |
---|
389 | |
---|
390 | USE kinds |
---|
391 | |
---|
392 | IMPLICIT NONE |
---|
393 | |
---|
394 | INTEGER(iwp) :: i !< |
---|
395 | INTEGER(iwp) :: j !< |
---|
396 | INTEGER(iwp) :: k !< |
---|
397 | |
---|
398 | REAL(wp) :: kmxm !< |
---|
399 | REAL(wp) :: kmxp !< |
---|
400 | REAL(wp) :: kmym !< |
---|
401 | REAL(wp) :: kmyp !< |
---|
402 | |
---|
403 | REAL(wp), DIMENSION(nzb:nzt+1) :: wsus |
---|
404 | REAL(wp), DIMENSION(nzb:nzt+1) :: wsvs |
---|
405 | |
---|
406 | |
---|
407 | DO k = nzb_w_outer(j,i)+1, nzt-1 |
---|
408 | ! |
---|
409 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
410 | kmxp = 0.25_wp * ( km(k,j,i)+km(k,j,i+1)+km(k+1,j,i)+km(k+1,j,i+1) ) |
---|
411 | kmxm = 0.25_wp * ( km(k,j,i)+km(k,j,i-1)+km(k+1,j,i)+km(k+1,j,i-1) ) |
---|
412 | kmyp = 0.25_wp * ( km(k,j,i)+km(k+1,j,i)+km(k,j+1,i)+km(k+1,j+1,i) ) |
---|
413 | kmym = 0.25_wp * ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
414 | |
---|
415 | tend(k,j,i) = tend(k,j,i) & |
---|
416 | & + ( kmxp * ( w(k,j,i+1) - w(k,j,i) ) * ddx & |
---|
417 | & + kmxp * ( u(k+1,j,i+1) - u(k,j,i+1) ) * ddzu(k+1) & |
---|
418 | & - kmxm * ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
419 | & - kmxm * ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
420 | & ) * ddx & |
---|
421 | & + ( kmyp * ( w(k,j+1,i) - w(k,j,i) ) * ddy & |
---|
422 | & + kmyp * ( v(k+1,j+1,i) - v(k,j+1,i) ) * ddzu(k+1) & |
---|
423 | & - kmym * ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
424 | & - kmym * ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
425 | & ) * ddy & |
---|
426 | & + 2.0_wp * ( & |
---|
427 | & km(k+1,j,i) * ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) & |
---|
428 | & - km(k,j,i) * ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) & |
---|
429 | & ) * ddzu(k+1) |
---|
430 | ENDDO |
---|
431 | |
---|
432 | ! |
---|
433 | !-- Wall functions at all vertical walls, where necessary |
---|
434 | IF ( wall_w_x(j,i) /= 0.0_wp .OR. wall_w_y(j,i) /= 0.0_wp ) THEN |
---|
435 | |
---|
436 | ! |
---|
437 | !-- Calculate the horizontal momentum fluxes w'u' and/or w'v' |
---|
438 | IF ( wall_w_x(j,i) /= 0.0_wp ) THEN |
---|
439 | CALL wall_fluxes( i, j, nzb_w_inner(j,i)+1, nzb_w_outer(j,i), & |
---|
440 | wsus, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp ) |
---|
441 | ELSE |
---|
442 | wsus = 0.0_wp |
---|
443 | ENDIF |
---|
444 | |
---|
445 | IF ( wall_w_y(j,i) /= 0.0_wp ) THEN |
---|
446 | CALL wall_fluxes( i, j, nzb_w_inner(j,i)+1, nzb_w_outer(j,i), & |
---|
447 | wsvs, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp ) |
---|
448 | ELSE |
---|
449 | wsvs = 0.0_wp |
---|
450 | ENDIF |
---|
451 | |
---|
452 | DO k = nzb_w_inner(j,i)+1, nzb_w_outer(j,i) |
---|
453 | ! |
---|
454 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
455 | kmxp = 0.25_wp * ( km(k,j,i)+km(k,j,i+1)+km(k+1,j,i)+km(k+1,j,i+1) ) |
---|
456 | kmxm = 0.25_wp * ( km(k,j,i)+km(k,j,i-1)+km(k+1,j,i)+km(k+1,j,i-1) ) |
---|
457 | kmyp = 0.25_wp * ( km(k,j,i)+km(k+1,j,i)+km(k,j+1,i)+km(k+1,j+1,i) ) |
---|
458 | kmym = 0.25_wp * ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
459 | |
---|
460 | tend(k,j,i) = tend(k,j,i) & |
---|
461 | + ( fwxp(j,i) * ( & |
---|
462 | kmxp * ( w(k,j,i+1) - w(k,j,i) ) * ddx & |
---|
463 | + kmxp * ( u(k+1,j,i+1) - u(k,j,i+1) ) * ddzu(k+1) & |
---|
464 | ) & |
---|
465 | - fwxm(j,i) * ( & |
---|
466 | kmxm * ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
467 | + kmxm * ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
468 | ) & |
---|
469 | + wall_w_x(j,i) * wsus(k) & |
---|
470 | ) * ddx & |
---|
471 | + ( fwyp(j,i) * ( & |
---|
472 | kmyp * ( w(k,j+1,i) - w(k,j,i) ) * ddy & |
---|
473 | + kmyp * ( v(k+1,j+1,i) - v(k,j+1,i) ) * ddzu(k+1) & |
---|
474 | ) & |
---|
475 | - fwym(j,i) * ( & |
---|
476 | kmym * ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
477 | + kmym * ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
478 | ) & |
---|
479 | + wall_w_y(j,i) * wsvs(k) & |
---|
480 | ) * ddy & |
---|
481 | + 2.0_wp * ( & |
---|
482 | km(k+1,j,i) * ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) & |
---|
483 | - km(k,j,i) * ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) & |
---|
484 | ) * ddzu(k+1) |
---|
485 | ENDDO |
---|
486 | ENDIF |
---|
487 | |
---|
488 | END SUBROUTINE diffusion_w_ij |
---|
489 | |
---|
490 | END MODULE diffusion_w_mod |
---|