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