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