1 | SUBROUTINE init_grid |
---|
2 | |
---|
3 | !------------------------------------------------------------------------------! |
---|
4 | ! Actual revisions: |
---|
5 | ! ----------------- |
---|
6 | ! Grid definition for ocean version |
---|
7 | ! |
---|
8 | ! Former revisions: |
---|
9 | ! ----------------- |
---|
10 | ! $Id: init_grid.f90 94 2007-06-01 15:25:22Z raasch $ |
---|
11 | ! |
---|
12 | ! 75 2007-03-22 09:54:05Z raasch |
---|
13 | ! storage of topography height arrays zu_s_inner and zw_s_inner, |
---|
14 | ! 2nd+3rd argument removed from exchange horiz |
---|
15 | ! |
---|
16 | ! 19 2007-02-23 04:53:48Z raasch |
---|
17 | ! Setting of nzt_diff |
---|
18 | ! |
---|
19 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
20 | ! |
---|
21 | ! Revision 1.17 2006/08/22 14:00:05 raasch |
---|
22 | ! +dz_max to limit vertical stretching, |
---|
23 | ! bugfix in index array initialization for line- or point-like topography |
---|
24 | ! structures |
---|
25 | ! |
---|
26 | ! Revision 1.1 1997/08/11 06:17:45 raasch |
---|
27 | ! Initial revision (Testversion) |
---|
28 | ! |
---|
29 | ! |
---|
30 | ! Description: |
---|
31 | ! ------------ |
---|
32 | ! Creating grid depending constants |
---|
33 | !------------------------------------------------------------------------------! |
---|
34 | |
---|
35 | USE arrays_3d |
---|
36 | USE control_parameters |
---|
37 | USE grid_variables |
---|
38 | USE indices |
---|
39 | USE pegrid |
---|
40 | |
---|
41 | IMPLICIT NONE |
---|
42 | |
---|
43 | INTEGER :: bh, blx, bly, bxl, bxr, byn, bys, i, i_center, j, j_center, k, & |
---|
44 | l, nzb_si, nzt_l, vi |
---|
45 | |
---|
46 | INTEGER, DIMENSION(:), ALLOCATABLE :: vertical_influence |
---|
47 | |
---|
48 | INTEGER, DIMENSION(:,:), ALLOCATABLE :: corner_nl, corner_nr, corner_sl, & |
---|
49 | corner_sr, wall_l, wall_n, wall_r,& |
---|
50 | wall_s, nzb_local, nzb_tmp |
---|
51 | |
---|
52 | REAL :: dx_l, dy_l, dz_stretched |
---|
53 | |
---|
54 | REAL, DIMENSION(0:ny,0:nx) :: topo_height |
---|
55 | |
---|
56 | REAL, DIMENSION(:,:,:), ALLOCATABLE :: distance |
---|
57 | |
---|
58 | ! |
---|
59 | !-- Allocate grid arrays |
---|
60 | ALLOCATE( ddzu(1:nzt+1), ddzw(1:nzt+1), dd2zu(1:nzt), dzu(1:nzt+1), & |
---|
61 | dzw(1:nzt+1), l_grid(1:nzt), zu(0:nzt+1), zw(0:nzt+1) ) |
---|
62 | |
---|
63 | ! |
---|
64 | !-- Compute height of u-levels from constant grid length and dz stretch factors |
---|
65 | IF ( dz == -1.0 ) THEN |
---|
66 | IF ( myid == 0 ) PRINT*,'+++ init_grid: missing dz' |
---|
67 | CALL local_stop |
---|
68 | ELSEIF ( dz <= 0.0 ) THEN |
---|
69 | IF ( myid == 0 ) PRINT*,'+++ init_grid: dz=',dz,' <= 0.0' |
---|
70 | CALL local_stop |
---|
71 | ENDIF |
---|
72 | |
---|
73 | ! |
---|
74 | !-- Define the vertical grid levels |
---|
75 | IF ( .NOT. ocean ) THEN |
---|
76 | ! |
---|
77 | !-- Grid for atmosphere with surface at z=0 (k=0, w-grid). |
---|
78 | !-- Since the w-level lies on the surface, the first u-level (staggered!) |
---|
79 | !-- lies below the surface (used for "mirror" boundary condition). |
---|
80 | !-- The first u-level above the surface corresponds to the top of the |
---|
81 | !-- Prandtl-layer. |
---|
82 | zu(0) = - dz * 0.5 |
---|
83 | zu(1) = dz * 0.5 |
---|
84 | |
---|
85 | dz_stretch_level_index = nzt+1 |
---|
86 | dz_stretched = dz |
---|
87 | DO k = 2, nzt+1 |
---|
88 | IF ( dz_stretch_level <= zu(k-1) .AND. dz_stretched < dz_max ) THEN |
---|
89 | dz_stretched = dz_stretched * dz_stretch_factor |
---|
90 | dz_stretched = MIN( dz_stretched, dz_max ) |
---|
91 | IF ( dz_stretch_level_index == nzt+1 ) dz_stretch_level_index = k-1 |
---|
92 | ENDIF |
---|
93 | zu(k) = zu(k-1) + dz_stretched |
---|
94 | ENDDO |
---|
95 | |
---|
96 | ! |
---|
97 | !-- Compute the w-levels. They are always staggered half-way between the |
---|
98 | !-- corresponding u-levels. The top w-level is extrapolated linearly. |
---|
99 | zw(0) = 0.0 |
---|
100 | DO k = 1, nzt |
---|
101 | zw(k) = ( zu(k) + zu(k+1) ) * 0.5 |
---|
102 | ENDDO |
---|
103 | zw(nzt+1) = zw(nzt) + 2.0 * ( zu(nzt+1) - zw(nzt) ) |
---|
104 | |
---|
105 | ELSE |
---|
106 | ! |
---|
107 | !-- Grid for ocean with solid surface at z=0 (k=0, w-grid). The free water |
---|
108 | !-- surface is at k=nzt (w-grid). |
---|
109 | !-- Since the w-level lies always on the surface, the first/last u-level |
---|
110 | !-- (staggered!) lies below the bottom surface / above the free surface. |
---|
111 | !-- It is used for "mirror" boundary condition. |
---|
112 | !-- The first u-level above the bottom surface corresponds to the top of the |
---|
113 | !-- Prandtl-layer. |
---|
114 | zu(nzt+1) = dz * 0.5 |
---|
115 | zu(nzt) = - dz * 0.5 |
---|
116 | |
---|
117 | dz_stretch_level_index = 0 |
---|
118 | dz_stretched = dz |
---|
119 | DO k = nzt-1, 0, -1 |
---|
120 | IF ( dz_stretch_level <= ABS( zu(k+1) ) .AND. & |
---|
121 | dz_stretched < dz_max ) THEN |
---|
122 | dz_stretched = dz_stretched * dz_stretch_factor |
---|
123 | dz_stretched = MIN( dz_stretched, dz_max ) |
---|
124 | IF ( dz_stretch_level_index == 0 ) dz_stretch_level_index = k+1 |
---|
125 | ENDIF |
---|
126 | zu(k) = zu(k+1) - dz_stretched |
---|
127 | ENDDO |
---|
128 | |
---|
129 | ! |
---|
130 | !-- Compute the w-levels. They are always staggered half-way between the |
---|
131 | !-- corresponding u-levels. |
---|
132 | !-- The top w-level (nzt+1) is not used but set for consistency, since |
---|
133 | !-- w and all scalar variables are defined up tp nzt+1. |
---|
134 | zw(nzt+1) = dz |
---|
135 | zw(nzt) = 0.0 |
---|
136 | DO k = 0, nzt |
---|
137 | zw(k) = ( zu(k) + zu(k+1) ) * 0.5 |
---|
138 | ENDDO |
---|
139 | |
---|
140 | ENDIF |
---|
141 | |
---|
142 | ! |
---|
143 | !-- Compute grid lengths. |
---|
144 | DO k = 1, nzt+1 |
---|
145 | dzu(k) = zu(k) - zu(k-1) |
---|
146 | ddzu(k) = 1.0 / dzu(k) |
---|
147 | dzw(k) = zw(k) - zw(k-1) |
---|
148 | ddzw(k) = 1.0 / dzw(k) |
---|
149 | ENDDO |
---|
150 | |
---|
151 | DO k = 1, nzt |
---|
152 | dd2zu(k) = 1.0 / ( dzu(k) + dzu(k+1) ) |
---|
153 | ENDDO |
---|
154 | |
---|
155 | ! |
---|
156 | !-- In case of multigrid method, compute grid lengths and grid factors for the |
---|
157 | !-- grid levels |
---|
158 | IF ( psolver == 'multigrid' ) THEN |
---|
159 | |
---|
160 | ALLOCATE( ddx2_mg(maximum_grid_level), ddy2_mg(maximum_grid_level), & |
---|
161 | dzu_mg(nzb+1:nzt+1,maximum_grid_level), & |
---|
162 | dzw_mg(nzb+1:nzt+1,maximum_grid_level), & |
---|
163 | f1_mg(nzb+1:nzt,maximum_grid_level), & |
---|
164 | f2_mg(nzb+1:nzt,maximum_grid_level), & |
---|
165 | f3_mg(nzb+1:nzt,maximum_grid_level) ) |
---|
166 | |
---|
167 | dzu_mg(:,maximum_grid_level) = dzu |
---|
168 | dzw_mg(:,maximum_grid_level) = dzw |
---|
169 | nzt_l = nzt |
---|
170 | DO l = maximum_grid_level-1, 1, -1 |
---|
171 | dzu_mg(nzb+1,l) = 2.0 * dzu_mg(nzb+1,l+1) |
---|
172 | dzw_mg(nzb+1,l) = 2.0 * dzw_mg(nzb+1,l+1) |
---|
173 | nzt_l = nzt_l / 2 |
---|
174 | DO k = 2, nzt_l+1 |
---|
175 | dzu_mg(k,l) = dzu_mg(2*k-2,l+1) + dzu_mg(2*k-1,l+1) |
---|
176 | dzw_mg(k,l) = dzw_mg(2*k-2,l+1) + dzw_mg(2*k-1,l+1) |
---|
177 | ENDDO |
---|
178 | ENDDO |
---|
179 | |
---|
180 | nzt_l = nzt |
---|
181 | dx_l = dx |
---|
182 | dy_l = dy |
---|
183 | DO l = maximum_grid_level, 1, -1 |
---|
184 | ddx2_mg(l) = 1.0 / dx_l**2 |
---|
185 | ddy2_mg(l) = 1.0 / dy_l**2 |
---|
186 | DO k = nzb+1, nzt_l |
---|
187 | f2_mg(k,l) = 1.0 / ( dzu_mg(k+1,l) * dzw_mg(k,l) ) |
---|
188 | f3_mg(k,l) = 1.0 / ( dzu_mg(k,l) * dzw_mg(k,l) ) |
---|
189 | f1_mg(k,l) = 2.0 * ( ddx2_mg(l) + ddy2_mg(l) ) + & |
---|
190 | f2_mg(k,l) + f3_mg(k,l) |
---|
191 | ENDDO |
---|
192 | nzt_l = nzt_l / 2 |
---|
193 | dx_l = dx_l * 2.0 |
---|
194 | dy_l = dy_l * 2.0 |
---|
195 | ENDDO |
---|
196 | |
---|
197 | ENDIF |
---|
198 | |
---|
199 | ! |
---|
200 | !-- Compute the reciprocal values of the horizontal grid lengths. |
---|
201 | ddx = 1.0 / dx |
---|
202 | ddy = 1.0 / dy |
---|
203 | dx2 = dx * dx |
---|
204 | dy2 = dy * dy |
---|
205 | ddx2 = 1.0 / dx2 |
---|
206 | ddy2 = 1.0 / dy2 |
---|
207 | |
---|
208 | ! |
---|
209 | !-- Compute the grid-dependent mixing length. |
---|
210 | DO k = 1, nzt |
---|
211 | l_grid(k) = ( dx * dy * dzw(k) )**0.33333333333333 |
---|
212 | ENDDO |
---|
213 | |
---|
214 | ! |
---|
215 | !-- Allocate outer and inner index arrays for topography and set |
---|
216 | !-- defaults |
---|
217 | ALLOCATE( corner_nl(nys:nyn,nxl:nxr), corner_nr(nys:nyn,nxl:nxr), & |
---|
218 | corner_sl(nys:nyn,nxl:nxr), corner_sr(nys:nyn,nxl:nxr), & |
---|
219 | nzb_local(-1:ny+1,-1:nx+1), nzb_tmp(-1:ny+1,-1:nx+1), & |
---|
220 | wall_l(nys:nyn,nxl:nxr), wall_n(nys:nyn,nxl:nxr), & |
---|
221 | wall_r(nys:nyn,nxl:nxr), wall_s(nys:nyn,nxl:nxr) ) |
---|
222 | ALLOCATE( fwxm(nys-1:nyn+1,nxl-1:nxr+1), fwxp(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
223 | fwym(nys-1:nyn+1,nxl-1:nxr+1), fwyp(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
224 | fxm(nys-1:nyn+1,nxl-1:nxr+1), fxp(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
225 | fym(nys-1:nyn+1,nxl-1:nxr+1), fyp(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
226 | nzb_s_inner(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
227 | nzb_s_outer(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
228 | nzb_u_inner(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
229 | nzb_u_outer(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
230 | nzb_v_inner(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
231 | nzb_v_outer(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
232 | nzb_w_inner(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
233 | nzb_w_outer(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
234 | nzb_diff_s_inner(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
235 | nzb_diff_s_outer(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
236 | nzb_diff_u(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
237 | nzb_diff_v(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
238 | nzb_2d(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
239 | wall_e_x(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
240 | wall_e_y(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
241 | wall_u(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
242 | wall_v(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
243 | wall_w_x(nys-1:nyn+1,nxl-1:nxr+1), & |
---|
244 | wall_w_y(nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
245 | |
---|
246 | ALLOCATE( l_wall(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
247 | |
---|
248 | nzb_s_inner = nzb; nzb_s_outer = nzb |
---|
249 | nzb_u_inner = nzb; nzb_u_outer = nzb |
---|
250 | nzb_v_inner = nzb; nzb_v_outer = nzb |
---|
251 | nzb_w_inner = nzb; nzb_w_outer = nzb |
---|
252 | |
---|
253 | ! |
---|
254 | !-- Define vertical gridpoint from (or to) which on the usual finite difference |
---|
255 | !-- form (which does not use surface fluxes) is applied |
---|
256 | IF ( prandtl_layer .OR. use_surface_fluxes ) THEN |
---|
257 | nzb_diff = nzb + 2 |
---|
258 | ELSE |
---|
259 | nzb_diff = nzb + 1 |
---|
260 | ENDIF |
---|
261 | IF ( use_top_fluxes ) THEN |
---|
262 | nzt_diff = nzt - 1 |
---|
263 | ELSE |
---|
264 | nzt_diff = nzt |
---|
265 | ENDIF |
---|
266 | |
---|
267 | nzb_diff_s_inner = nzb_diff; nzb_diff_s_outer = nzb_diff |
---|
268 | nzb_diff_u = nzb_diff; nzb_diff_v = nzb_diff |
---|
269 | |
---|
270 | wall_e_x = 0.0; wall_e_y = 0.0; wall_u = 0.0; wall_v = 0.0 |
---|
271 | wall_w_x = 0.0; wall_w_y = 0.0 |
---|
272 | fwxp = 1.0; fwxm = 1.0; fwyp = 1.0; fwym = 1.0 |
---|
273 | fxp = 1.0; fxm = 1.0; fyp = 1.0; fym = 1.0 |
---|
274 | |
---|
275 | ! |
---|
276 | !-- Initialize near-wall mixing length l_wall only in the vertical direction |
---|
277 | !-- for the moment, |
---|
278 | !-- multiplication with wall_adjustment_factor near the end of this routine |
---|
279 | l_wall(nzb,:,:) = l_grid(1) |
---|
280 | DO k = nzb+1, nzt |
---|
281 | l_wall(k,:,:) = l_grid(k) |
---|
282 | ENDDO |
---|
283 | l_wall(nzt+1,:,:) = l_grid(nzt) |
---|
284 | |
---|
285 | ALLOCATE ( vertical_influence(nzb:nzt) ) |
---|
286 | DO k = 1, nzt |
---|
287 | vertical_influence(k) = MIN ( INT( l_grid(k) / & |
---|
288 | ( wall_adjustment_factor * dzw(k) ) + 0.5 ), nzt - k ) |
---|
289 | ENDDO |
---|
290 | |
---|
291 | DO k = 1, MAXVAL( nzb_s_inner ) |
---|
292 | IF ( l_grid(k) > 1.5 * dx * wall_adjustment_factor .OR. & |
---|
293 | l_grid(k) > 1.5 * dy * wall_adjustment_factor ) THEN |
---|
294 | IF ( myid == 0 ) THEN |
---|
295 | PRINT*, '+++ WARNING: grid anisotropy exceeds '// & |
---|
296 | 'threshold given by only local' |
---|
297 | PRINT*, ' horizontal reduction of near_wall '// & |
---|
298 | 'mixing length l_wall' |
---|
299 | PRINT*, ' starting from height level k = ', k, '.' |
---|
300 | ENDIF |
---|
301 | EXIT |
---|
302 | ENDIF |
---|
303 | ENDDO |
---|
304 | vertical_influence(0) = vertical_influence(1) |
---|
305 | |
---|
306 | DO i = nxl-1, nxr+1 |
---|
307 | DO j = nys-1, nyn+1 |
---|
308 | DO k = nzb_s_inner(j,i) + 1, & |
---|
309 | nzb_s_inner(j,i) + vertical_influence(nzb_s_inner(j,i)) |
---|
310 | l_wall(k,j,i) = zu(k) - zw(nzb_s_inner(j,i)) |
---|
311 | ENDDO |
---|
312 | ENDDO |
---|
313 | ENDDO |
---|
314 | |
---|
315 | ! |
---|
316 | !-- Set outer and inner index arrays for non-flat topography. |
---|
317 | !-- Here consistency checks concerning domain size and periodicity are |
---|
318 | !-- necessary. |
---|
319 | !-- Within this SELECT CASE structure only nzb_local is initialized |
---|
320 | !-- individually depending on the chosen topography type, all other index |
---|
321 | !-- arrays are initialized further below. |
---|
322 | SELECT CASE ( TRIM( topography ) ) |
---|
323 | |
---|
324 | CASE ( 'flat' ) |
---|
325 | ! |
---|
326 | !-- No actions necessary |
---|
327 | |
---|
328 | CASE ( 'single_building' ) |
---|
329 | ! |
---|
330 | !-- Single rectangular building, by default centered in the middle of the |
---|
331 | !-- total domain |
---|
332 | blx = NINT( building_length_x / dx ) |
---|
333 | bly = NINT( building_length_y / dy ) |
---|
334 | bh = NINT( building_height / dz ) |
---|
335 | |
---|
336 | IF ( building_wall_left == 9999999.9 ) THEN |
---|
337 | building_wall_left = ( nx + 1 - blx ) / 2 * dx |
---|
338 | ENDIF |
---|
339 | bxl = NINT( building_wall_left / dx ) |
---|
340 | bxr = bxl + blx |
---|
341 | |
---|
342 | IF ( building_wall_south == 9999999.9 ) THEN |
---|
343 | building_wall_south = ( ny + 1 - bly ) / 2 * dy |
---|
344 | ENDIF |
---|
345 | bys = NINT( building_wall_south / dy ) |
---|
346 | byn = bys + bly |
---|
347 | |
---|
348 | ! |
---|
349 | !-- Building size has to meet some requirements |
---|
350 | IF ( ( bxl < 1 ) .OR. ( bxr > nx-1 ) .OR. ( bxr < bxl+3 ) .OR. & |
---|
351 | ( bys < 1 ) .OR. ( byn > ny-1 ) .OR. ( byn < bys+3 ) ) THEN |
---|
352 | IF ( myid == 0 ) THEN |
---|
353 | PRINT*, '+++ init_grid: inconsistent building parameters:' |
---|
354 | PRINT*, ' bxl=', bxl, 'bxr=', bxr, 'bys=', bys, & |
---|
355 | 'byn=', byn, 'nx=', nx, 'ny=', ny |
---|
356 | ENDIF |
---|
357 | CALL local_stop |
---|
358 | ENDIF |
---|
359 | |
---|
360 | ! |
---|
361 | !-- Set the individual index arrays for all velocity components and |
---|
362 | !-- scalars, taking into account the staggered grid. The horizontal |
---|
363 | !-- wind component normal to a wall defines the position of the wall, and |
---|
364 | !-- in the respective direction the building is as long as specified in |
---|
365 | !-- building_length_?, but in the other horizontal direction (for w and s |
---|
366 | !-- in both horizontal directions) the building appears shortened by one |
---|
367 | !-- grid length due to the staggered grid. |
---|
368 | nzb_local = 0 |
---|
369 | nzb_local(bys:byn-1,bxl:bxr-1) = bh |
---|
370 | |
---|
371 | CASE ( 'read_from_file' ) |
---|
372 | ! |
---|
373 | !-- Arbitrary irregular topography data in PALM format (exactly matching |
---|
374 | !-- the grid size and total domain size) |
---|
375 | OPEN( 90, FILE='TOPOGRAPHY_DATA', STATUS='OLD', FORM='FORMATTED', & |
---|
376 | ERR=10 ) |
---|
377 | DO j = ny, 0, -1 |
---|
378 | READ( 90, *, ERR=11, END=11 ) ( topo_height(j,i), i = 0, nx ) |
---|
379 | ENDDO |
---|
380 | ! |
---|
381 | !-- Calculate the index height of the topography |
---|
382 | DO i = 0, nx |
---|
383 | DO j = 0, ny |
---|
384 | nzb_local(j,i) = NINT( topo_height(j,i) / dz ) |
---|
385 | ENDDO |
---|
386 | ENDDO |
---|
387 | nzb_local(-1,0:nx) = nzb_local(ny,0:nx) |
---|
388 | nzb_local(ny+1,0:nx) = nzb_local(0,0:nx) |
---|
389 | nzb_local(:,-1) = nzb_local(:,nx) |
---|
390 | nzb_local(:,nx+1) = nzb_local(:,0) |
---|
391 | |
---|
392 | GOTO 12 |
---|
393 | |
---|
394 | 10 IF ( myid == 0 ) THEN |
---|
395 | PRINT*, '+++ init_grid: file TOPOGRAPHY_DATA does not exist' |
---|
396 | ENDIF |
---|
397 | CALL local_stop |
---|
398 | |
---|
399 | 11 IF ( myid == 0 ) THEN |
---|
400 | PRINT*, '+++ init_grid: errors in file TOPOGRAPHY_DATA' |
---|
401 | ENDIF |
---|
402 | CALL local_stop |
---|
403 | |
---|
404 | 12 CLOSE( 90 ) |
---|
405 | |
---|
406 | CASE DEFAULT |
---|
407 | ! |
---|
408 | !-- The DEFAULT case is reached either if the parameter topography |
---|
409 | !-- contains a wrong character string or if the user has coded a special |
---|
410 | !-- case in the user interface. There, the subroutine user_init_grid |
---|
411 | !-- checks which of these two conditions applies. |
---|
412 | CALL user_init_grid( nzb_local ) |
---|
413 | |
---|
414 | END SELECT |
---|
415 | |
---|
416 | ! |
---|
417 | !-- Consistency checks and index array initialization are only required for |
---|
418 | !-- non-flat topography, also the initialization of topography heigth arrays |
---|
419 | !-- zu_s_inner and zw_w_inner |
---|
420 | IF ( TRIM( topography ) /= 'flat' ) THEN |
---|
421 | |
---|
422 | ! |
---|
423 | !-- Consistency checks |
---|
424 | IF ( MINVAL( nzb_local ) < 0 .OR. MAXVAL( nzb_local ) > nz + 1 ) THEN |
---|
425 | IF ( myid == 0 ) THEN |
---|
426 | PRINT*, '+++ init_grid: nzb_local values are outside the', & |
---|
427 | 'model domain' |
---|
428 | PRINT*, ' MINVAL( nzb_local ) = ', MINVAL(nzb_local) |
---|
429 | PRINT*, ' MAXVAL( nzb_local ) = ', MAXVAL(nzb_local) |
---|
430 | ENDIF |
---|
431 | CALL local_stop |
---|
432 | ENDIF |
---|
433 | |
---|
434 | IF ( bc_lr == 'cyclic' ) THEN |
---|
435 | IF ( ANY( nzb_local(:,-1) /= nzb_local(:,nx) ) .OR. & |
---|
436 | ANY( nzb_local(:,0) /= nzb_local(:,nx+1) ) ) THEN |
---|
437 | IF ( myid == 0 ) THEN |
---|
438 | PRINT*, '+++ init_grid: nzb_local does not fulfill cyclic', & |
---|
439 | ' boundary condition in x-direction' |
---|
440 | ENDIF |
---|
441 | CALL local_stop |
---|
442 | ENDIF |
---|
443 | ENDIF |
---|
444 | IF ( bc_ns == 'cyclic' ) THEN |
---|
445 | IF ( ANY( nzb_local(-1,:) /= nzb_local(ny,:) ) .OR. & |
---|
446 | ANY( nzb_local(0,:) /= nzb_local(ny+1,:) ) ) THEN |
---|
447 | IF ( myid == 0 ) THEN |
---|
448 | PRINT*, '+++ init_grid: nzb_local does not fulfill cyclic', & |
---|
449 | ' boundary condition in y-direction' |
---|
450 | ENDIF |
---|
451 | CALL local_stop |
---|
452 | ENDIF |
---|
453 | ENDIF |
---|
454 | |
---|
455 | ! |
---|
456 | !-- Initialize index arrays nzb_s_inner and nzb_w_inner |
---|
457 | nzb_s_inner = nzb_local(nys-1:nyn+1,nxl-1:nxr+1) |
---|
458 | nzb_w_inner = nzb_local(nys-1:nyn+1,nxl-1:nxr+1) |
---|
459 | |
---|
460 | ! |
---|
461 | !-- Initialize remaining index arrays: |
---|
462 | !-- first pre-initialize them with nzb_s_inner... |
---|
463 | nzb_u_inner = nzb_s_inner |
---|
464 | nzb_u_outer = nzb_s_inner |
---|
465 | nzb_v_inner = nzb_s_inner |
---|
466 | nzb_v_outer = nzb_s_inner |
---|
467 | nzb_w_outer = nzb_s_inner |
---|
468 | nzb_s_outer = nzb_s_inner |
---|
469 | |
---|
470 | ! |
---|
471 | !-- ...then extend pre-initialized arrays in their according directions |
---|
472 | !-- based on nzb_local using nzb_tmp as a temporary global index array |
---|
473 | |
---|
474 | ! |
---|
475 | !-- nzb_s_outer: |
---|
476 | !-- extend nzb_local east-/westwards first, then north-/southwards |
---|
477 | nzb_tmp = nzb_local |
---|
478 | DO j = -1, ny + 1 |
---|
479 | DO i = 0, nx |
---|
480 | nzb_tmp(j,i) = MAX( nzb_local(j,i-1), nzb_local(j,i), & |
---|
481 | nzb_local(j,i+1) ) |
---|
482 | ENDDO |
---|
483 | ENDDO |
---|
484 | DO i = nxl, nxr |
---|
485 | DO j = nys, nyn |
---|
486 | nzb_s_outer(j,i) = MAX( nzb_tmp(j-1,i), nzb_tmp(j,i), & |
---|
487 | nzb_tmp(j+1,i) ) |
---|
488 | ENDDO |
---|
489 | ! |
---|
490 | !-- non-cyclic boundary conditions (overwritten by call of |
---|
491 | !-- exchange_horiz_2d_int below in case of cyclic boundary conditions) |
---|
492 | IF ( nys == 0 ) THEN |
---|
493 | j = -1 |
---|
494 | nzb_s_outer(j,i) = MAX( nzb_tmp(j+1,i), nzb_tmp(j,i) ) |
---|
495 | ENDIF |
---|
496 | IF ( nys == ny ) THEN |
---|
497 | j = ny + 1 |
---|
498 | nzb_s_outer(j,i) = MAX( nzb_tmp(j-1,i), nzb_tmp(j,i) ) |
---|
499 | ENDIF |
---|
500 | ENDDO |
---|
501 | ! |
---|
502 | !-- nzb_w_outer: |
---|
503 | !-- identical to nzb_s_outer |
---|
504 | nzb_w_outer = nzb_s_outer |
---|
505 | |
---|
506 | ! |
---|
507 | !-- nzb_u_inner: |
---|
508 | !-- extend nzb_local rightwards only |
---|
509 | nzb_tmp = nzb_local |
---|
510 | DO j = -1, ny + 1 |
---|
511 | DO i = 0, nx + 1 |
---|
512 | nzb_tmp(j,i) = MAX( nzb_local(j,i-1), nzb_local(j,i) ) |
---|
513 | ENDDO |
---|
514 | ENDDO |
---|
515 | nzb_u_inner = nzb_tmp(nys-1:nyn+1,nxl-1:nxr+1) |
---|
516 | |
---|
517 | ! |
---|
518 | !-- nzb_u_outer: |
---|
519 | !-- extend current nzb_tmp (nzb_u_inner) north-/southwards |
---|
520 | DO i = nxl, nxr |
---|
521 | DO j = nys, nyn |
---|
522 | nzb_u_outer(j,i) = MAX( nzb_tmp(j-1,i), nzb_tmp(j,i), & |
---|
523 | nzb_tmp(j+1,i) ) |
---|
524 | ENDDO |
---|
525 | ! |
---|
526 | !-- non-cyclic boundary conditions (overwritten by call of |
---|
527 | !-- exchange_horiz_2d_int below in case of cyclic boundary conditions) |
---|
528 | IF ( nys == 0 ) THEN |
---|
529 | j = -1 |
---|
530 | nzb_u_outer(j,i) = MAX( nzb_tmp(j+1,i), nzb_tmp(j,i) ) |
---|
531 | ENDIF |
---|
532 | IF ( nys == ny ) THEN |
---|
533 | j = ny + 1 |
---|
534 | nzb_u_outer(j,i) = MAX( nzb_tmp(j-1,i), nzb_tmp(j,i) ) |
---|
535 | ENDIF |
---|
536 | ENDDO |
---|
537 | |
---|
538 | ! |
---|
539 | !-- nzb_v_inner: |
---|
540 | !-- extend nzb_local northwards only |
---|
541 | nzb_tmp = nzb_local |
---|
542 | DO i = -1, nx + 1 |
---|
543 | DO j = 0, ny + 1 |
---|
544 | nzb_tmp(j,i) = MAX( nzb_local(j-1,i), nzb_local(j,i) ) |
---|
545 | ENDDO |
---|
546 | ENDDO |
---|
547 | nzb_v_inner = nzb_tmp(nys-1:nyn+1,nxl-1:nxr+1) |
---|
548 | |
---|
549 | ! |
---|
550 | !-- nzb_v_outer: |
---|
551 | !-- extend current nzb_tmp (nzb_v_inner) right-/leftwards |
---|
552 | DO j = nys, nyn |
---|
553 | DO i = nxl, nxr |
---|
554 | nzb_v_outer(j,i) = MAX( nzb_tmp(j,i-1), nzb_tmp(j,i), & |
---|
555 | nzb_tmp(j,i+1) ) |
---|
556 | ENDDO |
---|
557 | ! |
---|
558 | !-- non-cyclic boundary conditions (overwritten by call of |
---|
559 | !-- exchange_horiz_2d_int below in case of cyclic boundary conditions) |
---|
560 | IF ( nxl == 0 ) THEN |
---|
561 | i = -1 |
---|
562 | nzb_v_outer(j,i) = MAX( nzb_tmp(j,i+1), nzb_tmp(j,i) ) |
---|
563 | ENDIF |
---|
564 | IF ( nxr == nx ) THEN |
---|
565 | i = nx + 1 |
---|
566 | nzb_v_outer(j,i) = MAX( nzb_tmp(j,i-1), nzb_tmp(j,i) ) |
---|
567 | ENDIF |
---|
568 | ENDDO |
---|
569 | |
---|
570 | ! |
---|
571 | !-- Exchange of lateral boundary values (parallel computers) and cyclic |
---|
572 | !-- boundary conditions, if applicable. |
---|
573 | !-- Since nzb_s_inner and nzb_w_inner are derived directly from nzb_local |
---|
574 | !-- they do not require exchange and are not included here. |
---|
575 | CALL exchange_horiz_2d_int( nzb_u_inner ) |
---|
576 | CALL exchange_horiz_2d_int( nzb_u_outer ) |
---|
577 | CALL exchange_horiz_2d_int( nzb_v_inner ) |
---|
578 | CALL exchange_horiz_2d_int( nzb_v_outer ) |
---|
579 | CALL exchange_horiz_2d_int( nzb_w_outer ) |
---|
580 | CALL exchange_horiz_2d_int( nzb_s_outer ) |
---|
581 | |
---|
582 | ! |
---|
583 | !-- Allocate and set the arrays containing the topography height |
---|
584 | IF ( myid == 0 ) THEN |
---|
585 | |
---|
586 | ALLOCATE( zu_s_inner(0:nx+1,0:ny+1), zw_w_inner(0:nx+1,0:ny+1) ) |
---|
587 | |
---|
588 | DO i = 0, nx + 1 |
---|
589 | DO j = 0, ny + 1 |
---|
590 | zu_s_inner(i,j) = zu(nzb_local(j,i)) |
---|
591 | zw_w_inner(i,j) = zw(nzb_local(j,i)) |
---|
592 | ENDDO |
---|
593 | ENDDO |
---|
594 | |
---|
595 | ENDIF |
---|
596 | |
---|
597 | ENDIF |
---|
598 | |
---|
599 | ! |
---|
600 | !-- Preliminary: to be removed after completion of the topography code! |
---|
601 | !-- Set the former default k index arrays nzb_2d |
---|
602 | nzb_2d = nzb |
---|
603 | |
---|
604 | ! |
---|
605 | !-- Set the individual index arrays which define the k index from which on |
---|
606 | !-- the usual finite difference form (which does not use surface fluxes) is |
---|
607 | !-- applied |
---|
608 | IF ( prandtl_layer .OR. use_surface_fluxes ) THEN |
---|
609 | nzb_diff_u = nzb_u_inner + 2 |
---|
610 | nzb_diff_v = nzb_v_inner + 2 |
---|
611 | nzb_diff_s_inner = nzb_s_inner + 2 |
---|
612 | nzb_diff_s_outer = nzb_s_outer + 2 |
---|
613 | ELSE |
---|
614 | nzb_diff_u = nzb_u_inner + 1 |
---|
615 | nzb_diff_v = nzb_v_inner + 1 |
---|
616 | nzb_diff_s_inner = nzb_s_inner + 1 |
---|
617 | nzb_diff_s_outer = nzb_s_outer + 1 |
---|
618 | ENDIF |
---|
619 | |
---|
620 | ! |
---|
621 | !-- Calculation of wall switches and factors required by diffusion_u/v.f90 and |
---|
622 | !-- for limitation of near-wall mixing length l_wall further below |
---|
623 | corner_nl = 0 |
---|
624 | corner_nr = 0 |
---|
625 | corner_sl = 0 |
---|
626 | corner_sr = 0 |
---|
627 | wall_l = 0 |
---|
628 | wall_n = 0 |
---|
629 | wall_r = 0 |
---|
630 | wall_s = 0 |
---|
631 | |
---|
632 | DO i = nxl, nxr |
---|
633 | DO j = nys, nyn |
---|
634 | ! |
---|
635 | !-- u-component |
---|
636 | IF ( nzb_u_outer(j,i) > nzb_u_outer(j+1,i) ) THEN |
---|
637 | wall_u(j,i) = 1.0 ! north wall (location of adjacent fluid) |
---|
638 | fym(j,i) = 0.0 |
---|
639 | fyp(j,i) = 1.0 |
---|
640 | ELSEIF ( nzb_u_outer(j,i) > nzb_u_outer(j-1,i) ) THEN |
---|
641 | wall_u(j,i) = 1.0 ! south wall (location of adjacent fluid) |
---|
642 | fym(j,i) = 1.0 |
---|
643 | fyp(j,i) = 0.0 |
---|
644 | ENDIF |
---|
645 | ! |
---|
646 | !-- v-component |
---|
647 | IF ( nzb_v_outer(j,i) > nzb_v_outer(j,i+1) ) THEN |
---|
648 | wall_v(j,i) = 1.0 ! rigth wall (location of adjacent fluid) |
---|
649 | fxm(j,i) = 0.0 |
---|
650 | fxp(j,i) = 1.0 |
---|
651 | ELSEIF ( nzb_v_outer(j,i) > nzb_v_outer(j,i-1) ) THEN |
---|
652 | wall_v(j,i) = 1.0 ! left wall (location of adjacent fluid) |
---|
653 | fxm(j,i) = 1.0 |
---|
654 | fxp(j,i) = 0.0 |
---|
655 | ENDIF |
---|
656 | ! |
---|
657 | !-- w-component, also used for scalars, separate arrays for shear |
---|
658 | !-- production of tke |
---|
659 | IF ( nzb_w_outer(j,i) > nzb_w_outer(j+1,i) ) THEN |
---|
660 | wall_e_y(j,i) = 1.0 ! north wall (location of adjacent fluid) |
---|
661 | wall_w_y(j,i) = 1.0 |
---|
662 | fwym(j,i) = 0.0 |
---|
663 | fwyp(j,i) = 1.0 |
---|
664 | ELSEIF ( nzb_w_outer(j,i) > nzb_w_outer(j-1,i) ) THEN |
---|
665 | wall_e_y(j,i) = -1.0 ! south wall (location of adjacent fluid) |
---|
666 | wall_w_y(j,i) = 1.0 |
---|
667 | fwym(j,i) = 1.0 |
---|
668 | fwyp(j,i) = 0.0 |
---|
669 | ENDIF |
---|
670 | IF ( nzb_w_outer(j,i) > nzb_w_outer(j,i+1) ) THEN |
---|
671 | wall_e_x(j,i) = 1.0 ! right wall (location of adjacent fluid) |
---|
672 | wall_w_x(j,i) = 1.0 |
---|
673 | fwxm(j,i) = 0.0 |
---|
674 | fwxp(j,i) = 1.0 |
---|
675 | ELSEIF ( nzb_w_outer(j,i) > nzb_w_outer(j,i-1) ) THEN |
---|
676 | wall_e_x(j,i) = -1.0 ! left wall (location of adjacent fluid) |
---|
677 | wall_w_x(j,i) = 1.0 |
---|
678 | fwxm(j,i) = 1.0 |
---|
679 | fwxp(j,i) = 0.0 |
---|
680 | ENDIF |
---|
681 | ! |
---|
682 | !-- Wall and corner locations inside buildings for limitation of |
---|
683 | !-- near-wall mixing length l_wall |
---|
684 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j+1,i) ) THEN |
---|
685 | |
---|
686 | wall_n(j,i) = nzb_s_inner(j+1,i) + 1 ! North wall |
---|
687 | |
---|
688 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j,i-1) ) THEN |
---|
689 | corner_nl(j,i) = MAX( nzb_s_inner(j+1,i), & ! Northleft corner |
---|
690 | nzb_s_inner(j,i-1) ) + 1 |
---|
691 | ENDIF |
---|
692 | |
---|
693 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j,i+1) ) THEN |
---|
694 | corner_nr(j,i) = MAX( nzb_s_inner(j+1,i), & ! Northright corner |
---|
695 | nzb_s_inner(j,i+1) ) + 1 |
---|
696 | ENDIF |
---|
697 | |
---|
698 | ENDIF |
---|
699 | |
---|
700 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j-1,i) ) THEN |
---|
701 | |
---|
702 | wall_s(j,i) = nzb_s_inner(j-1,i) + 1 ! South wall |
---|
703 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j,i-1) ) THEN |
---|
704 | corner_sl(j,i) = MAX( nzb_s_inner(j-1,i), & ! Southleft corner |
---|
705 | nzb_s_inner(j,i-1) ) + 1 |
---|
706 | ENDIF |
---|
707 | |
---|
708 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j,i+1) ) THEN |
---|
709 | corner_sr(j,i) = MAX( nzb_s_inner(j-1,i), & ! Southright corner |
---|
710 | nzb_s_inner(j,i+1) ) + 1 |
---|
711 | ENDIF |
---|
712 | |
---|
713 | ENDIF |
---|
714 | |
---|
715 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j,i-1) ) THEN |
---|
716 | wall_l(j,i) = nzb_s_inner(j,i-1) + 1 ! Left wall |
---|
717 | ENDIF |
---|
718 | |
---|
719 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j,i+1) ) THEN |
---|
720 | wall_r(j,i) = nzb_s_inner(j,i+1) + 1 ! Right wall |
---|
721 | ENDIF |
---|
722 | |
---|
723 | ENDDO |
---|
724 | ENDDO |
---|
725 | |
---|
726 | ! |
---|
727 | !-- In case of topography: limit near-wall mixing length l_wall further: |
---|
728 | !-- Go through all points of the subdomain one by one and look for the closest |
---|
729 | !-- surface |
---|
730 | IF ( TRIM(topography) /= 'flat' ) THEN |
---|
731 | DO i = nxl, nxr |
---|
732 | DO j = nys, nyn |
---|
733 | |
---|
734 | nzb_si = nzb_s_inner(j,i) |
---|
735 | vi = vertical_influence(nzb_si) |
---|
736 | |
---|
737 | IF ( wall_n(j,i) > 0 ) THEN |
---|
738 | ! |
---|
739 | !-- North wall (y distance) |
---|
740 | DO k = wall_n(j,i), nzb_si |
---|
741 | l_wall(k,j+1,i) = MIN( l_wall(k,j+1,i), 0.5 * dy ) |
---|
742 | ENDDO |
---|
743 | ! |
---|
744 | !-- Above North wall (yz distance) |
---|
745 | DO k = nzb_si + 1, nzb_si + vi |
---|
746 | l_wall(k,j+1,i) = MIN( l_wall(k,j+1,i), & |
---|
747 | SQRT( 0.25 * dy**2 + & |
---|
748 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
749 | ENDDO |
---|
750 | ! |
---|
751 | !-- Northleft corner (xy distance) |
---|
752 | IF ( corner_nl(j,i) > 0 ) THEN |
---|
753 | DO k = corner_nl(j,i), nzb_si |
---|
754 | l_wall(k,j+1,i-1) = MIN( l_wall(k,j+1,i-1), & |
---|
755 | 0.5 * SQRT( dx**2 + dy**2 ) ) |
---|
756 | ENDDO |
---|
757 | ! |
---|
758 | !-- Above Northleft corner (xyz distance) |
---|
759 | DO k = nzb_si + 1, nzb_si + vi |
---|
760 | l_wall(k,j+1,i-1) = MIN( l_wall(k,j+1,i-1), & |
---|
761 | SQRT( 0.25 * (dx**2 + dy**2) + & |
---|
762 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
763 | ENDDO |
---|
764 | ENDIF |
---|
765 | ! |
---|
766 | !-- Northright corner (xy distance) |
---|
767 | IF ( corner_nr(j,i) > 0 ) THEN |
---|
768 | DO k = corner_nr(j,i), nzb_si |
---|
769 | l_wall(k,j+1,i+1) = MIN( l_wall(k,j+1,i+1), & |
---|
770 | 0.5 * SQRT( dx**2 + dy**2 ) ) |
---|
771 | ENDDO |
---|
772 | ! |
---|
773 | !-- Above northright corner (xyz distance) |
---|
774 | DO k = nzb_si + 1, nzb_si + vi |
---|
775 | l_wall(k,j+1,i+1) = MIN( l_wall(k,j+1,i+1), & |
---|
776 | SQRT( 0.25 * (dx**2 + dy**2) + & |
---|
777 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
778 | ENDDO |
---|
779 | ENDIF |
---|
780 | ENDIF |
---|
781 | |
---|
782 | IF ( wall_s(j,i) > 0 ) THEN |
---|
783 | ! |
---|
784 | !-- South wall (y distance) |
---|
785 | DO k = wall_s(j,i), nzb_si |
---|
786 | l_wall(k,j-1,i) = MIN( l_wall(k,j-1,i), 0.5 * dy ) |
---|
787 | ENDDO |
---|
788 | ! |
---|
789 | !-- Above south wall (yz distance) |
---|
790 | DO k = nzb_si + 1, & |
---|
791 | nzb_si + vi |
---|
792 | l_wall(k,j-1,i) = MIN( l_wall(k,j-1,i), & |
---|
793 | SQRT( 0.25 * dy**2 + & |
---|
794 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
795 | ENDDO |
---|
796 | ! |
---|
797 | !-- Southleft corner (xy distance) |
---|
798 | IF ( corner_sl(j,i) > 0 ) THEN |
---|
799 | DO k = corner_sl(j,i), nzb_si |
---|
800 | l_wall(k,j-1,i-1) = MIN( l_wall(k,j-1,i-1), & |
---|
801 | 0.5 * SQRT( dx**2 + dy**2 ) ) |
---|
802 | ENDDO |
---|
803 | ! |
---|
804 | !-- Above southleft corner (xyz distance) |
---|
805 | DO k = nzb_si + 1, nzb_si + vi |
---|
806 | l_wall(k,j-1,i-1) = MIN( l_wall(k,j-1,i-1), & |
---|
807 | SQRT( 0.25 * (dx**2 + dy**2) + & |
---|
808 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
809 | ENDDO |
---|
810 | ENDIF |
---|
811 | ! |
---|
812 | !-- Southright corner (xy distance) |
---|
813 | IF ( corner_sr(j,i) > 0 ) THEN |
---|
814 | DO k = corner_sr(j,i), nzb_si |
---|
815 | l_wall(k,j-1,i+1) = MIN( l_wall(k,j-1,i+1), & |
---|
816 | 0.5 * SQRT( dx**2 + dy**2 ) ) |
---|
817 | ENDDO |
---|
818 | ! |
---|
819 | !-- Above southright corner (xyz distance) |
---|
820 | DO k = nzb_si + 1, nzb_si + vi |
---|
821 | l_wall(k,j-1,i+1) = MIN( l_wall(k,j-1,i+1), & |
---|
822 | SQRT( 0.25 * (dx**2 + dy**2) + & |
---|
823 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
824 | ENDDO |
---|
825 | ENDIF |
---|
826 | |
---|
827 | ENDIF |
---|
828 | |
---|
829 | IF ( wall_l(j,i) > 0 ) THEN |
---|
830 | ! |
---|
831 | !-- Left wall (x distance) |
---|
832 | DO k = wall_l(j,i), nzb_si |
---|
833 | l_wall(k,j,i-1) = MIN( l_wall(k,j,i-1), 0.5 * dx ) |
---|
834 | ENDDO |
---|
835 | ! |
---|
836 | !-- Above left wall (xz distance) |
---|
837 | DO k = nzb_si + 1, nzb_si + vi |
---|
838 | l_wall(k,j,i-1) = MIN( l_wall(k,j,i-1), & |
---|
839 | SQRT( 0.25 * dx**2 + & |
---|
840 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
841 | ENDDO |
---|
842 | ENDIF |
---|
843 | |
---|
844 | IF ( wall_r(j,i) > 0 ) THEN |
---|
845 | ! |
---|
846 | !-- Right wall (x distance) |
---|
847 | DO k = wall_r(j,i), nzb_si |
---|
848 | l_wall(k,j,i+1) = MIN( l_wall(k,j,i+1), 0.5 * dx ) |
---|
849 | ENDDO |
---|
850 | ! |
---|
851 | !-- Above right wall (xz distance) |
---|
852 | DO k = nzb_si + 1, nzb_si + vi |
---|
853 | l_wall(k,j,i+1) = MIN( l_wall(k,j,i+1), & |
---|
854 | SQRT( 0.25 * dx**2 + & |
---|
855 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
856 | ENDDO |
---|
857 | |
---|
858 | ENDIF |
---|
859 | |
---|
860 | ENDDO |
---|
861 | ENDDO |
---|
862 | |
---|
863 | ENDIF |
---|
864 | |
---|
865 | ! |
---|
866 | !-- Multiplication with wall_adjustment_factor |
---|
867 | l_wall = wall_adjustment_factor * l_wall |
---|
868 | |
---|
869 | ! |
---|
870 | !-- Need to set lateral boundary conditions for l_wall |
---|
871 | CALL exchange_horiz( l_wall ) |
---|
872 | |
---|
873 | DEALLOCATE( corner_nl, corner_nr, corner_sl, corner_sr, nzb_local, & |
---|
874 | nzb_tmp, vertical_influence, wall_l, wall_n, wall_r, wall_s ) |
---|
875 | |
---|
876 | |
---|
877 | END SUBROUTINE init_grid |
---|