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