1 | !> @file init_pegrid.f90 |
---|
2 | !------------------------------------------------------------------------------! |
---|
3 | ! This file is part of PALM. |
---|
4 | ! |
---|
5 | ! PALM is free software: you can redistribute it and/or modify it under the |
---|
6 | ! terms of the GNU General Public License as published by the Free Software |
---|
7 | ! Foundation, either version 3 of the License, or (at your option) any later |
---|
8 | ! version. |
---|
9 | ! |
---|
10 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
11 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
12 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
13 | ! |
---|
14 | ! You should have received a copy of the GNU General Public License along with |
---|
15 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
16 | ! |
---|
17 | ! Copyright 1997-2017 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ------------------ |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: init_pegrid.f90 2600 2017-11-01 14:11:20Z basit $ |
---|
27 | ! calculation of block-I/O quantitites removed (is now done in parin) |
---|
28 | ! |
---|
29 | ! 2516 2017-10-04 11:03:04Z suehring |
---|
30 | ! Remove tabs |
---|
31 | ! |
---|
32 | ! 2514 2017-10-04 09:52:37Z suehring |
---|
33 | ! Redundant preprocessor directives removed |
---|
34 | ! |
---|
35 | ! 2372 2017-08-25 12:37:32Z sward |
---|
36 | ! Shifted cyclic boundary conditions implemented |
---|
37 | ! |
---|
38 | ! 2365 2017-08-21 14:59:59Z kanani |
---|
39 | ! Vertical nesting implemented (SadiqHuq) |
---|
40 | ! |
---|
41 | ! 2300 2017-06-29 13:31:14Z raasch |
---|
42 | ! host-specific settings removed |
---|
43 | ! |
---|
44 | ! 2298 2017-06-29 09:28:18Z raasch |
---|
45 | ! MPI2 related parts removed |
---|
46 | ! |
---|
47 | ! 2271 2017-06-09 12:34:55Z sward |
---|
48 | ! Error message changed |
---|
49 | ! |
---|
50 | ! 2259 2017-06-08 09:09:11Z gronemeier |
---|
51 | ! Implemented synthetic turbulence generator |
---|
52 | ! |
---|
53 | ! 2238 2017-05-31 16:49:16Z suehring |
---|
54 | ! Remove unnecessary module load of pmc_interface |
---|
55 | ! |
---|
56 | ! 2231 2017-05-30 16:44:33Z suehring |
---|
57 | ! |
---|
58 | ! 2200 2017-04-11 11:37:51Z suehring |
---|
59 | ! monotonic_adjustment removed |
---|
60 | ! |
---|
61 | ! 2197 2017-03-24 02:25:00Z raasch |
---|
62 | ! bugfix: do not allow odd values for nz at the coarsest grid level in case of |
---|
63 | ! optimized multigrid solver |
---|
64 | ! |
---|
65 | ! 2180 2017-03-17 13:33:05Z hellstea |
---|
66 | ! Checks to ensure (2178) that pdims match the grid dimensions in the |
---|
67 | ! automatic determination of pdims are canceled as unnecessary |
---|
68 | ! |
---|
69 | ! 2178 2017-03-17 11:07:39Z hellstea |
---|
70 | ! Checks to ensure that pdims match the grid dimensions are added in the |
---|
71 | ! automatic determination of pdims |
---|
72 | ! |
---|
73 | ! 2050 2016-11-08 15:00:55Z gronemeier |
---|
74 | ! Implement turbulent outflow condition |
---|
75 | ! |
---|
76 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
77 | ! Forced header and separation lines into 80 columns |
---|
78 | ! |
---|
79 | ! 1968 2016-07-18 12:01:49Z suehring |
---|
80 | ! Extent MPI-datatypes for exchange of 2D-INTEGER arrays on coarser multigrid |
---|
81 | ! level |
---|
82 | ! |
---|
83 | ! 1964 2016-07-14 15:35:18Z hellstea |
---|
84 | ! Bugfix: erroneous setting of nest_bound_l/r/s/n = .TRUE. for vertical nesting mode removed. |
---|
85 | ! |
---|
86 | ! 1923 2016-05-31 16:37:07Z boeske |
---|
87 | ! Initial version of purely vertical nesting introduced. |
---|
88 | ! |
---|
89 | ! 1922 2016-05-31 16:36:08Z boeske |
---|
90 | ! Bugfix: array transposition checks restricted to cases if a fourier |
---|
91 | ! transform is used , removed unused variable nnx_z |
---|
92 | ! |
---|
93 | ! 1833 2016-04-07 14:23:03Z raasch |
---|
94 | ! spectra related variables moved to spectra_mod |
---|
95 | ! |
---|
96 | ! 1815 2016-04-06 13:49:59Z raasch |
---|
97 | ! cpp-directives for intel openmp bug removed |
---|
98 | ! |
---|
99 | ! 1804 2016-04-05 16:30:18Z maronga |
---|
100 | ! Removed code for parameter file check (__check) |
---|
101 | ! |
---|
102 | ! 1779 2016-03-03 08:01:28Z raasch |
---|
103 | ! changes regarding nested domain removed: virtual PE grid will be automatically |
---|
104 | ! calculated for nested runs too |
---|
105 | ! |
---|
106 | ! 1764 2016-02-28 12:45:19Z raasch |
---|
107 | ! cpp-statements for nesting removed |
---|
108 | ! |
---|
109 | ! 1762 2016-02-25 12:31:13Z hellstea |
---|
110 | ! Introduction of nested domain feature |
---|
111 | ! |
---|
112 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
113 | ! Code annotations made doxygen readable |
---|
114 | ! |
---|
115 | ! 1677 2015-10-02 13:25:23Z boeske |
---|
116 | ! New MPI-data types for exchange of 3D integer arrays. |
---|
117 | ! |
---|
118 | ! 1575 2015-03-27 09:56:27Z raasch |
---|
119 | ! adjustments for psolver-queries, calculation of ngp_xz added |
---|
120 | ! |
---|
121 | ! 1565 2015-03-09 20:59:31Z suehring |
---|
122 | ! Refine if-clause for setting nbgp. |
---|
123 | ! |
---|
124 | ! 1557 2015-03-05 16:43:04Z suehring |
---|
125 | ! Adjustment for monotonic limiter |
---|
126 | ! |
---|
127 | ! 1468 2014-09-24 14:06:57Z maronga |
---|
128 | ! Adapted for use on up to 6-digit processor cores |
---|
129 | ! |
---|
130 | ! 1435 2014-07-21 10:37:02Z keck |
---|
131 | ! bugfix: added missing parameter coupling_mode_remote to ONLY-attribute |
---|
132 | ! |
---|
133 | ! 1402 2014-05-09 14:25:13Z raasch |
---|
134 | ! location messages modified |
---|
135 | ! |
---|
136 | ! 1384 2014-05-02 14:31:06Z raasch |
---|
137 | ! location messages added |
---|
138 | ! |
---|
139 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
140 | ! REAL constants provided with KIND-attribute |
---|
141 | ! |
---|
142 | ! 1322 2014-03-20 16:38:49Z raasch |
---|
143 | ! REAL functions provided with KIND-attribute |
---|
144 | ! |
---|
145 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
146 | ! ONLY-attribute added to USE-statements, |
---|
147 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
148 | ! kinds are defined in new module kinds, |
---|
149 | ! revision history before 2012 removed, |
---|
150 | ! comment fields (!:) to be used for variable explanations added to |
---|
151 | ! all variable declaration statements |
---|
152 | ! |
---|
153 | ! 1304 2014-03-12 10:29:42Z raasch |
---|
154 | ! bugfix: single core MPI runs missed some settings of transpose indices |
---|
155 | ! |
---|
156 | ! 1212 2013-08-15 08:46:27Z raasch |
---|
157 | ! error message for poisfft_hybrid removed |
---|
158 | ! |
---|
159 | ! 1159 2013-05-21 11:58:22Z fricke |
---|
160 | ! dirichlet/neumann and neumann/dirichlet removed |
---|
161 | ! |
---|
162 | ! 1139 2013-04-18 07:25:03Z raasch |
---|
163 | ! bugfix for calculating the id of the PE carrying the recycling plane |
---|
164 | ! |
---|
165 | ! 1111 2013-03-08 23:54:10Z raasch |
---|
166 | ! initialization of poisfft moved to module poisfft |
---|
167 | ! |
---|
168 | ! 1092 2013-02-02 11:24:22Z raasch |
---|
169 | ! unused variables removed |
---|
170 | ! |
---|
171 | ! 1056 2012-11-16 15:28:04Z raasch |
---|
172 | ! Indices for arrays n.._mg start from zero due to definition of arrays f2 and |
---|
173 | ! p2 as automatic arrays in recursive subroutine next_mg_level |
---|
174 | ! |
---|
175 | ! 1041 2012-11-06 02:36:29Z raasch |
---|
176 | ! a 2d virtual processor topology is used by default for all machines |
---|
177 | ! |
---|
178 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
179 | ! code put under GPL (PALM 3.9) |
---|
180 | ! |
---|
181 | ! 1003 2012-09-14 14:35:53Z raasch |
---|
182 | ! subdomains must have identical size (grid matching = "match" removed) |
---|
183 | ! |
---|
184 | ! 1001 2012-09-13 14:08:46Z raasch |
---|
185 | ! all actions concerning upstream-spline-method removed |
---|
186 | ! |
---|
187 | ! 978 2012-08-09 08:28:32Z fricke |
---|
188 | ! dirichlet/neumann and neumann/dirichlet added |
---|
189 | ! nxlu and nysv are also calculated for inflow boundary |
---|
190 | ! |
---|
191 | ! 809 2012-01-30 13:32:58Z maronga |
---|
192 | ! Bugfix: replaced .AND. and .NOT. with && and ! in the preprocessor directives |
---|
193 | ! |
---|
194 | ! 807 2012-01-25 11:53:51Z maronga |
---|
195 | ! New cpp directive "__check" implemented which is used by check_namelist_files |
---|
196 | ! |
---|
197 | ! Revision 1.1 1997/07/24 11:15:09 raasch |
---|
198 | ! Initial revision |
---|
199 | ! |
---|
200 | ! |
---|
201 | ! Description: |
---|
202 | ! ------------ |
---|
203 | !> Determination of the virtual processor topology (if not prescribed by the |
---|
204 | !> user)and computation of the grid point number and array bounds of the local |
---|
205 | !> domains. |
---|
206 | !------------------------------------------------------------------------------! |
---|
207 | SUBROUTINE init_pegrid |
---|
208 | |
---|
209 | |
---|
210 | USE control_parameters, & |
---|
211 | ONLY: bc_lr, bc_ns, coupling_mode, coupling_mode_remote, & |
---|
212 | coupling_topology, gathered_size, grid_level, & |
---|
213 | grid_level_count, inflow_l, inflow_n, inflow_r, inflow_s, & |
---|
214 | maximum_grid_level, message_string, & |
---|
215 | mg_switch_to_pe0_level, momentum_advec, nest_bound_l, & |
---|
216 | nest_bound_n, nest_bound_r, nest_bound_s, nest_domain, neutral, & |
---|
217 | psolver, outflow_l, outflow_n, outflow_r, outflow_s, & |
---|
218 | outflow_source_plane, recycling_width, scalar_advec, & |
---|
219 | subdomain_size, turbulent_outflow, y_shift |
---|
220 | |
---|
221 | USE grid_variables, & |
---|
222 | ONLY: dx |
---|
223 | |
---|
224 | USE indices, & |
---|
225 | ONLY: mg_loc_ind, nbgp, nnx, nny, nnz, nx, nx_a, nx_o, nxl, nxl_mg, & |
---|
226 | nxlu, nxr, nxr_mg, ny, ny_a, ny_o, nyn, nyn_mg, nys, nys_mg, & |
---|
227 | nysv, nz, nzb, nzt, nzt_mg, wall_flags_1, wall_flags_2, & |
---|
228 | wall_flags_3, wall_flags_4, wall_flags_5, wall_flags_6, & |
---|
229 | wall_flags_7, wall_flags_8, wall_flags_9, wall_flags_10 |
---|
230 | |
---|
231 | USE kinds |
---|
232 | |
---|
233 | USE pegrid |
---|
234 | |
---|
235 | USE spectra_mod, & |
---|
236 | ONLY: calculate_spectra, dt_dosp |
---|
237 | |
---|
238 | USE synthetic_turbulence_generator_mod, & |
---|
239 | ONLY: use_synthetic_turbulence_generator |
---|
240 | |
---|
241 | USE transpose_indices, & |
---|
242 | ONLY: nxl_y, nxl_yd, nxl_z, nxr_y, nxr_yd, nxr_z, nyn_x, nyn_z, nys_x,& |
---|
243 | nys_z, nzb_x, nzb_y, nzb_yd, nzt_x, nzt_yd, nzt_y |
---|
244 | |
---|
245 | USE vertical_nesting_mod, & |
---|
246 | ONLY: vnested, vnest_init_pegrid_domain, vnest_init_pegrid_rank |
---|
247 | |
---|
248 | IMPLICIT NONE |
---|
249 | |
---|
250 | INTEGER(iwp) :: i !< |
---|
251 | INTEGER(iwp) :: id_inflow_l !< |
---|
252 | INTEGER(iwp) :: id_outflow_l !< local value of id_outflow |
---|
253 | INTEGER(iwp) :: id_outflow_source_l !< local value of id_outflow_source |
---|
254 | INTEGER(iwp) :: id_recycling_l !< |
---|
255 | INTEGER(iwp) :: ind(5) !< |
---|
256 | INTEGER(iwp) :: j !< |
---|
257 | INTEGER(iwp) :: k !< |
---|
258 | INTEGER(iwp) :: maximum_grid_level_l !< |
---|
259 | INTEGER(iwp) :: mg_levels_x !< |
---|
260 | INTEGER(iwp) :: mg_levels_y !< |
---|
261 | INTEGER(iwp) :: mg_levels_z !< |
---|
262 | INTEGER(iwp) :: mg_switch_to_pe0_level_l !< |
---|
263 | INTEGER(iwp) :: nnx_y !< |
---|
264 | INTEGER(iwp) :: nnx_z !< |
---|
265 | INTEGER(iwp) :: nny_x !< |
---|
266 | INTEGER(iwp) :: nny_z !< |
---|
267 | INTEGER(iwp) :: nnz_x !< |
---|
268 | INTEGER(iwp) :: nnz_y !< |
---|
269 | INTEGER(iwp) :: numproc_sqr !< |
---|
270 | INTEGER(iwp) :: nxl_l !< |
---|
271 | INTEGER(iwp) :: nxr_l !< |
---|
272 | INTEGER(iwp) :: nyn_l !< |
---|
273 | INTEGER(iwp) :: nys_l !< |
---|
274 | INTEGER(iwp) :: nzb_l !< |
---|
275 | INTEGER(iwp) :: nzt_l !< |
---|
276 | INTEGER(iwp) :: omp_get_num_threads !< |
---|
277 | |
---|
278 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: ind_all !< |
---|
279 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: nxlf !< |
---|
280 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: nxrf !< |
---|
281 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: nynf !< |
---|
282 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: nysf !< |
---|
283 | |
---|
284 | INTEGER(iwp), DIMENSION(2) :: pdims_remote !< |
---|
285 | INTEGER(iwp) :: lcoord(2) !< PE coordinates of left neighbor along x and y |
---|
286 | INTEGER(iwp) :: rcoord(2) !< PE coordinates of right neighbor along x and y |
---|
287 | |
---|
288 | ! |
---|
289 | !-- Get the number of OpenMP threads |
---|
290 | !$OMP PARALLEL |
---|
291 | !$ threads_per_task = omp_get_num_threads() |
---|
292 | !$OMP END PARALLEL |
---|
293 | |
---|
294 | |
---|
295 | #if defined( __parallel ) |
---|
296 | |
---|
297 | CALL location_message( 'creating virtual PE grids + MPI derived data types', & |
---|
298 | .FALSE. ) |
---|
299 | |
---|
300 | ! |
---|
301 | !-- Determine the processor topology or check it, if prescribed by the user |
---|
302 | IF ( npex == -1 .AND. npey == -1 ) THEN |
---|
303 | |
---|
304 | ! |
---|
305 | !-- Automatic determination of the topology |
---|
306 | numproc_sqr = SQRT( REAL( numprocs, KIND=wp ) ) |
---|
307 | pdims(1) = MAX( numproc_sqr , 1 ) |
---|
308 | DO WHILE ( MOD( numprocs , pdims(1) ) /= 0 ) |
---|
309 | pdims(1) = pdims(1) - 1 |
---|
310 | ENDDO |
---|
311 | pdims(2) = numprocs / pdims(1) |
---|
312 | |
---|
313 | ELSEIF ( npex /= -1 .AND. npey /= -1 ) THEN |
---|
314 | |
---|
315 | ! |
---|
316 | !-- Prescribed by user. Number of processors on the prescribed topology |
---|
317 | !-- must be equal to the number of PEs available to the job |
---|
318 | IF ( ( npex * npey ) /= numprocs ) THEN |
---|
319 | WRITE( message_string, * ) 'number of PEs of the prescribed ', & |
---|
320 | 'topology (', npex*npey,') does not match & the number of ', & |
---|
321 | 'PEs available to the job (', numprocs, ')' |
---|
322 | CALL message( 'init_pegrid', 'PA0221', 1, 2, 0, 6, 0 ) |
---|
323 | ENDIF |
---|
324 | pdims(1) = npex |
---|
325 | pdims(2) = npey |
---|
326 | |
---|
327 | ELSE |
---|
328 | ! |
---|
329 | !-- If the processor topology is prescribed by the user, the number of |
---|
330 | !-- PEs must be given in both directions |
---|
331 | message_string = 'if the processor topology is prescribed by th' // & |
---|
332 | 'e user& both values of "npex" and "npey" must be given' // & |
---|
333 | ' in the &NAMELIST-parameter file' |
---|
334 | CALL message( 'init_pegrid', 'PA0222', 1, 2, 0, 6, 0 ) |
---|
335 | |
---|
336 | ENDIF |
---|
337 | |
---|
338 | ! |
---|
339 | !-- If necessary, set horizontal boundary conditions to non-cyclic |
---|
340 | IF ( bc_lr /= 'cyclic' ) cyclic(1) = .FALSE. |
---|
341 | IF ( bc_ns /= 'cyclic' ) cyclic(2) = .FALSE. |
---|
342 | |
---|
343 | |
---|
344 | ! |
---|
345 | !-- Create the virtual processor grid |
---|
346 | CALL MPI_CART_CREATE( comm_palm, ndim, pdims, cyclic, reorder, & |
---|
347 | comm2d, ierr ) |
---|
348 | CALL MPI_COMM_RANK( comm2d, myid, ierr ) |
---|
349 | WRITE (myid_char,'(''_'',I6.6)') myid |
---|
350 | |
---|
351 | CALL MPI_CART_COORDS( comm2d, myid, ndim, pcoord, ierr ) |
---|
352 | CALL MPI_CART_SHIFT( comm2d, 0, 1, pleft, pright, ierr ) |
---|
353 | CALL MPI_CART_SHIFT( comm2d, 1, 1, psouth, pnorth, ierr ) |
---|
354 | |
---|
355 | ! |
---|
356 | !-- In case of cyclic boundary conditions, a y-shift at the boundaries in |
---|
357 | !-- x-direction can be introduced via parameter y_shift. The shift is done |
---|
358 | !-- by modifying the processor grid in such a way that processors located |
---|
359 | !-- at the x-boundary communicate across it to processors with y-coordinate |
---|
360 | !-- shifted by y_shift relative to their own. This feature can not be used |
---|
361 | !-- in combination with an fft pressure solver. It has been implemented to |
---|
362 | !-- counter the effect of streak structures in case of cyclic boundary |
---|
363 | !-- conditions. For a description of these see Munters |
---|
364 | !-- (2016; dx.doi.org/10.1063/1.4941912) |
---|
365 | !-- |
---|
366 | !-- Get coordinates of left and right neighbor on PE grid |
---|
367 | IF ( y_shift /= 0 ) THEN |
---|
368 | |
---|
369 | IF ( bc_lr /= 'cyclic' .OR. bc_ns /= 'cyclic' ) THEN |
---|
370 | message_string = 'y_shift /= 0 is only allowed for cyclic ' // & |
---|
371 | 'boundary conditions in both directions ' |
---|
372 | CALL message( 'check_parameters', 'PA0467', 1, 2, 0, 6, 0 ) |
---|
373 | ENDIF |
---|
374 | IF ( TRIM( psolver ) /= 'multigrid' .AND. & |
---|
375 | TRIM( psolver ) /= 'multigrid_noopt') & |
---|
376 | THEN |
---|
377 | message_string = 'y_shift /= 0 requires a multigrid pressure solver ' |
---|
378 | CALL message( 'check_parameters', 'PA0468', 1, 2, 0, 6, 0 ) |
---|
379 | ENDIF |
---|
380 | |
---|
381 | CALL MPI_CART_COORDS( comm2d, pright, ndim, rcoord, ierr ) |
---|
382 | CALL MPI_CART_COORDS( comm2d, pleft, ndim, lcoord, ierr ) |
---|
383 | |
---|
384 | ! |
---|
385 | !-- If the x(y)-coordinate of the right (left) neighbor is smaller (greater) |
---|
386 | !-- than that of the calling process, then the calling process is located on |
---|
387 | !-- the right (left) boundary of the processor grid. In that case, |
---|
388 | !-- the y-coordinate of that neighbor is increased (decreased) by y_shift. |
---|
389 | !-- The rank of the process with that coordinate is then inquired and the |
---|
390 | !-- neighbor rank for MPI_SENDRECV, pright (pleft) is set to it. |
---|
391 | !-- In this way, the calling process receives a new right (left) neighbor |
---|
392 | !-- for all future MPI_SENDRECV calls. That neighbor has a y-coordinate |
---|
393 | !-- of y+(-)y_shift, where y is the original right (left) neighbor's |
---|
394 | !-- y-coordinate. The modulo-operation ensures that if the neighbor's |
---|
395 | !-- y-coordinate exceeds the grid-boundary, it will be relocated to |
---|
396 | !-- the opposite part of the grid cyclicly. |
---|
397 | IF ( rcoord(1) < pcoord(1) ) THEN |
---|
398 | rcoord(2) = MODULO( rcoord(2) + y_shift, pdims(2) ) |
---|
399 | CALL MPI_CART_RANK( comm2d, rcoord, pright, ierr ) |
---|
400 | ENDIF |
---|
401 | |
---|
402 | IF ( lcoord(1) > pcoord(1) ) THEN |
---|
403 | lcoord(2) = MODULO( lcoord(2) - y_shift, pdims(2) ) |
---|
404 | CALL MPI_CART_RANK( comm2d, lcoord, pleft, ierr ) |
---|
405 | ENDIF |
---|
406 | ENDIF |
---|
407 | |
---|
408 | ! |
---|
409 | !-- Vertical nesting: store four lists that identify partner ranks to exchange |
---|
410 | !-- data |
---|
411 | IF ( vnested ) CALL vnest_init_pegrid_rank |
---|
412 | |
---|
413 | ! |
---|
414 | !-- Determine sub-topologies for transpositions |
---|
415 | !-- Transposition from z to x: |
---|
416 | remain_dims(1) = .TRUE. |
---|
417 | remain_dims(2) = .FALSE. |
---|
418 | CALL MPI_CART_SUB( comm2d, remain_dims, comm1dx, ierr ) |
---|
419 | CALL MPI_COMM_RANK( comm1dx, myidx, ierr ) |
---|
420 | ! |
---|
421 | !-- Transposition from x to y |
---|
422 | remain_dims(1) = .FALSE. |
---|
423 | remain_dims(2) = .TRUE. |
---|
424 | CALL MPI_CART_SUB( comm2d, remain_dims, comm1dy, ierr ) |
---|
425 | CALL MPI_COMM_RANK( comm1dy, myidy, ierr ) |
---|
426 | |
---|
427 | |
---|
428 | ! |
---|
429 | !-- Calculate array bounds along x-direction for every PE. |
---|
430 | ALLOCATE( nxlf(0:pdims(1)-1), nxrf(0:pdims(1)-1), nynf(0:pdims(2)-1), & |
---|
431 | nysf(0:pdims(2)-1) ) |
---|
432 | |
---|
433 | IF ( MOD( nx+1 , pdims(1) ) /= 0 ) THEN |
---|
434 | WRITE( message_string, * ) 'x-direction: gridpoint number (',nx+1,') ',& |
---|
435 | 'is not an& integral divisor of the number ', & |
---|
436 | 'processors (', pdims(1),')' |
---|
437 | CALL message( 'init_pegrid', 'PA0225', 1, 2, 0, 6, 0 ) |
---|
438 | ELSE |
---|
439 | nnx = ( nx + 1 ) / pdims(1) |
---|
440 | IF ( nnx*pdims(1) - ( nx + 1) > nnx ) THEN |
---|
441 | WRITE( message_string, * ) 'x-direction: nx does not match the', & |
---|
442 | 'requirements given by the number of PEs &used', & |
---|
443 | '& please use nx = ', nx - ( pdims(1) - ( nnx*pdims(1) & |
---|
444 | - ( nx + 1 ) ) ), ' instead of nx =', nx |
---|
445 | CALL message( 'init_pegrid', 'PA0226', 1, 2, 0, 6, 0 ) |
---|
446 | ENDIF |
---|
447 | ENDIF |
---|
448 | |
---|
449 | ! |
---|
450 | !-- Left and right array bounds, number of gridpoints |
---|
451 | DO i = 0, pdims(1)-1 |
---|
452 | nxlf(i) = i * nnx |
---|
453 | nxrf(i) = ( i + 1 ) * nnx - 1 |
---|
454 | ENDDO |
---|
455 | |
---|
456 | ! |
---|
457 | !-- Calculate array bounds in y-direction for every PE. |
---|
458 | IF ( MOD( ny+1 , pdims(2) ) /= 0 ) THEN |
---|
459 | WRITE( message_string, * ) 'y-direction: gridpoint number (',ny+1,') ', & |
---|
460 | 'is not an& integral divisor of the number of', & |
---|
461 | 'processors (', pdims(2),')' |
---|
462 | CALL message( 'init_pegrid', 'PA0227', 1, 2, 0, 6, 0 ) |
---|
463 | ELSE |
---|
464 | nny = ( ny + 1 ) / pdims(2) |
---|
465 | IF ( nny*pdims(2) - ( ny + 1) > nny ) THEN |
---|
466 | WRITE( message_string, * ) 'y-direction: ny does not match the', & |
---|
467 | 'requirements given by the number of PEs &used ', & |
---|
468 | '& please use ny = ', ny - ( pdims(2) - ( nnx*pdims(2) & |
---|
469 | - ( ny + 1 ) ) ), ' instead of ny =', ny |
---|
470 | CALL message( 'init_pegrid', 'PA0228', 1, 2, 0, 6, 0 ) |
---|
471 | ENDIF |
---|
472 | ENDIF |
---|
473 | |
---|
474 | ! |
---|
475 | !-- South and north array bounds |
---|
476 | DO j = 0, pdims(2)-1 |
---|
477 | nysf(j) = j * nny |
---|
478 | nynf(j) = ( j + 1 ) * nny - 1 |
---|
479 | ENDDO |
---|
480 | |
---|
481 | ! |
---|
482 | !-- Local array bounds of the respective PEs |
---|
483 | nxl = nxlf(pcoord(1)) |
---|
484 | nxr = nxrf(pcoord(1)) |
---|
485 | nys = nysf(pcoord(2)) |
---|
486 | nyn = nynf(pcoord(2)) |
---|
487 | nzb = 0 |
---|
488 | nzt = nz |
---|
489 | nnz = nz |
---|
490 | |
---|
491 | ! |
---|
492 | !-- Set switches to define if the PE is situated at the border of the virtual |
---|
493 | !-- processor grid |
---|
494 | IF ( nxl == 0 ) left_border_pe = .TRUE. |
---|
495 | IF ( nxr == nx ) right_border_pe = .TRUE. |
---|
496 | IF ( nys == 0 ) south_border_pe = .TRUE. |
---|
497 | IF ( nyn == ny ) north_border_pe = .TRUE. |
---|
498 | |
---|
499 | ! |
---|
500 | !-- Calculate array bounds and gridpoint numbers for the transposed arrays |
---|
501 | !-- (needed in the pressure solver) |
---|
502 | !-- For the transposed arrays, cyclic boundaries as well as top and bottom |
---|
503 | !-- boundaries are omitted, because they are obstructive to the transposition |
---|
504 | |
---|
505 | ! |
---|
506 | !-- 1. transposition z --> x |
---|
507 | !-- This transposition is not neccessary in case of a 1d-decomposition along x |
---|
508 | IF ( psolver == 'poisfft' .OR. calculate_spectra .OR. & |
---|
509 | use_synthetic_turbulence_generator ) THEN |
---|
510 | |
---|
511 | IF ( pdims(2) /= 1 ) THEN |
---|
512 | IF ( MOD( nz , pdims(1) ) /= 0 ) THEN |
---|
513 | WRITE( message_string, * ) 'transposition z --> x:', & |
---|
514 | '&nz=',nz,' is not an integral divisior of pdims(1)=', & |
---|
515 | pdims(1) |
---|
516 | CALL message( 'init_pegrid', 'PA0230', 1, 2, 0, 6, 0 ) |
---|
517 | ENDIF |
---|
518 | ENDIF |
---|
519 | |
---|
520 | nys_x = nys |
---|
521 | nyn_x = nyn |
---|
522 | nny_x = nny |
---|
523 | nnz_x = nz / pdims(1) |
---|
524 | nzb_x = 1 + myidx * nnz_x |
---|
525 | nzt_x = ( myidx + 1 ) * nnz_x |
---|
526 | sendrecvcount_zx = nnx * nny * nnz_x |
---|
527 | |
---|
528 | ENDIF |
---|
529 | |
---|
530 | |
---|
531 | IF ( psolver == 'poisfft' ) THEN |
---|
532 | ! |
---|
533 | !-- 2. transposition x --> y |
---|
534 | IF ( MOD( nx+1 , pdims(2) ) /= 0 ) THEN |
---|
535 | WRITE( message_string, * ) 'transposition x --> y:', & |
---|
536 | '&nx+1=',nx+1,' is not an integral divisor of ', & |
---|
537 | 'pdims(2)=',pdims(2) |
---|
538 | CALL message( 'init_pegrid', 'PA0231', 1, 2, 0, 6, 0 ) |
---|
539 | ENDIF |
---|
540 | |
---|
541 | nnz_y = nnz_x |
---|
542 | nzb_y = nzb_x |
---|
543 | nzt_y = nzt_x |
---|
544 | nnx_y = (nx+1) / pdims(2) |
---|
545 | nxl_y = myidy * nnx_y |
---|
546 | nxr_y = ( myidy + 1 ) * nnx_y - 1 |
---|
547 | sendrecvcount_xy = nnx_y * nny_x * nnz_y |
---|
548 | ! |
---|
549 | !-- 3. transposition y --> z |
---|
550 | !-- (ELSE: x --> y in case of 1D-decomposition along x) |
---|
551 | nxl_z = nxl_y |
---|
552 | nxr_z = nxr_y |
---|
553 | nny_z = (ny+1) / pdims(1) |
---|
554 | nys_z = myidx * nny_z |
---|
555 | nyn_z = ( myidx + 1 ) * nny_z - 1 |
---|
556 | sendrecvcount_yz = nnx_y * nny_z * nnz_y |
---|
557 | |
---|
558 | IF ( pdims(2) /= 1 ) THEN |
---|
559 | ! |
---|
560 | !-- y --> z |
---|
561 | !-- This transposition is not neccessary in case of a 1d-decomposition |
---|
562 | !-- along x, except that the uptream-spline method is switched on |
---|
563 | IF ( MOD( ny+1 , pdims(1) ) /= 0 ) THEN |
---|
564 | WRITE( message_string, * ) 'transposition y --> z:', & |
---|
565 | '& ny+1=',ny+1,' is not an integral divisor of',& |
---|
566 | ' pdims(1)=',pdims(1) |
---|
567 | CALL message( 'init_pegrid', 'PA0232', 1, 2, 0, 6, 0 ) |
---|
568 | ENDIF |
---|
569 | |
---|
570 | ELSE |
---|
571 | ! |
---|
572 | !-- x --> y |
---|
573 | !-- This condition must be fulfilled for a 1D-decomposition along x |
---|
574 | IF ( MOD( ny+1 , pdims(1) ) /= 0 ) THEN |
---|
575 | WRITE( message_string, * ) 'transposition x --> y:', & |
---|
576 | '& ny+1=',ny+1,' is not an integral divisor of',& |
---|
577 | ' pdims(1)=',pdims(1) |
---|
578 | CALL message( 'init_pegrid', 'PA0233', 1, 2, 0, 6, 0 ) |
---|
579 | ENDIF |
---|
580 | |
---|
581 | ENDIF |
---|
582 | |
---|
583 | ENDIF |
---|
584 | |
---|
585 | ! |
---|
586 | !-- Indices for direct transpositions z --> y (used for calculating spectra) |
---|
587 | IF ( calculate_spectra ) THEN |
---|
588 | IF ( MOD( nz, pdims(2) ) /= 0 ) THEN |
---|
589 | WRITE( message_string, * ) 'direct transposition z --> y (needed ', & |
---|
590 | 'for spectra):& nz=',nz,' is not an integral divisor of ', & |
---|
591 | 'pdims(2)=',pdims(2) |
---|
592 | CALL message( 'init_pegrid', 'PA0234', 1, 2, 0, 6, 0 ) |
---|
593 | ELSE |
---|
594 | nxl_yd = nxl |
---|
595 | nxr_yd = nxr |
---|
596 | nzb_yd = 1 + myidy * ( nz / pdims(2) ) |
---|
597 | nzt_yd = ( myidy + 1 ) * ( nz / pdims(2) ) |
---|
598 | sendrecvcount_zyd = nnx * nny * ( nz / pdims(2) ) |
---|
599 | ENDIF |
---|
600 | ENDIF |
---|
601 | |
---|
602 | IF ( psolver == 'poisfft' .OR. calculate_spectra ) THEN |
---|
603 | ! |
---|
604 | !-- Indices for direct transpositions y --> x |
---|
605 | !-- (they are only possible in case of a 1d-decomposition along x) |
---|
606 | IF ( pdims(2) == 1 ) THEN |
---|
607 | nny_x = nny / pdims(1) |
---|
608 | nys_x = myid * nny_x |
---|
609 | nyn_x = ( myid + 1 ) * nny_x - 1 |
---|
610 | nzb_x = 1 |
---|
611 | nzt_x = nz |
---|
612 | sendrecvcount_xy = nnx * nny_x * nz |
---|
613 | ENDIF |
---|
614 | |
---|
615 | ENDIF |
---|
616 | |
---|
617 | IF ( psolver == 'poisfft' ) THEN |
---|
618 | ! |
---|
619 | !-- Indices for direct transpositions x --> y |
---|
620 | !-- (they are only possible in case of a 1d-decomposition along y) |
---|
621 | IF ( pdims(1) == 1 ) THEN |
---|
622 | nnx_y = nnx / pdims(2) |
---|
623 | nxl_y = myid * nnx_y |
---|
624 | nxr_y = ( myid + 1 ) * nnx_y - 1 |
---|
625 | nzb_y = 1 |
---|
626 | nzt_y = nz |
---|
627 | sendrecvcount_xy = nnx_y * nny * nz |
---|
628 | ENDIF |
---|
629 | |
---|
630 | ENDIF |
---|
631 | |
---|
632 | ! |
---|
633 | !-- Arrays for storing the array bounds are needed any more |
---|
634 | DEALLOCATE( nxlf , nxrf , nynf , nysf ) |
---|
635 | |
---|
636 | |
---|
637 | ! |
---|
638 | !-- Collect index bounds from other PEs (to be written to restart file later) |
---|
639 | ALLOCATE( hor_index_bounds(4,0:numprocs-1) ) |
---|
640 | |
---|
641 | IF ( myid == 0 ) THEN |
---|
642 | |
---|
643 | hor_index_bounds(1,0) = nxl |
---|
644 | hor_index_bounds(2,0) = nxr |
---|
645 | hor_index_bounds(3,0) = nys |
---|
646 | hor_index_bounds(4,0) = nyn |
---|
647 | |
---|
648 | ! |
---|
649 | !-- Receive data from all other PEs |
---|
650 | DO i = 1, numprocs-1 |
---|
651 | CALL MPI_RECV( ibuf, 4, MPI_INTEGER, i, MPI_ANY_TAG, comm2d, status, & |
---|
652 | ierr ) |
---|
653 | hor_index_bounds(:,i) = ibuf(1:4) |
---|
654 | ENDDO |
---|
655 | |
---|
656 | ELSE |
---|
657 | ! |
---|
658 | !-- Send index bounds to PE0 |
---|
659 | ibuf(1) = nxl |
---|
660 | ibuf(2) = nxr |
---|
661 | ibuf(3) = nys |
---|
662 | ibuf(4) = nyn |
---|
663 | CALL MPI_SEND( ibuf, 4, MPI_INTEGER, 0, myid, comm2d, ierr ) |
---|
664 | |
---|
665 | ENDIF |
---|
666 | |
---|
667 | |
---|
668 | #if defined( __print ) |
---|
669 | ! |
---|
670 | !-- Control output |
---|
671 | IF ( myid == 0 ) THEN |
---|
672 | PRINT*, '*** processor topology ***' |
---|
673 | PRINT*, ' ' |
---|
674 | PRINT*, 'myid pcoord left right south north idx idy nxl: nxr',& |
---|
675 | &' nys: nyn' |
---|
676 | PRINT*, '------------------------------------------------------------',& |
---|
677 | &'-----------' |
---|
678 | WRITE (*,1000) 0, pcoord(1), pcoord(2), pleft, pright, psouth, pnorth, & |
---|
679 | myidx, myidy, nxl, nxr, nys, nyn |
---|
680 | 1000 FORMAT (I4,2X,'(',I3,',',I3,')',3X,I4,2X,I4,3X,I4,2X,I4,2X,I3,1X,I3, & |
---|
681 | 2(2X,I4,':',I4)) |
---|
682 | |
---|
683 | ! |
---|
684 | !-- Receive data from the other PEs |
---|
685 | DO i = 1,numprocs-1 |
---|
686 | CALL MPI_RECV( ibuf, 12, MPI_INTEGER, i, MPI_ANY_TAG, comm2d, status, & |
---|
687 | ierr ) |
---|
688 | WRITE (*,1000) i, ( ibuf(j) , j = 1,12 ) |
---|
689 | ENDDO |
---|
690 | ELSE |
---|
691 | |
---|
692 | ! |
---|
693 | !-- Send data to PE0 |
---|
694 | ibuf(1) = pcoord(1); ibuf(2) = pcoord(2); ibuf(3) = pleft |
---|
695 | ibuf(4) = pright; ibuf(5) = psouth; ibuf(6) = pnorth; ibuf(7) = myidx |
---|
696 | ibuf(8) = myidy; ibuf(9) = nxl; ibuf(10) = nxr; ibuf(11) = nys |
---|
697 | ibuf(12) = nyn |
---|
698 | CALL MPI_SEND( ibuf, 12, MPI_INTEGER, 0, myid, comm2d, ierr ) |
---|
699 | ENDIF |
---|
700 | #endif |
---|
701 | |
---|
702 | |
---|
703 | ! |
---|
704 | !-- Determine the number of ghost point layers |
---|
705 | IF ( ( scalar_advec == 'ws-scheme' .AND. .NOT. neutral ) .OR. & |
---|
706 | momentum_advec == 'ws-scheme' ) THEN |
---|
707 | nbgp = 3 |
---|
708 | ELSE |
---|
709 | nbgp = 1 |
---|
710 | ENDIF |
---|
711 | |
---|
712 | ! |
---|
713 | !-- Create a new MPI derived datatype for the exchange of surface (xy) data, |
---|
714 | !-- which is needed for coupled atmosphere-ocean runs. |
---|
715 | !-- First, calculate number of grid points of an xy-plane. |
---|
716 | ngp_xy = ( nxr - nxl + 1 + 2 * nbgp ) * ( nyn - nys + 1 + 2 * nbgp ) |
---|
717 | CALL MPI_TYPE_VECTOR( ngp_xy, 1, nzt-nzb+2, MPI_REAL, type_xy, ierr ) |
---|
718 | CALL MPI_TYPE_COMMIT( type_xy, ierr ) |
---|
719 | |
---|
720 | IF ( TRIM( coupling_mode ) /= 'uncoupled' .AND. .NOT. vnested ) THEN |
---|
721 | |
---|
722 | ! |
---|
723 | !-- Pass the number of grid points of the atmosphere model to |
---|
724 | !-- the ocean model and vice versa |
---|
725 | IF ( coupling_mode == 'atmosphere_to_ocean' ) THEN |
---|
726 | |
---|
727 | nx_a = nx |
---|
728 | ny_a = ny |
---|
729 | |
---|
730 | IF ( myid == 0 ) THEN |
---|
731 | |
---|
732 | CALL MPI_SEND( nx_a, 1, MPI_INTEGER, numprocs, 1, comm_inter, & |
---|
733 | ierr ) |
---|
734 | CALL MPI_SEND( ny_a, 1, MPI_INTEGER, numprocs, 2, comm_inter, & |
---|
735 | ierr ) |
---|
736 | CALL MPI_SEND( pdims, 2, MPI_INTEGER, numprocs, 3, comm_inter, & |
---|
737 | ierr ) |
---|
738 | CALL MPI_RECV( nx_o, 1, MPI_INTEGER, numprocs, 4, comm_inter, & |
---|
739 | status, ierr ) |
---|
740 | CALL MPI_RECV( ny_o, 1, MPI_INTEGER, numprocs, 5, comm_inter, & |
---|
741 | status, ierr ) |
---|
742 | CALL MPI_RECV( pdims_remote, 2, MPI_INTEGER, numprocs, 6, & |
---|
743 | comm_inter, status, ierr ) |
---|
744 | ENDIF |
---|
745 | |
---|
746 | CALL MPI_BCAST( nx_o, 1, MPI_INTEGER, 0, comm2d, ierr ) |
---|
747 | CALL MPI_BCAST( ny_o, 1, MPI_INTEGER, 0, comm2d, ierr ) |
---|
748 | CALL MPI_BCAST( pdims_remote, 2, MPI_INTEGER, 0, comm2d, ierr ) |
---|
749 | |
---|
750 | ELSEIF ( coupling_mode == 'ocean_to_atmosphere' ) THEN |
---|
751 | |
---|
752 | nx_o = nx |
---|
753 | ny_o = ny |
---|
754 | |
---|
755 | IF ( myid == 0 ) THEN |
---|
756 | |
---|
757 | CALL MPI_RECV( nx_a, 1, MPI_INTEGER, 0, 1, comm_inter, status, & |
---|
758 | ierr ) |
---|
759 | CALL MPI_RECV( ny_a, 1, MPI_INTEGER, 0, 2, comm_inter, status, & |
---|
760 | ierr ) |
---|
761 | CALL MPI_RECV( pdims_remote, 2, MPI_INTEGER, 0, 3, comm_inter, & |
---|
762 | status, ierr ) |
---|
763 | CALL MPI_SEND( nx_o, 1, MPI_INTEGER, 0, 4, comm_inter, ierr ) |
---|
764 | CALL MPI_SEND( ny_o, 1, MPI_INTEGER, 0, 5, comm_inter, ierr ) |
---|
765 | CALL MPI_SEND( pdims, 2, MPI_INTEGER, 0, 6, comm_inter, ierr ) |
---|
766 | ENDIF |
---|
767 | |
---|
768 | CALL MPI_BCAST( nx_a, 1, MPI_INTEGER, 0, comm2d, ierr) |
---|
769 | CALL MPI_BCAST( ny_a, 1, MPI_INTEGER, 0, comm2d, ierr) |
---|
770 | CALL MPI_BCAST( pdims_remote, 2, MPI_INTEGER, 0, comm2d, ierr) |
---|
771 | |
---|
772 | ENDIF |
---|
773 | |
---|
774 | ngp_a = ( nx_a+1 + 2 * nbgp ) * ( ny_a+1 + 2 * nbgp ) |
---|
775 | ngp_o = ( nx_o+1 + 2 * nbgp ) * ( ny_o+1 + 2 * nbgp ) |
---|
776 | |
---|
777 | ! |
---|
778 | !-- Determine if the horizontal grid and the number of PEs in ocean and |
---|
779 | !-- atmosphere is same or not |
---|
780 | IF ( nx_o == nx_a .AND. ny_o == ny_a .AND. & |
---|
781 | pdims(1) == pdims_remote(1) .AND. pdims(2) == pdims_remote(2) ) & |
---|
782 | THEN |
---|
783 | coupling_topology = 0 |
---|
784 | ELSE |
---|
785 | coupling_topology = 1 |
---|
786 | ENDIF |
---|
787 | |
---|
788 | ! |
---|
789 | !-- Determine the target PEs for the exchange between ocean and |
---|
790 | !-- atmosphere (comm2d) |
---|
791 | IF ( coupling_topology == 0 ) THEN |
---|
792 | ! |
---|
793 | !-- In case of identical topologies, every atmosphere PE has exactly one |
---|
794 | !-- ocean PE counterpart and vice versa |
---|
795 | IF ( TRIM( coupling_mode ) == 'atmosphere_to_ocean' ) THEN |
---|
796 | target_id = myid + numprocs |
---|
797 | ELSE |
---|
798 | target_id = myid |
---|
799 | ENDIF |
---|
800 | |
---|
801 | ELSE |
---|
802 | ! |
---|
803 | !-- In case of nonequivalent topology in ocean and atmosphere only for |
---|
804 | !-- PE0 in ocean and PE0 in atmosphere a target_id is needed, since |
---|
805 | !-- data echxchange between ocean and atmosphere will be done only |
---|
806 | !-- between these PEs. |
---|
807 | IF ( myid == 0 ) THEN |
---|
808 | |
---|
809 | IF ( TRIM( coupling_mode ) == 'atmosphere_to_ocean' ) THEN |
---|
810 | target_id = numprocs |
---|
811 | ELSE |
---|
812 | target_id = 0 |
---|
813 | ENDIF |
---|
814 | |
---|
815 | ENDIF |
---|
816 | |
---|
817 | ENDIF |
---|
818 | |
---|
819 | ENDIF |
---|
820 | |
---|
821 | ! |
---|
822 | !-- Store partner grid point co-ordinates as lists. |
---|
823 | !-- Create custom MPI vector datatypes for contiguous data transfer |
---|
824 | IF ( vnested ) CALL vnest_init_pegrid_domain |
---|
825 | |
---|
826 | |
---|
827 | #else |
---|
828 | |
---|
829 | ! |
---|
830 | !-- Array bounds when running on a single PE (respectively a non-parallel |
---|
831 | !-- machine) |
---|
832 | nxl = 0 |
---|
833 | nxr = nx |
---|
834 | nnx = nxr - nxl + 1 |
---|
835 | nys = 0 |
---|
836 | nyn = ny |
---|
837 | nny = nyn - nys + 1 |
---|
838 | nzb = 0 |
---|
839 | nzt = nz |
---|
840 | nnz = nz |
---|
841 | |
---|
842 | ALLOCATE( hor_index_bounds(4,0:0) ) |
---|
843 | hor_index_bounds(1,0) = nxl |
---|
844 | hor_index_bounds(2,0) = nxr |
---|
845 | hor_index_bounds(3,0) = nys |
---|
846 | hor_index_bounds(4,0) = nyn |
---|
847 | |
---|
848 | ! |
---|
849 | !-- Array bounds for the pressure solver (in the parallel code, these bounds |
---|
850 | !-- are the ones for the transposed arrays) |
---|
851 | nys_x = nys |
---|
852 | nyn_x = nyn |
---|
853 | nzb_x = nzb + 1 |
---|
854 | nzt_x = nzt |
---|
855 | |
---|
856 | nxl_y = nxl |
---|
857 | nxr_y = nxr |
---|
858 | nzb_y = nzb + 1 |
---|
859 | nzt_y = nzt |
---|
860 | |
---|
861 | nxl_z = nxl |
---|
862 | nxr_z = nxr |
---|
863 | nys_z = nys |
---|
864 | nyn_z = nyn |
---|
865 | |
---|
866 | #endif |
---|
867 | |
---|
868 | ! |
---|
869 | !-- Calculate number of grid levels necessary for the multigrid poisson solver |
---|
870 | !-- as well as the gridpoint indices on each level |
---|
871 | IF ( psolver(1:9) == 'multigrid' ) THEN |
---|
872 | |
---|
873 | ! |
---|
874 | !-- First calculate number of possible grid levels for the subdomains |
---|
875 | mg_levels_x = 1 |
---|
876 | mg_levels_y = 1 |
---|
877 | mg_levels_z = 1 |
---|
878 | |
---|
879 | i = nnx |
---|
880 | DO WHILE ( MOD( i, 2 ) == 0 .AND. i /= 2 ) |
---|
881 | i = i / 2 |
---|
882 | mg_levels_x = mg_levels_x + 1 |
---|
883 | ENDDO |
---|
884 | |
---|
885 | j = nny |
---|
886 | DO WHILE ( MOD( j, 2 ) == 0 .AND. j /= 2 ) |
---|
887 | j = j / 2 |
---|
888 | mg_levels_y = mg_levels_y + 1 |
---|
889 | ENDDO |
---|
890 | |
---|
891 | k = nz ! do not use nnz because it might be > nz due to transposition |
---|
892 | ! requirements |
---|
893 | DO WHILE ( MOD( k, 2 ) == 0 .AND. k /= 2 ) |
---|
894 | k = k / 2 |
---|
895 | mg_levels_z = mg_levels_z + 1 |
---|
896 | ENDDO |
---|
897 | ! |
---|
898 | !-- The optimized MG-solver does not allow odd values for nz at the coarsest |
---|
899 | !-- grid level |
---|
900 | IF ( TRIM( psolver ) /= 'multigrid_noopt' ) THEN |
---|
901 | IF ( MOD( k, 2 ) /= 0 ) mg_levels_z = mg_levels_z - 1 |
---|
902 | ENDIF |
---|
903 | |
---|
904 | maximum_grid_level = MIN( mg_levels_x, mg_levels_y, mg_levels_z ) |
---|
905 | |
---|
906 | ! |
---|
907 | !-- Find out, if the total domain allows more levels. These additional |
---|
908 | !-- levels are identically processed on all PEs. |
---|
909 | IF ( numprocs > 1 .AND. mg_switch_to_pe0_level /= -1 ) THEN |
---|
910 | |
---|
911 | IF ( mg_levels_z > MIN( mg_levels_x, mg_levels_y ) ) THEN |
---|
912 | |
---|
913 | mg_switch_to_pe0_level_l = maximum_grid_level |
---|
914 | |
---|
915 | mg_levels_x = 1 |
---|
916 | mg_levels_y = 1 |
---|
917 | |
---|
918 | i = nx+1 |
---|
919 | DO WHILE ( MOD( i, 2 ) == 0 .AND. i /= 2 ) |
---|
920 | i = i / 2 |
---|
921 | mg_levels_x = mg_levels_x + 1 |
---|
922 | ENDDO |
---|
923 | |
---|
924 | j = ny+1 |
---|
925 | DO WHILE ( MOD( j, 2 ) == 0 .AND. j /= 2 ) |
---|
926 | j = j / 2 |
---|
927 | mg_levels_y = mg_levels_y + 1 |
---|
928 | ENDDO |
---|
929 | |
---|
930 | maximum_grid_level_l = MIN( mg_levels_x, mg_levels_y, mg_levels_z ) |
---|
931 | |
---|
932 | IF ( maximum_grid_level_l > mg_switch_to_pe0_level_l ) THEN |
---|
933 | mg_switch_to_pe0_level_l = maximum_grid_level_l - & |
---|
934 | mg_switch_to_pe0_level_l + 1 |
---|
935 | ELSE |
---|
936 | mg_switch_to_pe0_level_l = 0 |
---|
937 | ENDIF |
---|
938 | |
---|
939 | ELSE |
---|
940 | mg_switch_to_pe0_level_l = 0 |
---|
941 | maximum_grid_level_l = maximum_grid_level |
---|
942 | |
---|
943 | ENDIF |
---|
944 | |
---|
945 | ! |
---|
946 | !-- Use switch level calculated above only if it is not pre-defined |
---|
947 | !-- by user |
---|
948 | IF ( mg_switch_to_pe0_level == 0 ) THEN |
---|
949 | IF ( mg_switch_to_pe0_level_l /= 0 ) THEN |
---|
950 | mg_switch_to_pe0_level = mg_switch_to_pe0_level_l |
---|
951 | maximum_grid_level = maximum_grid_level_l |
---|
952 | ENDIF |
---|
953 | |
---|
954 | ELSE |
---|
955 | ! |
---|
956 | !-- Check pre-defined value and reset to default, if neccessary |
---|
957 | IF ( mg_switch_to_pe0_level < mg_switch_to_pe0_level_l .OR. & |
---|
958 | mg_switch_to_pe0_level >= maximum_grid_level_l ) THEN |
---|
959 | message_string = 'mg_switch_to_pe0_level ' // & |
---|
960 | 'out of range and reset to 0' |
---|
961 | CALL message( 'init_pegrid', 'PA0235', 0, 1, 0, 6, 0 ) |
---|
962 | mg_switch_to_pe0_level = 0 |
---|
963 | ELSE |
---|
964 | ! |
---|
965 | !-- Use the largest number of possible levels anyway and recalculate |
---|
966 | !-- the switch level to this largest number of possible values |
---|
967 | maximum_grid_level = maximum_grid_level_l |
---|
968 | |
---|
969 | ENDIF |
---|
970 | |
---|
971 | ENDIF |
---|
972 | |
---|
973 | ENDIF |
---|
974 | |
---|
975 | ALLOCATE( grid_level_count(maximum_grid_level), & |
---|
976 | nxl_mg(0:maximum_grid_level), nxr_mg(0:maximum_grid_level), & |
---|
977 | nyn_mg(0:maximum_grid_level), nys_mg(0:maximum_grid_level), & |
---|
978 | nzt_mg(0:maximum_grid_level) ) |
---|
979 | |
---|
980 | grid_level_count = 0 |
---|
981 | ! |
---|
982 | !-- Index zero required as dummy due to definition of arrays f2 and p2 in |
---|
983 | !-- recursive subroutine next_mg_level |
---|
984 | nxl_mg(0) = 0; nxr_mg(0) = 0; nyn_mg(0) = 0; nys_mg(0) = 0; nzt_mg(0) = 0 |
---|
985 | |
---|
986 | nxl_l = nxl; nxr_l = nxr; nys_l = nys; nyn_l = nyn; nzt_l = nzt |
---|
987 | |
---|
988 | DO i = maximum_grid_level, 1 , -1 |
---|
989 | |
---|
990 | IF ( i == mg_switch_to_pe0_level ) THEN |
---|
991 | #if defined( __parallel ) |
---|
992 | ! |
---|
993 | !-- Save the grid size of the subdomain at the switch level, because |
---|
994 | !-- it is needed in poismg. |
---|
995 | ind(1) = nxl_l; ind(2) = nxr_l |
---|
996 | ind(3) = nys_l; ind(4) = nyn_l |
---|
997 | ind(5) = nzt_l |
---|
998 | ALLOCATE( ind_all(5*numprocs), mg_loc_ind(5,0:numprocs-1) ) |
---|
999 | CALL MPI_ALLGATHER( ind, 5, MPI_INTEGER, ind_all, 5, & |
---|
1000 | MPI_INTEGER, comm2d, ierr ) |
---|
1001 | DO j = 0, numprocs-1 |
---|
1002 | DO k = 1, 5 |
---|
1003 | mg_loc_ind(k,j) = ind_all(k+j*5) |
---|
1004 | ENDDO |
---|
1005 | ENDDO |
---|
1006 | DEALLOCATE( ind_all ) |
---|
1007 | ! |
---|
1008 | !-- Calculate the grid size of the total domain |
---|
1009 | nxr_l = ( nxr_l-nxl_l+1 ) * pdims(1) - 1 |
---|
1010 | nxl_l = 0 |
---|
1011 | nyn_l = ( nyn_l-nys_l+1 ) * pdims(2) - 1 |
---|
1012 | nys_l = 0 |
---|
1013 | ! |
---|
1014 | !-- The size of this gathered array must not be larger than the |
---|
1015 | !-- array tend, which is used in the multigrid scheme as a temporary |
---|
1016 | !-- array. Therefore the subdomain size of an PE is calculated and |
---|
1017 | !-- the size of the gathered grid. These values are used in |
---|
1018 | !-- routines pres and poismg |
---|
1019 | subdomain_size = ( nxr - nxl + 2 * nbgp + 1 ) * & |
---|
1020 | ( nyn - nys + 2 * nbgp + 1 ) * ( nzt - nzb + 2 ) |
---|
1021 | gathered_size = ( nxr_l - nxl_l + 3 ) * ( nyn_l - nys_l + 3 ) * & |
---|
1022 | ( nzt_l - nzb + 2 ) |
---|
1023 | |
---|
1024 | #else |
---|
1025 | message_string = 'multigrid gather/scatter impossible ' // & |
---|
1026 | 'in non parallel mode' |
---|
1027 | CALL message( 'init_pegrid', 'PA0237', 1, 2, 0, 6, 0 ) |
---|
1028 | #endif |
---|
1029 | ENDIF |
---|
1030 | |
---|
1031 | nxl_mg(i) = nxl_l |
---|
1032 | nxr_mg(i) = nxr_l |
---|
1033 | nys_mg(i) = nys_l |
---|
1034 | nyn_mg(i) = nyn_l |
---|
1035 | nzt_mg(i) = nzt_l |
---|
1036 | |
---|
1037 | nxl_l = nxl_l / 2 |
---|
1038 | nxr_l = nxr_l / 2 |
---|
1039 | nys_l = nys_l / 2 |
---|
1040 | nyn_l = nyn_l / 2 |
---|
1041 | nzt_l = nzt_l / 2 |
---|
1042 | |
---|
1043 | ENDDO |
---|
1044 | |
---|
1045 | ! |
---|
1046 | !-- Temporary problem: Currently calculation of maxerror iin routine poismg crashes |
---|
1047 | !-- if grid data are collected on PE0 already on the finest grid level. |
---|
1048 | !-- To be solved later. |
---|
1049 | IF ( maximum_grid_level == mg_switch_to_pe0_level ) THEN |
---|
1050 | message_string = 'grid coarsening on subdomain level cannot be performed' |
---|
1051 | CALL message( 'poismg', 'PA0236', 1, 2, 0, 6, 0 ) |
---|
1052 | ENDIF |
---|
1053 | |
---|
1054 | ELSE |
---|
1055 | |
---|
1056 | maximum_grid_level = 0 |
---|
1057 | |
---|
1058 | ENDIF |
---|
1059 | |
---|
1060 | ! |
---|
1061 | !-- Default level 0 tells exchange_horiz that all ghost planes have to be |
---|
1062 | !-- exchanged. grid_level is adjusted in poismg, where only one ghost plane |
---|
1063 | !-- is required. |
---|
1064 | grid_level = 0 |
---|
1065 | |
---|
1066 | #if defined( __parallel ) |
---|
1067 | ! |
---|
1068 | !-- Gridpoint number for the exchange of ghost points (y-line for 2D-arrays) |
---|
1069 | ngp_y = nyn - nys + 1 + 2 * nbgp |
---|
1070 | |
---|
1071 | ! |
---|
1072 | !-- Define new MPI derived datatypes for the exchange of ghost points in |
---|
1073 | !-- x- and y-direction for 2D-arrays (line) |
---|
1074 | CALL MPI_TYPE_VECTOR( nxr-nxl+1+2*nbgp, nbgp, ngp_y, MPI_REAL, type_x, & |
---|
1075 | ierr ) |
---|
1076 | CALL MPI_TYPE_COMMIT( type_x, ierr ) |
---|
1077 | |
---|
1078 | CALL MPI_TYPE_VECTOR( nbgp, ngp_y, ngp_y, MPI_REAL, type_y, ierr ) |
---|
1079 | CALL MPI_TYPE_COMMIT( type_y, ierr ) |
---|
1080 | ! |
---|
1081 | !-- Define new MPI derived datatypes for the exchange of ghost points in |
---|
1082 | !-- x- and y-direction for 2D-INTEGER arrays (line) - on normal grid |
---|
1083 | ALLOCATE( type_x_int(0:maximum_grid_level), & |
---|
1084 | type_y_int(0:maximum_grid_level) ) |
---|
1085 | |
---|
1086 | CALL MPI_TYPE_VECTOR( nxr-nxl+1+2*nbgp, nbgp, ngp_y, MPI_INTEGER, & |
---|
1087 | type_x_int(0), ierr ) |
---|
1088 | CALL MPI_TYPE_COMMIT( type_x_int(0), ierr ) |
---|
1089 | |
---|
1090 | CALL MPI_TYPE_VECTOR( nbgp, ngp_y, ngp_y, MPI_INTEGER, type_y_int(0), ierr ) |
---|
1091 | CALL MPI_TYPE_COMMIT( type_y_int(0), ierr ) |
---|
1092 | ! |
---|
1093 | !-- Calculate gridpoint numbers for the exchange of ghost points along x |
---|
1094 | !-- (yz-plane for 3D-arrays) and define MPI derived data type(s) for the |
---|
1095 | !-- exchange of ghost points in y-direction (xz-plane). |
---|
1096 | !-- Do these calculations for the model grid and (if necessary) also |
---|
1097 | !-- for the coarser grid levels used in the multigrid method |
---|
1098 | ALLOCATE ( ngp_xz(0:maximum_grid_level), ngp_yz(0:maximum_grid_level), & |
---|
1099 | type_xz(0:maximum_grid_level), type_yz(0:maximum_grid_level) ) |
---|
1100 | |
---|
1101 | nxl_l = nxl; nxr_l = nxr; nys_l = nys; nyn_l = nyn; nzb_l = nzb; nzt_l = nzt |
---|
1102 | |
---|
1103 | ! |
---|
1104 | !-- Discern between the model grid, which needs nbgp ghost points and |
---|
1105 | !-- grid levels for the multigrid scheme. In the latter case only one |
---|
1106 | !-- ghost point is necessary. |
---|
1107 | !-- First definition of MPI-datatypes for exchange of ghost layers on normal |
---|
1108 | !-- grid. The following loop is needed for data exchange in poismg.f90. |
---|
1109 | ! |
---|
1110 | !-- Determine number of grid points of yz-layer for exchange |
---|
1111 | ngp_yz(0) = (nzt - nzb + 2) * (nyn - nys + 1 + 2 * nbgp) |
---|
1112 | |
---|
1113 | ! |
---|
1114 | !-- Define an MPI-datatype for the exchange of left/right boundaries. |
---|
1115 | !-- Although data are contiguous in physical memory (which does not |
---|
1116 | !-- necessarily require an MPI-derived datatype), the data exchange between |
---|
1117 | !-- left and right PE's using the MPI-derived type is 10% faster than without. |
---|
1118 | CALL MPI_TYPE_VECTOR( nxr-nxl+1+2*nbgp, nbgp*(nzt-nzb+2), ngp_yz(0), & |
---|
1119 | MPI_REAL, type_xz(0), ierr ) |
---|
1120 | CALL MPI_TYPE_COMMIT( type_xz(0), ierr ) |
---|
1121 | |
---|
1122 | CALL MPI_TYPE_VECTOR( nbgp, ngp_yz(0), ngp_yz(0), MPI_REAL, type_yz(0), & |
---|
1123 | ierr ) |
---|
1124 | CALL MPI_TYPE_COMMIT( type_yz(0), ierr ) |
---|
1125 | |
---|
1126 | ! |
---|
1127 | !-- Definition of MPI-datatypes for multigrid method (coarser level grids) |
---|
1128 | IF ( psolver(1:9) == 'multigrid' ) THEN |
---|
1129 | ! |
---|
1130 | !-- Definition of MPI-datatyoe as above, but only 1 ghost level is used |
---|
1131 | DO i = maximum_grid_level, 1 , -1 |
---|
1132 | ! |
---|
1133 | !-- For 3D-exchange |
---|
1134 | ngp_xz(i) = (nzt_l - nzb_l + 2) * (nxr_l - nxl_l + 3) |
---|
1135 | ngp_yz(i) = (nzt_l - nzb_l + 2) * (nyn_l - nys_l + 3) |
---|
1136 | |
---|
1137 | CALL MPI_TYPE_VECTOR( nxr_l-nxl_l+3, nzt_l-nzb_l+2, ngp_yz(i), & |
---|
1138 | MPI_REAL, type_xz(i), ierr ) |
---|
1139 | CALL MPI_TYPE_COMMIT( type_xz(i), ierr ) |
---|
1140 | |
---|
1141 | CALL MPI_TYPE_VECTOR( 1, ngp_yz(i), ngp_yz(i), MPI_REAL, type_yz(i), & |
---|
1142 | ierr ) |
---|
1143 | CALL MPI_TYPE_COMMIT( type_yz(i), ierr ) |
---|
1144 | |
---|
1145 | |
---|
1146 | !-- For 2D-exchange of INTEGER arrays on coarser grid level, where 2 ghost |
---|
1147 | !-- points need to be exchanged. |
---|
1148 | CALL MPI_TYPE_VECTOR( nxr_l-nxl_l+5, 2, nyn_l-nys_l+5, MPI_INTEGER, & |
---|
1149 | type_x_int(i), ierr ) |
---|
1150 | CALL MPI_TYPE_COMMIT( type_x_int(i), ierr ) |
---|
1151 | |
---|
1152 | |
---|
1153 | CALL MPI_TYPE_VECTOR( 2, nyn_l-nys_l+5, nyn_l-nys_l+5, MPI_INTEGER, & |
---|
1154 | type_y_int(i), ierr ) |
---|
1155 | CALL MPI_TYPE_COMMIT( type_y_int(i), ierr ) |
---|
1156 | |
---|
1157 | |
---|
1158 | |
---|
1159 | nxl_l = nxl_l / 2 |
---|
1160 | nxr_l = nxr_l / 2 |
---|
1161 | nys_l = nys_l / 2 |
---|
1162 | nyn_l = nyn_l / 2 |
---|
1163 | nzt_l = nzt_l / 2 |
---|
1164 | |
---|
1165 | ENDDO |
---|
1166 | |
---|
1167 | ENDIF |
---|
1168 | ! |
---|
1169 | !-- Define data types for exchange of 3D Integer arrays. |
---|
1170 | ngp_yz_int = (nzt - nzb + 2) * (nyn - nys + 1 + 2 * nbgp) |
---|
1171 | |
---|
1172 | CALL MPI_TYPE_VECTOR( nxr-nxl+1+2*nbgp, nbgp*(nzt-nzb+2), ngp_yz_int, & |
---|
1173 | MPI_INTEGER, type_xz_int, ierr ) |
---|
1174 | CALL MPI_TYPE_COMMIT( type_xz_int, ierr ) |
---|
1175 | |
---|
1176 | CALL MPI_TYPE_VECTOR( nbgp, ngp_yz_int, ngp_yz_int, MPI_INTEGER, type_yz_int, & |
---|
1177 | ierr ) |
---|
1178 | CALL MPI_TYPE_COMMIT( type_yz_int, ierr ) |
---|
1179 | |
---|
1180 | #endif |
---|
1181 | |
---|
1182 | #if defined( __parallel ) |
---|
1183 | ! |
---|
1184 | !-- Setting of flags for inflow/outflow/nesting conditions. |
---|
1185 | IF ( pleft == MPI_PROC_NULL ) THEN |
---|
1186 | IF ( bc_lr == 'dirichlet/radiation' ) THEN |
---|
1187 | inflow_l = .TRUE. |
---|
1188 | ELSEIF ( bc_lr == 'radiation/dirichlet' ) THEN |
---|
1189 | outflow_l = .TRUE. |
---|
1190 | ELSEIF ( bc_lr == 'nested' ) THEN |
---|
1191 | nest_bound_l = .TRUE. |
---|
1192 | ENDIF |
---|
1193 | ENDIF |
---|
1194 | |
---|
1195 | IF ( pright == MPI_PROC_NULL ) THEN |
---|
1196 | IF ( bc_lr == 'dirichlet/radiation' ) THEN |
---|
1197 | outflow_r = .TRUE. |
---|
1198 | ELSEIF ( bc_lr == 'radiation/dirichlet' ) THEN |
---|
1199 | inflow_r = .TRUE. |
---|
1200 | ELSEIF ( bc_lr == 'nested' ) THEN |
---|
1201 | nest_bound_r = .TRUE. |
---|
1202 | ENDIF |
---|
1203 | ENDIF |
---|
1204 | |
---|
1205 | IF ( psouth == MPI_PROC_NULL ) THEN |
---|
1206 | IF ( bc_ns == 'dirichlet/radiation' ) THEN |
---|
1207 | outflow_s = .TRUE. |
---|
1208 | ELSEIF ( bc_ns == 'radiation/dirichlet' ) THEN |
---|
1209 | inflow_s = .TRUE. |
---|
1210 | ELSEIF ( bc_ns == 'nested' ) THEN |
---|
1211 | nest_bound_s = .TRUE. |
---|
1212 | ENDIF |
---|
1213 | ENDIF |
---|
1214 | |
---|
1215 | IF ( pnorth == MPI_PROC_NULL ) THEN |
---|
1216 | IF ( bc_ns == 'dirichlet/radiation' ) THEN |
---|
1217 | inflow_n = .TRUE. |
---|
1218 | ELSEIF ( bc_ns == 'radiation/dirichlet' ) THEN |
---|
1219 | outflow_n = .TRUE. |
---|
1220 | ELSEIF ( bc_ns == 'nested' ) THEN |
---|
1221 | nest_bound_n = .TRUE. |
---|
1222 | ENDIF |
---|
1223 | ENDIF |
---|
1224 | |
---|
1225 | ! |
---|
1226 | !-- Broadcast the id of the inflow PE |
---|
1227 | IF ( inflow_l ) THEN |
---|
1228 | id_inflow_l = myidx |
---|
1229 | ELSE |
---|
1230 | id_inflow_l = 0 |
---|
1231 | ENDIF |
---|
1232 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
1233 | CALL MPI_ALLREDUCE( id_inflow_l, id_inflow, 1, MPI_INTEGER, MPI_SUM, & |
---|
1234 | comm1dx, ierr ) |
---|
1235 | |
---|
1236 | ! |
---|
1237 | !-- Broadcast the id of the recycling plane |
---|
1238 | !-- WARNING: needs to be adjusted in case of inflows other than from left side! |
---|
1239 | IF ( NINT( recycling_width / dx ) >= nxl .AND. & |
---|
1240 | NINT( recycling_width / dx ) <= nxr ) THEN |
---|
1241 | id_recycling_l = myidx |
---|
1242 | ELSE |
---|
1243 | id_recycling_l = 0 |
---|
1244 | ENDIF |
---|
1245 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
1246 | CALL MPI_ALLREDUCE( id_recycling_l, id_recycling, 1, MPI_INTEGER, MPI_SUM, & |
---|
1247 | comm1dx, ierr ) |
---|
1248 | |
---|
1249 | ! |
---|
1250 | !-- Broadcast the id of the outflow PE and outflow-source plane |
---|
1251 | IF ( turbulent_outflow ) THEN |
---|
1252 | |
---|
1253 | IF ( outflow_r ) THEN |
---|
1254 | id_outflow_l = myidx |
---|
1255 | ELSE |
---|
1256 | id_outflow_l = 0 |
---|
1257 | ENDIF |
---|
1258 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
1259 | CALL MPI_ALLREDUCE( id_outflow_l, id_outflow, 1, MPI_INTEGER, MPI_SUM, & |
---|
1260 | comm1dx, ierr ) |
---|
1261 | |
---|
1262 | IF ( NINT( outflow_source_plane / dx ) >= nxl .AND. & |
---|
1263 | NINT( outflow_source_plane / dx ) <= nxr ) THEN |
---|
1264 | id_outflow_source_l = myidx |
---|
1265 | ELSE |
---|
1266 | id_outflow_source_l = 0 |
---|
1267 | ENDIF |
---|
1268 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
1269 | CALL MPI_ALLREDUCE( id_outflow_source_l, id_outflow_source, 1, & |
---|
1270 | MPI_INTEGER, MPI_SUM, comm1dx, ierr ) |
---|
1271 | |
---|
1272 | ENDIF |
---|
1273 | |
---|
1274 | CALL location_message( 'finished', .TRUE. ) |
---|
1275 | |
---|
1276 | #else |
---|
1277 | IF ( bc_lr == 'dirichlet/radiation' ) THEN |
---|
1278 | inflow_l = .TRUE. |
---|
1279 | outflow_r = .TRUE. |
---|
1280 | ELSEIF ( bc_lr == 'radiation/dirichlet' ) THEN |
---|
1281 | outflow_l = .TRUE. |
---|
1282 | inflow_r = .TRUE. |
---|
1283 | ENDIF |
---|
1284 | |
---|
1285 | IF ( bc_ns == 'dirichlet/radiation' ) THEN |
---|
1286 | inflow_n = .TRUE. |
---|
1287 | outflow_s = .TRUE. |
---|
1288 | ELSEIF ( bc_ns == 'radiation/dirichlet' ) THEN |
---|
1289 | outflow_n = .TRUE. |
---|
1290 | inflow_s = .TRUE. |
---|
1291 | ENDIF |
---|
1292 | #endif |
---|
1293 | |
---|
1294 | ! |
---|
1295 | !-- At the inflow or outflow, u or v, respectively, have to be calculated for |
---|
1296 | !-- one more grid point. |
---|
1297 | IF ( inflow_l .OR. outflow_l .OR. nest_bound_l ) THEN |
---|
1298 | nxlu = nxl + 1 |
---|
1299 | ELSE |
---|
1300 | nxlu = nxl |
---|
1301 | ENDIF |
---|
1302 | IF ( inflow_s .OR. outflow_s .OR. nest_bound_s ) THEN |
---|
1303 | nysv = nys + 1 |
---|
1304 | ELSE |
---|
1305 | nysv = nys |
---|
1306 | ENDIF |
---|
1307 | |
---|
1308 | ! |
---|
1309 | !-- Allocate wall flag arrays used in the multigrid solver |
---|
1310 | IF ( psolver(1:9) == 'multigrid' ) THEN |
---|
1311 | |
---|
1312 | DO i = maximum_grid_level, 1, -1 |
---|
1313 | |
---|
1314 | SELECT CASE ( i ) |
---|
1315 | |
---|
1316 | CASE ( 1 ) |
---|
1317 | ALLOCATE( wall_flags_1(nzb:nzt_mg(i)+1, & |
---|
1318 | nys_mg(i)-1:nyn_mg(i)+1, & |
---|
1319 | nxl_mg(i)-1:nxr_mg(i)+1) ) |
---|
1320 | |
---|
1321 | CASE ( 2 ) |
---|
1322 | ALLOCATE( wall_flags_2(nzb:nzt_mg(i)+1, & |
---|
1323 | nys_mg(i)-1:nyn_mg(i)+1, & |
---|
1324 | nxl_mg(i)-1:nxr_mg(i)+1) ) |
---|
1325 | |
---|
1326 | CASE ( 3 ) |
---|
1327 | ALLOCATE( wall_flags_3(nzb:nzt_mg(i)+1, & |
---|
1328 | nys_mg(i)-1:nyn_mg(i)+1, & |
---|
1329 | nxl_mg(i)-1:nxr_mg(i)+1) ) |
---|
1330 | |
---|
1331 | CASE ( 4 ) |
---|
1332 | ALLOCATE( wall_flags_4(nzb:nzt_mg(i)+1, & |
---|
1333 | nys_mg(i)-1:nyn_mg(i)+1, & |
---|
1334 | nxl_mg(i)-1:nxr_mg(i)+1) ) |
---|
1335 | |
---|
1336 | CASE ( 5 ) |
---|
1337 | ALLOCATE( wall_flags_5(nzb:nzt_mg(i)+1, & |
---|
1338 | nys_mg(i)-1:nyn_mg(i)+1, & |
---|
1339 | nxl_mg(i)-1:nxr_mg(i)+1) ) |
---|
1340 | |
---|
1341 | CASE ( 6 ) |
---|
1342 | ALLOCATE( wall_flags_6(nzb:nzt_mg(i)+1, & |
---|
1343 | nys_mg(i)-1:nyn_mg(i)+1, & |
---|
1344 | nxl_mg(i)-1:nxr_mg(i)+1) ) |
---|
1345 | |
---|
1346 | CASE ( 7 ) |
---|
1347 | ALLOCATE( wall_flags_7(nzb:nzt_mg(i)+1, & |
---|
1348 | nys_mg(i)-1:nyn_mg(i)+1, & |
---|
1349 | nxl_mg(i)-1:nxr_mg(i)+1) ) |
---|
1350 | |
---|
1351 | CASE ( 8 ) |
---|
1352 | ALLOCATE( wall_flags_8(nzb:nzt_mg(i)+1, & |
---|
1353 | nys_mg(i)-1:nyn_mg(i)+1, & |
---|
1354 | nxl_mg(i)-1:nxr_mg(i)+1) ) |
---|
1355 | |
---|
1356 | CASE ( 9 ) |
---|
1357 | ALLOCATE( wall_flags_9(nzb:nzt_mg(i)+1, & |
---|
1358 | nys_mg(i)-1:nyn_mg(i)+1, & |
---|
1359 | nxl_mg(i)-1:nxr_mg(i)+1) ) |
---|
1360 | |
---|
1361 | CASE ( 10 ) |
---|
1362 | ALLOCATE( wall_flags_10(nzb:nzt_mg(i)+1, & |
---|
1363 | nys_mg(i)-1:nyn_mg(i)+1, & |
---|
1364 | nxl_mg(i)-1:nxr_mg(i)+1) ) |
---|
1365 | |
---|
1366 | CASE DEFAULT |
---|
1367 | message_string = 'more than 10 multigrid levels' |
---|
1368 | CALL message( 'init_pegrid', 'PA0238', 1, 2, 0, 6, 0 ) |
---|
1369 | |
---|
1370 | END SELECT |
---|
1371 | |
---|
1372 | ENDDO |
---|
1373 | |
---|
1374 | ENDIF |
---|
1375 | |
---|
1376 | END SUBROUTINE init_pegrid |
---|