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