1 | SUBROUTINE init_grid |
---|
2 | |
---|
3 | !--------------------------------------------------------------------------------! |
---|
4 | ! This file is part of PALM. |
---|
5 | ! |
---|
6 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
7 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
8 | ! either version 3 of the License, or (at your option) any later 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-2014 Leibniz Universitaet Hannover |
---|
18 | !--------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: init_grid.f90 1581 2015-04-10 13:45:59Z raasch $ |
---|
27 | ! |
---|
28 | ! 1580 2015-04-10 13:43:49Z suehring |
---|
29 | ! Bugfix: setting flags for 5th order scheme near buildings |
---|
30 | ! |
---|
31 | ! 1575 2015-03-27 09:56:27Z raasch |
---|
32 | ! adjustments for psolver-queries |
---|
33 | ! |
---|
34 | ! 1557 2015-03-05 16:43:04Z suehring |
---|
35 | ! Adjustment for monotoinic limiter |
---|
36 | ! |
---|
37 | ! 1418 2014-06-06 13:05:08Z fricke |
---|
38 | ! Bugfix: Change if-condition for stretched grid in the ocean, with the old |
---|
39 | ! condition and a negative value for dz_stretch_level the condition |
---|
40 | ! was always true for the whole model domain |
---|
41 | ! |
---|
42 | ! 1409 2014-05-23 12:11:32Z suehring |
---|
43 | ! Bugfix: set wall_flags_0 at inflow and outflow boundary also for i <= nxlu |
---|
44 | ! j <= nysv |
---|
45 | ! |
---|
46 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
47 | ! REAL constants provided with KIND-attribute |
---|
48 | ! |
---|
49 | ! 1322 2014-03-20 16:38:49Z raasch |
---|
50 | ! REAL constants defined as wp-kind |
---|
51 | ! |
---|
52 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
53 | ! ONLY-attribute added to USE-statements, |
---|
54 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
55 | ! kinds are defined in new module kinds, |
---|
56 | ! revision history before 2012 removed, |
---|
57 | ! comment fields (!:) to be used for variable explanations added to |
---|
58 | ! all variable declaration statements |
---|
59 | ! |
---|
60 | ! 1221 2013-09-10 08:59:13Z raasch |
---|
61 | ! wall_flags_00 introduced to hold bits 32-63, |
---|
62 | ! additional 3D-flag arrays for replacing the 2D-index array nzb_s_inner in |
---|
63 | ! loops optimized for openACC (pres + flow_statistics) |
---|
64 | ! |
---|
65 | ! 1092 2013-02-02 11:24:22Z raasch |
---|
66 | ! unused variables removed |
---|
67 | ! |
---|
68 | ! 1069 2012-11-28 16:18:43Z maronga |
---|
69 | ! bugfix: added coupling_char to TOPOGRAPHY_DATA to allow topography in the ocean |
---|
70 | ! model in case of coupled runs |
---|
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 | ! lower index for calculating wall_flags_0 set to nzb_w_inner instead of |
---|
77 | ! nzb_w_inner+1 |
---|
78 | ! |
---|
79 | ! 996 2012-09-07 10:41:47Z raasch |
---|
80 | ! little reformatting |
---|
81 | ! |
---|
82 | ! 978 2012-08-09 08:28:32Z fricke |
---|
83 | ! Bugfix: nzb_max is set to nzt at non-cyclic lateral boundaries |
---|
84 | ! Bugfix: Set wall_flags_0 for inflow boundary |
---|
85 | ! |
---|
86 | ! 927 2012-06-06 19:15:04Z raasch |
---|
87 | ! Wall flags are not set for multigrid method in case of masking method |
---|
88 | ! |
---|
89 | ! 864 2012-03-27 15:10:33Z gryschka |
---|
90 | ! In case of ocean and Dirichlet bottom bc for u and v dzu_mg and ddzu_pres |
---|
91 | ! were not correctly defined for k=1. |
---|
92 | ! |
---|
93 | ! 861 2012-03-26 14:18:34Z suehring |
---|
94 | ! Set wall_flags_0. The array is needed for degradation in ws-scheme near walls, |
---|
95 | ! inflow and outflow boundaries as well as near the bottom and the top of the |
---|
96 | ! model domain.! |
---|
97 | ! Initialization of nzb_s_inner and nzb_w_inner. |
---|
98 | ! gls has to be at least nbgp to do not exceed the array bounds of nzb_local |
---|
99 | ! while setting wall_flags_0 |
---|
100 | ! |
---|
101 | ! 843 2012-02-29 15:16:21Z gryschka |
---|
102 | ! In case of ocean and dirichlet bc for u and v at the bottom |
---|
103 | ! the first u-level ist defined at same height as the first w-level |
---|
104 | ! |
---|
105 | ! 818 2012-02-08 16:11:23Z maronga |
---|
106 | ! Bugfix: topo_height is only required if topography is used. It is thus now |
---|
107 | ! allocated in the topography branch |
---|
108 | ! |
---|
109 | ! 809 2012-01-30 13:32:58Z maronga |
---|
110 | ! Bugfix: replaced .AND. and .NOT. with && and ! in the preprocessor directives |
---|
111 | ! |
---|
112 | ! 807 2012-01-25 11:53:51Z maronga |
---|
113 | ! New cpp directive "__check" implemented which is used by check_namelist_files |
---|
114 | ! |
---|
115 | ! Revision 1.1 1997/08/11 06:17:45 raasch |
---|
116 | ! Initial revision (Testversion) |
---|
117 | ! |
---|
118 | ! |
---|
119 | ! Description: |
---|
120 | ! ------------ |
---|
121 | ! Creating grid depending constants |
---|
122 | !------------------------------------------------------------------------------! |
---|
123 | |
---|
124 | USE arrays_3d, & |
---|
125 | ONLY: dd2zu, ddzu, ddzu_pres, ddzw, dzu, dzu_mg, dzw, dzw_mg, f1_mg, & |
---|
126 | f2_mg, f3_mg, l_grid, l_wall, zu, zw |
---|
127 | |
---|
128 | USE control_parameters, & |
---|
129 | ONLY: bc_lr, bc_ns, building_height, building_length_x, & |
---|
130 | building_length_y, building_wall_left, building_wall_south, & |
---|
131 | canyon_height, canyon_wall_left, canyon_wall_south, & |
---|
132 | canyon_width_x, canyon_width_y, coupling_char, dp_level_ind_b, & |
---|
133 | dz, dz_max, dz_stretch_factor, dz_stretch_level, & |
---|
134 | dz_stretch_level_index, ibc_uv_b, io_blocks, io_group, & |
---|
135 | inflow_l, inflow_n, inflow_r, inflow_s, masking_method, & |
---|
136 | maximum_grid_level, message_string, momentum_advec, ocean, & |
---|
137 | outflow_l, outflow_n, outflow_r, outflow_s, prandtl_layer, & |
---|
138 | psolver, scalar_advec, topography, topography_grid_convention, & |
---|
139 | use_surface_fluxes, use_top_fluxes, wall_adjustment_factor |
---|
140 | |
---|
141 | USE grid_variables, & |
---|
142 | ONLY: ddx, ddx2, ddx2_mg, ddy, ddy2, ddy2_mg, dx, dx2, dy, dy2, fwxm, & |
---|
143 | fwxp, fwym, fwyp, fxm, fxp, fym, fyp, wall_e_x, wall_e_y, & |
---|
144 | wall_u, wall_v, wall_w_x, wall_w_y, zu_s_inner, zw_w_inner |
---|
145 | |
---|
146 | USE indices, & |
---|
147 | ONLY: flags, nbgp, nx, nxl, nxlg, nxlu, nxl_mg, nxr, nxrg, nxr_mg, & |
---|
148 | ny, nyn, nyng, nyn_mg, nys, nysv, nys_mg, nysg, nz, nzb, & |
---|
149 | nzb_2d, nzb_diff, nzb_diff_s_inner, nzb_diff_s_outer, & |
---|
150 | nzb_diff_u, nzb_diff_v, nzb_max, nzb_s_inner, nzb_s_outer, & |
---|
151 | nzb_u_inner, nzb_u_outer, nzb_v_inner, nzb_v_outer, & |
---|
152 | nzb_w_inner, nzb_w_outer, nzt, nzt_diff, nzt_mg, rflags_invers, & |
---|
153 | rflags_s_inner, wall_flags_0, wall_flags_00, wall_flags_1, & |
---|
154 | wall_flags_10, wall_flags_2, wall_flags_3, wall_flags_4, & |
---|
155 | wall_flags_5, wall_flags_6, wall_flags_7, wall_flags_8, & |
---|
156 | wall_flags_9 |
---|
157 | |
---|
158 | USE kinds |
---|
159 | |
---|
160 | USE pegrid |
---|
161 | |
---|
162 | IMPLICIT NONE |
---|
163 | |
---|
164 | INTEGER(iwp) :: bh !: |
---|
165 | INTEGER(iwp) :: blx !: |
---|
166 | INTEGER(iwp) :: bly !: |
---|
167 | INTEGER(iwp) :: bxl !: |
---|
168 | INTEGER(iwp) :: bxr !: |
---|
169 | INTEGER(iwp) :: byn !: |
---|
170 | INTEGER(iwp) :: bys !: |
---|
171 | INTEGER(iwp) :: ch !: |
---|
172 | INTEGER(iwp) :: cwx !: |
---|
173 | INTEGER(iwp) :: cwy !: |
---|
174 | INTEGER(iwp) :: cxl !: |
---|
175 | INTEGER(iwp) :: cxr !: |
---|
176 | INTEGER(iwp) :: cyn !: |
---|
177 | INTEGER(iwp) :: cys !: |
---|
178 | INTEGER(iwp) :: gls !: |
---|
179 | INTEGER(iwp) :: i !: |
---|
180 | INTEGER(iwp) :: ii !: |
---|
181 | INTEGER(iwp) :: inc !: |
---|
182 | INTEGER(iwp) :: j !: |
---|
183 | INTEGER(iwp) :: k !: |
---|
184 | INTEGER(iwp) :: l !: |
---|
185 | INTEGER(iwp) :: nxl_l !: |
---|
186 | INTEGER(iwp) :: nxr_l !: |
---|
187 | INTEGER(iwp) :: nyn_l !: |
---|
188 | INTEGER(iwp) :: nys_l !: |
---|
189 | INTEGER(iwp) :: nzb_si !: |
---|
190 | INTEGER(iwp) :: nzt_l !: |
---|
191 | INTEGER(iwp) :: vi !: |
---|
192 | |
---|
193 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: vertical_influence !: |
---|
194 | |
---|
195 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: corner_nl !: |
---|
196 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: corner_nr !: |
---|
197 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: corner_sl !: |
---|
198 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: corner_sr !: |
---|
199 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: wall_l !: |
---|
200 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: wall_n !: |
---|
201 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: wall_r !: |
---|
202 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: wall_s !: |
---|
203 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: nzb_local !: |
---|
204 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: nzb_tmp !: |
---|
205 | |
---|
206 | LOGICAL :: flag_set = .FALSE. !: |
---|
207 | |
---|
208 | REAL(wp) :: dx_l !: |
---|
209 | REAL(wp) :: dy_l !: |
---|
210 | REAL(wp) :: dz_stretched !: |
---|
211 | |
---|
212 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: topo_height !: |
---|
213 | |
---|
214 | |
---|
215 | ! |
---|
216 | !-- Calculation of horizontal array bounds including ghost layers |
---|
217 | nxlg = nxl - nbgp |
---|
218 | nxrg = nxr + nbgp |
---|
219 | nysg = nys - nbgp |
---|
220 | nyng = nyn + nbgp |
---|
221 | |
---|
222 | ! |
---|
223 | !-- Allocate grid arrays |
---|
224 | ALLOCATE( ddzu(1:nzt+1), ddzw(1:nzt+1), dd2zu(1:nzt), dzu(1:nzt+1), & |
---|
225 | dzw(1:nzt+1), l_grid(1:nzt), zu(nzb:nzt+1), zw(nzb:nzt+1) ) |
---|
226 | |
---|
227 | ! |
---|
228 | !-- Compute height of u-levels from constant grid length and dz stretch factors |
---|
229 | IF ( dz == -1.0_wp ) THEN |
---|
230 | message_string = 'missing dz' |
---|
231 | CALL message( 'init_grid', 'PA0200', 1, 2, 0, 6, 0 ) |
---|
232 | ELSEIF ( dz <= 0.0_wp ) THEN |
---|
233 | WRITE( message_string, * ) 'dz=',dz,' <= 0.0' |
---|
234 | CALL message( 'init_grid', 'PA0201', 1, 2, 0, 6, 0 ) |
---|
235 | ENDIF |
---|
236 | |
---|
237 | ! |
---|
238 | !-- Define the vertical grid levels |
---|
239 | IF ( .NOT. ocean ) THEN |
---|
240 | ! |
---|
241 | !-- Grid for atmosphere with surface at z=0 (k=0, w-grid). |
---|
242 | !-- The second u-level (k=1) corresponds to the top of the |
---|
243 | !-- Prandtl-layer. |
---|
244 | |
---|
245 | IF ( ibc_uv_b == 0 .OR. ibc_uv_b == 2 ) THEN |
---|
246 | zu(0) = 0.0_wp |
---|
247 | ! zu(0) = - dz * 0.5_wp |
---|
248 | ELSE |
---|
249 | zu(0) = - dz * 0.5_wp |
---|
250 | ENDIF |
---|
251 | zu(1) = dz * 0.5_wp |
---|
252 | |
---|
253 | dz_stretch_level_index = nzt+1 |
---|
254 | dz_stretched = dz |
---|
255 | DO k = 2, nzt+1 |
---|
256 | IF ( dz_stretch_level <= zu(k-1) .AND. dz_stretched < dz_max ) THEN |
---|
257 | dz_stretched = dz_stretched * dz_stretch_factor |
---|
258 | dz_stretched = MIN( dz_stretched, dz_max ) |
---|
259 | IF ( dz_stretch_level_index == nzt+1 ) dz_stretch_level_index = k-1 |
---|
260 | ENDIF |
---|
261 | zu(k) = zu(k-1) + dz_stretched |
---|
262 | ENDDO |
---|
263 | |
---|
264 | ! |
---|
265 | !-- Compute the w-levels. They are always staggered half-way between the |
---|
266 | !-- corresponding u-levels. In case of dirichlet bc for u and v at the |
---|
267 | !-- ground the first u- and w-level (k=0) are defined at same height (z=0). |
---|
268 | !-- The top w-level is extrapolated linearly. |
---|
269 | zw(0) = 0.0_wp |
---|
270 | DO k = 1, nzt |
---|
271 | zw(k) = ( zu(k) + zu(k+1) ) * 0.5_wp |
---|
272 | ENDDO |
---|
273 | zw(nzt+1) = zw(nzt) + 2.0_wp * ( zu(nzt+1) - zw(nzt) ) |
---|
274 | |
---|
275 | ELSE |
---|
276 | ! |
---|
277 | !-- Grid for ocean with free water surface is at k=nzt (w-grid). |
---|
278 | !-- In case of neumann bc at the ground the first first u-level (k=0) lies |
---|
279 | !-- below the first w-level (k=0). In case of dirichlet bc the first u- and |
---|
280 | !-- w-level are defined at same height, but staggered from the second level. |
---|
281 | !-- The second u-level (k=1) corresponds to the top of the Prandtl-layer. |
---|
282 | zu(nzt+1) = dz * 0.5_wp |
---|
283 | zu(nzt) = - dz * 0.5_wp |
---|
284 | |
---|
285 | dz_stretch_level_index = 0 |
---|
286 | dz_stretched = dz |
---|
287 | DO k = nzt-1, 0, -1 |
---|
288 | ! |
---|
289 | !-- The default value of dz_stretch_level is positive, thus the first |
---|
290 | !-- condition is always true. Hence, the second condition is necessary. |
---|
291 | IF ( dz_stretch_level >= zu(k+1) .AND. dz_stretch_level <= 0.0 & |
---|
292 | .AND. dz_stretched < dz_max ) THEN |
---|
293 | dz_stretched = dz_stretched * dz_stretch_factor |
---|
294 | dz_stretched = MIN( dz_stretched, dz_max ) |
---|
295 | IF ( dz_stretch_level_index == 0 ) dz_stretch_level_index = k+1 |
---|
296 | ENDIF |
---|
297 | zu(k) = zu(k+1) - dz_stretched |
---|
298 | ENDDO |
---|
299 | |
---|
300 | ! |
---|
301 | !-- Compute the w-levels. They are always staggered half-way between the |
---|
302 | !-- corresponding u-levels, except in case of dirichlet bc for u and v |
---|
303 | !-- at the ground. In this case the first u- and w-level are defined at |
---|
304 | !-- same height. The top w-level (nzt+1) is not used but set for |
---|
305 | !-- consistency, since w and all scalar variables are defined up tp nzt+1. |
---|
306 | zw(nzt+1) = dz |
---|
307 | zw(nzt) = 0.0_wp |
---|
308 | DO k = 0, nzt |
---|
309 | zw(k) = ( zu(k) + zu(k+1) ) * 0.5_wp |
---|
310 | ENDDO |
---|
311 | |
---|
312 | ! |
---|
313 | !-- In case of dirichlet bc for u and v the first u- and w-level are defined |
---|
314 | !-- at same height. |
---|
315 | IF ( ibc_uv_b == 0 ) THEN |
---|
316 | zu(0) = zw(0) |
---|
317 | ENDIF |
---|
318 | |
---|
319 | ENDIF |
---|
320 | |
---|
321 | ! |
---|
322 | !-- Compute grid lengths. |
---|
323 | DO k = 1, nzt+1 |
---|
324 | dzu(k) = zu(k) - zu(k-1) |
---|
325 | ddzu(k) = 1.0_wp / dzu(k) |
---|
326 | dzw(k) = zw(k) - zw(k-1) |
---|
327 | ddzw(k) = 1.0_wp / dzw(k) |
---|
328 | ENDDO |
---|
329 | |
---|
330 | DO k = 1, nzt |
---|
331 | dd2zu(k) = 1.0_wp / ( dzu(k) + dzu(k+1) ) |
---|
332 | ENDDO |
---|
333 | |
---|
334 | ! |
---|
335 | !-- The FFT- SOR-pressure solvers assume grid spacings of a staggered grid |
---|
336 | !-- everywhere. For the actual grid, the grid spacing at the lowest level |
---|
337 | !-- is only dz/2, but should be dz. Therefore, an additional array |
---|
338 | !-- containing with appropriate grid information is created for these |
---|
339 | !-- solvers. |
---|
340 | IF ( psolver(1:9) /= 'multigrid' ) THEN |
---|
341 | ALLOCATE( ddzu_pres(1:nzt+1) ) |
---|
342 | ddzu_pres = ddzu |
---|
343 | ddzu_pres(1) = ddzu_pres(2) ! change for lowest level |
---|
344 | ENDIF |
---|
345 | |
---|
346 | ! |
---|
347 | !-- In case of multigrid method, compute grid lengths and grid factors for the |
---|
348 | !-- grid levels |
---|
349 | IF ( psolver(1:9) == 'multigrid' ) THEN |
---|
350 | |
---|
351 | ALLOCATE( ddx2_mg(maximum_grid_level), ddy2_mg(maximum_grid_level), & |
---|
352 | dzu_mg(nzb+1:nzt+1,maximum_grid_level), & |
---|
353 | dzw_mg(nzb+1:nzt+1,maximum_grid_level), & |
---|
354 | f1_mg(nzb+1:nzt,maximum_grid_level), & |
---|
355 | f2_mg(nzb+1:nzt,maximum_grid_level), & |
---|
356 | f3_mg(nzb+1:nzt,maximum_grid_level) ) |
---|
357 | |
---|
358 | dzu_mg(:,maximum_grid_level) = dzu |
---|
359 | ! |
---|
360 | !-- Next line to ensure an equally spaced grid. |
---|
361 | dzu_mg(1,maximum_grid_level) = dzu(2) |
---|
362 | |
---|
363 | dzw_mg(:,maximum_grid_level) = dzw |
---|
364 | nzt_l = nzt |
---|
365 | DO l = maximum_grid_level-1, 1, -1 |
---|
366 | dzu_mg(nzb+1,l) = 2.0_wp * dzu_mg(nzb+1,l+1) |
---|
367 | dzw_mg(nzb+1,l) = 2.0_wp * dzw_mg(nzb+1,l+1) |
---|
368 | nzt_l = nzt_l / 2 |
---|
369 | DO k = 2, nzt_l+1 |
---|
370 | dzu_mg(k,l) = dzu_mg(2*k-2,l+1) + dzu_mg(2*k-1,l+1) |
---|
371 | dzw_mg(k,l) = dzw_mg(2*k-2,l+1) + dzw_mg(2*k-1,l+1) |
---|
372 | ENDDO |
---|
373 | ENDDO |
---|
374 | |
---|
375 | nzt_l = nzt |
---|
376 | dx_l = dx |
---|
377 | dy_l = dy |
---|
378 | DO l = maximum_grid_level, 1, -1 |
---|
379 | ddx2_mg(l) = 1.0_wp / dx_l**2 |
---|
380 | ddy2_mg(l) = 1.0_wp / dy_l**2 |
---|
381 | DO k = nzb+1, nzt_l |
---|
382 | f2_mg(k,l) = 1.0_wp / ( dzu_mg(k+1,l) * dzw_mg(k,l) ) |
---|
383 | f3_mg(k,l) = 1.0_wp / ( dzu_mg(k,l) * dzw_mg(k,l) ) |
---|
384 | f1_mg(k,l) = 2.0_wp * ( ddx2_mg(l) + ddy2_mg(l) ) + & |
---|
385 | f2_mg(k,l) + f3_mg(k,l) |
---|
386 | ENDDO |
---|
387 | nzt_l = nzt_l / 2 |
---|
388 | dx_l = dx_l * 2.0_wp |
---|
389 | dy_l = dy_l * 2.0_wp |
---|
390 | ENDDO |
---|
391 | |
---|
392 | ENDIF |
---|
393 | |
---|
394 | ! |
---|
395 | !-- Compute the reciprocal values of the horizontal grid lengths. |
---|
396 | ddx = 1.0_wp / dx |
---|
397 | ddy = 1.0_wp / dy |
---|
398 | dx2 = dx * dx |
---|
399 | dy2 = dy * dy |
---|
400 | ddx2 = 1.0_wp / dx2 |
---|
401 | ddy2 = 1.0_wp / dy2 |
---|
402 | |
---|
403 | ! |
---|
404 | !-- Compute the grid-dependent mixing length. |
---|
405 | DO k = 1, nzt |
---|
406 | l_grid(k) = ( dx * dy * dzw(k) )**0.33333333333333_wp |
---|
407 | ENDDO |
---|
408 | |
---|
409 | ! |
---|
410 | !-- Allocate outer and inner index arrays for topography and set |
---|
411 | !-- defaults. |
---|
412 | !-- nzb_local has to contain additional layers of ghost points for calculating |
---|
413 | !-- the flag arrays needed for the multigrid method |
---|
414 | gls = 2**( maximum_grid_level ) |
---|
415 | IF ( gls < nbgp ) gls = nbgp |
---|
416 | |
---|
417 | ALLOCATE( corner_nl(nys:nyn,nxl:nxr), corner_nr(nys:nyn,nxl:nxr), & |
---|
418 | corner_sl(nys:nyn,nxl:nxr), corner_sr(nys:nyn,nxl:nxr), & |
---|
419 | nzb_local(-gls:ny+gls,-gls:nx+gls), & |
---|
420 | nzb_tmp(-nbgp:ny+nbgp,-nbgp:nx+nbgp), & |
---|
421 | wall_l(nys:nyn,nxl:nxr), wall_n(nys:nyn,nxl:nxr), & |
---|
422 | wall_r(nys:nyn,nxl:nxr), wall_s(nys:nyn,nxl:nxr) ) |
---|
423 | ALLOCATE( fwxm(nysg:nyng,nxlg:nxrg), fwxp(nysg:nyng,nxlg:nxrg), & |
---|
424 | fwym(nysg:nyng,nxlg:nxrg), fwyp(nysg:nyng,nxlg:nxrg), & |
---|
425 | fxm(nysg:nyng,nxlg:nxrg), fxp(nysg:nyng,nxlg:nxrg), & |
---|
426 | fym(nysg:nyng,nxlg:nxrg), fyp(nysg:nyng,nxlg:nxrg), & |
---|
427 | nzb_s_inner(nysg:nyng,nxlg:nxrg), & |
---|
428 | nzb_s_outer(nysg:nyng,nxlg:nxrg), & |
---|
429 | nzb_u_inner(nysg:nyng,nxlg:nxrg), & |
---|
430 | nzb_u_outer(nysg:nyng,nxlg:nxrg), & |
---|
431 | nzb_v_inner(nysg:nyng,nxlg:nxrg), & |
---|
432 | nzb_v_outer(nysg:nyng,nxlg:nxrg), & |
---|
433 | nzb_w_inner(nysg:nyng,nxlg:nxrg), & |
---|
434 | nzb_w_outer(nysg:nyng,nxlg:nxrg), & |
---|
435 | nzb_diff_s_inner(nysg:nyng,nxlg:nxrg), & |
---|
436 | nzb_diff_s_outer(nysg:nyng,nxlg:nxrg), & |
---|
437 | nzb_diff_u(nysg:nyng,nxlg:nxrg), & |
---|
438 | nzb_diff_v(nysg:nyng,nxlg:nxrg), & |
---|
439 | nzb_2d(nysg:nyng,nxlg:nxrg), & |
---|
440 | rflags_s_inner(nzb:nzt+2,nysg:nyng,nxlg:nxrg), & |
---|
441 | rflags_invers(nysg:nyng,nxlg:nxrg,nzb:nzt+2), & |
---|
442 | wall_e_x(nysg:nyng,nxlg:nxrg), & |
---|
443 | wall_e_y(nysg:nyng,nxlg:nxrg), & |
---|
444 | wall_u(nysg:nyng,nxlg:nxrg), & |
---|
445 | wall_v(nysg:nyng,nxlg:nxrg), & |
---|
446 | wall_w_x(nysg:nyng,nxlg:nxrg), & |
---|
447 | wall_w_y(nysg:nyng,nxlg:nxrg) ) |
---|
448 | |
---|
449 | |
---|
450 | |
---|
451 | ALLOCATE( l_wall(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
452 | |
---|
453 | |
---|
454 | nzb_s_inner = nzb; nzb_s_outer = nzb |
---|
455 | nzb_u_inner = nzb; nzb_u_outer = nzb |
---|
456 | nzb_v_inner = nzb; nzb_v_outer = nzb |
---|
457 | nzb_w_inner = nzb; nzb_w_outer = nzb |
---|
458 | |
---|
459 | rflags_s_inner = 1.0_wp |
---|
460 | rflags_invers = 1.0_wp |
---|
461 | |
---|
462 | ! |
---|
463 | !-- Define vertical gridpoint from (or to) which on the usual finite difference |
---|
464 | !-- form (which does not use surface fluxes) is applied |
---|
465 | IF ( prandtl_layer .OR. use_surface_fluxes ) THEN |
---|
466 | nzb_diff = nzb + 2 |
---|
467 | ELSE |
---|
468 | nzb_diff = nzb + 1 |
---|
469 | ENDIF |
---|
470 | IF ( use_top_fluxes ) THEN |
---|
471 | nzt_diff = nzt - 1 |
---|
472 | ELSE |
---|
473 | nzt_diff = nzt |
---|
474 | ENDIF |
---|
475 | |
---|
476 | nzb_diff_s_inner = nzb_diff; nzb_diff_s_outer = nzb_diff |
---|
477 | nzb_diff_u = nzb_diff; nzb_diff_v = nzb_diff |
---|
478 | |
---|
479 | wall_e_x = 0.0_wp; wall_e_y = 0.0_wp; wall_u = 0.0_wp; wall_v = 0.0_wp |
---|
480 | wall_w_x = 0.0_wp; wall_w_y = 0.0_wp |
---|
481 | fwxp = 1.0_wp; fwxm = 1.0_wp; fwyp = 1.0_wp; fwym = 1.0_wp |
---|
482 | fxp = 1.0_wp; fxm = 1.0_wp; fyp = 1.0_wp; fym = 1.0_wp |
---|
483 | |
---|
484 | ! |
---|
485 | !-- Initialize near-wall mixing length l_wall only in the vertical direction |
---|
486 | !-- for the moment, |
---|
487 | !-- multiplication with wall_adjustment_factor near the end of this routine |
---|
488 | l_wall(nzb,:,:) = l_grid(1) |
---|
489 | DO k = nzb+1, nzt |
---|
490 | l_wall(k,:,:) = l_grid(k) |
---|
491 | ENDDO |
---|
492 | l_wall(nzt+1,:,:) = l_grid(nzt) |
---|
493 | |
---|
494 | ALLOCATE ( vertical_influence(nzb:nzt) ) |
---|
495 | DO k = 1, nzt |
---|
496 | vertical_influence(k) = MIN ( INT( l_grid(k) / & |
---|
497 | ( wall_adjustment_factor * dzw(k) ) + 0.5_wp ), nzt - k ) |
---|
498 | ENDDO |
---|
499 | |
---|
500 | DO k = 1, MAXVAL( nzb_s_inner ) |
---|
501 | IF ( l_grid(k) > 1.5_wp * dx * wall_adjustment_factor .OR. & |
---|
502 | l_grid(k) > 1.5_wp * dy * wall_adjustment_factor ) THEN |
---|
503 | WRITE( message_string, * ) 'grid anisotropy exceeds ', & |
---|
504 | 'threshold given by only local', & |
---|
505 | ' &horizontal reduction of near_wall ', & |
---|
506 | 'mixing length l_wall', & |
---|
507 | ' &starting from height level k = ', k, '.' |
---|
508 | CALL message( 'init_grid', 'PA0202', 0, 1, 0, 6, 0 ) |
---|
509 | EXIT |
---|
510 | ENDIF |
---|
511 | ENDDO |
---|
512 | vertical_influence(0) = vertical_influence(1) |
---|
513 | |
---|
514 | DO i = nxlg, nxrg |
---|
515 | DO j = nysg, nyng |
---|
516 | DO k = nzb_s_inner(j,i) + 1, & |
---|
517 | nzb_s_inner(j,i) + vertical_influence(nzb_s_inner(j,i)) |
---|
518 | l_wall(k,j,i) = zu(k) - zw(nzb_s_inner(j,i)) |
---|
519 | ENDDO |
---|
520 | ENDDO |
---|
521 | ENDDO |
---|
522 | |
---|
523 | ! |
---|
524 | !-- Set outer and inner index arrays for non-flat topography. |
---|
525 | !-- Here consistency checks concerning domain size and periodicity are |
---|
526 | !-- necessary. |
---|
527 | !-- Within this SELECT CASE structure only nzb_local is initialized |
---|
528 | !-- individually depending on the chosen topography type, all other index |
---|
529 | !-- arrays are initialized further below. |
---|
530 | SELECT CASE ( TRIM( topography ) ) |
---|
531 | |
---|
532 | CASE ( 'flat' ) |
---|
533 | ! |
---|
534 | !-- nzb_local is required for the multigrid solver |
---|
535 | nzb_local = 0 |
---|
536 | |
---|
537 | CASE ( 'single_building' ) |
---|
538 | ! |
---|
539 | !-- Single rectangular building, by default centered in the middle of the |
---|
540 | !-- total domain |
---|
541 | blx = NINT( building_length_x / dx ) |
---|
542 | bly = NINT( building_length_y / dy ) |
---|
543 | bh = NINT( building_height / dz ) |
---|
544 | |
---|
545 | IF ( building_wall_left == 9999999.9_wp ) THEN |
---|
546 | building_wall_left = ( nx + 1 - blx ) / 2 * dx |
---|
547 | ENDIF |
---|
548 | bxl = NINT( building_wall_left / dx ) |
---|
549 | bxr = bxl + blx |
---|
550 | |
---|
551 | IF ( building_wall_south == 9999999.9_wp ) THEN |
---|
552 | building_wall_south = ( ny + 1 - bly ) / 2 * dy |
---|
553 | ENDIF |
---|
554 | bys = NINT( building_wall_south / dy ) |
---|
555 | byn = bys + bly |
---|
556 | |
---|
557 | ! |
---|
558 | !-- Building size has to meet some requirements |
---|
559 | IF ( ( bxl < 1 ) .OR. ( bxr > nx-1 ) .OR. ( bxr < bxl+3 ) .OR. & |
---|
560 | ( bys < 1 ) .OR. ( byn > ny-1 ) .OR. ( byn < bys+3 ) ) THEN |
---|
561 | WRITE( message_string, * ) 'inconsistent building parameters:', & |
---|
562 | '& bxl=', bxl, 'bxr=', bxr, 'bys=', bys, & |
---|
563 | 'byn=', byn, 'nx=', nx, 'ny=', ny |
---|
564 | CALL message( 'init_grid', 'PA0203', 1, 2, 0, 6, 0 ) |
---|
565 | ENDIF |
---|
566 | |
---|
567 | ! |
---|
568 | !-- Define the building. |
---|
569 | nzb_local = 0 |
---|
570 | nzb_local(bys:byn,bxl:bxr) = bh |
---|
571 | |
---|
572 | CASE ( 'single_street_canyon' ) |
---|
573 | ! |
---|
574 | !-- Single quasi-2D street canyon of infinite length in x or y direction. |
---|
575 | !-- The canyon is centered in the other direction by default. |
---|
576 | IF ( canyon_width_x /= 9999999.9_wp ) THEN |
---|
577 | ! |
---|
578 | !-- Street canyon in y direction |
---|
579 | cwx = NINT( canyon_width_x / dx ) |
---|
580 | IF ( canyon_wall_left == 9999999.9_wp ) THEN |
---|
581 | canyon_wall_left = ( nx + 1 - cwx ) / 2 * dx |
---|
582 | ENDIF |
---|
583 | cxl = NINT( canyon_wall_left / dx ) |
---|
584 | cxr = cxl + cwx |
---|
585 | |
---|
586 | ELSEIF ( canyon_width_y /= 9999999.9_wp ) THEN |
---|
587 | ! |
---|
588 | !-- Street canyon in x direction |
---|
589 | cwy = NINT( canyon_width_y / dy ) |
---|
590 | IF ( canyon_wall_south == 9999999.9_wp ) THEN |
---|
591 | canyon_wall_south = ( ny + 1 - cwy ) / 2 * dy |
---|
592 | ENDIF |
---|
593 | cys = NINT( canyon_wall_south / dy ) |
---|
594 | cyn = cys + cwy |
---|
595 | |
---|
596 | ELSE |
---|
597 | |
---|
598 | message_string = 'no street canyon width given' |
---|
599 | CALL message( 'init_grid', 'PA0204', 1, 2, 0, 6, 0 ) |
---|
600 | |
---|
601 | ENDIF |
---|
602 | |
---|
603 | ch = NINT( canyon_height / dz ) |
---|
604 | dp_level_ind_b = ch |
---|
605 | ! |
---|
606 | !-- Street canyon size has to meet some requirements |
---|
607 | IF ( canyon_width_x /= 9999999.9_wp ) THEN |
---|
608 | IF ( ( cxl < 1 ) .OR. ( cxr > nx-1 ) .OR. ( cwx < 3 ) .OR. & |
---|
609 | ( ch < 3 ) ) THEN |
---|
610 | WRITE( message_string, * ) 'inconsistent canyon parameters:', & |
---|
611 | '&cxl=', cxl, 'cxr=', cxr, & |
---|
612 | 'cwx=', cwx, & |
---|
613 | 'ch=', ch, 'nx=', nx, 'ny=', ny |
---|
614 | CALL message( 'init_grid', 'PA0205', 1, 2, 0, 6, 0 ) |
---|
615 | ENDIF |
---|
616 | ELSEIF ( canyon_width_y /= 9999999.9_wp ) THEN |
---|
617 | IF ( ( cys < 1 ) .OR. ( cyn > ny-1 ) .OR. ( cwy < 3 ) .OR. & |
---|
618 | ( ch < 3 ) ) THEN |
---|
619 | WRITE( message_string, * ) 'inconsistent canyon parameters:', & |
---|
620 | '&cys=', cys, 'cyn=', cyn, & |
---|
621 | 'cwy=', cwy, & |
---|
622 | 'ch=', ch, 'nx=', nx, 'ny=', ny |
---|
623 | CALL message( 'init_grid', 'PA0206', 1, 2, 0, 6, 0 ) |
---|
624 | ENDIF |
---|
625 | ENDIF |
---|
626 | IF ( canyon_width_x /= 9999999.9_wp .AND. & |
---|
627 | canyon_width_y /= 9999999.9_wp ) THEN |
---|
628 | message_string = 'inconsistent canyon parameters:' // & |
---|
629 | '&street canyon can only be oriented' // & |
---|
630 | '&either in x- or in y-direction' |
---|
631 | CALL message( 'init_grid', 'PA0207', 1, 2, 0, 6, 0 ) |
---|
632 | ENDIF |
---|
633 | |
---|
634 | nzb_local = ch |
---|
635 | IF ( canyon_width_x /= 9999999.9_wp ) THEN |
---|
636 | nzb_local(:,cxl+1:cxr-1) = 0 |
---|
637 | ELSEIF ( canyon_width_y /= 9999999.9_wp ) THEN |
---|
638 | nzb_local(cys+1:cyn-1,:) = 0 |
---|
639 | ENDIF |
---|
640 | |
---|
641 | CASE ( 'read_from_file' ) |
---|
642 | |
---|
643 | ALLOCATE ( topo_height(0:ny,0:nx) ) |
---|
644 | |
---|
645 | DO ii = 0, io_blocks-1 |
---|
646 | IF ( ii == io_group ) THEN |
---|
647 | |
---|
648 | ! |
---|
649 | !-- Arbitrary irregular topography data in PALM format (exactly |
---|
650 | !-- matching the grid size and total domain size) |
---|
651 | OPEN( 90, FILE='TOPOGRAPHY_DATA'//coupling_char, STATUS='OLD', & |
---|
652 | FORM='FORMATTED', ERR=10 ) |
---|
653 | DO j = ny, 0, -1 |
---|
654 | READ( 90, *, ERR=11, END=11 ) ( topo_height(j,i), i = 0,nx ) |
---|
655 | ENDDO |
---|
656 | |
---|
657 | GOTO 12 |
---|
658 | |
---|
659 | 10 message_string = 'file TOPOGRAPHY'//coupling_char//' does not exist' |
---|
660 | CALL message( 'init_grid', 'PA0208', 1, 2, 0, 6, 0 ) |
---|
661 | |
---|
662 | 11 message_string = 'errors in file TOPOGRAPHY_DATA'//coupling_char |
---|
663 | CALL message( 'init_grid', 'PA0209', 1, 2, 0, 6, 0 ) |
---|
664 | |
---|
665 | 12 CLOSE( 90 ) |
---|
666 | |
---|
667 | ENDIF |
---|
668 | #if defined( __parallel ) && ! defined ( __check ) |
---|
669 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
670 | #endif |
---|
671 | ENDDO |
---|
672 | |
---|
673 | ! |
---|
674 | !-- Calculate the index height of the topography |
---|
675 | DO i = 0, nx |
---|
676 | DO j = 0, ny |
---|
677 | nzb_local(j,i) = NINT( topo_height(j,i) / dz ) |
---|
678 | ENDDO |
---|
679 | ENDDO |
---|
680 | |
---|
681 | DEALLOCATE ( topo_height ) |
---|
682 | ! |
---|
683 | !-- Add cyclic boundaries (additional layers are for calculating |
---|
684 | !-- flag arrays needed for the multigrid sover) |
---|
685 | nzb_local(-gls:-1,0:nx) = nzb_local(ny-gls+1:ny,0:nx) |
---|
686 | nzb_local(ny+1:ny+gls,0:nx) = nzb_local(0:gls-1,0:nx) |
---|
687 | nzb_local(:,-gls:-1) = nzb_local(:,nx-gls+1:nx) |
---|
688 | nzb_local(:,nx+1:nx+gls) = nzb_local(:,0:gls-1) |
---|
689 | |
---|
690 | CASE DEFAULT |
---|
691 | ! |
---|
692 | !-- The DEFAULT case is reached either if the parameter topography |
---|
693 | !-- contains a wrong character string or if the user has defined a special |
---|
694 | !-- case in the user interface. There, the subroutine user_init_grid |
---|
695 | !-- checks which of these two conditions applies. |
---|
696 | CALL user_init_grid( gls, nzb_local ) |
---|
697 | |
---|
698 | END SELECT |
---|
699 | ! |
---|
700 | !-- Determine the maximum level of topography. Furthermore it is used for |
---|
701 | !-- steering the degradation of order of the applied advection scheme. |
---|
702 | !-- In case of non-cyclic lateral boundaries, the order of the advection |
---|
703 | !-- scheme have to be reduced up to nzt (required at the lateral boundaries). |
---|
704 | nzb_max = MAXVAL( nzb_local ) |
---|
705 | IF ( inflow_l .OR. outflow_l .OR. inflow_r .OR. outflow_r .OR. & |
---|
706 | inflow_n .OR. outflow_n .OR. inflow_s .OR. outflow_s ) THEN |
---|
707 | nzb_max = nzt |
---|
708 | ENDIF |
---|
709 | |
---|
710 | ! |
---|
711 | !-- Consistency checks and index array initialization are only required for |
---|
712 | !-- non-flat topography, also the initialization of topography height arrays |
---|
713 | !-- zu_s_inner and zw_w_inner |
---|
714 | IF ( TRIM( topography ) /= 'flat' ) THEN |
---|
715 | |
---|
716 | ! |
---|
717 | !-- Consistency checks |
---|
718 | IF ( MINVAL( nzb_local ) < 0 .OR. MAXVAL( nzb_local ) > nz + 1 ) THEN |
---|
719 | WRITE( message_string, * ) 'nzb_local values are outside the', & |
---|
720 | 'model domain', & |
---|
721 | '&MINVAL( nzb_local ) = ', MINVAL(nzb_local), & |
---|
722 | '&MAXVAL( nzb_local ) = ', MAXVAL(nzb_local) |
---|
723 | CALL message( 'init_grid', 'PA0210', 1, 2, 0, 6, 0 ) |
---|
724 | ENDIF |
---|
725 | |
---|
726 | IF ( bc_lr == 'cyclic' ) THEN |
---|
727 | IF ( ANY( nzb_local(:,-1) /= nzb_local(:,nx) ) .OR. & |
---|
728 | ANY( nzb_local(:,0) /= nzb_local(:,nx+1) ) ) THEN |
---|
729 | message_string = 'nzb_local does not fulfill cyclic' // & |
---|
730 | ' boundary condition in x-direction' |
---|
731 | CALL message( 'init_grid', 'PA0211', 1, 2, 0, 6, 0 ) |
---|
732 | ENDIF |
---|
733 | ENDIF |
---|
734 | IF ( bc_ns == 'cyclic' ) THEN |
---|
735 | IF ( ANY( nzb_local(-1,:) /= nzb_local(ny,:) ) .OR. & |
---|
736 | ANY( nzb_local(0,:) /= nzb_local(ny+1,:) ) ) THEN |
---|
737 | message_string = 'nzb_local does not fulfill cyclic' // & |
---|
738 | ' boundary condition in y-direction' |
---|
739 | CALL message( 'init_grid', 'PA0212', 1, 2, 0, 6, 0 ) |
---|
740 | ENDIF |
---|
741 | ENDIF |
---|
742 | |
---|
743 | IF ( topography_grid_convention == 'cell_edge' ) THEN |
---|
744 | ! |
---|
745 | !-- The array nzb_local as defined using the 'cell_edge' convention |
---|
746 | !-- describes the actual total size of topography which is defined at the |
---|
747 | !-- cell edges where u=0 on the topography walls in x-direction and v=0 |
---|
748 | !-- on the topography walls in y-direction. However, PALM uses individual |
---|
749 | !-- arrays nzb_u|v|w|s_inner|outer that are based on nzb_s_inner. |
---|
750 | !-- Therefore, the extent of topography in nzb_local is now reduced by |
---|
751 | !-- 1dx at the E topography walls and by 1dy at the N topography walls |
---|
752 | !-- to form the basis for nzb_s_inner. |
---|
753 | DO j = -gls, ny + gls |
---|
754 | DO i = -gls, nx |
---|
755 | nzb_local(j,i) = MIN( nzb_local(j,i), nzb_local(j,i+1) ) |
---|
756 | ENDDO |
---|
757 | ENDDO |
---|
758 | !-- apply cyclic boundary conditions in x-direction |
---|
759 | !(ist das erforderlich? Ursache von Seung Bus Fehler?) |
---|
760 | nzb_local(:,nx+1:nx+gls) = nzb_local(:,0:gls-1) |
---|
761 | DO i = -gls, nx + gls |
---|
762 | DO j = -gls, ny |
---|
763 | nzb_local(j,i) = MIN( nzb_local(j,i), nzb_local(j+1,i) ) |
---|
764 | ENDDO |
---|
765 | ENDDO |
---|
766 | !-- apply cyclic boundary conditions in y-direction |
---|
767 | !(ist das erforderlich? Ursache von Seung Bus Fehler?) |
---|
768 | nzb_local(ny+1:ny+gls,:) = nzb_local(0:gls-1,:) |
---|
769 | ENDIF |
---|
770 | |
---|
771 | ! |
---|
772 | !-- Initialize index arrays nzb_s_inner and nzb_w_inner |
---|
773 | nzb_s_inner = nzb_local(nysg:nyng,nxlg:nxrg) |
---|
774 | nzb_w_inner = nzb_local(nysg:nyng,nxlg:nxrg) |
---|
775 | |
---|
776 | ! |
---|
777 | !-- Initialize remaining index arrays: |
---|
778 | !-- first pre-initialize them with nzb_s_inner... |
---|
779 | nzb_u_inner = nzb_s_inner |
---|
780 | nzb_u_outer = nzb_s_inner |
---|
781 | nzb_v_inner = nzb_s_inner |
---|
782 | nzb_v_outer = nzb_s_inner |
---|
783 | nzb_w_outer = nzb_s_inner |
---|
784 | nzb_s_outer = nzb_s_inner |
---|
785 | |
---|
786 | ! |
---|
787 | !-- ...then extend pre-initialized arrays in their according directions |
---|
788 | !-- based on nzb_local using nzb_tmp as a temporary global index array |
---|
789 | |
---|
790 | ! |
---|
791 | !-- nzb_s_outer: |
---|
792 | !-- extend nzb_local east-/westwards first, then north-/southwards |
---|
793 | nzb_tmp = nzb_local(-nbgp:ny+nbgp,-nbgp:nx+nbgp) |
---|
794 | DO j = -1, ny + 1 |
---|
795 | DO i = 0, nx |
---|
796 | nzb_tmp(j,i) = MAX( nzb_local(j,i-1), nzb_local(j,i), & |
---|
797 | nzb_local(j,i+1) ) |
---|
798 | ENDDO |
---|
799 | ENDDO |
---|
800 | DO i = nxl, nxr |
---|
801 | DO j = nys, nyn |
---|
802 | nzb_s_outer(j,i) = MAX( nzb_tmp(j-1,i), nzb_tmp(j,i), & |
---|
803 | nzb_tmp(j+1,i) ) |
---|
804 | ENDDO |
---|
805 | ! |
---|
806 | !-- non-cyclic boundary conditions (overwritten by call of |
---|
807 | !-- exchange_horiz_2d_int below in case of cyclic boundary conditions) |
---|
808 | IF ( nys == 0 ) THEN |
---|
809 | j = -1 |
---|
810 | nzb_s_outer(j,i) = MAX( nzb_tmp(j+1,i), nzb_tmp(j,i) ) |
---|
811 | ENDIF |
---|
812 | IF ( nys == ny ) THEN |
---|
813 | j = ny + 1 |
---|
814 | nzb_s_outer(j,i) = MAX( nzb_tmp(j-1,i), nzb_tmp(j,i) ) |
---|
815 | ENDIF |
---|
816 | ENDDO |
---|
817 | ! |
---|
818 | !-- nzb_w_outer: |
---|
819 | !-- identical to nzb_s_outer |
---|
820 | nzb_w_outer = nzb_s_outer |
---|
821 | |
---|
822 | ! |
---|
823 | !-- nzb_u_inner: |
---|
824 | !-- extend nzb_local rightwards only |
---|
825 | nzb_tmp = nzb_local(-nbgp:ny+nbgp,-nbgp:nx+nbgp) |
---|
826 | DO j = -1, ny + 1 |
---|
827 | DO i = 0, nx + 1 |
---|
828 | nzb_tmp(j,i) = MAX( nzb_local(j,i-1), nzb_local(j,i) ) |
---|
829 | ENDDO |
---|
830 | ENDDO |
---|
831 | nzb_u_inner = nzb_tmp(nysg:nyng,nxlg:nxrg) |
---|
832 | |
---|
833 | ! |
---|
834 | !-- nzb_u_outer: |
---|
835 | !-- extend current nzb_tmp (nzb_u_inner) north-/southwards |
---|
836 | DO i = nxl, nxr |
---|
837 | DO j = nys, nyn |
---|
838 | nzb_u_outer(j,i) = MAX( nzb_tmp(j-1,i), nzb_tmp(j,i), & |
---|
839 | nzb_tmp(j+1,i) ) |
---|
840 | ENDDO |
---|
841 | ! |
---|
842 | !-- non-cyclic boundary conditions (overwritten by call of |
---|
843 | !-- exchange_horiz_2d_int below in case of cyclic boundary conditions) |
---|
844 | IF ( nys == 0 ) THEN |
---|
845 | j = -1 |
---|
846 | nzb_u_outer(j,i) = MAX( nzb_tmp(j+1,i), nzb_tmp(j,i) ) |
---|
847 | ENDIF |
---|
848 | IF ( nys == ny ) THEN |
---|
849 | j = ny + 1 |
---|
850 | nzb_u_outer(j,i) = MAX( nzb_tmp(j-1,i), nzb_tmp(j,i) ) |
---|
851 | ENDIF |
---|
852 | ENDDO |
---|
853 | |
---|
854 | ! |
---|
855 | !-- nzb_v_inner: |
---|
856 | !-- extend nzb_local northwards only |
---|
857 | nzb_tmp = nzb_local(-nbgp:ny+nbgp,-nbgp:nx+nbgp) |
---|
858 | DO i = -1, nx + 1 |
---|
859 | DO j = 0, ny + 1 |
---|
860 | nzb_tmp(j,i) = MAX( nzb_local(j-1,i), nzb_local(j,i) ) |
---|
861 | ENDDO |
---|
862 | ENDDO |
---|
863 | nzb_v_inner = nzb_tmp(nys-nbgp:nyn+nbgp,nxl-nbgp:nxr+nbgp) |
---|
864 | |
---|
865 | ! |
---|
866 | !-- nzb_v_outer: |
---|
867 | !-- extend current nzb_tmp (nzb_v_inner) right-/leftwards |
---|
868 | DO j = nys, nyn |
---|
869 | DO i = nxl, nxr |
---|
870 | nzb_v_outer(j,i) = MAX( nzb_tmp(j,i-1), nzb_tmp(j,i), & |
---|
871 | nzb_tmp(j,i+1) ) |
---|
872 | ENDDO |
---|
873 | ! |
---|
874 | !-- non-cyclic boundary conditions (overwritten by call of |
---|
875 | !-- exchange_horiz_2d_int below in case of cyclic boundary conditions) |
---|
876 | IF ( nxl == 0 ) THEN |
---|
877 | i = -1 |
---|
878 | nzb_v_outer(j,i) = MAX( nzb_tmp(j,i+1), nzb_tmp(j,i) ) |
---|
879 | ENDIF |
---|
880 | IF ( nxr == nx ) THEN |
---|
881 | i = nx + 1 |
---|
882 | nzb_v_outer(j,i) = MAX( nzb_tmp(j,i-1), nzb_tmp(j,i) ) |
---|
883 | ENDIF |
---|
884 | ENDDO |
---|
885 | #if ! defined ( __check ) |
---|
886 | ! |
---|
887 | !-- Exchange of lateral boundary values (parallel computers) and cyclic |
---|
888 | !-- boundary conditions, if applicable. |
---|
889 | !-- Since nzb_s_inner and nzb_w_inner are derived directly from nzb_local |
---|
890 | !-- they do not require exchange and are not included here. |
---|
891 | CALL exchange_horiz_2d_int( nzb_u_inner ) |
---|
892 | CALL exchange_horiz_2d_int( nzb_u_outer ) |
---|
893 | CALL exchange_horiz_2d_int( nzb_v_inner ) |
---|
894 | CALL exchange_horiz_2d_int( nzb_v_outer ) |
---|
895 | CALL exchange_horiz_2d_int( nzb_w_outer ) |
---|
896 | CALL exchange_horiz_2d_int( nzb_s_outer ) |
---|
897 | |
---|
898 | ! |
---|
899 | !-- Allocate and set the arrays containing the topography height |
---|
900 | IF ( myid == 0 ) THEN |
---|
901 | |
---|
902 | ALLOCATE( zu_s_inner(0:nx+1,0:ny+1), zw_w_inner(0:nx+1,0:ny+1) ) |
---|
903 | |
---|
904 | DO i = 0, nx + 1 |
---|
905 | DO j = 0, ny + 1 |
---|
906 | zu_s_inner(i,j) = zu(nzb_local(j,i)) |
---|
907 | zw_w_inner(i,j) = zw(nzb_local(j,i)) |
---|
908 | ENDDO |
---|
909 | ENDDO |
---|
910 | |
---|
911 | ENDIF |
---|
912 | ! |
---|
913 | !-- Set flag arrays to be used for masking of grid points |
---|
914 | DO i = nxlg, nxrg |
---|
915 | DO j = nysg, nyng |
---|
916 | DO k = nzb, nzt+1 |
---|
917 | IF ( k <= nzb_s_inner(j,i) ) rflags_s_inner(k,j,i) = 0.0_wp |
---|
918 | IF ( k <= nzb_s_inner(j,i) ) rflags_invers(j,i,k) = 0.0_wp |
---|
919 | ENDDO |
---|
920 | ENDDO |
---|
921 | ENDDO |
---|
922 | #endif |
---|
923 | ENDIF |
---|
924 | |
---|
925 | #if ! defined ( __check ) |
---|
926 | ! |
---|
927 | !-- Preliminary: to be removed after completion of the topography code! |
---|
928 | !-- Set the former default k index arrays nzb_2d |
---|
929 | nzb_2d = nzb |
---|
930 | |
---|
931 | ! |
---|
932 | !-- Set the individual index arrays which define the k index from which on |
---|
933 | !-- the usual finite difference form (which does not use surface fluxes) is |
---|
934 | !-- applied |
---|
935 | IF ( prandtl_layer .OR. use_surface_fluxes ) THEN |
---|
936 | nzb_diff_u = nzb_u_inner + 2 |
---|
937 | nzb_diff_v = nzb_v_inner + 2 |
---|
938 | nzb_diff_s_inner = nzb_s_inner + 2 |
---|
939 | nzb_diff_s_outer = nzb_s_outer + 2 |
---|
940 | ELSE |
---|
941 | nzb_diff_u = nzb_u_inner + 1 |
---|
942 | nzb_diff_v = nzb_v_inner + 1 |
---|
943 | nzb_diff_s_inner = nzb_s_inner + 1 |
---|
944 | nzb_diff_s_outer = nzb_s_outer + 1 |
---|
945 | ENDIF |
---|
946 | |
---|
947 | ! |
---|
948 | !-- Calculation of wall switches and factors required by diffusion_u/v.f90 and |
---|
949 | !-- for limitation of near-wall mixing length l_wall further below |
---|
950 | corner_nl = 0 |
---|
951 | corner_nr = 0 |
---|
952 | corner_sl = 0 |
---|
953 | corner_sr = 0 |
---|
954 | wall_l = 0 |
---|
955 | wall_n = 0 |
---|
956 | wall_r = 0 |
---|
957 | wall_s = 0 |
---|
958 | |
---|
959 | DO i = nxl, nxr |
---|
960 | DO j = nys, nyn |
---|
961 | ! |
---|
962 | !-- u-component |
---|
963 | IF ( nzb_u_outer(j,i) > nzb_u_outer(j+1,i) ) THEN |
---|
964 | wall_u(j,i) = 1.0_wp ! north wall (location of adjacent fluid) |
---|
965 | fym(j,i) = 0.0_wp |
---|
966 | fyp(j,i) = 1.0_wp |
---|
967 | ELSEIF ( nzb_u_outer(j,i) > nzb_u_outer(j-1,i) ) THEN |
---|
968 | wall_u(j,i) = 1.0_wp ! south wall (location of adjacent fluid) |
---|
969 | fym(j,i) = 1.0_wp |
---|
970 | fyp(j,i) = 0.0_wp |
---|
971 | ENDIF |
---|
972 | ! |
---|
973 | !-- v-component |
---|
974 | IF ( nzb_v_outer(j,i) > nzb_v_outer(j,i+1) ) THEN |
---|
975 | wall_v(j,i) = 1.0_wp ! rigth wall (location of adjacent fluid) |
---|
976 | fxm(j,i) = 0.0_wp |
---|
977 | fxp(j,i) = 1.0_wp |
---|
978 | ELSEIF ( nzb_v_outer(j,i) > nzb_v_outer(j,i-1) ) THEN |
---|
979 | wall_v(j,i) = 1.0_wp ! left wall (location of adjacent fluid) |
---|
980 | fxm(j,i) = 1.0_wp |
---|
981 | fxp(j,i) = 0.0_wp |
---|
982 | ENDIF |
---|
983 | ! |
---|
984 | !-- w-component, also used for scalars, separate arrays for shear |
---|
985 | !-- production of tke |
---|
986 | IF ( nzb_w_outer(j,i) > nzb_w_outer(j+1,i) ) THEN |
---|
987 | wall_e_y(j,i) = 1.0_wp ! north wall (location of adjacent fluid) |
---|
988 | wall_w_y(j,i) = 1.0_wp |
---|
989 | fwym(j,i) = 0.0_wp |
---|
990 | fwyp(j,i) = 1.0_wp |
---|
991 | ELSEIF ( nzb_w_outer(j,i) > nzb_w_outer(j-1,i) ) THEN |
---|
992 | wall_e_y(j,i) = -1.0_wp ! south wall (location of adjacent fluid) |
---|
993 | wall_w_y(j,i) = 1.0_wp |
---|
994 | fwym(j,i) = 1.0_wp |
---|
995 | fwyp(j,i) = 0.0_wp |
---|
996 | ENDIF |
---|
997 | IF ( nzb_w_outer(j,i) > nzb_w_outer(j,i+1) ) THEN |
---|
998 | wall_e_x(j,i) = 1.0_wp ! right wall (location of adjacent fluid) |
---|
999 | wall_w_x(j,i) = 1.0_wp |
---|
1000 | fwxm(j,i) = 0.0_wp |
---|
1001 | fwxp(j,i) = 1.0_wp |
---|
1002 | ELSEIF ( nzb_w_outer(j,i) > nzb_w_outer(j,i-1) ) THEN |
---|
1003 | wall_e_x(j,i) = -1.0_wp ! left wall (location of adjacent fluid) |
---|
1004 | wall_w_x(j,i) = 1.0_wp |
---|
1005 | fwxm(j,i) = 1.0_wp |
---|
1006 | fwxp(j,i) = 0.0_wp |
---|
1007 | ENDIF |
---|
1008 | ! |
---|
1009 | !-- Wall and corner locations inside buildings for limitation of |
---|
1010 | !-- near-wall mixing length l_wall |
---|
1011 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j+1,i) ) THEN |
---|
1012 | |
---|
1013 | wall_n(j,i) = nzb_s_inner(j+1,i) + 1 ! North wall |
---|
1014 | |
---|
1015 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j,i-1) ) THEN |
---|
1016 | corner_nl(j,i) = MAX( nzb_s_inner(j+1,i), & ! Northleft corner |
---|
1017 | nzb_s_inner(j,i-1) ) + 1 |
---|
1018 | ENDIF |
---|
1019 | |
---|
1020 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j,i+1) ) THEN |
---|
1021 | corner_nr(j,i) = MAX( nzb_s_inner(j+1,i), & ! Northright corner |
---|
1022 | nzb_s_inner(j,i+1) ) + 1 |
---|
1023 | ENDIF |
---|
1024 | |
---|
1025 | ENDIF |
---|
1026 | |
---|
1027 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j-1,i) ) THEN |
---|
1028 | |
---|
1029 | wall_s(j,i) = nzb_s_inner(j-1,i) + 1 ! South wall |
---|
1030 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j,i-1) ) THEN |
---|
1031 | corner_sl(j,i) = MAX( nzb_s_inner(j-1,i), & ! Southleft corner |
---|
1032 | nzb_s_inner(j,i-1) ) + 1 |
---|
1033 | ENDIF |
---|
1034 | |
---|
1035 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j,i+1) ) THEN |
---|
1036 | corner_sr(j,i) = MAX( nzb_s_inner(j-1,i), & ! Southright corner |
---|
1037 | nzb_s_inner(j,i+1) ) + 1 |
---|
1038 | ENDIF |
---|
1039 | |
---|
1040 | ENDIF |
---|
1041 | |
---|
1042 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j,i-1) ) THEN |
---|
1043 | wall_l(j,i) = nzb_s_inner(j,i-1) + 1 ! Left wall |
---|
1044 | ENDIF |
---|
1045 | |
---|
1046 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j,i+1) ) THEN |
---|
1047 | wall_r(j,i) = nzb_s_inner(j,i+1) + 1 ! Right wall |
---|
1048 | ENDIF |
---|
1049 | |
---|
1050 | ENDDO |
---|
1051 | ENDDO |
---|
1052 | |
---|
1053 | ! |
---|
1054 | !-- Calculate wall flag arrays for the multigrid method |
---|
1055 | IF ( psolver(1:9) == 'multigrid' ) THEN |
---|
1056 | ! |
---|
1057 | !-- Gridpoint increment of the current level |
---|
1058 | inc = 1 |
---|
1059 | |
---|
1060 | DO l = maximum_grid_level, 1 , -1 |
---|
1061 | |
---|
1062 | nxl_l = nxl_mg(l) |
---|
1063 | nxr_l = nxr_mg(l) |
---|
1064 | nys_l = nys_mg(l) |
---|
1065 | nyn_l = nyn_mg(l) |
---|
1066 | nzt_l = nzt_mg(l) |
---|
1067 | |
---|
1068 | ! |
---|
1069 | !-- Assign the flag level to be calculated |
---|
1070 | SELECT CASE ( l ) |
---|
1071 | CASE ( 1 ) |
---|
1072 | flags => wall_flags_1 |
---|
1073 | CASE ( 2 ) |
---|
1074 | flags => wall_flags_2 |
---|
1075 | CASE ( 3 ) |
---|
1076 | flags => wall_flags_3 |
---|
1077 | CASE ( 4 ) |
---|
1078 | flags => wall_flags_4 |
---|
1079 | CASE ( 5 ) |
---|
1080 | flags => wall_flags_5 |
---|
1081 | CASE ( 6 ) |
---|
1082 | flags => wall_flags_6 |
---|
1083 | CASE ( 7 ) |
---|
1084 | flags => wall_flags_7 |
---|
1085 | CASE ( 8 ) |
---|
1086 | flags => wall_flags_8 |
---|
1087 | CASE ( 9 ) |
---|
1088 | flags => wall_flags_9 |
---|
1089 | CASE ( 10 ) |
---|
1090 | flags => wall_flags_10 |
---|
1091 | END SELECT |
---|
1092 | |
---|
1093 | ! |
---|
1094 | !-- Depending on the grid level, set the respective bits in case of |
---|
1095 | !-- neighbouring walls |
---|
1096 | !-- Bit 0: wall to the bottom |
---|
1097 | !-- Bit 1: wall to the top (not realized in remaining PALM code so far) |
---|
1098 | !-- Bit 2: wall to the south |
---|
1099 | !-- Bit 3: wall to the north |
---|
1100 | !-- Bit 4: wall to the left |
---|
1101 | !-- Bit 5: wall to the right |
---|
1102 | !-- Bit 6: inside building |
---|
1103 | |
---|
1104 | flags = 0 |
---|
1105 | |
---|
1106 | ! |
---|
1107 | !-- In case of masking method, flags are not set and multigrid method |
---|
1108 | !-- works like FFT-solver |
---|
1109 | IF ( .NOT. masking_method ) THEN |
---|
1110 | |
---|
1111 | DO i = nxl_l-1, nxr_l+1 |
---|
1112 | DO j = nys_l-1, nyn_l+1 |
---|
1113 | DO k = nzb, nzt_l+1 |
---|
1114 | |
---|
1115 | ! |
---|
1116 | !-- Inside/outside building (inside building does not need |
---|
1117 | !-- further tests for walls) |
---|
1118 | IF ( k*inc <= nzb_local(j*inc,i*inc) ) THEN |
---|
1119 | |
---|
1120 | flags(k,j,i) = IBSET( flags(k,j,i), 6 ) |
---|
1121 | |
---|
1122 | ELSE |
---|
1123 | ! |
---|
1124 | !-- Bottom wall |
---|
1125 | IF ( (k-1)*inc <= nzb_local(j*inc,i*inc) ) THEN |
---|
1126 | flags(k,j,i) = IBSET( flags(k,j,i), 0 ) |
---|
1127 | ENDIF |
---|
1128 | ! |
---|
1129 | !-- South wall |
---|
1130 | IF ( k*inc <= nzb_local((j-1)*inc,i*inc) ) THEN |
---|
1131 | flags(k,j,i) = IBSET( flags(k,j,i), 2 ) |
---|
1132 | ENDIF |
---|
1133 | ! |
---|
1134 | !-- North wall |
---|
1135 | IF ( k*inc <= nzb_local((j+1)*inc,i*inc) ) THEN |
---|
1136 | flags(k,j,i) = IBSET( flags(k,j,i), 3 ) |
---|
1137 | ENDIF |
---|
1138 | ! |
---|
1139 | !-- Left wall |
---|
1140 | IF ( k*inc <= nzb_local(j*inc,(i-1)*inc) ) THEN |
---|
1141 | flags(k,j,i) = IBSET( flags(k,j,i), 4 ) |
---|
1142 | ENDIF |
---|
1143 | ! |
---|
1144 | !-- Right wall |
---|
1145 | IF ( k*inc <= nzb_local(j*inc,(i+1)*inc) ) THEN |
---|
1146 | flags(k,j,i) = IBSET( flags(k,j,i), 5 ) |
---|
1147 | ENDIF |
---|
1148 | |
---|
1149 | ENDIF |
---|
1150 | |
---|
1151 | ENDDO |
---|
1152 | ENDDO |
---|
1153 | ENDDO |
---|
1154 | |
---|
1155 | ENDIF |
---|
1156 | |
---|
1157 | ! |
---|
1158 | !-- Test output of flag arrays |
---|
1159 | ! i = nxl_l |
---|
1160 | ! WRITE (9,*) ' ' |
---|
1161 | ! WRITE (9,*) '*** mg level ', l, ' ***', mg_switch_to_pe0_level |
---|
1162 | ! WRITE (9,*) ' inc=', inc, ' i =', nxl_l |
---|
1163 | ! WRITE (9,*) ' nxl_l',nxl_l,' nxr_l=',nxr_l,' nys_l=',nys_l,' nyn_l=',nyn_l |
---|
1164 | ! DO k = nzt_l+1, nzb, -1 |
---|
1165 | ! WRITE (9,'(194(1X,I2))') ( flags(k,j,i), j = nys_l-1, nyn_l+1 ) |
---|
1166 | ! ENDDO |
---|
1167 | |
---|
1168 | inc = inc * 2 |
---|
1169 | |
---|
1170 | ENDDO |
---|
1171 | |
---|
1172 | ENDIF |
---|
1173 | ! |
---|
1174 | !-- Allocate flags needed for masking walls. |
---|
1175 | ALLOCATE( wall_flags_0(nzb:nzt,nys:nyn,nxl:nxr), & |
---|
1176 | wall_flags_00(nzb:nzt,nys:nyn,nxl:nxr) ) |
---|
1177 | wall_flags_0 = 0 |
---|
1178 | wall_flags_00 = 0 |
---|
1179 | |
---|
1180 | IF ( scalar_advec == 'ws-scheme' .OR. & |
---|
1181 | scalar_advec == 'ws-scheme-mono' ) THEN |
---|
1182 | ! |
---|
1183 | !-- Set flags to steer the degradation of the advection scheme in advec_ws |
---|
1184 | !-- near topography, inflow- and outflow boundaries as well as bottom and |
---|
1185 | !-- top of model domain. wall_flags_0 remains zero for all non-prognostic |
---|
1186 | !-- grid points. |
---|
1187 | DO i = nxl, nxr |
---|
1188 | DO j = nys, nyn |
---|
1189 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
1190 | ! |
---|
1191 | !-- scalar - x-direction |
---|
1192 | !-- WS1 (0), WS3 (1), WS5 (2) |
---|
1193 | IF ( k <= nzb_s_inner(j,i+1) .OR. ( ( inflow_l .OR. outflow_l )& |
---|
1194 | .AND. i == nxl ) .OR. ( ( inflow_r .OR. outflow_r ) & |
---|
1195 | .AND. i == nxr ) ) THEN |
---|
1196 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 0 ) |
---|
1197 | ELSEIF ( k <= nzb_s_inner(j,i+2) .OR. k <= nzb_s_inner(j,i-1) & |
---|
1198 | .OR. ( ( inflow_r .OR. outflow_r ) .AND. i == nxr-1 ) & |
---|
1199 | .OR. ( ( inflow_l .OR. outflow_l ) .AND. i == nxlu ) & |
---|
1200 | ) THEN |
---|
1201 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 1 ) |
---|
1202 | ELSE |
---|
1203 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 2 ) |
---|
1204 | ENDIF |
---|
1205 | ! |
---|
1206 | !-- scalar - y-direction |
---|
1207 | !-- WS1 (3), WS3 (4), WS5 (5) |
---|
1208 | IF ( k <= nzb_s_inner(j+1,i) .OR. ( ( inflow_s .OR. outflow_s )& |
---|
1209 | .AND. j == nys ) .OR. ( ( inflow_n .OR. outflow_n ) & |
---|
1210 | .AND. j == nyn ) ) THEN |
---|
1211 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 3 ) |
---|
1212 | !-- WS3 |
---|
1213 | ELSEIF ( k <= nzb_s_inner(j+2,i) .OR. k <= nzb_s_inner(j-1,i) & |
---|
1214 | .OR. ( ( inflow_s .OR. outflow_s ) .AND. j == nysv ) & |
---|
1215 | .OR. ( ( inflow_n .OR. outflow_n ) .AND. j == nyn-1 ) & |
---|
1216 | ) THEN |
---|
1217 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 4 ) |
---|
1218 | !-- WS5 |
---|
1219 | ELSE |
---|
1220 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 5 ) |
---|
1221 | ENDIF |
---|
1222 | ! |
---|
1223 | !-- scalar - z-direction |
---|
1224 | !-- WS1 (6), WS3 (7), WS5 (8) |
---|
1225 | flag_set = .FALSE. |
---|
1226 | IF ( k == nzb_s_inner(j,i) + 1 .OR. k == nzt ) THEN |
---|
1227 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 6 ) |
---|
1228 | flag_set = .TRUE. |
---|
1229 | ELSEIF ( k == nzb_s_inner(j,i) + 2 .OR. k == nzt - 1 ) THEN |
---|
1230 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 7 ) |
---|
1231 | flag_set = .TRUE. |
---|
1232 | ELSEIF ( k > nzb_s_inner(j,i) .AND. .NOT. flag_set ) THEN |
---|
1233 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 8 ) |
---|
1234 | ENDIF |
---|
1235 | ENDDO |
---|
1236 | ENDDO |
---|
1237 | ENDDO |
---|
1238 | ENDIF |
---|
1239 | |
---|
1240 | IF ( momentum_advec == 'ws-scheme' ) THEN |
---|
1241 | ! |
---|
1242 | !-- Set wall_flags_0 to steer the degradation of the advection scheme in advec_ws |
---|
1243 | !-- near topography, inflow- and outflow boundaries as well as bottom and |
---|
1244 | !-- top of model domain. wall_flags_0 remains zero for all non-prognostic |
---|
1245 | !-- grid points. |
---|
1246 | DO i = nxl, nxr |
---|
1247 | DO j = nys, nyn |
---|
1248 | DO k = nzb+1, nzt |
---|
1249 | ! |
---|
1250 | !-- At first, set flags to WS1. |
---|
1251 | !-- Since fluxes are swapped in advec_ws.f90, this is necessary to |
---|
1252 | !-- in order to handle the left/south flux. |
---|
1253 | !-- near vertical walls. |
---|
1254 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 9 ) |
---|
1255 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 12 ) |
---|
1256 | ! |
---|
1257 | !-- u component - x-direction |
---|
1258 | !-- WS1 (9), WS3 (10), WS5 (11) |
---|
1259 | IF ( k <= nzb_u_inner(j,i+1) & |
---|
1260 | .OR. ( ( inflow_l .OR. outflow_l ) .AND. i <= nxlu ) & |
---|
1261 | .OR. ( ( inflow_r .OR. outflow_r ) .AND. i == nxr ) & |
---|
1262 | ) THEN |
---|
1263 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 9 ) |
---|
1264 | ELSEIF ( k <= nzb_u_inner(j,i+2) .OR. k <= nzb_u_inner(j,i-1) & |
---|
1265 | .OR. ( ( inflow_r .OR. outflow_r ) .AND. i == nxr-1 )& |
---|
1266 | .OR. ( ( inflow_l .OR. outflow_l ) .AND. i == nxlu+1)& |
---|
1267 | ) THEN |
---|
1268 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 10 ) |
---|
1269 | ! |
---|
1270 | !-- Clear flag for WS1 |
---|
1271 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 9 ) |
---|
1272 | ELSE |
---|
1273 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 11 ) |
---|
1274 | ! |
---|
1275 | !-- Clear flag for WS1 |
---|
1276 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 9 ) |
---|
1277 | ENDIF |
---|
1278 | ! |
---|
1279 | !-- u component - y-direction |
---|
1280 | !-- WS1 (12), WS3 (13), WS5 (14) |
---|
1281 | IF ( k <= nzb_u_inner(j+1,i) .OR. ( ( inflow_s .OR. outflow_s )& |
---|
1282 | .AND. j == nys ) .OR. ( ( inflow_n .OR. outflow_n ) & |
---|
1283 | .AND. j == nyn ) ) THEN |
---|
1284 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 12 ) |
---|
1285 | ELSEIF ( k <= nzb_u_inner(j+2,i) .OR. k <= nzb_u_inner(j-1,i) & |
---|
1286 | .OR. ( ( inflow_s .OR. outflow_s ) .AND. j == nysv ) & |
---|
1287 | .OR. ( ( inflow_n .OR. outflow_n ) .AND. j == nyn-1 ) & |
---|
1288 | ) THEN |
---|
1289 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 13 ) |
---|
1290 | ! |
---|
1291 | !-- Clear flag for WS1 |
---|
1292 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 12 ) |
---|
1293 | ELSE |
---|
1294 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 14 ) |
---|
1295 | ! |
---|
1296 | !-- Clear flag for WS1 |
---|
1297 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 12 ) |
---|
1298 | ENDIF |
---|
1299 | ! |
---|
1300 | !-- u component - z-direction |
---|
1301 | !-- WS1 (15), WS3 (16), WS5 (17) |
---|
1302 | flag_set = .FALSE. |
---|
1303 | IF ( k == nzb_u_inner(j,i) + 1 .OR. k == nzt ) THEN |
---|
1304 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 15 ) |
---|
1305 | flag_set = .TRUE. |
---|
1306 | ELSEIF ( k == nzb_u_inner(j,i) + 2 .OR. k == nzt - 1 ) THEN |
---|
1307 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 16 ) |
---|
1308 | flag_set = .TRUE. |
---|
1309 | ELSEIF ( k > nzb_u_inner(j,i) .AND. .NOT. flag_set ) THEN |
---|
1310 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 17 ) |
---|
1311 | ENDIF |
---|
1312 | |
---|
1313 | ENDDO |
---|
1314 | ENDDO |
---|
1315 | ENDDO |
---|
1316 | |
---|
1317 | DO i = nxl, nxr |
---|
1318 | DO j = nys, nyn |
---|
1319 | DO k = nzb+1, nzt |
---|
1320 | ! |
---|
1321 | !-- At first, set flags to WS1. |
---|
1322 | !-- Since fluxes are swapped in advec_ws.f90, this is necessary to |
---|
1323 | !-- in order to handle the left/south flux. |
---|
1324 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 18 ) |
---|
1325 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 21 ) |
---|
1326 | ! |
---|
1327 | !-- v component - x-direction |
---|
1328 | !-- WS1 (18), WS3 (19), WS5 (20) |
---|
1329 | IF ( k <= nzb_v_inner(j,i+1) .OR. ( ( inflow_l .OR. outflow_l )& |
---|
1330 | .AND. i == nxl ) .OR. (( inflow_r .OR. outflow_r ) & |
---|
1331 | .AND. i == nxr ) ) THEN |
---|
1332 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 18 ) |
---|
1333 | !-- WS3 |
---|
1334 | ELSEIF ( k <= nzb_v_inner(j,i+2) .OR. k <= nzb_v_inner(j,i-1) & |
---|
1335 | .OR. ( ( inflow_r .OR. outflow_r ) .AND. i == nxr-1 ) & |
---|
1336 | .OR. ( ( inflow_l .OR. outflow_l ) .AND. i == nxlu ) & |
---|
1337 | ) THEN |
---|
1338 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 19 ) |
---|
1339 | ! |
---|
1340 | !-- Clear flag for WS1 |
---|
1341 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 18 ) |
---|
1342 | ELSE |
---|
1343 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 20 ) |
---|
1344 | ! |
---|
1345 | !-- Clear flag for WS1 |
---|
1346 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 18 ) |
---|
1347 | ENDIF |
---|
1348 | ! |
---|
1349 | !-- v component - y-direction |
---|
1350 | !-- WS1 (21), WS3 (22), WS5 (23) |
---|
1351 | IF ( k <= nzb_v_inner(j+1,i) & |
---|
1352 | .OR. ( ( inflow_s .OR. outflow_s ) .AND. j <= nysv ) & |
---|
1353 | .OR. ( ( inflow_n .OR. outflow_n ) .AND. j == nyn ) & |
---|
1354 | ) THEN |
---|
1355 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 21 ) |
---|
1356 | ELSEIF ( k <= nzb_v_inner(j+2,i) .OR. k <= nzb_v_inner(j-1,i) & |
---|
1357 | .OR. ( ( inflow_s .OR. outflow_s ) .AND. j == nysv+1 )& |
---|
1358 | .OR. ( ( inflow_n .OR. outflow_n ) .AND. j == nyn-1 )& |
---|
1359 | ) THEN |
---|
1360 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 22 ) |
---|
1361 | ! |
---|
1362 | !-- Clear flag for WS1 |
---|
1363 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 21 ) |
---|
1364 | ELSE |
---|
1365 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 23 ) |
---|
1366 | ! |
---|
1367 | !-- Clear flag for WS1 |
---|
1368 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 21 ) |
---|
1369 | ENDIF |
---|
1370 | ! |
---|
1371 | !-- v component - z-direction |
---|
1372 | !-- WS1 (24), WS3 (25), WS5 (26) |
---|
1373 | flag_set = .FALSE. |
---|
1374 | IF ( k == nzb_v_inner(j,i) + 1 .OR. k == nzt ) THEN |
---|
1375 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 24 ) |
---|
1376 | flag_set = .TRUE. |
---|
1377 | ELSEIF ( k == nzb_v_inner(j,i) + 2 .OR. k == nzt - 1 ) THEN |
---|
1378 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 25 ) |
---|
1379 | flag_set = .TRUE. |
---|
1380 | ELSEIF ( k > nzb_v_inner(j,i) .AND. .NOT. flag_set ) THEN |
---|
1381 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 26 ) |
---|
1382 | ENDIF |
---|
1383 | |
---|
1384 | ENDDO |
---|
1385 | ENDDO |
---|
1386 | ENDDO |
---|
1387 | DO i = nxl, nxr |
---|
1388 | DO j = nys, nyn |
---|
1389 | DO k = nzb+1, nzt |
---|
1390 | ! |
---|
1391 | !-- At first, set flags to WS1. |
---|
1392 | !-- Since fluxes are swapped in advec_ws.f90, this is necessary to |
---|
1393 | !-- in order to handle the left/south flux. |
---|
1394 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 27 ) |
---|
1395 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 30 ) |
---|
1396 | ! |
---|
1397 | !-- w component - x-direction |
---|
1398 | !-- WS1 (27), WS3 (28), WS5 (29) |
---|
1399 | IF ( k <= nzb_w_inner(j,i+1) .OR. ( ( inflow_l .OR. outflow_l )& |
---|
1400 | .AND. i == nxl ) .OR. ( ( inflow_r .OR. outflow_r ) & |
---|
1401 | .AND. i == nxr ) ) THEN |
---|
1402 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 27 ) |
---|
1403 | ELSEIF ( k <= nzb_w_inner(j,i+2) .OR. k <= nzb_w_inner(j,i-1) & |
---|
1404 | .OR. ( ( inflow_r .OR. outflow_r ) .AND. i == nxr-1 ) & |
---|
1405 | .OR. ( ( inflow_l .OR. outflow_l ) .AND. i == nxlu ) & |
---|
1406 | ) THEN |
---|
1407 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 28 ) |
---|
1408 | ! |
---|
1409 | !-- Clear flag for WS1 |
---|
1410 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 27 ) |
---|
1411 | ELSE |
---|
1412 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i),29 ) |
---|
1413 | ! |
---|
1414 | !-- Clear flag for WS1 |
---|
1415 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 27 ) |
---|
1416 | ENDIF |
---|
1417 | ! |
---|
1418 | !-- w component - y-direction |
---|
1419 | !-- WS1 (30), WS3 (31), WS5 (32) |
---|
1420 | IF ( k <= nzb_w_inner(j+1,i) .OR. ( ( inflow_s .OR. outflow_s )& |
---|
1421 | .AND. j == nys ) .OR. ( ( inflow_n .OR. outflow_n ) & |
---|
1422 | .AND. j == nyn ) ) THEN |
---|
1423 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 30 ) |
---|
1424 | ELSEIF ( k <= nzb_w_inner(j+2,i) .OR. k <= nzb_w_inner(j-1,i) & |
---|
1425 | .OR. ( ( inflow_s .OR. outflow_s ) .AND. j == nysv ) & |
---|
1426 | .OR. ( ( inflow_n .OR. outflow_n ) .AND. j == nyn-1 ) & |
---|
1427 | ) THEN |
---|
1428 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 31 ) |
---|
1429 | ! |
---|
1430 | !-- Clear flag for WS1 |
---|
1431 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 30 ) |
---|
1432 | ELSE |
---|
1433 | wall_flags_00(k,j,i) = IBSET( wall_flags_00(k,j,i), 0 ) |
---|
1434 | ! |
---|
1435 | !-- Clear flag for WS1 |
---|
1436 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 30 ) |
---|
1437 | ENDIF |
---|
1438 | ! |
---|
1439 | !-- w component - z-direction |
---|
1440 | !-- WS1 (33), WS3 (34), WS5 (35) |
---|
1441 | flag_set = .FALSE. |
---|
1442 | IF ( k == nzb_w_inner(j,i) .OR. k == nzb_w_inner(j,i) + 1 & |
---|
1443 | .OR. k == nzt ) THEN |
---|
1444 | ! |
---|
1445 | !-- Please note, at k == nzb_w_inner(j,i) a flag is explictely |
---|
1446 | !-- set, although this is not a prognostic level. However, |
---|
1447 | !-- contrary to the advection of u,v and s this is necessary |
---|
1448 | !-- because flux_t(nzb_w_inner(j,i)) is used for the tendency |
---|
1449 | !-- at k == nzb_w_inner(j,i)+1. |
---|
1450 | wall_flags_00(k,j,i) = IBSET( wall_flags_00(k,j,i), 1 ) |
---|
1451 | flag_set = .TRUE. |
---|
1452 | ELSEIF ( k == nzb_w_inner(j,i) + 2 .OR. k == nzt - 1 ) THEN |
---|
1453 | wall_flags_00(k,j,i) = IBSET( wall_flags_00(k,j,i), 2 ) |
---|
1454 | flag_set = .TRUE. |
---|
1455 | ELSEIF ( k > nzb_w_inner(j,i) .AND. .NOT. flag_set ) THEN |
---|
1456 | wall_flags_00(k,j,i) = IBSET( wall_flags_00(k,j,i), 3 ) |
---|
1457 | ENDIF |
---|
1458 | |
---|
1459 | ENDDO |
---|
1460 | ENDDO |
---|
1461 | ENDDO |
---|
1462 | |
---|
1463 | ENDIF |
---|
1464 | |
---|
1465 | ! |
---|
1466 | !-- In case of topography: limit near-wall mixing length l_wall further: |
---|
1467 | !-- Go through all points of the subdomain one by one and look for the closest |
---|
1468 | !-- surface |
---|
1469 | IF ( TRIM(topography) /= 'flat' ) THEN |
---|
1470 | DO i = nxl, nxr |
---|
1471 | DO j = nys, nyn |
---|
1472 | |
---|
1473 | nzb_si = nzb_s_inner(j,i) |
---|
1474 | vi = vertical_influence(nzb_si) |
---|
1475 | |
---|
1476 | IF ( wall_n(j,i) > 0 ) THEN |
---|
1477 | ! |
---|
1478 | !-- North wall (y distance) |
---|
1479 | DO k = wall_n(j,i), nzb_si |
---|
1480 | l_wall(k,j+1,i) = MIN( l_wall(k,j+1,i), 0.5_wp * dy ) |
---|
1481 | ENDDO |
---|
1482 | ! |
---|
1483 | !-- Above North wall (yz distance) |
---|
1484 | DO k = nzb_si + 1, nzb_si + vi |
---|
1485 | l_wall(k,j+1,i) = MIN( l_wall(k,j+1,i), & |
---|
1486 | SQRT( 0.25_wp * dy**2 + & |
---|
1487 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
1488 | ENDDO |
---|
1489 | ! |
---|
1490 | !-- Northleft corner (xy distance) |
---|
1491 | IF ( corner_nl(j,i) > 0 ) THEN |
---|
1492 | DO k = corner_nl(j,i), nzb_si |
---|
1493 | l_wall(k,j+1,i-1) = MIN( l_wall(k,j+1,i-1), & |
---|
1494 | 0.5_wp * SQRT( dx**2 + dy**2 ) ) |
---|
1495 | ENDDO |
---|
1496 | ! |
---|
1497 | !-- Above Northleft corner (xyz distance) |
---|
1498 | DO k = nzb_si + 1, nzb_si + vi |
---|
1499 | l_wall(k,j+1,i-1) = MIN( l_wall(k,j+1,i-1), & |
---|
1500 | SQRT( 0.25_wp * (dx**2 + dy**2) + & |
---|
1501 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
1502 | ENDDO |
---|
1503 | ENDIF |
---|
1504 | ! |
---|
1505 | !-- Northright corner (xy distance) |
---|
1506 | IF ( corner_nr(j,i) > 0 ) THEN |
---|
1507 | DO k = corner_nr(j,i), nzb_si |
---|
1508 | l_wall(k,j+1,i+1) = MIN( l_wall(k,j+1,i+1), & |
---|
1509 | 0.5_wp * SQRT( dx**2 + dy**2 ) ) |
---|
1510 | ENDDO |
---|
1511 | ! |
---|
1512 | !-- Above northright corner (xyz distance) |
---|
1513 | DO k = nzb_si + 1, nzb_si + vi |
---|
1514 | l_wall(k,j+1,i+1) = MIN( l_wall(k,j+1,i+1), & |
---|
1515 | SQRT( 0.25_wp * (dx**2 + dy**2) + & |
---|
1516 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
1517 | ENDDO |
---|
1518 | ENDIF |
---|
1519 | ENDIF |
---|
1520 | |
---|
1521 | IF ( wall_s(j,i) > 0 ) THEN |
---|
1522 | ! |
---|
1523 | !-- South wall (y distance) |
---|
1524 | DO k = wall_s(j,i), nzb_si |
---|
1525 | l_wall(k,j-1,i) = MIN( l_wall(k,j-1,i), 0.5_wp * dy ) |
---|
1526 | ENDDO |
---|
1527 | ! |
---|
1528 | !-- Above south wall (yz distance) |
---|
1529 | DO k = nzb_si + 1, nzb_si + vi |
---|
1530 | l_wall(k,j-1,i) = MIN( l_wall(k,j-1,i), & |
---|
1531 | SQRT( 0.25_wp * dy**2 + & |
---|
1532 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
1533 | ENDDO |
---|
1534 | ! |
---|
1535 | !-- Southleft corner (xy distance) |
---|
1536 | IF ( corner_sl(j,i) > 0 ) THEN |
---|
1537 | DO k = corner_sl(j,i), nzb_si |
---|
1538 | l_wall(k,j-1,i-1) = MIN( l_wall(k,j-1,i-1), & |
---|
1539 | 0.5_wp * SQRT( dx**2 + dy**2 ) ) |
---|
1540 | ENDDO |
---|
1541 | ! |
---|
1542 | !-- Above southleft corner (xyz distance) |
---|
1543 | DO k = nzb_si + 1, nzb_si + vi |
---|
1544 | l_wall(k,j-1,i-1) = MIN( l_wall(k,j-1,i-1), & |
---|
1545 | SQRT( 0.25_wp * (dx**2 + dy**2) + & |
---|
1546 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
1547 | ENDDO |
---|
1548 | ENDIF |
---|
1549 | ! |
---|
1550 | !-- Southright corner (xy distance) |
---|
1551 | IF ( corner_sr(j,i) > 0 ) THEN |
---|
1552 | DO k = corner_sr(j,i), nzb_si |
---|
1553 | l_wall(k,j-1,i+1) = MIN( l_wall(k,j-1,i+1), & |
---|
1554 | 0.5_wp * SQRT( dx**2 + dy**2 ) ) |
---|
1555 | ENDDO |
---|
1556 | ! |
---|
1557 | !-- Above southright corner (xyz distance) |
---|
1558 | DO k = nzb_si + 1, nzb_si + vi |
---|
1559 | l_wall(k,j-1,i+1) = MIN( l_wall(k,j-1,i+1), & |
---|
1560 | SQRT( 0.25_wp * (dx**2 + dy**2) + & |
---|
1561 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
1562 | ENDDO |
---|
1563 | ENDIF |
---|
1564 | |
---|
1565 | ENDIF |
---|
1566 | |
---|
1567 | IF ( wall_l(j,i) > 0 ) THEN |
---|
1568 | ! |
---|
1569 | !-- Left wall (x distance) |
---|
1570 | DO k = wall_l(j,i), nzb_si |
---|
1571 | l_wall(k,j,i-1) = MIN( l_wall(k,j,i-1), 0.5_wp * dx ) |
---|
1572 | ENDDO |
---|
1573 | ! |
---|
1574 | !-- Above left wall (xz distance) |
---|
1575 | DO k = nzb_si + 1, nzb_si + vi |
---|
1576 | l_wall(k,j,i-1) = MIN( l_wall(k,j,i-1), & |
---|
1577 | SQRT( 0.25_wp * dx**2 + & |
---|
1578 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
1579 | ENDDO |
---|
1580 | ENDIF |
---|
1581 | |
---|
1582 | IF ( wall_r(j,i) > 0 ) THEN |
---|
1583 | ! |
---|
1584 | !-- Right wall (x distance) |
---|
1585 | DO k = wall_r(j,i), nzb_si |
---|
1586 | l_wall(k,j,i+1) = MIN( l_wall(k,j,i+1), 0.5_wp * dx ) |
---|
1587 | ENDDO |
---|
1588 | ! |
---|
1589 | !-- Above right wall (xz distance) |
---|
1590 | DO k = nzb_si + 1, nzb_si + vi |
---|
1591 | l_wall(k,j,i+1) = MIN( l_wall(k,j,i+1), & |
---|
1592 | SQRT( 0.25_wp * dx**2 + & |
---|
1593 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
1594 | ENDDO |
---|
1595 | |
---|
1596 | ENDIF |
---|
1597 | |
---|
1598 | ENDDO |
---|
1599 | ENDDO |
---|
1600 | |
---|
1601 | ENDIF |
---|
1602 | |
---|
1603 | ! |
---|
1604 | !-- Multiplication with wall_adjustment_factor |
---|
1605 | l_wall = wall_adjustment_factor * l_wall |
---|
1606 | |
---|
1607 | ! |
---|
1608 | !-- Set lateral boundary conditions for l_wall |
---|
1609 | CALL exchange_horiz( l_wall, nbgp ) |
---|
1610 | |
---|
1611 | DEALLOCATE( corner_nl, corner_nr, corner_sl, corner_sr, nzb_local, & |
---|
1612 | nzb_tmp, vertical_influence, wall_l, wall_n, wall_r, wall_s ) |
---|
1613 | |
---|
1614 | #endif |
---|
1615 | |
---|
1616 | END SUBROUTINE init_grid |
---|