1 | !> @file diffusion_v.f90 |
---|
2 | !------------------------------------------------------------------------------! |
---|
3 | ! This file is part of the PALM model system. |
---|
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-2019 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: diffusion_v.f90 4182 2019-08-22 15:20:23Z knoop $ |
---|
27 | ! Corrected "Former revisions" section |
---|
28 | ! |
---|
29 | ! 3655 2019-01-07 16:51:22Z knoop |
---|
30 | ! OpenACC port for SPEC |
---|
31 | ! |
---|
32 | ! Revision 1.1 1997/09/12 06:24:01 raasch |
---|
33 | ! Initial revision |
---|
34 | ! |
---|
35 | ! |
---|
36 | ! Description: |
---|
37 | ! ------------ |
---|
38 | !> Diffusion term of the v-component |
---|
39 | !------------------------------------------------------------------------------! |
---|
40 | MODULE diffusion_v_mod |
---|
41 | |
---|
42 | |
---|
43 | PRIVATE |
---|
44 | PUBLIC diffusion_v |
---|
45 | |
---|
46 | INTERFACE diffusion_v |
---|
47 | MODULE PROCEDURE diffusion_v |
---|
48 | MODULE PROCEDURE diffusion_v_ij |
---|
49 | END INTERFACE diffusion_v |
---|
50 | |
---|
51 | CONTAINS |
---|
52 | |
---|
53 | |
---|
54 | !------------------------------------------------------------------------------! |
---|
55 | ! Description: |
---|
56 | ! ------------ |
---|
57 | !> Call for all grid points |
---|
58 | !------------------------------------------------------------------------------! |
---|
59 | SUBROUTINE diffusion_v |
---|
60 | |
---|
61 | USE arrays_3d, & |
---|
62 | ONLY: ddzu, ddzw, km, tend, u, v, w, drho_air, rho_air_zw |
---|
63 | |
---|
64 | USE control_parameters, & |
---|
65 | ONLY: constant_top_momentumflux, use_surface_fluxes, & |
---|
66 | use_top_fluxes |
---|
67 | |
---|
68 | USE grid_variables, & |
---|
69 | ONLY: ddx, ddy, ddy2 |
---|
70 | |
---|
71 | USE indices, & |
---|
72 | ONLY: nxl, nxr, nyn, nysv, nzb, nzt, wall_flags_0 |
---|
73 | |
---|
74 | USE kinds |
---|
75 | |
---|
76 | USE surface_mod, & |
---|
77 | ONLY : surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_usm_h, & |
---|
78 | surf_usm_v |
---|
79 | |
---|
80 | IMPLICIT NONE |
---|
81 | |
---|
82 | INTEGER(iwp) :: i !< running index x direction |
---|
83 | INTEGER(iwp) :: j !< running index y direction |
---|
84 | INTEGER(iwp) :: k !< running index z direction |
---|
85 | INTEGER(iwp) :: l !< running index of surface type, south- or north-facing wall |
---|
86 | INTEGER(iwp) :: m !< running index surface elements |
---|
87 | INTEGER(iwp) :: surf_e !< End index of surface elements at (j,i)-gridpoint |
---|
88 | INTEGER(iwp) :: surf_s !< Start index of surface elements at (j,i)-gridpoint |
---|
89 | |
---|
90 | REAL(wp) :: flag !< flag to mask topography grid points |
---|
91 | REAL(wp) :: kmxm !< diffusion coefficient on leftward side of the v-gridbox - interpolated onto xu-yv grid |
---|
92 | REAL(wp) :: kmxp !< diffusion coefficient on rightward side of the v-gridbox - interpolated onto xu-yv grid |
---|
93 | REAL(wp) :: kmzm !< diffusion coefficient on bottom of the gridbox - interpolated onto yv-zw grid |
---|
94 | REAL(wp) :: kmzp !< diffusion coefficient on top of the gridbox - interpolated onto yv-zw grid |
---|
95 | REAL(wp) :: mask_bottom !< flag to mask vertical upward-facing surface |
---|
96 | REAL(wp) :: mask_east !< flag to mask vertical surface south of the grid point |
---|
97 | REAL(wp) :: mask_west !< flag to mask vertical surface north of the grid point |
---|
98 | REAL(wp) :: mask_top !< flag to mask vertical downward-facing surface |
---|
99 | |
---|
100 | !$ACC PARALLEL LOOP COLLAPSE(2) PRIVATE(i, j, k, l, m) & |
---|
101 | !$ACC PRIVATE(surf_e, surf_s, flag, kmxm, kmxp, kmzm, kmzp) & |
---|
102 | !$ACC PRIVATE(mask_bottom, mask_east, mask_west, mask_top) & |
---|
103 | !$ACC PRESENT(wall_flags_0, km) & |
---|
104 | !$ACC PRESENT(u, v, w) & |
---|
105 | !$ACC PRESENT(ddzu, ddzw, drho_air, rho_air_zw) & |
---|
106 | !$ACC PRESENT(surf_def_h(0:2), surf_def_v(2:3)) & |
---|
107 | !$ACC PRESENT(surf_lsm_h, surf_lsm_v(2:3)) & |
---|
108 | !$ACC PRESENT(surf_usm_h, surf_usm_v(0:3)) & |
---|
109 | !$ACC PRESENT(tend) |
---|
110 | DO i = nxl, nxr |
---|
111 | DO j = nysv, nyn |
---|
112 | ! |
---|
113 | !-- Compute horizontal diffusion |
---|
114 | DO k = nzb+1, nzt |
---|
115 | |
---|
116 | ! |
---|
117 | !-- Predetermine flag to mask topography and wall-bounded grid points. |
---|
118 | !-- It is sufficient to masked only east- and west-facing surfaces, which |
---|
119 | !-- need special treatment for the v-component. |
---|
120 | flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i), 2 ) ) |
---|
121 | mask_east = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i+1), 2 ) ) |
---|
122 | mask_west = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i-1), 2 ) ) |
---|
123 | ! |
---|
124 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
125 | kmxp = 0.25_wp * ( km(k,j,i)+km(k,j,i+1)+km(k,j-1,i)+km(k,j-1,i+1) ) |
---|
126 | kmxm = 0.25_wp * ( km(k,j,i)+km(k,j,i-1)+km(k,j-1,i)+km(k,j-1,i-1) ) |
---|
127 | |
---|
128 | tend(k,j,i) = tend(k,j,i) + ( & |
---|
129 | mask_east * kmxp * ( & |
---|
130 | ( v(k,j,i+1) - v(k,j,i) ) * ddx & |
---|
131 | + ( u(k,j,i+1) - u(k,j-1,i+1) ) * ddy & |
---|
132 | ) & |
---|
133 | - mask_west * kmxm * ( & |
---|
134 | ( v(k,j,i) - v(k,j,i-1) ) * ddx & |
---|
135 | + ( u(k,j,i) - u(k,j-1,i) ) * ddy & |
---|
136 | ) & |
---|
137 | ) * ddx * flag & |
---|
138 | + 2.0_wp * ( & |
---|
139 | km(k,j,i) * ( v(k,j+1,i) - v(k,j,i) ) & |
---|
140 | - km(k,j-1,i) * ( v(k,j,i) - v(k,j-1,i) ) & |
---|
141 | ) * ddy2 * flag |
---|
142 | |
---|
143 | ENDDO |
---|
144 | |
---|
145 | ! |
---|
146 | !-- Add horizontal momentum flux v'u' at east- (l=2) and west-facing (l=3) |
---|
147 | !-- surfaces. Note, in the the flat case, loops won't be entered as |
---|
148 | !-- start_index > end_index. Furtermore, note, no vertical natural surfaces |
---|
149 | !-- so far. |
---|
150 | !-- Default-type surfaces |
---|
151 | DO l = 2, 3 |
---|
152 | surf_s = surf_def_v(l)%start_index(j,i) |
---|
153 | surf_e = surf_def_v(l)%end_index(j,i) |
---|
154 | DO m = surf_s, surf_e |
---|
155 | k = surf_def_v(l)%k(m) |
---|
156 | tend(k,j,i) = tend(k,j,i) + & |
---|
157 | surf_def_v(l)%mom_flux_uv(m) * ddx |
---|
158 | ENDDO |
---|
159 | ENDDO |
---|
160 | ! |
---|
161 | !-- Natural-type surfaces |
---|
162 | DO l = 2, 3 |
---|
163 | surf_s = surf_lsm_v(l)%start_index(j,i) |
---|
164 | surf_e = surf_lsm_v(l)%end_index(j,i) |
---|
165 | DO m = surf_s, surf_e |
---|
166 | k = surf_lsm_v(l)%k(m) |
---|
167 | tend(k,j,i) = tend(k,j,i) + & |
---|
168 | surf_lsm_v(l)%mom_flux_uv(m) * ddx |
---|
169 | ENDDO |
---|
170 | ENDDO |
---|
171 | ! |
---|
172 | !-- Urban-type surfaces |
---|
173 | DO l = 2, 3 |
---|
174 | surf_s = surf_usm_v(l)%start_index(j,i) |
---|
175 | surf_e = surf_usm_v(l)%end_index(j,i) |
---|
176 | DO m = surf_s, surf_e |
---|
177 | k = surf_usm_v(l)%k(m) |
---|
178 | tend(k,j,i) = tend(k,j,i) + & |
---|
179 | surf_usm_v(l)%mom_flux_uv(m) * ddx |
---|
180 | ENDDO |
---|
181 | ENDDO |
---|
182 | ! |
---|
183 | !-- Compute vertical diffusion. In case of simulating a surface layer, |
---|
184 | !-- respective grid diffusive fluxes are masked (flag 10) within this |
---|
185 | !-- loop, and added further below, else, simple gradient approach is |
---|
186 | !-- applied. Model top is also mask if top-momentum flux is given. |
---|
187 | DO k = nzb+1, nzt |
---|
188 | ! |
---|
189 | !-- Determine flags to mask topography below and above. Flag 2 is |
---|
190 | !-- used to mask topography in general, while flag 8 implies also |
---|
191 | !-- information about use_surface_fluxes. Flag 9 is used to control |
---|
192 | !-- momentum flux at model top. |
---|
193 | mask_bottom = MERGE( 1.0_wp, 0.0_wp, & |
---|
194 | BTEST( wall_flags_0(k-1,j,i), 8 ) ) |
---|
195 | mask_top = MERGE( 1.0_wp, 0.0_wp, & |
---|
196 | BTEST( wall_flags_0(k+1,j,i), 8 ) ) * & |
---|
197 | MERGE( 1.0_wp, 0.0_wp, & |
---|
198 | BTEST( wall_flags_0(k+1,j,i), 9 ) ) |
---|
199 | flag = MERGE( 1.0_wp, 0.0_wp, & |
---|
200 | BTEST( wall_flags_0(k,j,i), 2 ) ) |
---|
201 | ! |
---|
202 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
203 | kmzp = 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 | kmzm = 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 | & + ( kmzp * ( ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
210 | & + ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
211 | & ) * rho_air_zw(k) * mask_top & |
---|
212 | & - kmzm * ( ( v(k,j,i) - v(k-1,j,i) ) * ddzu(k) & |
---|
213 | & + ( w(k-1,j,i) - w(k-1,j-1,i) ) * ddy & |
---|
214 | & ) * rho_air_zw(k-1) * mask_bottom & |
---|
215 | & ) * ddzw(k) * drho_air(k) * flag |
---|
216 | ENDDO |
---|
217 | |
---|
218 | ! |
---|
219 | !-- Vertical diffusion at the first grid point above the surface, |
---|
220 | !-- if the momentum flux at the bottom is given by the Prandtl law |
---|
221 | !-- or if it is prescribed by the user. |
---|
222 | !-- Difference quotient of the momentum flux is not formed over |
---|
223 | !-- half of the grid spacing (2.0*ddzw(k)) any more, since the |
---|
224 | !-- comparison with other (LES) models showed that the values of |
---|
225 | !-- the momentum flux becomes too large in this case. |
---|
226 | IF ( use_surface_fluxes ) THEN |
---|
227 | ! |
---|
228 | !-- Default-type surfaces, upward-facing |
---|
229 | surf_s = surf_def_h(0)%start_index(j,i) |
---|
230 | surf_e = surf_def_h(0)%end_index(j,i) |
---|
231 | DO m = surf_s, surf_e |
---|
232 | k = surf_def_h(0)%k(m) |
---|
233 | |
---|
234 | tend(k,j,i) = tend(k,j,i) & |
---|
235 | + ( - ( - surf_def_h(0)%vsws(m) ) & |
---|
236 | ) * ddzw(k) * drho_air(k) |
---|
237 | ENDDO |
---|
238 | ! |
---|
239 | !-- Default-type surfaces, dowward-facing |
---|
240 | surf_s = surf_def_h(1)%start_index(j,i) |
---|
241 | surf_e = surf_def_h(1)%end_index(j,i) |
---|
242 | DO m = surf_s, surf_e |
---|
243 | k = surf_def_h(1)%k(m) |
---|
244 | |
---|
245 | tend(k,j,i) = tend(k,j,i) & |
---|
246 | + ( - surf_def_h(1)%vsws(m) & |
---|
247 | ) * ddzw(k) * drho_air(k) |
---|
248 | ENDDO |
---|
249 | ! |
---|
250 | !-- Natural-type surfaces, upward-facing |
---|
251 | surf_s = surf_lsm_h%start_index(j,i) |
---|
252 | surf_e = surf_lsm_h%end_index(j,i) |
---|
253 | DO m = surf_s, surf_e |
---|
254 | k = surf_lsm_h%k(m) |
---|
255 | |
---|
256 | tend(k,j,i) = tend(k,j,i) & |
---|
257 | + ( - ( - surf_lsm_h%vsws(m) ) & |
---|
258 | ) * ddzw(k) * drho_air(k) |
---|
259 | |
---|
260 | ENDDO |
---|
261 | ! |
---|
262 | !-- Urban-type surfaces, upward-facing |
---|
263 | surf_s = surf_usm_h%start_index(j,i) |
---|
264 | surf_e = surf_usm_h%end_index(j,i) |
---|
265 | DO m = surf_s, surf_e |
---|
266 | k = surf_usm_h%k(m) |
---|
267 | |
---|
268 | tend(k,j,i) = tend(k,j,i) & |
---|
269 | + ( - ( - surf_usm_h%vsws(m) ) & |
---|
270 | ) * ddzw(k) * drho_air(k) |
---|
271 | |
---|
272 | ENDDO |
---|
273 | ENDIF |
---|
274 | ! |
---|
275 | !-- Add momentum flux at model top |
---|
276 | IF ( use_top_fluxes .AND. constant_top_momentumflux ) THEN |
---|
277 | surf_s = surf_def_h(2)%start_index(j,i) |
---|
278 | surf_e = surf_def_h(2)%end_index(j,i) |
---|
279 | DO m = surf_s, surf_e |
---|
280 | |
---|
281 | k = surf_def_h(2)%k(m) |
---|
282 | |
---|
283 | tend(k,j,i) = tend(k,j,i) & |
---|
284 | + ( - surf_def_h(2)%vsws(m) ) * ddzw(k) * drho_air(k) |
---|
285 | ENDDO |
---|
286 | ENDIF |
---|
287 | |
---|
288 | ENDDO |
---|
289 | ENDDO |
---|
290 | |
---|
291 | END SUBROUTINE diffusion_v |
---|
292 | |
---|
293 | |
---|
294 | !------------------------------------------------------------------------------! |
---|
295 | ! Description: |
---|
296 | ! ------------ |
---|
297 | !> Call for grid point i,j |
---|
298 | !------------------------------------------------------------------------------! |
---|
299 | SUBROUTINE diffusion_v_ij( i, j ) |
---|
300 | |
---|
301 | USE arrays_3d, & |
---|
302 | ONLY: ddzu, ddzw, km, tend, u, v, w, drho_air, rho_air_zw |
---|
303 | |
---|
304 | USE control_parameters, & |
---|
305 | ONLY: constant_top_momentumflux, use_surface_fluxes, & |
---|
306 | use_top_fluxes |
---|
307 | |
---|
308 | USE grid_variables, & |
---|
309 | ONLY: ddx, ddy, ddy2 |
---|
310 | |
---|
311 | USE indices, & |
---|
312 | ONLY: nzb, nzt, wall_flags_0 |
---|
313 | |
---|
314 | USE kinds |
---|
315 | |
---|
316 | USE surface_mod, & |
---|
317 | ONLY : surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_usm_h, & |
---|
318 | surf_usm_v |
---|
319 | |
---|
320 | IMPLICIT NONE |
---|
321 | |
---|
322 | |
---|
323 | INTEGER(iwp) :: i !< running index x direction |
---|
324 | INTEGER(iwp) :: j !< running index y direction |
---|
325 | INTEGER(iwp) :: k !< running index z direction |
---|
326 | INTEGER(iwp) :: l !< running index of surface type, south- or north-facing wall |
---|
327 | INTEGER(iwp) :: m !< running index surface elements |
---|
328 | INTEGER(iwp) :: surf_e !< End index of surface elements at (j,i)-gridpoint |
---|
329 | INTEGER(iwp) :: surf_s !< Start index of surface elements at (j,i)-gridpoint |
---|
330 | |
---|
331 | REAL(wp) :: flag !< flag to mask topography grid points |
---|
332 | REAL(wp) :: kmxm !< diffusion coefficient on leftward side of the v-gridbox - interpolated onto xu-yv grid |
---|
333 | REAL(wp) :: kmxp !< diffusion coefficient on rightward side of the v-gridbox - interpolated onto xu-yv grid |
---|
334 | REAL(wp) :: kmzm !< diffusion coefficient on bottom of the gridbox - interpolated onto xu-zw grid |
---|
335 | REAL(wp) :: kmzp !< diffusion coefficient on top of the gridbox - interpolated onto xu-zw grid |
---|
336 | REAL(wp) :: mask_bottom !< flag to mask vertical upward-facing surface |
---|
337 | REAL(wp) :: mask_east !< flag to mask vertical surface south of the grid point |
---|
338 | REAL(wp) :: mask_west !< flag to mask vertical surface north of the grid point |
---|
339 | REAL(wp) :: mask_top !< flag to mask vertical downward-facing surface |
---|
340 | |
---|
341 | ! |
---|
342 | !-- Compute horizontal diffusion |
---|
343 | DO k = nzb+1, nzt |
---|
344 | ! |
---|
345 | !-- Predetermine flag to mask topography and wall-bounded grid points. |
---|
346 | !-- It is sufficient to masked only east- and west-facing surfaces, which |
---|
347 | !-- need special treatment for the v-component. |
---|
348 | flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i), 2 ) ) |
---|
349 | mask_east = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i+1), 2 ) ) |
---|
350 | mask_west = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i-1), 2 ) ) |
---|
351 | ! |
---|
352 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
353 | kmxp = 0.25_wp * ( km(k,j,i)+km(k,j,i+1)+km(k,j-1,i)+km(k,j-1,i+1) ) |
---|
354 | kmxm = 0.25_wp * ( km(k,j,i)+km(k,j,i-1)+km(k,j-1,i)+km(k,j-1,i-1) ) |
---|
355 | |
---|
356 | tend(k,j,i) = tend(k,j,i) + ( & |
---|
357 | mask_east * kmxp * ( & |
---|
358 | ( v(k,j,i+1) - v(k,j,i) ) * ddx & |
---|
359 | + ( u(k,j,i+1) - u(k,j-1,i+1) ) * ddy & |
---|
360 | ) & |
---|
361 | - mask_west * kmxm * ( & |
---|
362 | ( v(k,j,i) - v(k,j,i-1) ) * ddx & |
---|
363 | + ( u(k,j,i) - u(k,j-1,i) ) * ddy & |
---|
364 | ) & |
---|
365 | ) * ddx * flag & |
---|
366 | + 2.0_wp * ( & |
---|
367 | km(k,j,i) * ( v(k,j+1,i) - v(k,j,i) ) & |
---|
368 | - km(k,j-1,i) * ( v(k,j,i) - v(k,j-1,i) ) & |
---|
369 | ) * ddy2 * flag |
---|
370 | ENDDO |
---|
371 | |
---|
372 | ! |
---|
373 | !-- Add horizontal momentum flux v'u' at east- (l=2) and west-facing (l=3) |
---|
374 | !-- surfaces. Note, in the the flat case, loops won't be entered as |
---|
375 | !-- start_index > end_index. Furtermore, note, no vertical natural surfaces |
---|
376 | !-- so far. |
---|
377 | !-- Default-type surfaces |
---|
378 | DO l = 2, 3 |
---|
379 | surf_s = surf_def_v(l)%start_index(j,i) |
---|
380 | surf_e = surf_def_v(l)%end_index(j,i) |
---|
381 | DO m = surf_s, surf_e |
---|
382 | k = surf_def_v(l)%k(m) |
---|
383 | tend(k,j,i) = tend(k,j,i) + surf_def_v(l)%mom_flux_uv(m) * ddx |
---|
384 | ENDDO |
---|
385 | ENDDO |
---|
386 | ! |
---|
387 | !-- Natural-type surfaces |
---|
388 | DO l = 2, 3 |
---|
389 | surf_s = surf_lsm_v(l)%start_index(j,i) |
---|
390 | surf_e = surf_lsm_v(l)%end_index(j,i) |
---|
391 | DO m = surf_s, surf_e |
---|
392 | k = surf_lsm_v(l)%k(m) |
---|
393 | tend(k,j,i) = tend(k,j,i) + surf_lsm_v(l)%mom_flux_uv(m) * ddx |
---|
394 | ENDDO |
---|
395 | ENDDO |
---|
396 | ! |
---|
397 | !-- Urban-type surfaces |
---|
398 | DO l = 2, 3 |
---|
399 | surf_s = surf_usm_v(l)%start_index(j,i) |
---|
400 | surf_e = surf_usm_v(l)%end_index(j,i) |
---|
401 | DO m = surf_s, surf_e |
---|
402 | k = surf_usm_v(l)%k(m) |
---|
403 | tend(k,j,i) = tend(k,j,i) + surf_usm_v(l)%mom_flux_uv(m) * ddx |
---|
404 | ENDDO |
---|
405 | ENDDO |
---|
406 | ! |
---|
407 | !-- Compute vertical diffusion. In case of simulating a surface layer, |
---|
408 | !-- respective grid diffusive fluxes are masked (flag 8) within this |
---|
409 | !-- loop, and added further below, else, simple gradient approach is |
---|
410 | !-- applied. Model top is also mask if top-momentum flux is given. |
---|
411 | DO k = nzb+1, nzt |
---|
412 | ! |
---|
413 | !-- Determine flags to mask topography below and above. Flag 2 is |
---|
414 | !-- used to mask topography in general, while flag 10 implies also |
---|
415 | !-- information about use_surface_fluxes. Flag 9 is used to control |
---|
416 | !-- momentum flux at model top. |
---|
417 | mask_bottom = MERGE( 1.0_wp, 0.0_wp, & |
---|
418 | BTEST( wall_flags_0(k-1,j,i), 8 ) ) |
---|
419 | mask_top = MERGE( 1.0_wp, 0.0_wp, & |
---|
420 | BTEST( wall_flags_0(k+1,j,i), 8 ) ) * & |
---|
421 | MERGE( 1.0_wp, 0.0_wp, & |
---|
422 | BTEST( wall_flags_0(k+1,j,i), 9 ) ) |
---|
423 | flag = MERGE( 1.0_wp, 0.0_wp, & |
---|
424 | BTEST( wall_flags_0(k,j,i), 2 ) ) |
---|
425 | ! |
---|
426 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
427 | kmzp = 0.25_wp * ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
428 | kmzm = 0.25_wp * ( km(k,j,i)+km(k-1,j,i)+km(k,j-1,i)+km(k-1,j-1,i) ) |
---|
429 | |
---|
430 | tend(k,j,i) = tend(k,j,i) & |
---|
431 | & + ( kmzp * ( ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
432 | & + ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
433 | & ) * rho_air_zw(k) * mask_top & |
---|
434 | & - kmzm * ( ( v(k,j,i) - v(k-1,j,i) ) * ddzu(k) & |
---|
435 | & + ( w(k-1,j,i) - w(k-1,j-1,i) ) * ddy & |
---|
436 | & ) * rho_air_zw(k-1) * mask_bottom & |
---|
437 | & ) * ddzw(k) * drho_air(k) * flag |
---|
438 | ENDDO |
---|
439 | |
---|
440 | ! |
---|
441 | !-- Vertical diffusion at the first grid point above the surface, if the |
---|
442 | !-- momentum flux at the bottom is given by the Prandtl law or if it is |
---|
443 | !-- prescribed by the user. |
---|
444 | !-- Difference quotient of the momentum flux is not formed over half of |
---|
445 | !-- the grid spacing (2.0*ddzw(k)) any more, since the comparison with |
---|
446 | !-- other (LES) models showed that the values of the momentum flux becomes |
---|
447 | !-- too large in this case. |
---|
448 | IF ( use_surface_fluxes ) THEN |
---|
449 | ! |
---|
450 | !-- Default-type surfaces, upward-facing |
---|
451 | surf_s = surf_def_h(0)%start_index(j,i) |
---|
452 | surf_e = surf_def_h(0)%end_index(j,i) |
---|
453 | DO m = surf_s, surf_e |
---|
454 | k = surf_def_h(0)%k(m) |
---|
455 | |
---|
456 | tend(k,j,i) = tend(k,j,i) & |
---|
457 | + ( - ( - surf_def_h(0)%vsws(m) ) & |
---|
458 | ) * ddzw(k) * drho_air(k) |
---|
459 | ENDDO |
---|
460 | ! |
---|
461 | !-- Default-type surfaces, dowward-facing |
---|
462 | surf_s = surf_def_h(1)%start_index(j,i) |
---|
463 | surf_e = surf_def_h(1)%end_index(j,i) |
---|
464 | DO m = surf_s, surf_e |
---|
465 | k = surf_def_h(1)%k(m) |
---|
466 | |
---|
467 | tend(k,j,i) = tend(k,j,i) & |
---|
468 | + ( - surf_def_h(1)%vsws(m) & |
---|
469 | ) * ddzw(k) * drho_air(k) |
---|
470 | ENDDO |
---|
471 | ! |
---|
472 | !-- Natural-type surfaces, upward-facing |
---|
473 | surf_s = surf_lsm_h%start_index(j,i) |
---|
474 | surf_e = surf_lsm_h%end_index(j,i) |
---|
475 | DO m = surf_s, surf_e |
---|
476 | k = surf_lsm_h%k(m) |
---|
477 | |
---|
478 | tend(k,j,i) = tend(k,j,i) & |
---|
479 | + ( - ( - surf_lsm_h%vsws(m) ) & |
---|
480 | ) * ddzw(k) * drho_air(k) |
---|
481 | |
---|
482 | ENDDO |
---|
483 | ! |
---|
484 | !-- Urban-type surfaces, upward-facing |
---|
485 | surf_s = surf_usm_h%start_index(j,i) |
---|
486 | surf_e = surf_usm_h%end_index(j,i) |
---|
487 | DO m = surf_s, surf_e |
---|
488 | k = surf_usm_h%k(m) |
---|
489 | |
---|
490 | tend(k,j,i) = tend(k,j,i) & |
---|
491 | + ( - ( - surf_usm_h%vsws(m) ) & |
---|
492 | ) * ddzw(k) * drho_air(k) |
---|
493 | |
---|
494 | ENDDO |
---|
495 | ENDIF |
---|
496 | ! |
---|
497 | !-- Add momentum flux at model top |
---|
498 | IF ( use_top_fluxes .AND. constant_top_momentumflux ) THEN |
---|
499 | surf_s = surf_def_h(2)%start_index(j,i) |
---|
500 | surf_e = surf_def_h(2)%end_index(j,i) |
---|
501 | DO m = surf_s, surf_e |
---|
502 | |
---|
503 | k = surf_def_h(2)%k(m) |
---|
504 | |
---|
505 | tend(k,j,i) = tend(k,j,i) & |
---|
506 | + ( - surf_def_h(2)%vsws(m) ) * ddzw(k) * drho_air(k) |
---|
507 | ENDDO |
---|
508 | ENDIF |
---|
509 | |
---|
510 | END SUBROUTINE diffusion_v_ij |
---|
511 | |
---|
512 | END MODULE diffusion_v_mod |
---|