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 |
---|
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-2017 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: diffusion_w.f90 2119 2017-01-17 16:51:50Z suehring $ |
---|
27 | ! |
---|
28 | ! 2118 2017-01-17 16:38:49Z raasch |
---|
29 | ! OpenACC version of subroutine removed |
---|
30 | ! |
---|
31 | ! 2037 2016-10-26 11:15:40Z knoop |
---|
32 | ! Anelastic approximation implemented |
---|
33 | ! |
---|
34 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
35 | ! Forced header and separation lines into 80 columns |
---|
36 | ! |
---|
37 | ! 1873 2016-04-18 14:50:06Z maronga |
---|
38 | ! Module renamed (removed _mod) |
---|
39 | ! |
---|
40 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
41 | ! Module renamed |
---|
42 | ! |
---|
43 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
44 | ! Code annotations made doxygen readable |
---|
45 | ! |
---|
46 | ! 1374 2014-04-25 12:55:07Z raasch |
---|
47 | ! vsws + vswst removed from acc-present-list |
---|
48 | ! |
---|
49 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
50 | ! REAL constants provided with KIND-attribute |
---|
51 | ! |
---|
52 | ! 1340 2014-03-25 19:45:13Z kanani |
---|
53 | ! REAL constants defined as wp-kind |
---|
54 | ! |
---|
55 | ! 1322 2014-03-20 16:38:49Z raasch |
---|
56 | ! REAL constants defined as wp-kind |
---|
57 | ! |
---|
58 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
59 | ! ONLY-attribute added to USE-statements, |
---|
60 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
61 | ! kinds are defined in new module kinds, |
---|
62 | ! revision history before 2012 removed, |
---|
63 | ! comment fields (!:) to be used for variable explanations added to |
---|
64 | ! all variable declaration statements |
---|
65 | ! |
---|
66 | ! 1257 2013-11-08 15:18:40Z raasch |
---|
67 | ! openacc loop and loop vector clauses removed, declare create moved after |
---|
68 | ! the FORTRAN declaration statement |
---|
69 | ! |
---|
70 | ! 1128 2013-04-12 06:19:32Z raasch |
---|
71 | ! loop index bounds in accelerator version replaced by i_left, i_right, j_south, |
---|
72 | ! j_north |
---|
73 | ! |
---|
74 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
75 | ! code put under GPL (PALM 3.9) |
---|
76 | ! |
---|
77 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
78 | ! accelerator version (*_acc) added |
---|
79 | ! |
---|
80 | ! 1001 2012-09-13 14:08:46Z raasch |
---|
81 | ! arrays comunicated by module instead of parameter list |
---|
82 | ! |
---|
83 | ! 978 2012-08-09 08:28:32Z fricke |
---|
84 | ! outflow damping layer removed |
---|
85 | ! kmxm_x/_z and kmxp_x/_z change to kmxm and kmxp |
---|
86 | ! kmym_y/_z and kmyp_y/_z change to kmym and kmyp |
---|
87 | ! |
---|
88 | ! Revision 1.1 1997/09/12 06:24:11 raasch |
---|
89 | ! Initial revision |
---|
90 | ! |
---|
91 | ! |
---|
92 | ! Description: |
---|
93 | ! ------------ |
---|
94 | !> Diffusion term of the w-component |
---|
95 | !------------------------------------------------------------------------------! |
---|
96 | MODULE diffusion_w_mod |
---|
97 | |
---|
98 | |
---|
99 | USE wall_fluxes_mod, & |
---|
100 | ONLY : wall_fluxes |
---|
101 | |
---|
102 | PRIVATE |
---|
103 | PUBLIC diffusion_w |
---|
104 | |
---|
105 | INTERFACE diffusion_w |
---|
106 | MODULE PROCEDURE diffusion_w |
---|
107 | MODULE PROCEDURE diffusion_w_ij |
---|
108 | END INTERFACE diffusion_w |
---|
109 | |
---|
110 | CONTAINS |
---|
111 | |
---|
112 | |
---|
113 | !------------------------------------------------------------------------------! |
---|
114 | ! Description: |
---|
115 | ! ------------ |
---|
116 | !> Call for all grid points |
---|
117 | !------------------------------------------------------------------------------! |
---|
118 | SUBROUTINE diffusion_w |
---|
119 | |
---|
120 | USE arrays_3d, & |
---|
121 | ONLY : ddzu, ddzw, km, tend, u, v, w, drho_air_zw, rho_air |
---|
122 | |
---|
123 | USE control_parameters, & |
---|
124 | ONLY : topography |
---|
125 | |
---|
126 | USE grid_variables, & |
---|
127 | ONLY : ddx, ddy, fwxm, fwxp, fwym, fwyp, wall_w_x, wall_w_y |
---|
128 | |
---|
129 | USE indices, & |
---|
130 | ONLY : nxl, nxr, nyn, nys, nzb, nzb_w_inner, nzb_w_outer, nzt |
---|
131 | |
---|
132 | USE kinds |
---|
133 | |
---|
134 | IMPLICIT NONE |
---|
135 | |
---|
136 | INTEGER(iwp) :: i !< |
---|
137 | INTEGER(iwp) :: j !< |
---|
138 | INTEGER(iwp) :: k !< |
---|
139 | |
---|
140 | REAL(wp) :: kmxm !< |
---|
141 | REAL(wp) :: kmxp !< |
---|
142 | REAL(wp) :: kmym !< |
---|
143 | REAL(wp) :: kmyp !< |
---|
144 | |
---|
145 | REAL(wp), DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: wsus !< |
---|
146 | REAL(wp), DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: wsvs !< |
---|
147 | |
---|
148 | |
---|
149 | ! |
---|
150 | !-- First calculate horizontal momentum flux w'u' and/or w'v' at vertical |
---|
151 | !-- walls, if neccessary |
---|
152 | IF ( topography /= 'flat' ) THEN |
---|
153 | CALL wall_fluxes( wsus, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, nzb_w_inner, & |
---|
154 | nzb_w_outer, wall_w_x ) |
---|
155 | CALL wall_fluxes( wsvs, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, nzb_w_inner, & |
---|
156 | nzb_w_outer, wall_w_y ) |
---|
157 | ENDIF |
---|
158 | |
---|
159 | DO i = nxl, nxr |
---|
160 | DO j = nys, nyn |
---|
161 | DO k = nzb_w_outer(j,i)+1, nzt-1 |
---|
162 | ! |
---|
163 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
164 | kmxp = 0.25_wp * & |
---|
165 | ( km(k,j,i)+km(k,j,i+1)+km(k+1,j,i)+km(k+1,j,i+1) ) |
---|
166 | kmxm = 0.25_wp * & |
---|
167 | ( km(k,j,i)+km(k,j,i-1)+km(k+1,j,i)+km(k+1,j,i-1) ) |
---|
168 | kmyp = 0.25_wp * & |
---|
169 | ( km(k,j,i)+km(k+1,j,i)+km(k,j+1,i)+km(k+1,j+1,i) ) |
---|
170 | kmym = 0.25_wp * & |
---|
171 | ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
172 | |
---|
173 | tend(k,j,i) = tend(k,j,i) & |
---|
174 | & + ( kmxp * ( w(k,j,i+1) - w(k,j,i) ) * ddx & |
---|
175 | & + kmxp * ( u(k+1,j,i+1) - u(k,j,i+1) ) * ddzu(k+1) & |
---|
176 | & - kmxm * ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
177 | & - kmxm * ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
178 | & ) * ddx & |
---|
179 | & + ( kmyp * ( w(k,j+1,i) - w(k,j,i) ) * ddy & |
---|
180 | & + kmyp * ( v(k+1,j+1,i) - v(k,j+1,i) ) * ddzu(k+1) & |
---|
181 | & - kmym * ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
182 | & - kmym * ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
183 | & ) * ddy & |
---|
184 | & + 2.0_wp * ( & |
---|
185 | & km(k+1,j,i) * ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) & |
---|
186 | & * rho_air(k+1) & |
---|
187 | & - km(k,j,i) * ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) & |
---|
188 | & * rho_air(k) & |
---|
189 | & ) * ddzu(k+1) * drho_air_zw(k) |
---|
190 | ENDDO |
---|
191 | |
---|
192 | ! |
---|
193 | !-- Wall functions at all vertical walls, where necessary |
---|
194 | IF ( wall_w_x(j,i) /= 0.0_wp .OR. wall_w_y(j,i) /= 0.0_wp ) THEN |
---|
195 | |
---|
196 | DO k = nzb_w_inner(j,i)+1, nzb_w_outer(j,i) |
---|
197 | ! |
---|
198 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
199 | kmxp = 0.25_wp * & |
---|
200 | ( km(k,j,i)+km(k,j,i+1)+km(k+1,j,i)+km(k+1,j,i+1) ) |
---|
201 | kmxm = 0.25_wp * & |
---|
202 | ( km(k,j,i)+km(k,j,i-1)+km(k+1,j,i)+km(k+1,j,i-1) ) |
---|
203 | kmyp = 0.25_wp * & |
---|
204 | ( km(k,j,i)+km(k+1,j,i)+km(k,j+1,i)+km(k+1,j+1,i) ) |
---|
205 | kmym = 0.25_wp * & |
---|
206 | ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
207 | |
---|
208 | tend(k,j,i) = tend(k,j,i) & |
---|
209 | + ( fwxp(j,i) * ( & |
---|
210 | kmxp * ( w(k,j,i+1) - w(k,j,i) ) * ddx & |
---|
211 | + kmxp * ( u(k+1,j,i+1) - u(k,j,i+1) ) * ddzu(k+1) & |
---|
212 | ) & |
---|
213 | - fwxm(j,i) * ( & |
---|
214 | kmxm * ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
215 | + kmxm * ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
216 | ) & |
---|
217 | + wall_w_x(j,i) * wsus(k,j,i) & |
---|
218 | ) * ddx & |
---|
219 | + ( fwyp(j,i) * ( & |
---|
220 | kmyp * ( w(k,j+1,i) - w(k,j,i) ) * ddy & |
---|
221 | + kmyp * ( v(k+1,j+1,i) - v(k,j+1,i) ) * ddzu(k+1) & |
---|
222 | ) & |
---|
223 | - fwym(j,i) * ( & |
---|
224 | kmym * ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
225 | + kmym * ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
226 | ) & |
---|
227 | + wall_w_y(j,i) * wsvs(k,j,i) & |
---|
228 | ) * ddy & |
---|
229 | + 2.0_wp * ( & |
---|
230 | km(k+1,j,i) * ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) & |
---|
231 | * rho_air(k+1) & |
---|
232 | - km(k,j,i) * ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) & |
---|
233 | * rho_air(k) & |
---|
234 | ) * ddzu(k+1) * drho_air_zw(k) |
---|
235 | ENDDO |
---|
236 | ENDIF |
---|
237 | |
---|
238 | ENDDO |
---|
239 | ENDDO |
---|
240 | |
---|
241 | END SUBROUTINE diffusion_w |
---|
242 | |
---|
243 | |
---|
244 | !------------------------------------------------------------------------------! |
---|
245 | ! Description: |
---|
246 | ! ------------ |
---|
247 | !> Call for grid point i,j |
---|
248 | !------------------------------------------------------------------------------! |
---|
249 | SUBROUTINE diffusion_w_ij( i, j ) |
---|
250 | |
---|
251 | USE arrays_3d, & |
---|
252 | ONLY : ddzu, ddzw, km, tend, u, v, w, drho_air_zw, rho_air |
---|
253 | |
---|
254 | USE control_parameters, & |
---|
255 | ONLY : topography |
---|
256 | |
---|
257 | USE grid_variables, & |
---|
258 | ONLY : ddx, ddy, fwxm, fwxp, fwym, fwyp, wall_w_x, wall_w_y |
---|
259 | |
---|
260 | USE indices, & |
---|
261 | ONLY : nxl, nxr, nyn, nys, nzb, nzb_w_inner, nzb_w_outer, nzt |
---|
262 | |
---|
263 | USE kinds |
---|
264 | |
---|
265 | IMPLICIT NONE |
---|
266 | |
---|
267 | INTEGER(iwp) :: i !< |
---|
268 | INTEGER(iwp) :: j !< |
---|
269 | INTEGER(iwp) :: k !< |
---|
270 | |
---|
271 | REAL(wp) :: kmxm !< |
---|
272 | REAL(wp) :: kmxp !< |
---|
273 | REAL(wp) :: kmym !< |
---|
274 | REAL(wp) :: kmyp !< |
---|
275 | |
---|
276 | REAL(wp), DIMENSION(nzb:nzt+1) :: wsus |
---|
277 | REAL(wp), DIMENSION(nzb:nzt+1) :: wsvs |
---|
278 | |
---|
279 | |
---|
280 | DO k = nzb_w_outer(j,i)+1, nzt-1 |
---|
281 | ! |
---|
282 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
283 | kmxp = 0.25_wp * ( km(k,j,i)+km(k,j,i+1)+km(k+1,j,i)+km(k+1,j,i+1) ) |
---|
284 | kmxm = 0.25_wp * ( km(k,j,i)+km(k,j,i-1)+km(k+1,j,i)+km(k+1,j,i-1) ) |
---|
285 | kmyp = 0.25_wp * ( km(k,j,i)+km(k+1,j,i)+km(k,j+1,i)+km(k+1,j+1,i) ) |
---|
286 | kmym = 0.25_wp * ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
287 | |
---|
288 | tend(k,j,i) = tend(k,j,i) & |
---|
289 | & + ( kmxp * ( w(k,j,i+1) - w(k,j,i) ) * ddx & |
---|
290 | & + kmxp * ( u(k+1,j,i+1) - u(k,j,i+1) ) * ddzu(k+1) & |
---|
291 | & - kmxm * ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
292 | & - kmxm * ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
293 | & ) * ddx & |
---|
294 | & + ( kmyp * ( w(k,j+1,i) - w(k,j,i) ) * ddy & |
---|
295 | & + kmyp * ( v(k+1,j+1,i) - v(k,j+1,i) ) * ddzu(k+1) & |
---|
296 | & - kmym * ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
297 | & - kmym * ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
298 | & ) * ddy & |
---|
299 | & + 2.0_wp * ( & |
---|
300 | & km(k+1,j,i) * ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) & |
---|
301 | & * rho_air(k+1) & |
---|
302 | & - km(k,j,i) * ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) & |
---|
303 | & * rho_air(k) & |
---|
304 | & ) * ddzu(k+1) * drho_air_zw(k) |
---|
305 | ENDDO |
---|
306 | |
---|
307 | ! |
---|
308 | !-- Wall functions at all vertical walls, where necessary |
---|
309 | IF ( wall_w_x(j,i) /= 0.0_wp .OR. wall_w_y(j,i) /= 0.0_wp ) THEN |
---|
310 | |
---|
311 | ! |
---|
312 | !-- Calculate the horizontal momentum fluxes w'u' and/or w'v' |
---|
313 | IF ( wall_w_x(j,i) /= 0.0_wp ) THEN |
---|
314 | CALL wall_fluxes( i, j, nzb_w_inner(j,i)+1, nzb_w_outer(j,i), & |
---|
315 | wsus, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp ) |
---|
316 | ELSE |
---|
317 | wsus = 0.0_wp |
---|
318 | ENDIF |
---|
319 | |
---|
320 | IF ( wall_w_y(j,i) /= 0.0_wp ) THEN |
---|
321 | CALL wall_fluxes( i, j, nzb_w_inner(j,i)+1, nzb_w_outer(j,i), & |
---|
322 | wsvs, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp ) |
---|
323 | ELSE |
---|
324 | wsvs = 0.0_wp |
---|
325 | ENDIF |
---|
326 | |
---|
327 | DO k = nzb_w_inner(j,i)+1, nzb_w_outer(j,i) |
---|
328 | ! |
---|
329 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
330 | kmxp = 0.25_wp * ( km(k,j,i)+km(k,j,i+1)+km(k+1,j,i)+km(k+1,j,i+1) ) |
---|
331 | kmxm = 0.25_wp * ( km(k,j,i)+km(k,j,i-1)+km(k+1,j,i)+km(k+1,j,i-1) ) |
---|
332 | kmyp = 0.25_wp * ( km(k,j,i)+km(k+1,j,i)+km(k,j+1,i)+km(k+1,j+1,i) ) |
---|
333 | kmym = 0.25_wp * ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
334 | |
---|
335 | tend(k,j,i) = tend(k,j,i) & |
---|
336 | + ( fwxp(j,i) * ( & |
---|
337 | kmxp * ( w(k,j,i+1) - w(k,j,i) ) * ddx & |
---|
338 | + kmxp * ( u(k+1,j,i+1) - u(k,j,i+1) ) * ddzu(k+1) & |
---|
339 | ) & |
---|
340 | - fwxm(j,i) * ( & |
---|
341 | kmxm * ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
342 | + kmxm * ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
343 | ) & |
---|
344 | + wall_w_x(j,i) * wsus(k) & |
---|
345 | ) * ddx & |
---|
346 | + ( fwyp(j,i) * ( & |
---|
347 | kmyp * ( w(k,j+1,i) - w(k,j,i) ) * ddy & |
---|
348 | + kmyp * ( v(k+1,j+1,i) - v(k,j+1,i) ) * ddzu(k+1) & |
---|
349 | ) & |
---|
350 | - fwym(j,i) * ( & |
---|
351 | kmym * ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
352 | + kmym * ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
353 | ) & |
---|
354 | + wall_w_y(j,i) * wsvs(k) & |
---|
355 | ) * ddy & |
---|
356 | + 2.0_wp * ( & |
---|
357 | km(k+1,j,i) * ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) & |
---|
358 | * rho_air(k+1) & |
---|
359 | - km(k,j,i) * ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) & |
---|
360 | * rho_air(k) & |
---|
361 | ) * ddzu(k+1) * drho_air_zw(k) |
---|
362 | ENDDO |
---|
363 | ENDIF |
---|
364 | |
---|
365 | END SUBROUTINE diffusion_w_ij |
---|
366 | |
---|
367 | END MODULE diffusion_w_mod |
---|