1 | !> @file diffusion_s.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_s.f90 1818 2016-04-06 15:53:27Z witha $ |
---|
26 | ! |
---|
27 | ! 1691 2015-10-26 16:17:44Z maronga |
---|
28 | ! Formatting corrections. |
---|
29 | ! |
---|
30 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
31 | ! Code annotations made doxygen readable |
---|
32 | ! |
---|
33 | ! 1374 2014-04-25 12:55:07Z raasch |
---|
34 | ! missing variables added to ONLY list |
---|
35 | ! |
---|
36 | ! 1340 2014-03-25 19:45:13Z kanani |
---|
37 | ! REAL constants defined as wp-kind |
---|
38 | ! |
---|
39 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
40 | ! ONLY-attribute added to USE-statements, |
---|
41 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
42 | ! kinds are defined in new module kinds, |
---|
43 | ! revision history before 2012 removed, |
---|
44 | ! comment fields (!:) to be used for variable explanations added to |
---|
45 | ! all variable declaration statements |
---|
46 | ! |
---|
47 | ! 1257 2013-11-08 15:18:40Z raasch |
---|
48 | ! openacc loop and loop vector clauses removed |
---|
49 | ! |
---|
50 | ! 1128 2013-04-12 06:19:32Z raasch |
---|
51 | ! loop index bounds in accelerator version replaced by i_left, i_right, j_south, |
---|
52 | ! j_north |
---|
53 | ! |
---|
54 | ! 1092 2013-02-02 11:24:22Z raasch |
---|
55 | ! unused variables removed |
---|
56 | ! |
---|
57 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
58 | ! code put under GPL (PALM 3.9) |
---|
59 | ! |
---|
60 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
61 | ! accelerator version (*_acc) added |
---|
62 | ! |
---|
63 | ! 1010 2012-09-20 07:59:54Z raasch |
---|
64 | ! cpp switch __nopointer added for pointer free version |
---|
65 | ! |
---|
66 | ! 1001 2012-09-13 14:08:46Z raasch |
---|
67 | ! some arrays comunicated by module instead of parameter list |
---|
68 | ! |
---|
69 | ! Revision 1.1 2000/04/13 14:54:02 schroeter |
---|
70 | ! Initial revision |
---|
71 | ! |
---|
72 | ! |
---|
73 | ! Description: |
---|
74 | ! ------------ |
---|
75 | !> Diffusion term of scalar quantities (temperature and water content) |
---|
76 | !------------------------------------------------------------------------------! |
---|
77 | MODULE diffusion_s_mod |
---|
78 | |
---|
79 | |
---|
80 | PRIVATE |
---|
81 | PUBLIC diffusion_s, diffusion_s_acc |
---|
82 | |
---|
83 | INTERFACE diffusion_s |
---|
84 | MODULE PROCEDURE diffusion_s |
---|
85 | MODULE PROCEDURE diffusion_s_ij |
---|
86 | END INTERFACE diffusion_s |
---|
87 | |
---|
88 | INTERFACE diffusion_s_acc |
---|
89 | MODULE PROCEDURE diffusion_s_acc |
---|
90 | END INTERFACE diffusion_s_acc |
---|
91 | |
---|
92 | CONTAINS |
---|
93 | |
---|
94 | |
---|
95 | !------------------------------------------------------------------------------! |
---|
96 | ! Description: |
---|
97 | ! ------------ |
---|
98 | !> Call for all grid points |
---|
99 | !------------------------------------------------------------------------------! |
---|
100 | SUBROUTINE diffusion_s( s, s_flux_b, s_flux_t, wall_s_flux ) |
---|
101 | |
---|
102 | USE arrays_3d, & |
---|
103 | ONLY: ddzu, ddzw, kh, tend |
---|
104 | |
---|
105 | USE control_parameters, & |
---|
106 | ONLY: use_surface_fluxes, use_top_fluxes |
---|
107 | |
---|
108 | USE grid_variables, & |
---|
109 | ONLY: ddx2, ddy2, fwxm, fwxp, fwym, fwyp, wall_w_x, wall_w_y |
---|
110 | |
---|
111 | USE indices, & |
---|
112 | ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, & |
---|
113 | nzb_diff_s_inner, nzb_s_inner, nzb_s_outer, nzt, nzt_diff |
---|
114 | |
---|
115 | USE kinds |
---|
116 | |
---|
117 | IMPLICIT NONE |
---|
118 | |
---|
119 | INTEGER(iwp) :: i !< |
---|
120 | INTEGER(iwp) :: j !< |
---|
121 | INTEGER(iwp) :: k !< |
---|
122 | REAL(wp) :: wall_s_flux(0:4) !< |
---|
123 | REAL(wp), DIMENSION(nysg:nyng,nxlg:nxrg) :: s_flux_b, s_flux_t !< |
---|
124 | #if defined( __nopointer ) |
---|
125 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: s !< |
---|
126 | #else |
---|
127 | REAL(wp), DIMENSION(:,:,:), POINTER :: s !< |
---|
128 | #endif |
---|
129 | |
---|
130 | DO i = nxl, nxr |
---|
131 | DO j = nys,nyn |
---|
132 | ! |
---|
133 | !-- Compute horizontal diffusion |
---|
134 | DO k = nzb_s_outer(j,i)+1, nzt |
---|
135 | |
---|
136 | tend(k,j,i) = tend(k,j,i) & |
---|
137 | + 0.5_wp * ( & |
---|
138 | ( kh(k,j,i) + kh(k,j,i+1) ) * ( s(k,j,i+1)-s(k,j,i) ) & |
---|
139 | - ( kh(k,j,i) + kh(k,j,i-1) ) * ( s(k,j,i)-s(k,j,i-1) ) & |
---|
140 | ) * ddx2 & |
---|
141 | + 0.5_wp * ( & |
---|
142 | ( kh(k,j,i) + kh(k,j+1,i) ) * ( s(k,j+1,i)-s(k,j,i) ) & |
---|
143 | - ( kh(k,j,i) + kh(k,j-1,i) ) * ( s(k,j,i)-s(k,j-1,i) ) & |
---|
144 | ) * ddy2 |
---|
145 | ENDDO |
---|
146 | |
---|
147 | ! |
---|
148 | !-- Apply prescribed horizontal wall heatflux where necessary |
---|
149 | IF ( ( wall_w_x(j,i) /= 0.0_wp ) .OR. ( wall_w_y(j,i) /= 0.0_wp ) & |
---|
150 | ) THEN |
---|
151 | DO k = nzb_s_inner(j,i)+1, nzb_s_outer(j,i) |
---|
152 | |
---|
153 | tend(k,j,i) = tend(k,j,i) & |
---|
154 | + ( fwxp(j,i) * 0.5_wp * & |
---|
155 | ( kh(k,j,i) + kh(k,j,i+1) ) * ( s(k,j,i+1)-s(k,j,i) ) & |
---|
156 | + ( 1.0_wp - fwxp(j,i) ) * wall_s_flux(1) & |
---|
157 | -fwxm(j,i) * 0.5_wp * & |
---|
158 | ( kh(k,j,i) + kh(k,j,i-1) ) * ( s(k,j,i)-s(k,j,i-1) ) & |
---|
159 | + ( 1.0_wp - fwxm(j,i) ) * wall_s_flux(2) & |
---|
160 | ) * ddx2 & |
---|
161 | + ( fwyp(j,i) * 0.5_wp * & |
---|
162 | ( kh(k,j,i) + kh(k,j+1,i) ) * ( s(k,j+1,i)-s(k,j,i) ) & |
---|
163 | + ( 1.0_wp - fwyp(j,i) ) * wall_s_flux(3) & |
---|
164 | -fwym(j,i) * 0.5_wp * & |
---|
165 | ( kh(k,j,i) + kh(k,j-1,i) ) * ( s(k,j,i)-s(k,j-1,i) ) & |
---|
166 | + ( 1.0_wp - fwym(j,i) ) * wall_s_flux(4) & |
---|
167 | ) * ddy2 |
---|
168 | ENDDO |
---|
169 | ENDIF |
---|
170 | |
---|
171 | ! |
---|
172 | !-- Compute vertical diffusion. In case that surface fluxes have been |
---|
173 | !-- prescribed or computed at bottom and/or top, index k starts/ends at |
---|
174 | !-- nzb+2 or nzt-1, respectively. |
---|
175 | DO k = nzb_diff_s_inner(j,i), nzt_diff |
---|
176 | |
---|
177 | tend(k,j,i) = tend(k,j,i) & |
---|
178 | + 0.5_wp * ( & |
---|
179 | ( kh(k,j,i) + kh(k+1,j,i) ) * ( s(k+1,j,i)-s(k,j,i) ) * ddzu(k+1) & |
---|
180 | - ( kh(k,j,i) + kh(k-1,j,i) ) * ( s(k,j,i)-s(k-1,j,i) ) * ddzu(k) & |
---|
181 | ) * ddzw(k) |
---|
182 | ENDDO |
---|
183 | |
---|
184 | ! |
---|
185 | !-- Vertical diffusion at the first computational gridpoint along |
---|
186 | !-- z-direction |
---|
187 | IF ( use_surface_fluxes ) THEN |
---|
188 | |
---|
189 | k = nzb_s_inner(j,i)+1 |
---|
190 | |
---|
191 | tend(k,j,i) = tend(k,j,i) & |
---|
192 | + ( 0.5_wp * ( kh(k,j,i)+kh(k+1,j,i) ) & |
---|
193 | * ( s(k+1,j,i)-s(k,j,i) ) & |
---|
194 | * ddzu(k+1) & |
---|
195 | + s_flux_b(j,i) & |
---|
196 | ) * ddzw(k) |
---|
197 | |
---|
198 | ENDIF |
---|
199 | |
---|
200 | ! |
---|
201 | !-- Vertical diffusion at the last computational gridpoint along |
---|
202 | !-- z-direction |
---|
203 | IF ( use_top_fluxes ) THEN |
---|
204 | |
---|
205 | k = nzt |
---|
206 | |
---|
207 | tend(k,j,i) = tend(k,j,i) & |
---|
208 | + ( - s_flux_t(j,i) & |
---|
209 | - 0.5_wp * ( kh(k-1,j,i)+kh(k,j,i) )& |
---|
210 | * ( s(k,j,i)-s(k-1,j,i) ) & |
---|
211 | * ddzu(k) & |
---|
212 | ) * ddzw(k) |
---|
213 | |
---|
214 | ENDIF |
---|
215 | |
---|
216 | ENDDO |
---|
217 | ENDDO |
---|
218 | |
---|
219 | END SUBROUTINE diffusion_s |
---|
220 | |
---|
221 | |
---|
222 | !------------------------------------------------------------------------------! |
---|
223 | ! Description: |
---|
224 | ! ------------ |
---|
225 | !> Call for all grid points - accelerator version |
---|
226 | !------------------------------------------------------------------------------! |
---|
227 | SUBROUTINE diffusion_s_acc( s, s_flux_b, s_flux_t, wall_s_flux ) |
---|
228 | |
---|
229 | USE arrays_3d, & |
---|
230 | ONLY: ddzu, ddzw, kh, tend |
---|
231 | |
---|
232 | USE control_parameters, & |
---|
233 | ONLY: use_surface_fluxes, use_top_fluxes |
---|
234 | |
---|
235 | USE grid_variables, & |
---|
236 | ONLY: ddx2, ddy2, fwxm, fwxp, fwym, fwyp, wall_w_x, wall_w_y |
---|
237 | |
---|
238 | USE indices, & |
---|
239 | ONLY: i_left, i_right, j_north, j_south, nxlg, nxrg, nyng, nysg, & |
---|
240 | nzb, nzb_diff_s_inner, nzb_s_inner, nzb_s_outer, nzt, nzt_diff |
---|
241 | |
---|
242 | USE kinds |
---|
243 | |
---|
244 | IMPLICIT NONE |
---|
245 | |
---|
246 | INTEGER(iwp) :: i !< |
---|
247 | INTEGER(iwp) :: j !< |
---|
248 | INTEGER(iwp) :: k !< |
---|
249 | REAL(wp) :: wall_s_flux(0:4) !< |
---|
250 | REAL(wp), DIMENSION(nysg:nyng,nxlg:nxrg) :: s_flux_b !< |
---|
251 | REAL(wp), DIMENSION(nysg:nyng,nxlg:nxrg) :: s_flux_t !< |
---|
252 | #if defined( __nopointer ) |
---|
253 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: s !< |
---|
254 | #else |
---|
255 | REAL(wp), DIMENSION(:,:,:), POINTER :: s !< |
---|
256 | #endif |
---|
257 | |
---|
258 | !$acc kernels present( ddzu, ddzw, fwxm, fwxp, fwym, fwyp, kh ) & |
---|
259 | !$acc present( nzb_diff_s_inner, nzb_s_inner, nzb_s_outer, s ) & |
---|
260 | !$acc present( s_flux_b, s_flux_t, tend, wall_s_flux ) & |
---|
261 | !$acc present( wall_w_x, wall_w_y ) |
---|
262 | DO i = i_left, i_right |
---|
263 | DO j = j_south, j_north |
---|
264 | ! |
---|
265 | !-- Compute horizontal diffusion |
---|
266 | DO k = 1, nzt |
---|
267 | IF ( k > nzb_s_outer(j,i) ) THEN |
---|
268 | |
---|
269 | tend(k,j,i) = tend(k,j,i) & |
---|
270 | + 0.5_wp * ( & |
---|
271 | ( kh(k,j,i) + kh(k,j,i+1) ) * ( s(k,j,i+1)-s(k,j,i) ) & |
---|
272 | - ( kh(k,j,i) + kh(k,j,i-1) ) * ( s(k,j,i)-s(k,j,i-1) ) & |
---|
273 | ) * ddx2 & |
---|
274 | + 0.5_wp * ( & |
---|
275 | ( kh(k,j,i) + kh(k,j+1,i) ) * ( s(k,j+1,i)-s(k,j,i) ) & |
---|
276 | - ( kh(k,j,i) + kh(k,j-1,i) ) * ( s(k,j,i)-s(k,j-1,i) ) & |
---|
277 | ) * ddy2 |
---|
278 | ENDIF |
---|
279 | ENDDO |
---|
280 | |
---|
281 | ! |
---|
282 | !-- Apply prescribed horizontal wall heatflux where necessary |
---|
283 | DO k = 1, nzt |
---|
284 | IF ( k > nzb_s_inner(j,i) .AND. k <= nzb_s_outer(j,i) .AND. & |
---|
285 | ( wall_w_x(j,i) /= 0.0_wp .OR. wall_w_y(j,i) /= 0.0_wp ) ) & |
---|
286 | THEN |
---|
287 | tend(k,j,i) = tend(k,j,i) & |
---|
288 | + ( fwxp(j,i) * 0.5_wp * & |
---|
289 | ( kh(k,j,i) + kh(k,j,i+1) ) * ( s(k,j,i+1)-s(k,j,i) ) & |
---|
290 | + ( 1.0_wp - fwxp(j,i) ) * wall_s_flux(1) & |
---|
291 | -fwxm(j,i) * 0.5_wp * & |
---|
292 | ( kh(k,j,i) + kh(k,j,i-1) ) * ( s(k,j,i)-s(k,j,i-1) ) & |
---|
293 | + ( 1.0_wp - fwxm(j,i) ) * wall_s_flux(2) & |
---|
294 | ) * ddx2 & |
---|
295 | + ( fwyp(j,i) * 0.5_wp * & |
---|
296 | ( kh(k,j,i) + kh(k,j+1,i) ) * ( s(k,j+1,i)-s(k,j,i) ) & |
---|
297 | + ( 1.0_wp - fwyp(j,i) ) * wall_s_flux(3) & |
---|
298 | -fwym(j,i) * 0.5_wp * & |
---|
299 | ( kh(k,j,i) + kh(k,j-1,i) ) * ( s(k,j,i)-s(k,j-1,i) ) & |
---|
300 | + ( 1.0_wp - fwym(j,i) ) * wall_s_flux(4) & |
---|
301 | ) * ddy2 |
---|
302 | ENDIF |
---|
303 | ENDDO |
---|
304 | |
---|
305 | ! |
---|
306 | !-- Compute vertical diffusion. In case that surface fluxes have been |
---|
307 | !-- prescribed or computed at bottom and/or top, index k starts/ends at |
---|
308 | !-- nzb+2 or nzt-1, respectively. |
---|
309 | DO k = 1, nzt_diff |
---|
310 | IF ( k >= nzb_diff_s_inner(j,i) ) THEN |
---|
311 | tend(k,j,i) = tend(k,j,i) & |
---|
312 | + 0.5_wp * ( & |
---|
313 | ( kh(k,j,i) + kh(k+1,j,i) ) * ( s(k+1,j,i)-s(k,j,i) ) * ddzu(k+1) & |
---|
314 | - ( kh(k,j,i) + kh(k-1,j,i) ) * ( s(k,j,i)-s(k-1,j,i) ) * ddzu(k) & |
---|
315 | ) * ddzw(k) |
---|
316 | ENDIF |
---|
317 | ENDDO |
---|
318 | |
---|
319 | ! |
---|
320 | !-- Vertical diffusion at the first computational gridpoint along |
---|
321 | !-- z-direction |
---|
322 | DO k = 1, nzt |
---|
323 | IF ( use_surface_fluxes .AND. k == nzb_s_inner(j,i)+1 ) THEN |
---|
324 | tend(k,j,i) = tend(k,j,i) & |
---|
325 | + ( 0.5_wp * ( kh(k,j,i)+kh(k+1,j,i) )& |
---|
326 | * ( s(k+1,j,i)-s(k,j,i) ) & |
---|
327 | * ddzu(k+1) & |
---|
328 | + s_flux_b(j,i) & |
---|
329 | ) * ddzw(k) |
---|
330 | ENDIF |
---|
331 | |
---|
332 | ! |
---|
333 | !-- Vertical diffusion at the last computational gridpoint along |
---|
334 | !-- z-direction |
---|
335 | IF ( use_top_fluxes .AND. k == nzt ) THEN |
---|
336 | tend(k,j,i) = tend(k,j,i) & |
---|
337 | + ( - s_flux_t(j,i) & |
---|
338 | - 0.5_wp * ( kh(k-1,j,i)+kh(k,j,i) )& |
---|
339 | * ( s(k,j,i)-s(k-1,j,i) ) & |
---|
340 | * ddzu(k) & |
---|
341 | ) * ddzw(k) |
---|
342 | ENDIF |
---|
343 | ENDDO |
---|
344 | |
---|
345 | ENDDO |
---|
346 | ENDDO |
---|
347 | !$acc end kernels |
---|
348 | |
---|
349 | END SUBROUTINE diffusion_s_acc |
---|
350 | |
---|
351 | |
---|
352 | !------------------------------------------------------------------------------! |
---|
353 | ! Description: |
---|
354 | ! ------------ |
---|
355 | !> Call for grid point i,j |
---|
356 | !------------------------------------------------------------------------------! |
---|
357 | SUBROUTINE diffusion_s_ij( i, j, s, s_flux_b, s_flux_t, wall_s_flux ) |
---|
358 | |
---|
359 | USE arrays_3d, & |
---|
360 | ONLY: ddzu, ddzw, kh, tend |
---|
361 | |
---|
362 | USE control_parameters, & |
---|
363 | ONLY: use_surface_fluxes, use_top_fluxes |
---|
364 | |
---|
365 | USE grid_variables, & |
---|
366 | ONLY: ddx2, ddy2, fwxm, fwxp, fwym, fwyp, wall_w_x, wall_w_y |
---|
367 | |
---|
368 | USE indices, & |
---|
369 | ONLY: nxlg, nxrg, nyng, nysg, nzb, nzb_diff_s_inner, nzb_s_inner, & |
---|
370 | nzb_s_outer, nzt, nzt_diff |
---|
371 | |
---|
372 | USE kinds |
---|
373 | |
---|
374 | IMPLICIT NONE |
---|
375 | |
---|
376 | INTEGER(iwp) :: i !< |
---|
377 | INTEGER(iwp) :: j !< |
---|
378 | INTEGER(iwp) :: k !< |
---|
379 | REAL(wp) :: wall_s_flux(0:4) !< |
---|
380 | REAL(wp), DIMENSION(nysg:nyng,nxlg:nxrg) :: s_flux_b !< |
---|
381 | REAL(wp), DIMENSION(nysg:nyng,nxlg:nxrg) :: s_flux_t !< |
---|
382 | #if defined( __nopointer ) |
---|
383 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: s !< |
---|
384 | #else |
---|
385 | REAL(wp), DIMENSION(:,:,:), POINTER :: s !< |
---|
386 | #endif |
---|
387 | |
---|
388 | ! |
---|
389 | !-- Compute horizontal diffusion |
---|
390 | DO k = nzb_s_outer(j,i)+1, nzt |
---|
391 | |
---|
392 | tend(k,j,i) = tend(k,j,i) & |
---|
393 | + 0.5_wp * ( & |
---|
394 | ( kh(k,j,i) + kh(k,j,i+1) ) * ( s(k,j,i+1)-s(k,j,i) ) & |
---|
395 | - ( kh(k,j,i) + kh(k,j,i-1) ) * ( s(k,j,i)-s(k,j,i-1) ) & |
---|
396 | ) * ddx2 & |
---|
397 | + 0.5_wp * ( & |
---|
398 | ( kh(k,j,i) + kh(k,j+1,i) ) * ( s(k,j+1,i)-s(k,j,i) ) & |
---|
399 | - ( kh(k,j,i) + kh(k,j-1,i) ) * ( s(k,j,i)-s(k,j-1,i) ) & |
---|
400 | ) * ddy2 |
---|
401 | ENDDO |
---|
402 | |
---|
403 | ! |
---|
404 | !-- Apply prescribed horizontal wall heatflux where necessary |
---|
405 | IF ( ( wall_w_x(j,i) /= 0.0_wp ) .OR. ( wall_w_y(j,i) /= 0.0_wp ) ) & |
---|
406 | THEN |
---|
407 | DO k = nzb_s_inner(j,i)+1, nzb_s_outer(j,i) |
---|
408 | |
---|
409 | tend(k,j,i) = tend(k,j,i) & |
---|
410 | + ( fwxp(j,i) * 0.5_wp * & |
---|
411 | ( kh(k,j,i) + kh(k,j,i+1) ) * ( s(k,j,i+1)-s(k,j,i) ) & |
---|
412 | + ( 1.0_wp - fwxp(j,i) ) * wall_s_flux(1) & |
---|
413 | -fwxm(j,i) * 0.5_wp * & |
---|
414 | ( kh(k,j,i) + kh(k,j,i-1) ) * ( s(k,j,i)-s(k,j,i-1) ) & |
---|
415 | + ( 1.0_wp - fwxm(j,i) ) * wall_s_flux(2) & |
---|
416 | ) * ddx2 & |
---|
417 | + ( fwyp(j,i) * 0.5_wp * & |
---|
418 | ( kh(k,j,i) + kh(k,j+1,i) ) * ( s(k,j+1,i)-s(k,j,i) ) & |
---|
419 | + ( 1.0_wp - fwyp(j,i) ) * wall_s_flux(3) & |
---|
420 | -fwym(j,i) * 0.5_wp * & |
---|
421 | ( kh(k,j,i) + kh(k,j-1,i) ) * ( s(k,j,i)-s(k,j-1,i) ) & |
---|
422 | + ( 1.0_wp - fwym(j,i) ) * wall_s_flux(4) & |
---|
423 | ) * ddy2 |
---|
424 | ENDDO |
---|
425 | ENDIF |
---|
426 | |
---|
427 | ! |
---|
428 | !-- Compute vertical diffusion. In case that surface fluxes have been |
---|
429 | !-- prescribed or computed at bottom and/or top, index k starts/ends at |
---|
430 | !-- nzb+2 or nzt-1, respectively. |
---|
431 | DO k = nzb_diff_s_inner(j,i), nzt_diff |
---|
432 | |
---|
433 | tend(k,j,i) = tend(k,j,i) & |
---|
434 | + 0.5_wp * ( & |
---|
435 | ( kh(k,j,i) + kh(k+1,j,i) ) * ( s(k+1,j,i)-s(k,j,i) ) * ddzu(k+1) & |
---|
436 | - ( kh(k,j,i) + kh(k-1,j,i) ) * ( s(k,j,i)-s(k-1,j,i) ) * ddzu(k) & |
---|
437 | ) * ddzw(k) |
---|
438 | ENDDO |
---|
439 | |
---|
440 | ! |
---|
441 | !-- Vertical diffusion at the first computational gridpoint along z-direction |
---|
442 | IF ( use_surface_fluxes ) THEN |
---|
443 | |
---|
444 | k = nzb_s_inner(j,i)+1 |
---|
445 | |
---|
446 | tend(k,j,i) = tend(k,j,i) + ( 0.5_wp * ( kh(k,j,i)+kh(k+1,j,i) ) & |
---|
447 | * ( s(k+1,j,i)-s(k,j,i) ) & |
---|
448 | * ddzu(k+1) & |
---|
449 | + s_flux_b(j,i) & |
---|
450 | ) * ddzw(k) |
---|
451 | |
---|
452 | ENDIF |
---|
453 | |
---|
454 | ! |
---|
455 | !-- Vertical diffusion at the last computational gridpoint along z-direction |
---|
456 | IF ( use_top_fluxes ) THEN |
---|
457 | |
---|
458 | k = nzt |
---|
459 | |
---|
460 | tend(k,j,i) = tend(k,j,i) + ( - s_flux_t(j,i) & |
---|
461 | - 0.5_wp * ( kh(k-1,j,i)+kh(k,j,i) ) & |
---|
462 | * ( s(k,j,i)-s(k-1,j,i) ) & |
---|
463 | * ddzu(k) & |
---|
464 | ) * ddzw(k) |
---|
465 | |
---|
466 | ENDIF |
---|
467 | |
---|
468 | END SUBROUTINE diffusion_s_ij |
---|
469 | |
---|
470 | END MODULE diffusion_s_mod |
---|