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