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