[1] | 1 | SUBROUTINE init_pegrid |
---|
| 2 | |
---|
| 3 | !------------------------------------------------------------------------------! |
---|
[254] | 4 | ! Current revisions: |
---|
[1] | 5 | ! ----------------- |
---|
[668] | 6 | ! |
---|
[760] | 7 | ! |
---|
[668] | 8 | ! ATTENTION: nnz_x undefined problem still has to be solved!!!!!!!! |
---|
| 9 | ! TEST OUTPUT (TO BE REMOVED) logging mpi2 ierr values |
---|
[667] | 10 | ! |
---|
[668] | 11 | ! Former revisions: |
---|
| 12 | ! ----------------- |
---|
| 13 | ! $Id: init_pegrid.f90 760 2011-09-15 14:37:54Z suehring $ |
---|
| 14 | ! |
---|
[760] | 15 | ! 759 2011-09-15 13:58:31Z raasch |
---|
| 16 | ! |
---|
| 17 | ! calculation of number of io_blocks and the io_group to which the respective |
---|
| 18 | ! PE belongs |
---|
| 19 | ! |
---|
[756] | 20 | ! 755 2011-08-29 09:55:16Z witha |
---|
| 21 | ! 2d-decomposition is default for lcflow (ForWind cluster in Oldenburg) |
---|
| 22 | ! |
---|
[723] | 23 | ! 722 2011-04-11 06:21:09Z raasch |
---|
| 24 | ! Bugfix: bc_lr/ns_cyc/dirrad/raddir replaced by bc_lr/ns, because variables |
---|
| 25 | ! are not yet set here; grid_level set to 0 |
---|
| 26 | ! |
---|
[710] | 27 | ! 709 2011-03-30 09:31:40Z raasch |
---|
| 28 | ! formatting adjustments |
---|
| 29 | ! |
---|
[708] | 30 | ! 707 2011-03-29 11:39:40Z raasch |
---|
| 31 | ! bc_lr/ns replaced by bc_lr/ns_cyc/dirrad/raddir |
---|
| 32 | ! |
---|
[668] | 33 | ! 667 2010-12-23 12:06:00Z suehring/gryschka |
---|
[667] | 34 | ! Moved determination of target_id's from init_coupling |
---|
[669] | 35 | ! Determination of parameters needed for coupling (coupling_topology, ngp_a, |
---|
| 36 | ! ngp_o) with different grid/processor-topology in ocean and atmosphere |
---|
[667] | 37 | ! Adaption of ngp_xy, ngp_y to a dynamic number of ghost points. |
---|
| 38 | ! The maximum_grid_level changed from 1 to 0. 0 is the normal grid, 1 to |
---|
| 39 | ! maximum_grid_level the grids for multigrid, in which 0 and 1 are normal grids. |
---|
| 40 | ! This distinction is due to reasons of data exchange and performance for the |
---|
| 41 | ! normal grid and grids in poismg. |
---|
| 42 | ! The definition of MPI-Vectors adapted to a dynamic numer of ghost points. |
---|
| 43 | ! New MPI-Vectors for data exchange between left and right boundaries added. |
---|
| 44 | ! This is due to reasons of performance (10% faster). |
---|
[77] | 45 | ! |
---|
[647] | 46 | ! 646 2010-12-15 13:03:52Z raasch |
---|
| 47 | ! lctit is now using a 2d decomposition by default |
---|
| 48 | ! |
---|
[623] | 49 | ! 622 2010-12-10 08:08:13Z raasch |
---|
| 50 | ! optional barriers included in order to speed up collective operations |
---|
| 51 | ! |
---|
[482] | 52 | ! 438 2010-02-01 04:32:43Z raasch |
---|
| 53 | ! 2d-decomposition is default for Cray-XT machines |
---|
[77] | 54 | ! |
---|
[392] | 55 | ! 274 2009-03-26 15:11:21Z heinze |
---|
| 56 | ! Output of messages replaced by message handling routine. |
---|
| 57 | ! |
---|
[226] | 58 | ! 206 2008-10-13 14:59:11Z raasch |
---|
| 59 | ! Implementation of a MPI-1 coupling: added __parallel within the __mpi2 part |
---|
| 60 | ! 2d-decomposition is default on SGI-ICE systems |
---|
| 61 | ! |
---|
[198] | 62 | ! 197 2008-09-16 15:29:03Z raasch |
---|
| 63 | ! multigrid levels are limited by subdomains if mg_switch_to_pe0_level = -1, |
---|
| 64 | ! nz is used instead nnz for calculating mg-levels |
---|
| 65 | ! Collect on PE0 horizontal index bounds from all other PEs, |
---|
| 66 | ! broadcast the id of the inflow PE (using the respective communicator) |
---|
| 67 | ! |
---|
[139] | 68 | ! 114 2007-10-10 00:03:15Z raasch |
---|
| 69 | ! Allocation of wall flag arrays for multigrid solver |
---|
| 70 | ! |
---|
[110] | 71 | ! 108 2007-08-24 15:10:38Z letzel |
---|
| 72 | ! Intercommunicator (comm_inter) and derived data type (type_xy) for |
---|
| 73 | ! coupled model runs created, assign coupling_mode_remote, |
---|
| 74 | ! indices nxlu and nysv are calculated (needed for non-cyclic boundary |
---|
| 75 | ! conditions) |
---|
| 76 | ! |
---|
[83] | 77 | ! 82 2007-04-16 15:40:52Z raasch |
---|
| 78 | ! Cpp-directive lcmuk changed to intel_openmp_bug, setting of host on lcmuk by |
---|
| 79 | ! cpp-directive removed |
---|
| 80 | ! |
---|
[77] | 81 | ! 75 2007-03-22 09:54:05Z raasch |
---|
[73] | 82 | ! uxrp, vynp eliminated, |
---|
[75] | 83 | ! dirichlet/neumann changed to dirichlet/radiation, etc., |
---|
| 84 | ! poisfft_init is only called if fft-solver is switched on |
---|
[1] | 85 | ! |
---|
[3] | 86 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
| 87 | ! |
---|
[1] | 88 | ! Revision 1.28 2006/04/26 13:23:32 raasch |
---|
| 89 | ! lcmuk does not understand the !$ comment so a cpp-directive is required |
---|
| 90 | ! |
---|
| 91 | ! Revision 1.1 1997/07/24 11:15:09 raasch |
---|
| 92 | ! Initial revision |
---|
| 93 | ! |
---|
| 94 | ! |
---|
| 95 | ! Description: |
---|
| 96 | ! ------------ |
---|
| 97 | ! Determination of the virtual processor topology (if not prescribed by the |
---|
| 98 | ! user)and computation of the grid point number and array bounds of the local |
---|
| 99 | ! domains. |
---|
| 100 | !------------------------------------------------------------------------------! |
---|
| 101 | |
---|
| 102 | USE control_parameters |
---|
| 103 | USE fft_xy |
---|
[163] | 104 | USE grid_variables |
---|
[1] | 105 | USE indices |
---|
| 106 | USE pegrid |
---|
| 107 | USE poisfft_mod |
---|
| 108 | USE poisfft_hybrid_mod |
---|
| 109 | USE statistics |
---|
| 110 | USE transpose_indices |
---|
| 111 | |
---|
| 112 | |
---|
[667] | 113 | |
---|
[1] | 114 | IMPLICIT NONE |
---|
| 115 | |
---|
[163] | 116 | INTEGER :: gathered_size, i, id_inflow_l, id_recycling_l, ind(5), j, k, & |
---|
[151] | 117 | maximum_grid_level_l, mg_switch_to_pe0_level_l, mg_levels_x, & |
---|
| 118 | mg_levels_y, mg_levels_z, nnx_y, nnx_z, nny_x, nny_z, nnz_x, & |
---|
| 119 | nnz_y, numproc_sqr, nx_total, nxl_l, nxr_l, nyn_l, nys_l, & |
---|
| 120 | nzb_l, nzt_l, omp_get_num_threads, subdomain_size |
---|
[1] | 121 | |
---|
| 122 | INTEGER, DIMENSION(:), ALLOCATABLE :: ind_all, nxlf, nxrf, nynf, nysf |
---|
| 123 | |
---|
[667] | 124 | INTEGER, DIMENSION(2) :: pdims_remote |
---|
| 125 | |
---|
[1] | 126 | LOGICAL :: found |
---|
| 127 | |
---|
| 128 | ! |
---|
| 129 | !-- Get the number of OpenMP threads |
---|
| 130 | !$OMP PARALLEL |
---|
[82] | 131 | #if defined( __intel_openmp_bug ) |
---|
[1] | 132 | threads_per_task = omp_get_num_threads() |
---|
| 133 | #else |
---|
| 134 | !$ threads_per_task = omp_get_num_threads() |
---|
| 135 | #endif |
---|
| 136 | !$OMP END PARALLEL |
---|
| 137 | |
---|
| 138 | |
---|
| 139 | #if defined( __parallel ) |
---|
[667] | 140 | |
---|
[1] | 141 | ! |
---|
| 142 | !-- Determine the processor topology or check it, if prescribed by the user |
---|
| 143 | IF ( npex == -1 .AND. npey == -1 ) THEN |
---|
| 144 | |
---|
| 145 | ! |
---|
| 146 | !-- Automatic determination of the topology |
---|
| 147 | !-- The default on SMP- and cluster-hosts is a 1d-decomposition along x |
---|
[206] | 148 | IF ( host(1:3) == 'ibm' .OR. host(1:3) == 'nec' .OR. & |
---|
[438] | 149 | ( host(1:2) == 'lc' .AND. host(3:5) /= 'sgi' .AND. & |
---|
[755] | 150 | host(3:4) /= 'xt' .AND. host(3:5) /= 'tit' .AND. & |
---|
| 151 | host(3:6) /= 'flow' ) .OR. host(1:3) == 'dec' ) THEN |
---|
[1] | 152 | |
---|
| 153 | pdims(1) = numprocs |
---|
| 154 | pdims(2) = 1 |
---|
| 155 | |
---|
| 156 | ELSE |
---|
| 157 | |
---|
| 158 | numproc_sqr = SQRT( REAL( numprocs ) ) |
---|
| 159 | pdims(1) = MAX( numproc_sqr , 1 ) |
---|
| 160 | DO WHILE ( MOD( numprocs , pdims(1) ) /= 0 ) |
---|
| 161 | pdims(1) = pdims(1) - 1 |
---|
| 162 | ENDDO |
---|
| 163 | pdims(2) = numprocs / pdims(1) |
---|
| 164 | |
---|
| 165 | ENDIF |
---|
| 166 | |
---|
| 167 | ELSEIF ( npex /= -1 .AND. npey /= -1 ) THEN |
---|
| 168 | |
---|
| 169 | ! |
---|
| 170 | !-- Prescribed by user. Number of processors on the prescribed topology |
---|
| 171 | !-- must be equal to the number of PEs available to the job |
---|
| 172 | IF ( ( npex * npey ) /= numprocs ) THEN |
---|
[274] | 173 | WRITE( message_string, * ) 'number of PEs of the prescribed ', & |
---|
| 174 | 'topology (', npex*npey,') does not match & the number of ', & |
---|
| 175 | 'PEs available to the job (', numprocs, ')' |
---|
[254] | 176 | CALL message( 'init_pegrid', 'PA0221', 1, 2, 0, 6, 0 ) |
---|
[1] | 177 | ENDIF |
---|
| 178 | pdims(1) = npex |
---|
| 179 | pdims(2) = npey |
---|
| 180 | |
---|
| 181 | ELSE |
---|
| 182 | ! |
---|
| 183 | !-- If the processor topology is prescribed by the user, the number of |
---|
| 184 | !-- PEs must be given in both directions |
---|
[274] | 185 | message_string = 'if the processor topology is prescribed by the, ' // & |
---|
| 186 | ' user& both values of "npex" and "npey" must be given ' // & |
---|
| 187 | 'in the &NAMELIST-parameter file' |
---|
[254] | 188 | CALL message( 'init_pegrid', 'PA0222', 1, 2, 0, 6, 0 ) |
---|
[1] | 189 | |
---|
| 190 | ENDIF |
---|
| 191 | |
---|
| 192 | ! |
---|
| 193 | !-- The hybrid solver can only be used in case of a 1d-decomposition along x |
---|
| 194 | IF ( pdims(2) /= 1 .AND. psolver == 'poisfft_hybrid' ) THEN |
---|
[254] | 195 | message_string = 'psolver = "poisfft_hybrid" can only be' // & |
---|
| 196 | '& used in case of a 1d-decomposition along x' |
---|
| 197 | CALL message( 'init_pegrid', 'PA0223', 1, 2, 0, 6, 0 ) |
---|
[1] | 198 | ENDIF |
---|
| 199 | |
---|
| 200 | ! |
---|
[622] | 201 | !-- For communication speedup, set barriers in front of collective |
---|
| 202 | !-- communications by default on SGI-type systems |
---|
| 203 | IF ( host(3:5) == 'sgi' ) collective_wait = .TRUE. |
---|
| 204 | |
---|
| 205 | ! |
---|
[1] | 206 | !-- If necessary, set horizontal boundary conditions to non-cyclic |
---|
[722] | 207 | IF ( bc_lr /= 'cyclic' ) cyclic(1) = .FALSE. |
---|
| 208 | IF ( bc_ns /= 'cyclic' ) cyclic(2) = .FALSE. |
---|
[1] | 209 | |
---|
| 210 | ! |
---|
| 211 | !-- Create the virtual processor grid |
---|
| 212 | CALL MPI_CART_CREATE( comm_palm, ndim, pdims, cyclic, reorder, & |
---|
| 213 | comm2d, ierr ) |
---|
| 214 | CALL MPI_COMM_RANK( comm2d, myid, ierr ) |
---|
| 215 | WRITE (myid_char,'(''_'',I4.4)') myid |
---|
| 216 | |
---|
| 217 | CALL MPI_CART_COORDS( comm2d, myid, ndim, pcoord, ierr ) |
---|
| 218 | CALL MPI_CART_SHIFT( comm2d, 0, 1, pleft, pright, ierr ) |
---|
| 219 | CALL MPI_CART_SHIFT( comm2d, 1, 1, psouth, pnorth, ierr ) |
---|
| 220 | |
---|
| 221 | ! |
---|
| 222 | !-- Determine sub-topologies for transpositions |
---|
| 223 | !-- Transposition from z to x: |
---|
| 224 | remain_dims(1) = .TRUE. |
---|
| 225 | remain_dims(2) = .FALSE. |
---|
| 226 | CALL MPI_CART_SUB( comm2d, remain_dims, comm1dx, ierr ) |
---|
| 227 | CALL MPI_COMM_RANK( comm1dx, myidx, ierr ) |
---|
| 228 | ! |
---|
| 229 | !-- Transposition from x to y |
---|
| 230 | remain_dims(1) = .FALSE. |
---|
| 231 | remain_dims(2) = .TRUE. |
---|
| 232 | CALL MPI_CART_SUB( comm2d, remain_dims, comm1dy, ierr ) |
---|
| 233 | CALL MPI_COMM_RANK( comm1dy, myidy, ierr ) |
---|
| 234 | |
---|
| 235 | |
---|
| 236 | ! |
---|
| 237 | !-- Find a grid (used for array d) which will match the transposition demands |
---|
| 238 | IF ( grid_matching == 'strict' ) THEN |
---|
| 239 | |
---|
| 240 | nxa = nx; nya = ny; nza = nz |
---|
| 241 | |
---|
| 242 | ELSE |
---|
| 243 | |
---|
| 244 | found = .FALSE. |
---|
| 245 | xn: DO nxa = nx, 2*nx |
---|
| 246 | ! |
---|
| 247 | !-- Meet conditions for nx |
---|
| 248 | IF ( MOD( nxa+1, pdims(1) ) /= 0 .OR. & |
---|
| 249 | MOD( nxa+1, pdims(2) ) /= 0 ) CYCLE xn |
---|
| 250 | |
---|
| 251 | yn: DO nya = ny, 2*ny |
---|
| 252 | ! |
---|
| 253 | !-- Meet conditions for ny |
---|
| 254 | IF ( MOD( nya+1, pdims(2) ) /= 0 .OR. & |
---|
| 255 | MOD( nya+1, pdims(1) ) /= 0 ) CYCLE yn |
---|
| 256 | |
---|
| 257 | |
---|
| 258 | zn: DO nza = nz, 2*nz |
---|
| 259 | ! |
---|
| 260 | !-- Meet conditions for nz |
---|
| 261 | IF ( ( MOD( nza, pdims(1) ) /= 0 .AND. pdims(1) /= 1 .AND. & |
---|
| 262 | pdims(2) /= 1 ) .OR. & |
---|
| 263 | ( MOD( nza, pdims(2) ) /= 0 .AND. dt_dosp /= 9999999.9 & |
---|
| 264 | ) ) THEN |
---|
| 265 | CYCLE zn |
---|
| 266 | ELSE |
---|
| 267 | found = .TRUE. |
---|
| 268 | EXIT xn |
---|
| 269 | ENDIF |
---|
| 270 | |
---|
| 271 | ENDDO zn |
---|
| 272 | |
---|
| 273 | ENDDO yn |
---|
| 274 | |
---|
| 275 | ENDDO xn |
---|
| 276 | |
---|
| 277 | IF ( .NOT. found ) THEN |
---|
[254] | 278 | message_string = 'no matching grid for transpositions found' |
---|
| 279 | CALL message( 'init_pegrid', 'PA0224', 1, 2, 0, 6, 0 ) |
---|
[1] | 280 | ENDIF |
---|
| 281 | |
---|
| 282 | ENDIF |
---|
| 283 | |
---|
| 284 | ! |
---|
| 285 | !-- Calculate array bounds in x-direction for every PE. |
---|
| 286 | !-- The last PE along x may get less grid points than the others |
---|
| 287 | ALLOCATE( nxlf(0:pdims(1)-1), nxrf(0:pdims(1)-1), nynf(0:pdims(2)-1), & |
---|
| 288 | nysf(0:pdims(2)-1), nnx_pe(0:pdims(1)-1), nny_pe(0:pdims(2)-1) ) |
---|
| 289 | |
---|
| 290 | IF ( MOD( nxa+1 , pdims(1) ) /= 0 ) THEN |
---|
[274] | 291 | WRITE( message_string, * ) 'x-direction: gridpoint number (',nx+1,') ',& |
---|
| 292 | 'is not an& integral divisor of the number ', & |
---|
| 293 | 'processors (', pdims(1),')' |
---|
[254] | 294 | CALL message( 'init_pegrid', 'PA0225', 1, 2, 0, 6, 0 ) |
---|
[1] | 295 | ELSE |
---|
| 296 | nnx = ( nxa + 1 ) / pdims(1) |
---|
| 297 | IF ( nnx*pdims(1) - ( nx + 1) > nnx ) THEN |
---|
[274] | 298 | WRITE( message_string, * ) 'x-direction: nx does not match the', & |
---|
| 299 | 'requirements given by the number of PEs &used', & |
---|
| 300 | '& please use nx = ', nx - ( pdims(1) - ( nnx*pdims(1) & |
---|
| 301 | - ( nx + 1 ) ) ), ' instead of nx =', nx |
---|
[254] | 302 | CALL message( 'init_pegrid', 'PA0226', 1, 2, 0, 6, 0 ) |
---|
[1] | 303 | ENDIF |
---|
| 304 | ENDIF |
---|
| 305 | |
---|
| 306 | ! |
---|
| 307 | !-- Left and right array bounds, number of gridpoints |
---|
| 308 | DO i = 0, pdims(1)-1 |
---|
| 309 | nxlf(i) = i * nnx |
---|
| 310 | nxrf(i) = ( i + 1 ) * nnx - 1 |
---|
| 311 | nnx_pe(i) = MIN( nx, nxrf(i) ) - nxlf(i) + 1 |
---|
| 312 | ENDDO |
---|
| 313 | |
---|
| 314 | ! |
---|
| 315 | !-- Calculate array bounds in y-direction for every PE. |
---|
| 316 | IF ( MOD( nya+1 , pdims(2) ) /= 0 ) THEN |
---|
[274] | 317 | WRITE( message_string, * ) 'y-direction: gridpoint number (',ny+1,') ', & |
---|
| 318 | 'is not an& integral divisor of the number of', & |
---|
| 319 | 'processors (', pdims(2),')' |
---|
[254] | 320 | CALL message( 'init_pegrid', 'PA0227', 1, 2, 0, 6, 0 ) |
---|
[1] | 321 | ELSE |
---|
| 322 | nny = ( nya + 1 ) / pdims(2) |
---|
| 323 | IF ( nny*pdims(2) - ( ny + 1) > nny ) THEN |
---|
[274] | 324 | WRITE( message_string, * ) 'y-direction: ny does not match the', & |
---|
| 325 | 'requirements given by the number of PEs &used ', & |
---|
| 326 | '& please use ny = ', ny - ( pdims(2) - ( nnx*pdims(2) & |
---|
[254] | 327 | - ( ny + 1 ) ) ), ' instead of ny =', ny |
---|
| 328 | CALL message( 'init_pegrid', 'PA0228', 1, 2, 0, 6, 0 ) |
---|
[1] | 329 | ENDIF |
---|
| 330 | ENDIF |
---|
| 331 | |
---|
| 332 | ! |
---|
| 333 | !-- South and north array bounds |
---|
| 334 | DO j = 0, pdims(2)-1 |
---|
| 335 | nysf(j) = j * nny |
---|
| 336 | nynf(j) = ( j + 1 ) * nny - 1 |
---|
| 337 | nny_pe(j) = MIN( ny, nynf(j) ) - nysf(j) + 1 |
---|
| 338 | ENDDO |
---|
| 339 | |
---|
| 340 | ! |
---|
| 341 | !-- Local array bounds of the respective PEs |
---|
| 342 | nxl = nxlf(pcoord(1)) |
---|
| 343 | nxra = nxrf(pcoord(1)) |
---|
| 344 | nxr = MIN( nx, nxra ) |
---|
| 345 | nys = nysf(pcoord(2)) |
---|
| 346 | nyna = nynf(pcoord(2)) |
---|
| 347 | nyn = MIN( ny, nyna ) |
---|
| 348 | nzb = 0 |
---|
| 349 | nzta = nza |
---|
| 350 | nzt = MIN( nz, nzta ) |
---|
| 351 | nnz = nza |
---|
| 352 | |
---|
| 353 | ! |
---|
[707] | 354 | !-- Set switches to define if the PE is situated at the border of the virtual |
---|
| 355 | !-- processor grid |
---|
| 356 | IF ( nxl == 0 ) left_border_pe = .TRUE. |
---|
| 357 | IF ( nxr == nx ) right_border_pe = .TRUE. |
---|
| 358 | IF ( nys == 0 ) south_border_pe = .TRUE. |
---|
| 359 | IF ( nyn == ny ) north_border_pe = .TRUE. |
---|
| 360 | |
---|
| 361 | ! |
---|
[1] | 362 | !-- Calculate array bounds and gridpoint numbers for the transposed arrays |
---|
| 363 | !-- (needed in the pressure solver) |
---|
| 364 | !-- For the transposed arrays, cyclic boundaries as well as top and bottom |
---|
| 365 | !-- boundaries are omitted, because they are obstructive to the transposition |
---|
| 366 | |
---|
| 367 | ! |
---|
| 368 | !-- 1. transposition z --> x |
---|
| 369 | !-- This transposition is not neccessary in case of a 1d-decomposition along x, |
---|
| 370 | !-- except that the uptream-spline method is switched on |
---|
| 371 | IF ( pdims(2) /= 1 .OR. momentum_advec == 'ups-scheme' .OR. & |
---|
| 372 | scalar_advec == 'ups-scheme' ) THEN |
---|
| 373 | |
---|
| 374 | IF ( pdims(2) == 1 .AND. ( momentum_advec == 'ups-scheme' .OR. & |
---|
| 375 | scalar_advec == 'ups-scheme' ) ) THEN |
---|
[254] | 376 | message_string = '1d-decomposition along x ' // & |
---|
| 377 | 'chosen but nz restrictions may occur' // & |
---|
| 378 | '& since ups-scheme is activated' |
---|
| 379 | CALL message( 'init_pegrid', 'PA0229', 0, 1, 0, 6, 0 ) |
---|
[1] | 380 | ENDIF |
---|
| 381 | nys_x = nys |
---|
| 382 | nyn_xa = nyna |
---|
| 383 | nyn_x = nyn |
---|
| 384 | nny_x = nny |
---|
| 385 | IF ( MOD( nza , pdims(1) ) /= 0 ) THEN |
---|
[274] | 386 | WRITE( message_string, * ) 'transposition z --> x:', & |
---|
| 387 | '&nz=',nz,' is not an integral divisior of pdims(1)=', & |
---|
| 388 | pdims(1) |
---|
[254] | 389 | CALL message( 'init_pegrid', 'PA0230', 1, 2, 0, 6, 0 ) |
---|
[1] | 390 | ENDIF |
---|
| 391 | nnz_x = nza / pdims(1) |
---|
| 392 | nzb_x = 1 + myidx * nnz_x |
---|
| 393 | nzt_xa = ( myidx + 1 ) * nnz_x |
---|
| 394 | nzt_x = MIN( nzt, nzt_xa ) |
---|
| 395 | |
---|
| 396 | sendrecvcount_zx = nnx * nny * nnz_x |
---|
| 397 | |
---|
[181] | 398 | ELSE |
---|
| 399 | ! |
---|
| 400 | !--- Setting of dummy values because otherwise variables are undefined in |
---|
| 401 | !--- the next step x --> y |
---|
| 402 | !--- WARNING: This case has still to be clarified!!!!!!!!!!!! |
---|
| 403 | nnz_x = 1 |
---|
| 404 | nzb_x = 1 |
---|
| 405 | nzt_xa = 1 |
---|
| 406 | nzt_x = 1 |
---|
| 407 | nny_x = nny |
---|
| 408 | |
---|
[1] | 409 | ENDIF |
---|
| 410 | |
---|
| 411 | ! |
---|
| 412 | !-- 2. transposition x --> y |
---|
| 413 | nnz_y = nnz_x |
---|
| 414 | nzb_y = nzb_x |
---|
| 415 | nzt_ya = nzt_xa |
---|
| 416 | nzt_y = nzt_x |
---|
| 417 | IF ( MOD( nxa+1 , pdims(2) ) /= 0 ) THEN |
---|
[274] | 418 | WRITE( message_string, * ) 'transposition x --> y:', & |
---|
| 419 | '&nx+1=',nx+1,' is not an integral divisor of ',& |
---|
| 420 | 'pdims(2)=',pdims(2) |
---|
[254] | 421 | CALL message( 'init_pegrid', 'PA0231', 1, 2, 0, 6, 0 ) |
---|
[1] | 422 | ENDIF |
---|
| 423 | nnx_y = (nxa+1) / pdims(2) |
---|
| 424 | nxl_y = myidy * nnx_y |
---|
| 425 | nxr_ya = ( myidy + 1 ) * nnx_y - 1 |
---|
| 426 | nxr_y = MIN( nx, nxr_ya ) |
---|
| 427 | |
---|
| 428 | sendrecvcount_xy = nnx_y * nny_x * nnz_y |
---|
| 429 | |
---|
| 430 | ! |
---|
| 431 | !-- 3. transposition y --> z (ELSE: x --> y in case of 1D-decomposition |
---|
| 432 | !-- along x) |
---|
| 433 | IF ( pdims(2) /= 1 .OR. momentum_advec == 'ups-scheme' .OR. & |
---|
| 434 | scalar_advec == 'ups-scheme' ) THEN |
---|
| 435 | ! |
---|
| 436 | !-- y --> z |
---|
| 437 | !-- This transposition is not neccessary in case of a 1d-decomposition |
---|
| 438 | !-- along x, except that the uptream-spline method is switched on |
---|
| 439 | nnx_z = nnx_y |
---|
| 440 | nxl_z = nxl_y |
---|
| 441 | nxr_za = nxr_ya |
---|
| 442 | nxr_z = nxr_y |
---|
| 443 | IF ( MOD( nya+1 , pdims(1) ) /= 0 ) THEN |
---|
[274] | 444 | WRITE( message_string, * ) 'transposition y --> z:', & |
---|
| 445 | '& ny+1=',ny+1,' is not an integral divisor of ',& |
---|
| 446 | 'pdims(1)=',pdims(1) |
---|
[254] | 447 | CALL message( 'init_pegrid', 'PA0232', 1, 2, 0, 6, 0 ) |
---|
[1] | 448 | ENDIF |
---|
| 449 | nny_z = (nya+1) / pdims(1) |
---|
| 450 | nys_z = myidx * nny_z |
---|
| 451 | nyn_za = ( myidx + 1 ) * nny_z - 1 |
---|
| 452 | nyn_z = MIN( ny, nyn_za ) |
---|
| 453 | |
---|
| 454 | sendrecvcount_yz = nnx_y * nny_z * nnz_y |
---|
| 455 | |
---|
| 456 | ELSE |
---|
| 457 | ! |
---|
| 458 | !-- x --> y. This condition must be fulfilled for a 1D-decomposition along x |
---|
| 459 | IF ( MOD( nya+1 , pdims(1) ) /= 0 ) THEN |
---|
[274] | 460 | WRITE( message_string, * ) 'transposition x --> y:', & |
---|
| 461 | '& ny+1=',ny+1,' is not an integral divisor of ',& |
---|
| 462 | 'pdims(1)=',pdims(1) |
---|
[254] | 463 | CALL message( 'init_pegrid', 'PA0233', 1, 2, 0, 6, 0 ) |
---|
[1] | 464 | ENDIF |
---|
| 465 | |
---|
| 466 | ENDIF |
---|
| 467 | |
---|
| 468 | ! |
---|
| 469 | !-- Indices for direct transpositions z --> y (used for calculating spectra) |
---|
| 470 | IF ( dt_dosp /= 9999999.9 ) THEN |
---|
| 471 | IF ( MOD( nza, pdims(2) ) /= 0 ) THEN |
---|
[274] | 472 | WRITE( message_string, * ) 'direct transposition z --> y (needed ', & |
---|
| 473 | 'for spectra):& nz=',nz,' is not an integral divisor of ',& |
---|
| 474 | 'pdims(2)=',pdims(2) |
---|
[254] | 475 | CALL message( 'init_pegrid', 'PA0234', 1, 2, 0, 6, 0 ) |
---|
[1] | 476 | ELSE |
---|
| 477 | nxl_yd = nxl |
---|
| 478 | nxr_yda = nxra |
---|
| 479 | nxr_yd = nxr |
---|
| 480 | nzb_yd = 1 + myidy * ( nza / pdims(2) ) |
---|
| 481 | nzt_yda = ( myidy + 1 ) * ( nza / pdims(2) ) |
---|
| 482 | nzt_yd = MIN( nzt, nzt_yda ) |
---|
| 483 | |
---|
| 484 | sendrecvcount_zyd = nnx * nny * ( nza / pdims(2) ) |
---|
| 485 | ENDIF |
---|
| 486 | ENDIF |
---|
| 487 | |
---|
| 488 | ! |
---|
| 489 | !-- Indices for direct transpositions y --> x (they are only possible in case |
---|
| 490 | !-- of a 1d-decomposition along x) |
---|
| 491 | IF ( pdims(2) == 1 ) THEN |
---|
| 492 | nny_x = nny / pdims(1) |
---|
| 493 | nys_x = myid * nny_x |
---|
| 494 | nyn_xa = ( myid + 1 ) * nny_x - 1 |
---|
| 495 | nyn_x = MIN( ny, nyn_xa ) |
---|
| 496 | nzb_x = 1 |
---|
| 497 | nzt_xa = nza |
---|
| 498 | nzt_x = nz |
---|
| 499 | sendrecvcount_xy = nnx * nny_x * nza |
---|
| 500 | ENDIF |
---|
| 501 | |
---|
| 502 | ! |
---|
| 503 | !-- Indices for direct transpositions x --> y (they are only possible in case |
---|
| 504 | !-- of a 1d-decomposition along y) |
---|
| 505 | IF ( pdims(1) == 1 ) THEN |
---|
| 506 | nnx_y = nnx / pdims(2) |
---|
| 507 | nxl_y = myid * nnx_y |
---|
| 508 | nxr_ya = ( myid + 1 ) * nnx_y - 1 |
---|
| 509 | nxr_y = MIN( nx, nxr_ya ) |
---|
| 510 | nzb_y = 1 |
---|
| 511 | nzt_ya = nza |
---|
| 512 | nzt_y = nz |
---|
| 513 | sendrecvcount_xy = nnx_y * nny * nza |
---|
| 514 | ENDIF |
---|
| 515 | |
---|
| 516 | ! |
---|
| 517 | !-- Arrays for storing the array bounds are needed any more |
---|
| 518 | DEALLOCATE( nxlf , nxrf , nynf , nysf ) |
---|
| 519 | |
---|
[145] | 520 | ! |
---|
| 521 | !-- Collect index bounds from other PEs (to be written to restart file later) |
---|
| 522 | ALLOCATE( hor_index_bounds(4,0:numprocs-1) ) |
---|
| 523 | |
---|
| 524 | IF ( myid == 0 ) THEN |
---|
| 525 | |
---|
| 526 | hor_index_bounds(1,0) = nxl |
---|
| 527 | hor_index_bounds(2,0) = nxr |
---|
| 528 | hor_index_bounds(3,0) = nys |
---|
| 529 | hor_index_bounds(4,0) = nyn |
---|
| 530 | |
---|
| 531 | ! |
---|
| 532 | !-- Receive data from all other PEs |
---|
| 533 | DO i = 1, numprocs-1 |
---|
| 534 | CALL MPI_RECV( ibuf, 4, MPI_INTEGER, i, MPI_ANY_TAG, comm2d, status, & |
---|
| 535 | ierr ) |
---|
| 536 | hor_index_bounds(:,i) = ibuf(1:4) |
---|
| 537 | ENDDO |
---|
| 538 | |
---|
| 539 | ELSE |
---|
| 540 | ! |
---|
| 541 | !-- Send index bounds to PE0 |
---|
| 542 | ibuf(1) = nxl |
---|
| 543 | ibuf(2) = nxr |
---|
| 544 | ibuf(3) = nys |
---|
| 545 | ibuf(4) = nyn |
---|
| 546 | CALL MPI_SEND( ibuf, 4, MPI_INTEGER, 0, myid, comm2d, ierr ) |
---|
| 547 | |
---|
| 548 | ENDIF |
---|
| 549 | |
---|
[1] | 550 | #if defined( __print ) |
---|
| 551 | ! |
---|
| 552 | !-- Control output |
---|
| 553 | IF ( myid == 0 ) THEN |
---|
| 554 | PRINT*, '*** processor topology ***' |
---|
| 555 | PRINT*, ' ' |
---|
| 556 | PRINT*, 'myid pcoord left right south north idx idy nxl: nxr',& |
---|
| 557 | &' nys: nyn' |
---|
| 558 | PRINT*, '------------------------------------------------------------',& |
---|
| 559 | &'-----------' |
---|
| 560 | WRITE (*,1000) 0, pcoord(1), pcoord(2), pleft, pright, psouth, pnorth, & |
---|
| 561 | myidx, myidy, nxl, nxr, nys, nyn |
---|
| 562 | 1000 FORMAT (I4,2X,'(',I3,',',I3,')',3X,I4,2X,I4,3X,I4,2X,I4,2X,I3,1X,I3, & |
---|
| 563 | 2(2X,I4,':',I4)) |
---|
| 564 | |
---|
| 565 | ! |
---|
[108] | 566 | !-- Receive data from the other PEs |
---|
[1] | 567 | DO i = 1,numprocs-1 |
---|
| 568 | CALL MPI_RECV( ibuf, 12, MPI_INTEGER, i, MPI_ANY_TAG, comm2d, status, & |
---|
| 569 | ierr ) |
---|
| 570 | WRITE (*,1000) i, ( ibuf(j) , j = 1,12 ) |
---|
| 571 | ENDDO |
---|
| 572 | ELSE |
---|
| 573 | |
---|
| 574 | ! |
---|
| 575 | !-- Send data to PE0 |
---|
| 576 | ibuf(1) = pcoord(1); ibuf(2) = pcoord(2); ibuf(3) = pleft |
---|
| 577 | ibuf(4) = pright; ibuf(5) = psouth; ibuf(6) = pnorth; ibuf(7) = myidx |
---|
| 578 | ibuf(8) = myidy; ibuf(9) = nxl; ibuf(10) = nxr; ibuf(11) = nys |
---|
| 579 | ibuf(12) = nyn |
---|
| 580 | CALL MPI_SEND( ibuf, 12, MPI_INTEGER, 0, myid, comm2d, ierr ) |
---|
| 581 | ENDIF |
---|
| 582 | #endif |
---|
| 583 | |
---|
[206] | 584 | #if defined( __parallel ) |
---|
[102] | 585 | #if defined( __mpi2 ) |
---|
| 586 | ! |
---|
| 587 | !-- In case of coupled runs, get the port name on PE0 of the atmosphere model |
---|
| 588 | !-- and pass it to PE0 of the ocean model |
---|
| 589 | IF ( myid == 0 ) THEN |
---|
| 590 | |
---|
| 591 | IF ( coupling_mode == 'atmosphere_to_ocean' ) THEN |
---|
| 592 | |
---|
| 593 | CALL MPI_OPEN_PORT( MPI_INFO_NULL, port_name, ierr ) |
---|
[108] | 594 | |
---|
[102] | 595 | CALL MPI_PUBLISH_NAME( 'palm_coupler', MPI_INFO_NULL, port_name, & |
---|
| 596 | ierr ) |
---|
[108] | 597 | |
---|
| 598 | ! |
---|
[104] | 599 | !-- Write a flag file for the ocean model and the other atmosphere |
---|
| 600 | !-- processes. |
---|
| 601 | !-- There seems to be a bug in MPICH2 which causes hanging processes |
---|
| 602 | !-- in case that execution of LOOKUP_NAME is continued too early |
---|
| 603 | !-- (i.e. before the port has been created) |
---|
| 604 | OPEN( 90, FILE='COUPLING_PORT_OPENED', FORM='FORMATTED' ) |
---|
| 605 | WRITE ( 90, '(''TRUE'')' ) |
---|
| 606 | CLOSE ( 90 ) |
---|
[102] | 607 | |
---|
| 608 | ELSEIF ( coupling_mode == 'ocean_to_atmosphere' ) THEN |
---|
| 609 | |
---|
[104] | 610 | ! |
---|
| 611 | !-- Continue only if the atmosphere model has created the port. |
---|
| 612 | !-- There seems to be a bug in MPICH2 which causes hanging processes |
---|
| 613 | !-- in case that execution of LOOKUP_NAME is continued too early |
---|
| 614 | !-- (i.e. before the port has been created) |
---|
| 615 | INQUIRE( FILE='COUPLING_PORT_OPENED', EXIST=found ) |
---|
| 616 | DO WHILE ( .NOT. found ) |
---|
| 617 | INQUIRE( FILE='COUPLING_PORT_OPENED', EXIST=found ) |
---|
| 618 | ENDDO |
---|
| 619 | |
---|
[102] | 620 | CALL MPI_LOOKUP_NAME( 'palm_coupler', MPI_INFO_NULL, port_name, ierr ) |
---|
| 621 | |
---|
| 622 | ENDIF |
---|
| 623 | |
---|
| 624 | ENDIF |
---|
| 625 | |
---|
| 626 | ! |
---|
| 627 | !-- In case of coupled runs, establish the connection between the atmosphere |
---|
| 628 | !-- and the ocean model and define the intercommunicator (comm_inter) |
---|
| 629 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 630 | IF ( coupling_mode == 'atmosphere_to_ocean' ) THEN |
---|
| 631 | |
---|
| 632 | CALL MPI_COMM_ACCEPT( port_name, MPI_INFO_NULL, 0, MPI_COMM_WORLD, & |
---|
| 633 | comm_inter, ierr ) |
---|
[108] | 634 | coupling_mode_remote = 'ocean_to_atmosphere' |
---|
| 635 | |
---|
[102] | 636 | ELSEIF ( coupling_mode == 'ocean_to_atmosphere' ) THEN |
---|
| 637 | |
---|
| 638 | CALL MPI_COMM_CONNECT( port_name, MPI_INFO_NULL, 0, MPI_COMM_WORLD, & |
---|
| 639 | comm_inter, ierr ) |
---|
[108] | 640 | coupling_mode_remote = 'atmosphere_to_ocean' |
---|
| 641 | |
---|
[102] | 642 | ENDIF |
---|
[206] | 643 | #endif |
---|
[102] | 644 | |
---|
[667] | 645 | ! |
---|
[709] | 646 | !-- Determine the number of ghost point layers |
---|
| 647 | IF ( scalar_advec == 'ws-scheme' .OR. momentum_advec == 'ws-scheme' ) THEN |
---|
[667] | 648 | nbgp = 3 |
---|
| 649 | ELSE |
---|
| 650 | nbgp = 1 |
---|
[709] | 651 | ENDIF |
---|
[667] | 652 | |
---|
[102] | 653 | ! |
---|
[709] | 654 | !-- Create a new MPI derived datatype for the exchange of surface (xy) data, |
---|
| 655 | !-- which is needed for coupled atmosphere-ocean runs. |
---|
| 656 | !-- First, calculate number of grid points of an xy-plane. |
---|
[667] | 657 | ngp_xy = ( nxr - nxl + 1 + 2 * nbgp ) * ( nyn - nys + 1 + 2 * nbgp ) |
---|
[102] | 658 | CALL MPI_TYPE_VECTOR( ngp_xy, 1, nzt-nzb+2, MPI_REAL, type_xy, ierr ) |
---|
| 659 | CALL MPI_TYPE_COMMIT( type_xy, ierr ) |
---|
[667] | 660 | |
---|
[709] | 661 | IF ( TRIM( coupling_mode ) /= 'uncoupled' ) THEN |
---|
[667] | 662 | |
---|
| 663 | ! |
---|
| 664 | !-- Pass the number of grid points of the atmosphere model to |
---|
| 665 | !-- the ocean model and vice versa |
---|
| 666 | IF ( coupling_mode == 'atmosphere_to_ocean' ) THEN |
---|
| 667 | |
---|
| 668 | nx_a = nx |
---|
| 669 | ny_a = ny |
---|
| 670 | |
---|
[709] | 671 | IF ( myid == 0 ) THEN |
---|
| 672 | |
---|
| 673 | CALL MPI_SEND( nx_a, 1, MPI_INTEGER, numprocs, 1, comm_inter, & |
---|
| 674 | ierr ) |
---|
| 675 | CALL MPI_SEND( ny_a, 1, MPI_INTEGER, numprocs, 2, comm_inter, & |
---|
| 676 | ierr ) |
---|
| 677 | CALL MPI_SEND( pdims, 2, MPI_INTEGER, numprocs, 3, comm_inter, & |
---|
| 678 | ierr ) |
---|
| 679 | CALL MPI_RECV( nx_o, 1, MPI_INTEGER, numprocs, 4, comm_inter, & |
---|
| 680 | status, ierr ) |
---|
| 681 | CALL MPI_RECV( ny_o, 1, MPI_INTEGER, numprocs, 5, comm_inter, & |
---|
| 682 | status, ierr ) |
---|
| 683 | CALL MPI_RECV( pdims_remote, 2, MPI_INTEGER, numprocs, 6, & |
---|
[667] | 684 | comm_inter, status, ierr ) |
---|
| 685 | ENDIF |
---|
| 686 | |
---|
[709] | 687 | CALL MPI_BCAST( nx_o, 1, MPI_INTEGER, 0, comm2d, ierr ) |
---|
| 688 | CALL MPI_BCAST( ny_o, 1, MPI_INTEGER, 0, comm2d, ierr ) |
---|
| 689 | CALL MPI_BCAST( pdims_remote, 2, MPI_INTEGER, 0, comm2d, ierr ) |
---|
[667] | 690 | |
---|
| 691 | ELSEIF ( coupling_mode == 'ocean_to_atmosphere' ) THEN |
---|
| 692 | |
---|
| 693 | nx_o = nx |
---|
| 694 | ny_o = ny |
---|
| 695 | |
---|
| 696 | IF ( myid == 0 ) THEN |
---|
[709] | 697 | |
---|
| 698 | CALL MPI_RECV( nx_a, 1, MPI_INTEGER, 0, 1, comm_inter, status, & |
---|
| 699 | ierr ) |
---|
| 700 | CALL MPI_RECV( ny_a, 1, MPI_INTEGER, 0, 2, comm_inter, status, & |
---|
| 701 | ierr ) |
---|
| 702 | CALL MPI_RECV( pdims_remote, 2, MPI_INTEGER, 0, 3, comm_inter, & |
---|
| 703 | status, ierr ) |
---|
| 704 | CALL MPI_SEND( nx_o, 1, MPI_INTEGER, 0, 4, comm_inter, ierr ) |
---|
| 705 | CALL MPI_SEND( ny_o, 1, MPI_INTEGER, 0, 5, comm_inter, ierr ) |
---|
| 706 | CALL MPI_SEND( pdims, 2, MPI_INTEGER, 0, 6, comm_inter, ierr ) |
---|
[667] | 707 | ENDIF |
---|
| 708 | |
---|
| 709 | CALL MPI_BCAST( nx_a, 1, MPI_INTEGER, 0, comm2d, ierr) |
---|
| 710 | CALL MPI_BCAST( ny_a, 1, MPI_INTEGER, 0, comm2d, ierr) |
---|
| 711 | CALL MPI_BCAST( pdims_remote, 2, MPI_INTEGER, 0, comm2d, ierr) |
---|
| 712 | |
---|
| 713 | ENDIF |
---|
| 714 | |
---|
[709] | 715 | ngp_a = ( nx_a+1 + 2 * nbgp ) * ( ny_a+1 + 2 * nbgp ) |
---|
| 716 | ngp_o = ( nx_o+1 + 2 * nbgp ) * ( ny_o+1 + 2 * nbgp ) |
---|
[667] | 717 | |
---|
| 718 | ! |
---|
[709] | 719 | !-- Determine if the horizontal grid and the number of PEs in ocean and |
---|
| 720 | !-- atmosphere is same or not |
---|
| 721 | IF ( nx_o == nx_a .AND. ny_o == ny_a .AND. & |
---|
[667] | 722 | pdims(1) == pdims_remote(1) .AND. pdims(2) == pdims_remote(2) ) & |
---|
| 723 | THEN |
---|
| 724 | coupling_topology = 0 |
---|
| 725 | ELSE |
---|
| 726 | coupling_topology = 1 |
---|
| 727 | ENDIF |
---|
| 728 | |
---|
| 729 | ! |
---|
| 730 | !-- Determine the target PEs for the exchange between ocean and |
---|
| 731 | !-- atmosphere (comm2d) |
---|
[709] | 732 | IF ( coupling_topology == 0 ) THEN |
---|
| 733 | ! |
---|
| 734 | !-- In case of identical topologies, every atmosphere PE has exactly one |
---|
| 735 | !-- ocean PE counterpart and vice versa |
---|
| 736 | IF ( TRIM( coupling_mode ) == 'atmosphere_to_ocean' ) THEN |
---|
[667] | 737 | target_id = myid + numprocs |
---|
| 738 | ELSE |
---|
| 739 | target_id = myid |
---|
| 740 | ENDIF |
---|
| 741 | |
---|
| 742 | ELSE |
---|
| 743 | ! |
---|
| 744 | !-- In case of nonequivalent topology in ocean and atmosphere only for |
---|
| 745 | !-- PE0 in ocean and PE0 in atmosphere a target_id is needed, since |
---|
[709] | 746 | !-- data echxchange between ocean and atmosphere will be done only |
---|
| 747 | !-- between these PEs. |
---|
| 748 | IF ( myid == 0 ) THEN |
---|
| 749 | |
---|
| 750 | IF ( TRIM( coupling_mode ) == 'atmosphere_to_ocean' ) THEN |
---|
[667] | 751 | target_id = numprocs |
---|
| 752 | ELSE |
---|
| 753 | target_id = 0 |
---|
| 754 | ENDIF |
---|
[709] | 755 | |
---|
[667] | 756 | ENDIF |
---|
[709] | 757 | |
---|
[667] | 758 | ENDIF |
---|
| 759 | |
---|
| 760 | ENDIF |
---|
| 761 | |
---|
| 762 | |
---|
[102] | 763 | #endif |
---|
| 764 | |
---|
[1] | 765 | #else |
---|
| 766 | |
---|
| 767 | ! |
---|
| 768 | !-- Array bounds when running on a single PE (respectively a non-parallel |
---|
| 769 | !-- machine) |
---|
| 770 | nxl = 0 |
---|
| 771 | nxr = nx |
---|
| 772 | nxra = nx |
---|
| 773 | nnx = nxr - nxl + 1 |
---|
| 774 | nys = 0 |
---|
| 775 | nyn = ny |
---|
| 776 | nyna = ny |
---|
| 777 | nny = nyn - nys + 1 |
---|
| 778 | nzb = 0 |
---|
| 779 | nzt = nz |
---|
| 780 | nzta = nz |
---|
| 781 | nnz = nz |
---|
| 782 | |
---|
[145] | 783 | ALLOCATE( hor_index_bounds(4,0:0) ) |
---|
| 784 | hor_index_bounds(1,0) = nxl |
---|
| 785 | hor_index_bounds(2,0) = nxr |
---|
| 786 | hor_index_bounds(3,0) = nys |
---|
| 787 | hor_index_bounds(4,0) = nyn |
---|
| 788 | |
---|
[1] | 789 | ! |
---|
| 790 | !-- Array bounds for the pressure solver (in the parallel code, these bounds |
---|
| 791 | !-- are the ones for the transposed arrays) |
---|
| 792 | nys_x = nys |
---|
| 793 | nyn_x = nyn |
---|
| 794 | nyn_xa = nyn |
---|
| 795 | nzb_x = nzb + 1 |
---|
| 796 | nzt_x = nzt |
---|
| 797 | nzt_xa = nzt |
---|
| 798 | |
---|
| 799 | nxl_y = nxl |
---|
| 800 | nxr_y = nxr |
---|
| 801 | nxr_ya = nxr |
---|
| 802 | nzb_y = nzb + 1 |
---|
| 803 | nzt_y = nzt |
---|
| 804 | nzt_ya = nzt |
---|
| 805 | |
---|
| 806 | nxl_z = nxl |
---|
| 807 | nxr_z = nxr |
---|
| 808 | nxr_za = nxr |
---|
| 809 | nys_z = nys |
---|
| 810 | nyn_z = nyn |
---|
| 811 | nyn_za = nyn |
---|
| 812 | |
---|
| 813 | #endif |
---|
| 814 | |
---|
| 815 | ! |
---|
| 816 | !-- Calculate number of grid levels necessary for the multigrid poisson solver |
---|
| 817 | !-- as well as the gridpoint indices on each level |
---|
| 818 | IF ( psolver == 'multigrid' ) THEN |
---|
| 819 | |
---|
| 820 | ! |
---|
| 821 | !-- First calculate number of possible grid levels for the subdomains |
---|
| 822 | mg_levels_x = 1 |
---|
| 823 | mg_levels_y = 1 |
---|
| 824 | mg_levels_z = 1 |
---|
| 825 | |
---|
| 826 | i = nnx |
---|
| 827 | DO WHILE ( MOD( i, 2 ) == 0 .AND. i /= 2 ) |
---|
| 828 | i = i / 2 |
---|
| 829 | mg_levels_x = mg_levels_x + 1 |
---|
| 830 | ENDDO |
---|
| 831 | |
---|
| 832 | j = nny |
---|
| 833 | DO WHILE ( MOD( j, 2 ) == 0 .AND. j /= 2 ) |
---|
| 834 | j = j / 2 |
---|
| 835 | mg_levels_y = mg_levels_y + 1 |
---|
| 836 | ENDDO |
---|
| 837 | |
---|
[181] | 838 | k = nz ! do not use nnz because it might be > nz due to transposition |
---|
| 839 | ! requirements |
---|
[1] | 840 | DO WHILE ( MOD( k, 2 ) == 0 .AND. k /= 2 ) |
---|
| 841 | k = k / 2 |
---|
| 842 | mg_levels_z = mg_levels_z + 1 |
---|
| 843 | ENDDO |
---|
| 844 | |
---|
| 845 | maximum_grid_level = MIN( mg_levels_x, mg_levels_y, mg_levels_z ) |
---|
| 846 | |
---|
| 847 | ! |
---|
| 848 | !-- Find out, if the total domain allows more levels. These additional |
---|
[709] | 849 | !-- levels are identically processed on all PEs. |
---|
[197] | 850 | IF ( numprocs > 1 .AND. mg_switch_to_pe0_level /= -1 ) THEN |
---|
[709] | 851 | |
---|
[1] | 852 | IF ( mg_levels_z > MIN( mg_levels_x, mg_levels_y ) ) THEN |
---|
[709] | 853 | |
---|
[1] | 854 | mg_switch_to_pe0_level_l = maximum_grid_level |
---|
| 855 | |
---|
| 856 | mg_levels_x = 1 |
---|
| 857 | mg_levels_y = 1 |
---|
| 858 | |
---|
| 859 | i = nx+1 |
---|
| 860 | DO WHILE ( MOD( i, 2 ) == 0 .AND. i /= 2 ) |
---|
| 861 | i = i / 2 |
---|
| 862 | mg_levels_x = mg_levels_x + 1 |
---|
| 863 | ENDDO |
---|
| 864 | |
---|
| 865 | j = ny+1 |
---|
| 866 | DO WHILE ( MOD( j, 2 ) == 0 .AND. j /= 2 ) |
---|
| 867 | j = j / 2 |
---|
| 868 | mg_levels_y = mg_levels_y + 1 |
---|
| 869 | ENDDO |
---|
| 870 | |
---|
| 871 | maximum_grid_level_l = MIN( mg_levels_x, mg_levels_y, mg_levels_z ) |
---|
| 872 | |
---|
| 873 | IF ( maximum_grid_level_l > mg_switch_to_pe0_level_l ) THEN |
---|
| 874 | mg_switch_to_pe0_level_l = maximum_grid_level_l - & |
---|
| 875 | mg_switch_to_pe0_level_l + 1 |
---|
| 876 | ELSE |
---|
| 877 | mg_switch_to_pe0_level_l = 0 |
---|
| 878 | ENDIF |
---|
[709] | 879 | |
---|
[1] | 880 | ELSE |
---|
[709] | 881 | |
---|
[1] | 882 | mg_switch_to_pe0_level_l = 0 |
---|
| 883 | maximum_grid_level_l = maximum_grid_level |
---|
[709] | 884 | |
---|
[1] | 885 | ENDIF |
---|
| 886 | |
---|
| 887 | ! |
---|
| 888 | !-- Use switch level calculated above only if it is not pre-defined |
---|
| 889 | !-- by user |
---|
| 890 | IF ( mg_switch_to_pe0_level == 0 ) THEN |
---|
| 891 | |
---|
| 892 | IF ( mg_switch_to_pe0_level_l /= 0 ) THEN |
---|
| 893 | mg_switch_to_pe0_level = mg_switch_to_pe0_level_l |
---|
| 894 | maximum_grid_level = maximum_grid_level_l |
---|
| 895 | ENDIF |
---|
| 896 | |
---|
| 897 | ELSE |
---|
| 898 | ! |
---|
| 899 | !-- Check pre-defined value and reset to default, if neccessary |
---|
| 900 | IF ( mg_switch_to_pe0_level < mg_switch_to_pe0_level_l .OR. & |
---|
| 901 | mg_switch_to_pe0_level >= maximum_grid_level_l ) THEN |
---|
[254] | 902 | message_string = 'mg_switch_to_pe0_level ' // & |
---|
| 903 | 'out of range and reset to default (=0)' |
---|
| 904 | CALL message( 'init_pegrid', 'PA0235', 0, 1, 0, 6, 0 ) |
---|
[1] | 905 | mg_switch_to_pe0_level = 0 |
---|
| 906 | ELSE |
---|
| 907 | ! |
---|
| 908 | !-- Use the largest number of possible levels anyway and recalculate |
---|
| 909 | !-- the switch level to this largest number of possible values |
---|
| 910 | maximum_grid_level = maximum_grid_level_l |
---|
| 911 | |
---|
| 912 | ENDIF |
---|
[709] | 913 | |
---|
[1] | 914 | ENDIF |
---|
| 915 | |
---|
| 916 | ENDIF |
---|
| 917 | |
---|
| 918 | ALLOCATE( grid_level_count(maximum_grid_level), & |
---|
| 919 | nxl_mg(maximum_grid_level), nxr_mg(maximum_grid_level), & |
---|
| 920 | nyn_mg(maximum_grid_level), nys_mg(maximum_grid_level), & |
---|
| 921 | nzt_mg(maximum_grid_level) ) |
---|
| 922 | |
---|
| 923 | grid_level_count = 0 |
---|
| 924 | nxl_l = nxl; nxr_l = nxr; nys_l = nys; nyn_l = nyn; nzt_l = nzt |
---|
| 925 | |
---|
| 926 | DO i = maximum_grid_level, 1 , -1 |
---|
| 927 | |
---|
| 928 | IF ( i == mg_switch_to_pe0_level ) THEN |
---|
| 929 | #if defined( __parallel ) |
---|
| 930 | ! |
---|
| 931 | !-- Save the grid size of the subdomain at the switch level, because |
---|
| 932 | !-- it is needed in poismg. |
---|
| 933 | ind(1) = nxl_l; ind(2) = nxr_l |
---|
| 934 | ind(3) = nys_l; ind(4) = nyn_l |
---|
| 935 | ind(5) = nzt_l |
---|
| 936 | ALLOCATE( ind_all(5*numprocs), mg_loc_ind(5,0:numprocs-1) ) |
---|
| 937 | CALL MPI_ALLGATHER( ind, 5, MPI_INTEGER, ind_all, 5, & |
---|
| 938 | MPI_INTEGER, comm2d, ierr ) |
---|
| 939 | DO j = 0, numprocs-1 |
---|
| 940 | DO k = 1, 5 |
---|
| 941 | mg_loc_ind(k,j) = ind_all(k+j*5) |
---|
| 942 | ENDDO |
---|
| 943 | ENDDO |
---|
| 944 | DEALLOCATE( ind_all ) |
---|
| 945 | ! |
---|
[709] | 946 | !-- Calculate the grid size of the total domain |
---|
[1] | 947 | nxr_l = ( nxr_l-nxl_l+1 ) * pdims(1) - 1 |
---|
| 948 | nxl_l = 0 |
---|
| 949 | nyn_l = ( nyn_l-nys_l+1 ) * pdims(2) - 1 |
---|
| 950 | nys_l = 0 |
---|
| 951 | ! |
---|
| 952 | !-- The size of this gathered array must not be larger than the |
---|
| 953 | !-- array tend, which is used in the multigrid scheme as a temporary |
---|
| 954 | !-- array |
---|
| 955 | subdomain_size = ( nxr - nxl + 3 ) * ( nyn - nys + 3 ) * & |
---|
| 956 | ( nzt - nzb + 2 ) |
---|
| 957 | gathered_size = ( nxr_l - nxl_l + 3 ) * ( nyn_l - nys_l + 3 ) * & |
---|
| 958 | ( nzt_l - nzb + 2 ) |
---|
| 959 | |
---|
| 960 | IF ( gathered_size > subdomain_size ) THEN |
---|
[254] | 961 | message_string = 'not enough memory for storing ' // & |
---|
| 962 | 'gathered multigrid data on PE0' |
---|
| 963 | CALL message( 'init_pegrid', 'PA0236', 1, 2, 0, 6, 0 ) |
---|
[1] | 964 | ENDIF |
---|
| 965 | #else |
---|
[254] | 966 | message_string = 'multigrid gather/scatter impossible ' // & |
---|
[1] | 967 | 'in non parallel mode' |
---|
[254] | 968 | CALL message( 'init_pegrid', 'PA0237', 1, 2, 0, 6, 0 ) |
---|
[1] | 969 | #endif |
---|
| 970 | ENDIF |
---|
| 971 | |
---|
| 972 | nxl_mg(i) = nxl_l |
---|
| 973 | nxr_mg(i) = nxr_l |
---|
| 974 | nys_mg(i) = nys_l |
---|
| 975 | nyn_mg(i) = nyn_l |
---|
| 976 | nzt_mg(i) = nzt_l |
---|
| 977 | |
---|
| 978 | nxl_l = nxl_l / 2 |
---|
| 979 | nxr_l = nxr_l / 2 |
---|
| 980 | nys_l = nys_l / 2 |
---|
| 981 | nyn_l = nyn_l / 2 |
---|
| 982 | nzt_l = nzt_l / 2 |
---|
| 983 | ENDDO |
---|
| 984 | |
---|
| 985 | ELSE |
---|
| 986 | |
---|
[667] | 987 | maximum_grid_level = 0 |
---|
[1] | 988 | |
---|
| 989 | ENDIF |
---|
| 990 | |
---|
[722] | 991 | ! |
---|
| 992 | !-- Default level 0 tells exchange_horiz that all ghost planes have to be |
---|
| 993 | !-- exchanged. grid_level is adjusted in poismg, where only one ghost plane |
---|
| 994 | !-- is required. |
---|
| 995 | grid_level = 0 |
---|
[1] | 996 | |
---|
| 997 | #if defined( __parallel ) |
---|
| 998 | ! |
---|
| 999 | !-- Gridpoint number for the exchange of ghost points (y-line for 2D-arrays) |
---|
[667] | 1000 | ngp_y = nyn - nys + 1 + 2 * nbgp |
---|
[1] | 1001 | |
---|
| 1002 | ! |
---|
[709] | 1003 | !-- Define new MPI derived datatypes for the exchange of ghost points in |
---|
| 1004 | !-- x- and y-direction for 2D-arrays (line) |
---|
| 1005 | CALL MPI_TYPE_VECTOR( nxr-nxl+1+2*nbgp, nbgp, ngp_y, MPI_REAL, type_x, & |
---|
| 1006 | ierr ) |
---|
[1] | 1007 | CALL MPI_TYPE_COMMIT( type_x, ierr ) |
---|
[709] | 1008 | CALL MPI_TYPE_VECTOR( nxr-nxl+1+2*nbgp, nbgp, ngp_y, MPI_INTEGER, & |
---|
| 1009 | type_x_int, ierr ) |
---|
[1] | 1010 | CALL MPI_TYPE_COMMIT( type_x_int, ierr ) |
---|
| 1011 | |
---|
[667] | 1012 | CALL MPI_TYPE_VECTOR( nbgp, ngp_y, ngp_y, MPI_REAL, type_y, ierr ) |
---|
| 1013 | CALL MPI_TYPE_COMMIT( type_y, ierr ) |
---|
| 1014 | CALL MPI_TYPE_VECTOR( nbgp, ngp_y, ngp_y, MPI_INTEGER, type_y_int, ierr ) |
---|
| 1015 | CALL MPI_TYPE_COMMIT( type_y_int, ierr ) |
---|
| 1016 | |
---|
| 1017 | |
---|
[1] | 1018 | ! |
---|
| 1019 | !-- Calculate gridpoint numbers for the exchange of ghost points along x |
---|
| 1020 | !-- (yz-plane for 3D-arrays) and define MPI derived data type(s) for the |
---|
| 1021 | !-- exchange of ghost points in y-direction (xz-plane). |
---|
| 1022 | !-- Do these calculations for the model grid and (if necessary) also |
---|
| 1023 | !-- for the coarser grid levels used in the multigrid method |
---|
[667] | 1024 | ALLOCATE ( ngp_yz(0:maximum_grid_level), type_xz(0:maximum_grid_level),& |
---|
| 1025 | type_yz(0:maximum_grid_level) ) |
---|
[1] | 1026 | |
---|
| 1027 | nxl_l = nxl; nxr_l = nxr; nys_l = nys; nyn_l = nyn; nzb_l = nzb; nzt_l = nzt |
---|
[709] | 1028 | |
---|
[667] | 1029 | ! |
---|
| 1030 | !-- Discern between the model grid, which needs nbgp ghost points and |
---|
| 1031 | !-- grid levels for the multigrid scheme. In the latter case only one |
---|
| 1032 | !-- ghost point is necessary. |
---|
[709] | 1033 | !-- First definition of MPI-datatypes for exchange of ghost layers on normal |
---|
[667] | 1034 | !-- grid. The following loop is needed for data exchange in poismg.f90. |
---|
| 1035 | ! |
---|
| 1036 | !-- Determine number of grid points of yz-layer for exchange |
---|
| 1037 | ngp_yz(0) = (nzt - nzb + 2) * (nyn - nys + 1 + 2 * nbgp) |
---|
[709] | 1038 | |
---|
[667] | 1039 | ! |
---|
[709] | 1040 | !-- Define an MPI-datatype for the exchange of left/right boundaries. |
---|
| 1041 | !-- Although data are contiguous in physical memory (which does not |
---|
| 1042 | !-- necessarily require an MPI-derived datatype), the data exchange between |
---|
| 1043 | !-- left and right PE's using the MPI-derived type is 10% faster than without. |
---|
[667] | 1044 | CALL MPI_TYPE_VECTOR( nxr-nxl+1+2*nbgp, nbgp*(nzt-nzb+2), ngp_yz(0), & |
---|
[709] | 1045 | MPI_REAL, type_xz(0), ierr ) |
---|
[667] | 1046 | CALL MPI_TYPE_COMMIT( type_xz(0), ierr ) |
---|
[1] | 1047 | |
---|
[709] | 1048 | CALL MPI_TYPE_VECTOR( nbgp, ngp_yz(0), ngp_yz(0), MPI_REAL, type_yz(0), & |
---|
| 1049 | ierr ) |
---|
[667] | 1050 | CALL MPI_TYPE_COMMIT( type_yz(0), ierr ) |
---|
[709] | 1051 | |
---|
[667] | 1052 | ! |
---|
[709] | 1053 | !-- Definition of MPI-datatypes for multigrid method (coarser level grids) |
---|
[667] | 1054 | IF ( psolver == 'multigrid' ) THEN |
---|
| 1055 | ! |
---|
[709] | 1056 | !-- Definition of MPI-datatyoe as above, but only 1 ghost level is used |
---|
| 1057 | DO i = maximum_grid_level, 1 , -1 |
---|
| 1058 | |
---|
[667] | 1059 | ngp_yz(i) = (nzt_l - nzb_l + 2) * (nyn_l - nys_l + 3) |
---|
| 1060 | |
---|
| 1061 | CALL MPI_TYPE_VECTOR( nxr_l-nxl_l+3, nzt_l-nzb_l+2, ngp_yz(i), & |
---|
[709] | 1062 | MPI_REAL, type_xz(i), ierr ) |
---|
[667] | 1063 | CALL MPI_TYPE_COMMIT( type_xz(i), ierr ) |
---|
[1] | 1064 | |
---|
[709] | 1065 | CALL MPI_TYPE_VECTOR( 1, ngp_yz(i), ngp_yz(i), MPI_REAL, type_yz(i), & |
---|
| 1066 | ierr ) |
---|
[667] | 1067 | CALL MPI_TYPE_COMMIT( type_yz(i), ierr ) |
---|
| 1068 | |
---|
| 1069 | nxl_l = nxl_l / 2 |
---|
| 1070 | nxr_l = nxr_l / 2 |
---|
| 1071 | nys_l = nys_l / 2 |
---|
| 1072 | nyn_l = nyn_l / 2 |
---|
| 1073 | nzt_l = nzt_l / 2 |
---|
[709] | 1074 | |
---|
[667] | 1075 | ENDDO |
---|
[709] | 1076 | |
---|
| 1077 | ENDIF |
---|
[1] | 1078 | #endif |
---|
| 1079 | |
---|
| 1080 | #if defined( __parallel ) |
---|
| 1081 | ! |
---|
| 1082 | !-- Setting of flags for inflow/outflow conditions in case of non-cyclic |
---|
[106] | 1083 | !-- horizontal boundary conditions. |
---|
[1] | 1084 | IF ( pleft == MPI_PROC_NULL ) THEN |
---|
[722] | 1085 | IF ( bc_lr == 'dirichlet/radiation' ) THEN |
---|
[1] | 1086 | inflow_l = .TRUE. |
---|
[722] | 1087 | ELSEIF ( bc_lr == 'radiation/dirichlet' ) THEN |
---|
[1] | 1088 | outflow_l = .TRUE. |
---|
| 1089 | ENDIF |
---|
| 1090 | ENDIF |
---|
| 1091 | |
---|
| 1092 | IF ( pright == MPI_PROC_NULL ) THEN |
---|
[722] | 1093 | IF ( bc_lr == 'dirichlet/radiation' ) THEN |
---|
[1] | 1094 | outflow_r = .TRUE. |
---|
[722] | 1095 | ELSEIF ( bc_lr == 'radiation/dirichlet' ) THEN |
---|
[1] | 1096 | inflow_r = .TRUE. |
---|
| 1097 | ENDIF |
---|
| 1098 | ENDIF |
---|
| 1099 | |
---|
| 1100 | IF ( psouth == MPI_PROC_NULL ) THEN |
---|
[722] | 1101 | IF ( bc_ns == 'dirichlet/radiation' ) THEN |
---|
[1] | 1102 | outflow_s = .TRUE. |
---|
[722] | 1103 | ELSEIF ( bc_ns == 'radiation/dirichlet' ) THEN |
---|
[1] | 1104 | inflow_s = .TRUE. |
---|
| 1105 | ENDIF |
---|
| 1106 | ENDIF |
---|
| 1107 | |
---|
| 1108 | IF ( pnorth == MPI_PROC_NULL ) THEN |
---|
[722] | 1109 | IF ( bc_ns == 'dirichlet/radiation' ) THEN |
---|
[1] | 1110 | inflow_n = .TRUE. |
---|
[722] | 1111 | ELSEIF ( bc_ns == 'radiation/dirichlet' ) THEN |
---|
[1] | 1112 | outflow_n = .TRUE. |
---|
| 1113 | ENDIF |
---|
| 1114 | ENDIF |
---|
| 1115 | |
---|
[151] | 1116 | ! |
---|
| 1117 | !-- Broadcast the id of the inflow PE |
---|
| 1118 | IF ( inflow_l ) THEN |
---|
[163] | 1119 | id_inflow_l = myidx |
---|
[151] | 1120 | ELSE |
---|
| 1121 | id_inflow_l = 0 |
---|
| 1122 | ENDIF |
---|
[622] | 1123 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
[151] | 1124 | CALL MPI_ALLREDUCE( id_inflow_l, id_inflow, 1, MPI_INTEGER, MPI_SUM, & |
---|
| 1125 | comm1dx, ierr ) |
---|
| 1126 | |
---|
[163] | 1127 | ! |
---|
| 1128 | !-- Broadcast the id of the recycling plane |
---|
| 1129 | !-- WARNING: needs to be adjusted in case of inflows other than from left side! |
---|
[622] | 1130 | IF ( ( recycling_width / dx ) >= nxl .AND. & |
---|
| 1131 | ( recycling_width / dx ) <= nxr ) THEN |
---|
[163] | 1132 | id_recycling_l = myidx |
---|
| 1133 | ELSE |
---|
| 1134 | id_recycling_l = 0 |
---|
| 1135 | ENDIF |
---|
[622] | 1136 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
[163] | 1137 | CALL MPI_ALLREDUCE( id_recycling_l, id_recycling, 1, MPI_INTEGER, MPI_SUM, & |
---|
| 1138 | comm1dx, ierr ) |
---|
| 1139 | |
---|
[1] | 1140 | #else |
---|
[722] | 1141 | IF ( bc_lr == 'dirichlet/radiation' ) THEN |
---|
[1] | 1142 | inflow_l = .TRUE. |
---|
| 1143 | outflow_r = .TRUE. |
---|
[722] | 1144 | ELSEIF ( bc_lr == 'radiation/dirichlet' ) THEN |
---|
[1] | 1145 | outflow_l = .TRUE. |
---|
| 1146 | inflow_r = .TRUE. |
---|
| 1147 | ENDIF |
---|
| 1148 | |
---|
[722] | 1149 | IF ( bc_ns == 'dirichlet/radiation' ) THEN |
---|
[1] | 1150 | inflow_n = .TRUE. |
---|
| 1151 | outflow_s = .TRUE. |
---|
[722] | 1152 | ELSEIF ( bc_ns == 'radiation/dirichlet' ) THEN |
---|
[1] | 1153 | outflow_n = .TRUE. |
---|
| 1154 | inflow_s = .TRUE. |
---|
| 1155 | ENDIF |
---|
| 1156 | #endif |
---|
[106] | 1157 | ! |
---|
[110] | 1158 | !-- At the outflow, u or v, respectively, have to be calculated for one more |
---|
| 1159 | !-- grid point. |
---|
[106] | 1160 | IF ( outflow_l ) THEN |
---|
| 1161 | nxlu = nxl + 1 |
---|
| 1162 | ELSE |
---|
| 1163 | nxlu = nxl |
---|
| 1164 | ENDIF |
---|
| 1165 | IF ( outflow_s ) THEN |
---|
| 1166 | nysv = nys + 1 |
---|
| 1167 | ELSE |
---|
| 1168 | nysv = nys |
---|
| 1169 | ENDIF |
---|
[1] | 1170 | |
---|
| 1171 | IF ( psolver == 'poisfft_hybrid' ) THEN |
---|
| 1172 | CALL poisfft_hybrid_ini |
---|
[75] | 1173 | ELSEIF ( psolver == 'poisfft' ) THEN |
---|
[1] | 1174 | CALL poisfft_init |
---|
| 1175 | ENDIF |
---|
| 1176 | |
---|
[114] | 1177 | ! |
---|
| 1178 | !-- Allocate wall flag arrays used in the multigrid solver |
---|
| 1179 | IF ( psolver == 'multigrid' ) THEN |
---|
| 1180 | |
---|
| 1181 | DO i = maximum_grid_level, 1, -1 |
---|
| 1182 | |
---|
| 1183 | SELECT CASE ( i ) |
---|
| 1184 | |
---|
| 1185 | CASE ( 1 ) |
---|
| 1186 | ALLOCATE( wall_flags_1(nzb:nzt_mg(i)+1, & |
---|
| 1187 | nys_mg(i)-1:nyn_mg(i)+1, & |
---|
| 1188 | nxl_mg(i)-1:nxr_mg(i)+1) ) |
---|
| 1189 | |
---|
| 1190 | CASE ( 2 ) |
---|
| 1191 | ALLOCATE( wall_flags_2(nzb:nzt_mg(i)+1, & |
---|
| 1192 | nys_mg(i)-1:nyn_mg(i)+1, & |
---|
| 1193 | nxl_mg(i)-1:nxr_mg(i)+1) ) |
---|
| 1194 | |
---|
| 1195 | CASE ( 3 ) |
---|
| 1196 | ALLOCATE( wall_flags_3(nzb:nzt_mg(i)+1, & |
---|
| 1197 | nys_mg(i)-1:nyn_mg(i)+1, & |
---|
| 1198 | nxl_mg(i)-1:nxr_mg(i)+1) ) |
---|
| 1199 | |
---|
| 1200 | CASE ( 4 ) |
---|
| 1201 | ALLOCATE( wall_flags_4(nzb:nzt_mg(i)+1, & |
---|
| 1202 | nys_mg(i)-1:nyn_mg(i)+1, & |
---|
| 1203 | nxl_mg(i)-1:nxr_mg(i)+1) ) |
---|
| 1204 | |
---|
| 1205 | CASE ( 5 ) |
---|
| 1206 | ALLOCATE( wall_flags_5(nzb:nzt_mg(i)+1, & |
---|
| 1207 | nys_mg(i)-1:nyn_mg(i)+1, & |
---|
| 1208 | nxl_mg(i)-1:nxr_mg(i)+1) ) |
---|
| 1209 | |
---|
| 1210 | CASE ( 6 ) |
---|
| 1211 | ALLOCATE( wall_flags_6(nzb:nzt_mg(i)+1, & |
---|
| 1212 | nys_mg(i)-1:nyn_mg(i)+1, & |
---|
| 1213 | nxl_mg(i)-1:nxr_mg(i)+1) ) |
---|
| 1214 | |
---|
| 1215 | CASE ( 7 ) |
---|
| 1216 | ALLOCATE( wall_flags_7(nzb:nzt_mg(i)+1, & |
---|
| 1217 | nys_mg(i)-1:nyn_mg(i)+1, & |
---|
| 1218 | nxl_mg(i)-1:nxr_mg(i)+1) ) |
---|
| 1219 | |
---|
| 1220 | CASE ( 8 ) |
---|
| 1221 | ALLOCATE( wall_flags_8(nzb:nzt_mg(i)+1, & |
---|
| 1222 | nys_mg(i)-1:nyn_mg(i)+1, & |
---|
| 1223 | nxl_mg(i)-1:nxr_mg(i)+1) ) |
---|
| 1224 | |
---|
| 1225 | CASE ( 9 ) |
---|
| 1226 | ALLOCATE( wall_flags_9(nzb:nzt_mg(i)+1, & |
---|
| 1227 | nys_mg(i)-1:nyn_mg(i)+1, & |
---|
| 1228 | nxl_mg(i)-1:nxr_mg(i)+1) ) |
---|
| 1229 | |
---|
| 1230 | CASE ( 10 ) |
---|
| 1231 | ALLOCATE( wall_flags_10(nzb:nzt_mg(i)+1, & |
---|
| 1232 | nys_mg(i)-1:nyn_mg(i)+1, & |
---|
| 1233 | nxl_mg(i)-1:nxr_mg(i)+1) ) |
---|
| 1234 | |
---|
| 1235 | CASE DEFAULT |
---|
[254] | 1236 | message_string = 'more than 10 multigrid levels' |
---|
| 1237 | CALL message( 'init_pegrid', 'PA0238', 1, 2, 0, 6, 0 ) |
---|
[114] | 1238 | |
---|
| 1239 | END SELECT |
---|
| 1240 | |
---|
| 1241 | ENDDO |
---|
| 1242 | |
---|
| 1243 | ENDIF |
---|
| 1244 | |
---|
[759] | 1245 | ! |
---|
| 1246 | !-- Calculate the number of groups into which parallel I/O is split. |
---|
| 1247 | !-- The default for files which are opened by all PEs (or where each |
---|
| 1248 | !-- PE opens his own independent file) is, that all PEs are doing input/output |
---|
| 1249 | !-- in parallel at the same time. This might cause performance or even more |
---|
| 1250 | !-- severe problems depending on the configuration of the underlying file |
---|
| 1251 | !-- system. |
---|
| 1252 | !-- First, set the default: |
---|
| 1253 | IF ( maximum_parallel_io_streams == -1 .OR. & |
---|
| 1254 | maximum_parallel_io_streams > numprocs ) THEN |
---|
| 1255 | maximum_parallel_io_streams = numprocs |
---|
| 1256 | ENDIF |
---|
| 1257 | |
---|
| 1258 | ! |
---|
| 1259 | !-- Now calculate the number of io_blocks and the io_group to which the |
---|
| 1260 | !-- respective PE belongs. I/O of the groups is done in serial, but in parallel |
---|
| 1261 | !-- for all PEs belonging to the same group. A preliminary setting with myid |
---|
| 1262 | !-- based on MPI_COMM_WORLD has been done in parin. |
---|
| 1263 | io_blocks = numprocs / maximum_parallel_io_streams |
---|
| 1264 | io_group = MOD( myid+1, io_blocks ) |
---|
| 1265 | |
---|
| 1266 | |
---|
[1] | 1267 | END SUBROUTINE init_pegrid |
---|