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