[1] | 1 | SUBROUTINE init_pegrid |
---|
| 2 | |
---|
| 3 | !------------------------------------------------------------------------------! |
---|
| 4 | ! Actual revisions: |
---|
| 5 | ! ----------------- |
---|
| 6 | ! |
---|
| 7 | ! |
---|
| 8 | ! Former revisions: |
---|
| 9 | ! ----------------- |
---|
| 10 | ! $Log: init_pegrid.f90,v $ |
---|
| 11 | ! Revision 1.28 2006/04/26 13:23:32 raasch |
---|
| 12 | ! lcmuk does not understand the !$ comment so a cpp-directive is required |
---|
| 13 | ! |
---|
| 14 | ! Revision 1.27 2006/04/26 12:50:32 raasch |
---|
| 15 | ! Get the number of OpenMP threads |
---|
| 16 | ! |
---|
| 17 | ! Revision 1.26 2006/02/23 12:34:57 raasch |
---|
| 18 | ! Calculation of nanz_sums, nanz_2dh and nanz_3d moved to init_3d_model, |
---|
| 19 | ! anz_y.. renamed ngp_y.., + MPI type type_x_int |
---|
| 20 | ! |
---|
| 21 | ! Revision 1.25 2005/10/20 15:37:36 raasch |
---|
| 22 | ! error removed: the last PE in a row is not allowed to have more grid points |
---|
| 23 | ! than the other PES (only less) |
---|
| 24 | ! |
---|
| 25 | ! Revision 1.24 2005/03/26 20:35:06 raasch |
---|
| 26 | ! Extensions for non-cyclic boundary conditions |
---|
| 27 | ! MIN function must be used instead of MAX for deciding if a switch to PE0 is |
---|
| 28 | ! useful (multigrid-method), maximuma_grid_level_l is defined in case that a |
---|
| 29 | ! pre-defined value for mg_switch_to_pe0_level is given (caused errors on NEC) |
---|
| 30 | ! |
---|
| 31 | ! Revision 1.23 2004/04/30 12:27:13 raasch |
---|
| 32 | ! Setting 1d-decomposition as default on decalpha, indices for direct |
---|
| 33 | ! transpositions z --> y and y --> x added, +module poisfft_mod, |
---|
| 34 | ! data types for mpi_alltoallv removed (not neeeded any more), |
---|
| 35 | ! poisfft_hybrid is no longer enforced in case of a 1d-decomposition along x, |
---|
| 36 | ! an enlarged grid which will fit all transposition demands is calculated, |
---|
| 37 | ! impulse_advec renamed momentum_advec |
---|
| 38 | ! |
---|
| 39 | ! Revision 1.22 2003/10/29 08:56:20 raasch |
---|
| 40 | ! Number of possible grid levels for the mulitgrid-method are calculated |
---|
| 41 | ! based on the total domain grid |
---|
| 42 | ! |
---|
| 43 | ! Revision 1.21 2003/08/01 08:40:03 raasch |
---|
| 44 | ! Error removed: for a 1D-decomposition along x, the number PEs must also |
---|
| 45 | ! be an integral divisor of the number of gridpoints along y |
---|
| 46 | ! |
---|
| 47 | ! Revision 1.20 2003/05/09 14:27:26 raasch |
---|
| 48 | ! Setting 1d-decomposition as default on linux clusters |
---|
| 49 | ! |
---|
| 50 | ! Revision 1.19 2003/04/16 13:00:11 raasch |
---|
| 51 | ! Call of fft_1dd_init, +module fft_for_1d_decomp |
---|
| 52 | ! |
---|
| 53 | ! Revision 1.18 2003/03/16 09:39:57 raasch |
---|
| 54 | ! Two underscores (_) are placed in front of all define-strings |
---|
| 55 | ! |
---|
| 56 | ! Revision 1.17 2003/03/12 16:32:47 raasch |
---|
| 57 | ! A 1d-decomposition along x is the default on NEC hosts |
---|
| 58 | ! |
---|
| 59 | ! Revision 1.16 2002/12/19 15:40:39 raasch |
---|
| 60 | ! In case of 1d-decomposition along x only a part of the integral divisor |
---|
| 61 | ! conditions is checked, on IBM hosts a 1d-decomposition along x is the |
---|
| 62 | ! default, a switch from Poisson-FFT-solver to the hybrid-solver is made |
---|
| 63 | ! in case of 1d-decomposition along x, the hybrid-solver does not force a |
---|
| 64 | ! 1d-decomposition any more, STOP replaced by call of local_stop |
---|
| 65 | ! |
---|
| 66 | ! Revision 1.15 2002/06/11 13:10:58 raasch |
---|
| 67 | ! Usage of the Poisson-hybrid-solver forces a 1d-decomposition, |
---|
| 68 | ! initialization of hybrid-solver |
---|
| 69 | ! |
---|
| 70 | ! Revision 1.14 2001/08/21 09:49:45 09:49:45 raasch (Siegfried Raasch) |
---|
| 71 | ! MPI_COMM_WORLD replaced by comm_palm |
---|
| 72 | ! |
---|
| 73 | ! Revision 1.13 2001/07/20 13:07:26 raasch |
---|
| 74 | ! In case of using multigrid method, grid levels and additional MPI derived data |
---|
| 75 | ! types are calculated. anz_yz and type_xz are now arrays. |
---|
| 76 | ! |
---|
| 77 | ! Revision 1.12 2001/03/30 07:32:01 raasch |
---|
| 78 | ! Calculations of nw and nw1 removed, |
---|
| 79 | ! Translation of remaining German identifiers (variables, subroutines, etc.) |
---|
| 80 | ! |
---|
| 81 | ! Revision 1.11 2001/01/22 08:33:48 raasch |
---|
| 82 | ! Module test_variables removed |
---|
| 83 | ! |
---|
| 84 | ! Revision 1.9 2000/12/28 13:16:37 raasch |
---|
| 85 | ! definition of mpi_particle_type moved to subroutine init_particles |
---|
| 86 | ! |
---|
| 87 | ! Revision 1.8 2000/04/27 06:54:03 raasch |
---|
| 88 | ! Processor topology can now be prescribed by the user using npex and npey, |
---|
| 89 | ! all comments translated into English |
---|
| 90 | ! |
---|
| 91 | ! Revision 1.7 1999/11/25 16:23:36 raasch |
---|
| 92 | ! MPI-Datentyp fuer Partikeltransfer vereinbart |
---|
| 93 | ! |
---|
| 94 | ! Revision 1.6 1998/07/16 06:50:23 raasch |
---|
| 95 | ! cpp-Direktiven fuer t3ej2 und t3ej5 erweitert |
---|
| 96 | ! |
---|
| 97 | ! Revision 1.5 1998/07/06 12:17:06 raasch |
---|
| 98 | ! + USE test_variables |
---|
| 99 | ! |
---|
| 100 | ! Revision 1.4 1998/03/18 20:13:42 raasch |
---|
| 101 | ! myid_char auf 5 Zeichen erweitert |
---|
| 102 | ! |
---|
| 103 | ! Revision 1.3 1998/01/23 10:02:08 raasch |
---|
| 104 | ! Gitterpunktzahlen und Datentyp fuer 2D-Randaustausch |
---|
| 105 | ! anz_yz_p, type_xz_p in anz_yz und type_xz umbenannt |
---|
| 106 | ! |
---|
| 107 | ! Revision 1.2 1997/08/11 06:18:28 raasch |
---|
| 108 | ! Gitterpunktanzahl von globalen Feldern werden berechnet |
---|
| 109 | ! |
---|
| 110 | ! Revision 1.1 1997/07/24 11:15:09 raasch |
---|
| 111 | ! Initial revision |
---|
| 112 | ! |
---|
| 113 | ! |
---|
| 114 | ! Description: |
---|
| 115 | ! ------------ |
---|
| 116 | ! Determination of the virtual processor topology (if not prescribed by the |
---|
| 117 | ! user)and computation of the grid point number and array bounds of the local |
---|
| 118 | ! domains. |
---|
| 119 | !------------------------------------------------------------------------------! |
---|
| 120 | |
---|
| 121 | USE control_parameters |
---|
| 122 | USE fft_xy |
---|
| 123 | USE indices |
---|
| 124 | USE pegrid |
---|
| 125 | USE poisfft_mod |
---|
| 126 | USE poisfft_hybrid_mod |
---|
| 127 | USE statistics |
---|
| 128 | USE transpose_indices |
---|
| 129 | |
---|
| 130 | |
---|
| 131 | IMPLICIT NONE |
---|
| 132 | |
---|
| 133 | INTEGER :: gathered_size, i, ind(5), j, k, maximum_grid_level_l, & |
---|
| 134 | mg_switch_to_pe0_level_l, mg_levels_x, mg_levels_y, & |
---|
| 135 | mg_levels_z, nnx_y, nnx_z, nny_x, nny_z, nnz_x, nnz_y, & |
---|
| 136 | numproc_sqr, nx_total, nxl_l, nxr_l, nyn_l, nys_l, nzb_l, & |
---|
| 137 | nzt_l, omp_get_num_threads, subdomain_size |
---|
| 138 | |
---|
| 139 | INTEGER, DIMENSION(:), ALLOCATABLE :: ind_all, nxlf, nxrf, nynf, nysf |
---|
| 140 | |
---|
| 141 | LOGICAL :: found |
---|
| 142 | |
---|
| 143 | ! |
---|
| 144 | !-- Get the number of OpenMP threads |
---|
| 145 | !$OMP PARALLEL |
---|
| 146 | #if defined( __lcmuk ) |
---|
| 147 | threads_per_task = omp_get_num_threads() |
---|
| 148 | #else |
---|
| 149 | !$ threads_per_task = omp_get_num_threads() |
---|
| 150 | #endif |
---|
| 151 | !$OMP END PARALLEL |
---|
| 152 | |
---|
| 153 | |
---|
| 154 | #if defined( __parallel ) |
---|
| 155 | ! |
---|
| 156 | !-- Determine the processor topology or check it, if prescribed by the user |
---|
| 157 | IF ( npex == -1 .AND. npey == -1 ) THEN |
---|
| 158 | |
---|
| 159 | ! |
---|
| 160 | !-- Automatic determination of the topology |
---|
| 161 | !-- The default on SMP- and cluster-hosts is a 1d-decomposition along x |
---|
| 162 | #if defined( __lcmuk ) |
---|
| 163 | host = 'lcmuk' |
---|
| 164 | #endif |
---|
| 165 | IF ( host(1:3) == 'ibm' .OR. host(1:3) == 'nec' .OR. & |
---|
| 166 | host(1:2) == 'lc' .OR. host(1:3) == 'dec' ) THEN |
---|
| 167 | |
---|
| 168 | pdims(1) = numprocs |
---|
| 169 | pdims(2) = 1 |
---|
| 170 | |
---|
| 171 | ELSE |
---|
| 172 | |
---|
| 173 | numproc_sqr = SQRT( REAL( numprocs ) ) |
---|
| 174 | pdims(1) = MAX( numproc_sqr , 1 ) |
---|
| 175 | DO WHILE ( MOD( numprocs , pdims(1) ) /= 0 ) |
---|
| 176 | pdims(1) = pdims(1) - 1 |
---|
| 177 | ENDDO |
---|
| 178 | pdims(2) = numprocs / pdims(1) |
---|
| 179 | |
---|
| 180 | ENDIF |
---|
| 181 | |
---|
| 182 | ELSEIF ( npex /= -1 .AND. npey /= -1 ) THEN |
---|
| 183 | |
---|
| 184 | ! |
---|
| 185 | !-- Prescribed by user. Number of processors on the prescribed topology |
---|
| 186 | !-- must be equal to the number of PEs available to the job |
---|
| 187 | IF ( ( npex * npey ) /= numprocs ) THEN |
---|
| 188 | PRINT*, '+++ init_pegrid:' |
---|
| 189 | PRINT*, ' number of PEs of the prescribed topology (', npex*npey, & |
---|
| 190 | ') does not match the number of PEs available to the ', & |
---|
| 191 | 'job (', numprocs, ')' |
---|
| 192 | CALL local_stop |
---|
| 193 | ENDIF |
---|
| 194 | pdims(1) = npex |
---|
| 195 | pdims(2) = npey |
---|
| 196 | |
---|
| 197 | ELSE |
---|
| 198 | ! |
---|
| 199 | !-- If the processor topology is prescribed by the user, the number of |
---|
| 200 | !-- PEs must be given in both directions |
---|
| 201 | PRINT*, '+++ init_pegrid:' |
---|
| 202 | PRINT*, ' if the processor topology is prescribed by the user, ', & |
---|
| 203 | 'both values of "npex" and "npey" must be given in the ', & |
---|
| 204 | 'NAMELIST-parameter file' |
---|
| 205 | CALL local_stop |
---|
| 206 | |
---|
| 207 | ENDIF |
---|
| 208 | |
---|
| 209 | ! |
---|
| 210 | !-- The hybrid solver can only be used in case of a 1d-decomposition along x |
---|
| 211 | IF ( pdims(2) /= 1 .AND. psolver == 'poisfft_hybrid' ) THEN |
---|
| 212 | IF ( myid == 0 ) THEN |
---|
| 213 | PRINT*, '*** init_pegrid: psolver = "poisfft_hybrid" can only be' |
---|
| 214 | PRINT*, ' used in case of a 1d-decomposition along x' |
---|
| 215 | ENDIF |
---|
| 216 | ENDIF |
---|
| 217 | |
---|
| 218 | ! |
---|
| 219 | !-- If necessary, set horizontal boundary conditions to non-cyclic |
---|
| 220 | IF ( bc_lr /= 'cyclic' ) cyclic(1) = .FALSE. |
---|
| 221 | IF ( bc_ns /= 'cyclic' ) cyclic(2) = .FALSE. |
---|
| 222 | |
---|
| 223 | ! |
---|
| 224 | !-- Create the virtual processor grid |
---|
| 225 | CALL MPI_CART_CREATE( comm_palm, ndim, pdims, cyclic, reorder, & |
---|
| 226 | comm2d, ierr ) |
---|
| 227 | CALL MPI_COMM_RANK( comm2d, myid, ierr ) |
---|
| 228 | WRITE (myid_char,'(''_'',I4.4)') myid |
---|
| 229 | |
---|
| 230 | CALL MPI_CART_COORDS( comm2d, myid, ndim, pcoord, ierr ) |
---|
| 231 | CALL MPI_CART_SHIFT( comm2d, 0, 1, pleft, pright, ierr ) |
---|
| 232 | CALL MPI_CART_SHIFT( comm2d, 1, 1, psouth, pnorth, ierr ) |
---|
| 233 | |
---|
| 234 | ! |
---|
| 235 | !-- Determine sub-topologies for transpositions |
---|
| 236 | !-- Transposition from z to x: |
---|
| 237 | remain_dims(1) = .TRUE. |
---|
| 238 | remain_dims(2) = .FALSE. |
---|
| 239 | CALL MPI_CART_SUB( comm2d, remain_dims, comm1dx, ierr ) |
---|
| 240 | CALL MPI_COMM_RANK( comm1dx, myidx, ierr ) |
---|
| 241 | ! |
---|
| 242 | !-- Transposition from x to y |
---|
| 243 | remain_dims(1) = .FALSE. |
---|
| 244 | remain_dims(2) = .TRUE. |
---|
| 245 | CALL MPI_CART_SUB( comm2d, remain_dims, comm1dy, ierr ) |
---|
| 246 | CALL MPI_COMM_RANK( comm1dy, myidy, ierr ) |
---|
| 247 | |
---|
| 248 | |
---|
| 249 | ! |
---|
| 250 | !-- Find a grid (used for array d) which will match the transposition demands |
---|
| 251 | IF ( grid_matching == 'strict' ) THEN |
---|
| 252 | |
---|
| 253 | nxa = nx; nya = ny; nza = nz |
---|
| 254 | |
---|
| 255 | ELSE |
---|
| 256 | |
---|
| 257 | found = .FALSE. |
---|
| 258 | xn: DO nxa = nx, 2*nx |
---|
| 259 | ! |
---|
| 260 | !-- Meet conditions for nx |
---|
| 261 | IF ( MOD( nxa+1, pdims(1) ) /= 0 .OR. & |
---|
| 262 | MOD( nxa+1, pdims(2) ) /= 0 ) CYCLE xn |
---|
| 263 | |
---|
| 264 | yn: DO nya = ny, 2*ny |
---|
| 265 | ! |
---|
| 266 | !-- Meet conditions for ny |
---|
| 267 | IF ( MOD( nya+1, pdims(2) ) /= 0 .OR. & |
---|
| 268 | MOD( nya+1, pdims(1) ) /= 0 ) CYCLE yn |
---|
| 269 | |
---|
| 270 | |
---|
| 271 | zn: DO nza = nz, 2*nz |
---|
| 272 | ! |
---|
| 273 | !-- Meet conditions for nz |
---|
| 274 | IF ( ( MOD( nza, pdims(1) ) /= 0 .AND. pdims(1) /= 1 .AND. & |
---|
| 275 | pdims(2) /= 1 ) .OR. & |
---|
| 276 | ( MOD( nza, pdims(2) ) /= 0 .AND. dt_dosp /= 9999999.9 & |
---|
| 277 | ) ) THEN |
---|
| 278 | CYCLE zn |
---|
| 279 | ELSE |
---|
| 280 | found = .TRUE. |
---|
| 281 | EXIT xn |
---|
| 282 | ENDIF |
---|
| 283 | |
---|
| 284 | ENDDO zn |
---|
| 285 | |
---|
| 286 | ENDDO yn |
---|
| 287 | |
---|
| 288 | ENDDO xn |
---|
| 289 | |
---|
| 290 | IF ( .NOT. found ) THEN |
---|
| 291 | IF ( myid == 0 ) THEN |
---|
| 292 | PRINT*,'+++ init_pegrid: no matching grid for transpositions found' |
---|
| 293 | ENDIF |
---|
| 294 | CALL local_stop |
---|
| 295 | ENDIF |
---|
| 296 | |
---|
| 297 | ENDIF |
---|
| 298 | |
---|
| 299 | ! |
---|
| 300 | !-- Calculate array bounds in x-direction for every PE. |
---|
| 301 | !-- The last PE along x may get less grid points than the others |
---|
| 302 | ALLOCATE( nxlf(0:pdims(1)-1), nxrf(0:pdims(1)-1), nynf(0:pdims(2)-1), & |
---|
| 303 | nysf(0:pdims(2)-1), nnx_pe(0:pdims(1)-1), nny_pe(0:pdims(2)-1) ) |
---|
| 304 | |
---|
| 305 | IF ( MOD( nxa+1 , pdims(1) ) /= 0 ) THEN |
---|
| 306 | IF ( myid == 0 ) THEN |
---|
| 307 | PRINT*,'+++ x-direction: gridpoint number (',nx+1,') is not an' |
---|
| 308 | PRINT*,' integral divisor of the number of proces', & |
---|
| 309 | &'sors (', pdims(1),')' |
---|
| 310 | ENDIF |
---|
| 311 | CALL local_stop |
---|
| 312 | ELSE |
---|
| 313 | nnx = ( nxa + 1 ) / pdims(1) |
---|
| 314 | IF ( nnx*pdims(1) - ( nx + 1) > nnx ) THEN |
---|
| 315 | IF ( myid == 0 ) THEN |
---|
| 316 | PRINT*,'+++ x-direction: nx does not match the requirements ', & |
---|
| 317 | 'given by the number of PEs' |
---|
| 318 | PRINT*,' used' |
---|
| 319 | PRINT*,' please use nx = ', nx - ( pdims(1) - ( nnx*pdims(1) & |
---|
| 320 | - ( nx + 1 ) ) ), ' instead of nx =', nx |
---|
| 321 | ENDIF |
---|
| 322 | CALL local_stop |
---|
| 323 | ENDIF |
---|
| 324 | ENDIF |
---|
| 325 | |
---|
| 326 | ! |
---|
| 327 | !-- Left and right array bounds, number of gridpoints |
---|
| 328 | DO i = 0, pdims(1)-1 |
---|
| 329 | nxlf(i) = i * nnx |
---|
| 330 | nxrf(i) = ( i + 1 ) * nnx - 1 |
---|
| 331 | nnx_pe(i) = MIN( nx, nxrf(i) ) - nxlf(i) + 1 |
---|
| 332 | ENDDO |
---|
| 333 | |
---|
| 334 | ! |
---|
| 335 | !-- Calculate array bounds in y-direction for every PE. |
---|
| 336 | IF ( MOD( nya+1 , pdims(2) ) /= 0 ) THEN |
---|
| 337 | IF ( myid == 0 ) THEN |
---|
| 338 | PRINT*,'+++ y-direction: gridpoint number (',ny+1,') is not an' |
---|
| 339 | PRINT*,' integral divisor of the number of proces', & |
---|
| 340 | &'sors (', pdims(2),')' |
---|
| 341 | ENDIF |
---|
| 342 | CALL local_stop |
---|
| 343 | ELSE |
---|
| 344 | nny = ( nya + 1 ) / pdims(2) |
---|
| 345 | IF ( nny*pdims(2) - ( ny + 1) > nny ) THEN |
---|
| 346 | IF ( myid == 0 ) THEN |
---|
| 347 | PRINT*,'+++ x-direction: nx does not match the requirements ', & |
---|
| 348 | 'given by the number of PEs' |
---|
| 349 | PRINT*,' used' |
---|
| 350 | PRINT*,' please use nx = ', nx - ( pdims(1) - ( nnx*pdims(1) & |
---|
| 351 | - ( nx + 1 ) ) ), ' instead of nx =', nx |
---|
| 352 | ENDIF |
---|
| 353 | CALL local_stop |
---|
| 354 | ENDIF |
---|
| 355 | ENDIF |
---|
| 356 | |
---|
| 357 | ! |
---|
| 358 | !-- South and north array bounds |
---|
| 359 | DO j = 0, pdims(2)-1 |
---|
| 360 | nysf(j) = j * nny |
---|
| 361 | nynf(j) = ( j + 1 ) * nny - 1 |
---|
| 362 | nny_pe(j) = MIN( ny, nynf(j) ) - nysf(j) + 1 |
---|
| 363 | ENDDO |
---|
| 364 | |
---|
| 365 | ! |
---|
| 366 | !-- Local array bounds of the respective PEs |
---|
| 367 | nxl = nxlf(pcoord(1)) |
---|
| 368 | nxra = nxrf(pcoord(1)) |
---|
| 369 | nxr = MIN( nx, nxra ) |
---|
| 370 | nys = nysf(pcoord(2)) |
---|
| 371 | nyna = nynf(pcoord(2)) |
---|
| 372 | nyn = MIN( ny, nyna ) |
---|
| 373 | nzb = 0 |
---|
| 374 | nzta = nza |
---|
| 375 | nzt = MIN( nz, nzta ) |
---|
| 376 | nnz = nza |
---|
| 377 | |
---|
| 378 | ! |
---|
| 379 | !-- Calculate array bounds and gridpoint numbers for the transposed arrays |
---|
| 380 | !-- (needed in the pressure solver) |
---|
| 381 | !-- For the transposed arrays, cyclic boundaries as well as top and bottom |
---|
| 382 | !-- boundaries are omitted, because they are obstructive to the transposition |
---|
| 383 | |
---|
| 384 | ! |
---|
| 385 | !-- 1. transposition z --> x |
---|
| 386 | !-- This transposition is not neccessary in case of a 1d-decomposition along x, |
---|
| 387 | !-- except that the uptream-spline method is switched on |
---|
| 388 | IF ( pdims(2) /= 1 .OR. momentum_advec == 'ups-scheme' .OR. & |
---|
| 389 | scalar_advec == 'ups-scheme' ) THEN |
---|
| 390 | |
---|
| 391 | IF ( pdims(2) == 1 .AND. ( momentum_advec == 'ups-scheme' .OR. & |
---|
| 392 | scalar_advec == 'ups-scheme' ) ) THEN |
---|
| 393 | IF ( myid == 0 ) THEN |
---|
| 394 | PRINT*,'+++ WARNING: init_pegrid: 1d-decomposition along x ', & |
---|
| 395 | &'chosen but nz restrictions may occur' |
---|
| 396 | PRINT*,' since ups-scheme is activated' |
---|
| 397 | ENDIF |
---|
| 398 | ENDIF |
---|
| 399 | nys_x = nys |
---|
| 400 | nyn_xa = nyna |
---|
| 401 | nyn_x = nyn |
---|
| 402 | nny_x = nny |
---|
| 403 | IF ( MOD( nza , pdims(1) ) /= 0 ) THEN |
---|
| 404 | IF ( myid == 0 ) THEN |
---|
| 405 | PRINT*,'+++ transposition z --> x:' |
---|
| 406 | PRINT*,' nz=',nz,' is not an integral divisior of pdims(1)=', & |
---|
| 407 | &pdims(1) |
---|
| 408 | ENDIF |
---|
| 409 | CALL local_stop |
---|
| 410 | ENDIF |
---|
| 411 | nnz_x = nza / pdims(1) |
---|
| 412 | nzb_x = 1 + myidx * nnz_x |
---|
| 413 | nzt_xa = ( myidx + 1 ) * nnz_x |
---|
| 414 | nzt_x = MIN( nzt, nzt_xa ) |
---|
| 415 | |
---|
| 416 | sendrecvcount_zx = nnx * nny * nnz_x |
---|
| 417 | |
---|
| 418 | ENDIF |
---|
| 419 | |
---|
| 420 | ! |
---|
| 421 | !-- 2. transposition x --> y |
---|
| 422 | nnz_y = nnz_x |
---|
| 423 | nzb_y = nzb_x |
---|
| 424 | nzt_ya = nzt_xa |
---|
| 425 | nzt_y = nzt_x |
---|
| 426 | IF ( MOD( nxa+1 , pdims(2) ) /= 0 ) THEN |
---|
| 427 | IF ( myid == 0 ) THEN |
---|
| 428 | PRINT*,'+++ transposition x --> y:' |
---|
| 429 | PRINT*,' nx+1=',nx+1,' is not an integral divisor of ',& |
---|
| 430 | &'pdims(2)=',pdims(2) |
---|
| 431 | ENDIF |
---|
| 432 | CALL local_stop |
---|
| 433 | ENDIF |
---|
| 434 | nnx_y = (nxa+1) / pdims(2) |
---|
| 435 | nxl_y = myidy * nnx_y |
---|
| 436 | nxr_ya = ( myidy + 1 ) * nnx_y - 1 |
---|
| 437 | nxr_y = MIN( nx, nxr_ya ) |
---|
| 438 | |
---|
| 439 | sendrecvcount_xy = nnx_y * nny_x * nnz_y |
---|
| 440 | |
---|
| 441 | ! |
---|
| 442 | !-- 3. transposition y --> z (ELSE: x --> y in case of 1D-decomposition |
---|
| 443 | !-- along x) |
---|
| 444 | IF ( pdims(2) /= 1 .OR. momentum_advec == 'ups-scheme' .OR. & |
---|
| 445 | scalar_advec == 'ups-scheme' ) THEN |
---|
| 446 | ! |
---|
| 447 | !-- y --> z |
---|
| 448 | !-- This transposition is not neccessary in case of a 1d-decomposition |
---|
| 449 | !-- along x, except that the uptream-spline method is switched on |
---|
| 450 | nnx_z = nnx_y |
---|
| 451 | nxl_z = nxl_y |
---|
| 452 | nxr_za = nxr_ya |
---|
| 453 | nxr_z = nxr_y |
---|
| 454 | IF ( MOD( nya+1 , pdims(1) ) /= 0 ) THEN |
---|
| 455 | IF ( myid == 0 ) THEN |
---|
| 456 | PRINT*,'+++ Transposition y --> z:' |
---|
| 457 | PRINT*,' ny+1=',ny+1,' is not an integral divisor of ',& |
---|
| 458 | &'pdims(1)=',pdims(1) |
---|
| 459 | ENDIF |
---|
| 460 | CALL local_stop |
---|
| 461 | ENDIF |
---|
| 462 | nny_z = (nya+1) / pdims(1) |
---|
| 463 | nys_z = myidx * nny_z |
---|
| 464 | nyn_za = ( myidx + 1 ) * nny_z - 1 |
---|
| 465 | nyn_z = MIN( ny, nyn_za ) |
---|
| 466 | |
---|
| 467 | sendrecvcount_yz = nnx_y * nny_z * nnz_y |
---|
| 468 | |
---|
| 469 | ELSE |
---|
| 470 | ! |
---|
| 471 | !-- x --> y. This condition must be fulfilled for a 1D-decomposition along x |
---|
| 472 | IF ( MOD( nya+1 , pdims(1) ) /= 0 ) THEN |
---|
| 473 | IF ( myid == 0 ) THEN |
---|
| 474 | PRINT*,'+++ Transposition x --> y:' |
---|
| 475 | PRINT*,' ny+1=',ny+1,' is not an integral divisor of ',& |
---|
| 476 | &'pdims(1)=',pdims(1) |
---|
| 477 | ENDIF |
---|
| 478 | CALL local_stop |
---|
| 479 | ENDIF |
---|
| 480 | |
---|
| 481 | ENDIF |
---|
| 482 | |
---|
| 483 | ! |
---|
| 484 | !-- Indices for direct transpositions z --> y (used for calculating spectra) |
---|
| 485 | IF ( dt_dosp /= 9999999.9 ) THEN |
---|
| 486 | IF ( MOD( nza, pdims(2) ) /= 0 ) THEN |
---|
| 487 | IF ( myid == 0 ) THEN |
---|
| 488 | PRINT*,'+++ Direct transposition z --> y (needed for spectra):' |
---|
| 489 | PRINT*,' nz=',nz,' is not an integral divisor of ',& |
---|
| 490 | &'pdims(2)=',pdims(2) |
---|
| 491 | ENDIF |
---|
| 492 | CALL local_stop |
---|
| 493 | ELSE |
---|
| 494 | nxl_yd = nxl |
---|
| 495 | nxr_yda = nxra |
---|
| 496 | nxr_yd = nxr |
---|
| 497 | nzb_yd = 1 + myidy * ( nza / pdims(2) ) |
---|
| 498 | nzt_yda = ( myidy + 1 ) * ( nza / pdims(2) ) |
---|
| 499 | nzt_yd = MIN( nzt, nzt_yda ) |
---|
| 500 | |
---|
| 501 | sendrecvcount_zyd = nnx * nny * ( nza / pdims(2) ) |
---|
| 502 | ENDIF |
---|
| 503 | ENDIF |
---|
| 504 | |
---|
| 505 | ! |
---|
| 506 | !-- Indices for direct transpositions y --> x (they are only possible in case |
---|
| 507 | !-- of a 1d-decomposition along x) |
---|
| 508 | IF ( pdims(2) == 1 ) THEN |
---|
| 509 | nny_x = nny / pdims(1) |
---|
| 510 | nys_x = myid * nny_x |
---|
| 511 | nyn_xa = ( myid + 1 ) * nny_x - 1 |
---|
| 512 | nyn_x = MIN( ny, nyn_xa ) |
---|
| 513 | nzb_x = 1 |
---|
| 514 | nzt_xa = nza |
---|
| 515 | nzt_x = nz |
---|
| 516 | sendrecvcount_xy = nnx * nny_x * nza |
---|
| 517 | ENDIF |
---|
| 518 | |
---|
| 519 | ! |
---|
| 520 | !-- Indices for direct transpositions x --> y (they are only possible in case |
---|
| 521 | !-- of a 1d-decomposition along y) |
---|
| 522 | IF ( pdims(1) == 1 ) THEN |
---|
| 523 | nnx_y = nnx / pdims(2) |
---|
| 524 | nxl_y = myid * nnx_y |
---|
| 525 | nxr_ya = ( myid + 1 ) * nnx_y - 1 |
---|
| 526 | nxr_y = MIN( nx, nxr_ya ) |
---|
| 527 | nzb_y = 1 |
---|
| 528 | nzt_ya = nza |
---|
| 529 | nzt_y = nz |
---|
| 530 | sendrecvcount_xy = nnx_y * nny * nza |
---|
| 531 | ENDIF |
---|
| 532 | |
---|
| 533 | ! |
---|
| 534 | !-- Arrays for storing the array bounds are needed any more |
---|
| 535 | DEALLOCATE( nxlf , nxrf , nynf , nysf ) |
---|
| 536 | |
---|
| 537 | #if defined( __print ) |
---|
| 538 | ! |
---|
| 539 | !-- Control output |
---|
| 540 | IF ( myid == 0 ) THEN |
---|
| 541 | PRINT*, '*** processor topology ***' |
---|
| 542 | PRINT*, ' ' |
---|
| 543 | PRINT*, 'myid pcoord left right south north idx idy nxl: nxr',& |
---|
| 544 | &' nys: nyn' |
---|
| 545 | PRINT*, '------------------------------------------------------------',& |
---|
| 546 | &'-----------' |
---|
| 547 | WRITE (*,1000) 0, pcoord(1), pcoord(2), pleft, pright, psouth, pnorth, & |
---|
| 548 | myidx, myidy, nxl, nxr, nys, nyn |
---|
| 549 | 1000 FORMAT (I4,2X,'(',I3,',',I3,')',3X,I4,2X,I4,3X,I4,2X,I4,2X,I3,1X,I3, & |
---|
| 550 | 2(2X,I4,':',I4)) |
---|
| 551 | |
---|
| 552 | ! |
---|
| 553 | !-- Recieve data from the other PEs |
---|
| 554 | DO i = 1,numprocs-1 |
---|
| 555 | CALL MPI_RECV( ibuf, 12, MPI_INTEGER, i, MPI_ANY_TAG, comm2d, status, & |
---|
| 556 | ierr ) |
---|
| 557 | WRITE (*,1000) i, ( ibuf(j) , j = 1,12 ) |
---|
| 558 | ENDDO |
---|
| 559 | ELSE |
---|
| 560 | |
---|
| 561 | ! |
---|
| 562 | !-- Send data to PE0 |
---|
| 563 | ibuf(1) = pcoord(1); ibuf(2) = pcoord(2); ibuf(3) = pleft |
---|
| 564 | ibuf(4) = pright; ibuf(5) = psouth; ibuf(6) = pnorth; ibuf(7) = myidx |
---|
| 565 | ibuf(8) = myidy; ibuf(9) = nxl; ibuf(10) = nxr; ibuf(11) = nys |
---|
| 566 | ibuf(12) = nyn |
---|
| 567 | CALL MPI_SEND( ibuf, 12, MPI_INTEGER, 0, myid, comm2d, ierr ) |
---|
| 568 | ENDIF |
---|
| 569 | #endif |
---|
| 570 | |
---|
| 571 | #else |
---|
| 572 | |
---|
| 573 | ! |
---|
| 574 | !-- Array bounds when running on a single PE (respectively a non-parallel |
---|
| 575 | !-- machine) |
---|
| 576 | nxl = 0 |
---|
| 577 | nxr = nx |
---|
| 578 | nxra = nx |
---|
| 579 | nnx = nxr - nxl + 1 |
---|
| 580 | nys = 0 |
---|
| 581 | nyn = ny |
---|
| 582 | nyna = ny |
---|
| 583 | nny = nyn - nys + 1 |
---|
| 584 | nzb = 0 |
---|
| 585 | nzt = nz |
---|
| 586 | nzta = nz |
---|
| 587 | nnz = nz |
---|
| 588 | |
---|
| 589 | ! |
---|
| 590 | !-- For non-cyclic boundaries extend array u (v) by one gridpoint |
---|
| 591 | IF ( bc_lr /= 'cyclic' ) uxrp = 1 |
---|
| 592 | IF ( bc_ns /= 'cyclic' ) vynp = 1 |
---|
| 593 | |
---|
| 594 | ! |
---|
| 595 | !-- Array bounds for the pressure solver (in the parallel code, these bounds |
---|
| 596 | !-- are the ones for the transposed arrays) |
---|
| 597 | nys_x = nys |
---|
| 598 | nyn_x = nyn |
---|
| 599 | nyn_xa = nyn |
---|
| 600 | nzb_x = nzb + 1 |
---|
| 601 | nzt_x = nzt |
---|
| 602 | nzt_xa = nzt |
---|
| 603 | |
---|
| 604 | nxl_y = nxl |
---|
| 605 | nxr_y = nxr |
---|
| 606 | nxr_ya = nxr |
---|
| 607 | nzb_y = nzb + 1 |
---|
| 608 | nzt_y = nzt |
---|
| 609 | nzt_ya = nzt |
---|
| 610 | |
---|
| 611 | nxl_z = nxl |
---|
| 612 | nxr_z = nxr |
---|
| 613 | nxr_za = nxr |
---|
| 614 | nys_z = nys |
---|
| 615 | nyn_z = nyn |
---|
| 616 | nyn_za = nyn |
---|
| 617 | |
---|
| 618 | #endif |
---|
| 619 | |
---|
| 620 | ! |
---|
| 621 | !-- Calculate number of grid levels necessary for the multigrid poisson solver |
---|
| 622 | !-- as well as the gridpoint indices on each level |
---|
| 623 | IF ( psolver == 'multigrid' ) THEN |
---|
| 624 | |
---|
| 625 | ! |
---|
| 626 | !-- First calculate number of possible grid levels for the subdomains |
---|
| 627 | mg_levels_x = 1 |
---|
| 628 | mg_levels_y = 1 |
---|
| 629 | mg_levels_z = 1 |
---|
| 630 | |
---|
| 631 | i = nnx |
---|
| 632 | DO WHILE ( MOD( i, 2 ) == 0 .AND. i /= 2 ) |
---|
| 633 | i = i / 2 |
---|
| 634 | mg_levels_x = mg_levels_x + 1 |
---|
| 635 | ENDDO |
---|
| 636 | |
---|
| 637 | j = nny |
---|
| 638 | DO WHILE ( MOD( j, 2 ) == 0 .AND. j /= 2 ) |
---|
| 639 | j = j / 2 |
---|
| 640 | mg_levels_y = mg_levels_y + 1 |
---|
| 641 | ENDDO |
---|
| 642 | |
---|
| 643 | k = nnz |
---|
| 644 | DO WHILE ( MOD( k, 2 ) == 0 .AND. k /= 2 ) |
---|
| 645 | k = k / 2 |
---|
| 646 | mg_levels_z = mg_levels_z + 1 |
---|
| 647 | ENDDO |
---|
| 648 | |
---|
| 649 | maximum_grid_level = MIN( mg_levels_x, mg_levels_y, mg_levels_z ) |
---|
| 650 | |
---|
| 651 | ! |
---|
| 652 | !-- Find out, if the total domain allows more levels. These additional |
---|
| 653 | !-- levels are processed on PE0 only. |
---|
| 654 | IF ( numprocs > 1 ) THEN |
---|
| 655 | IF ( mg_levels_z > MIN( mg_levels_x, mg_levels_y ) ) THEN |
---|
| 656 | mg_switch_to_pe0_level_l = maximum_grid_level |
---|
| 657 | |
---|
| 658 | mg_levels_x = 1 |
---|
| 659 | mg_levels_y = 1 |
---|
| 660 | |
---|
| 661 | i = nx+1 |
---|
| 662 | DO WHILE ( MOD( i, 2 ) == 0 .AND. i /= 2 ) |
---|
| 663 | i = i / 2 |
---|
| 664 | mg_levels_x = mg_levels_x + 1 |
---|
| 665 | ENDDO |
---|
| 666 | |
---|
| 667 | j = ny+1 |
---|
| 668 | DO WHILE ( MOD( j, 2 ) == 0 .AND. j /= 2 ) |
---|
| 669 | j = j / 2 |
---|
| 670 | mg_levels_y = mg_levels_y + 1 |
---|
| 671 | ENDDO |
---|
| 672 | |
---|
| 673 | maximum_grid_level_l = MIN( mg_levels_x, mg_levels_y, mg_levels_z ) |
---|
| 674 | |
---|
| 675 | IF ( maximum_grid_level_l > mg_switch_to_pe0_level_l ) THEN |
---|
| 676 | mg_switch_to_pe0_level_l = maximum_grid_level_l - & |
---|
| 677 | mg_switch_to_pe0_level_l + 1 |
---|
| 678 | ELSE |
---|
| 679 | mg_switch_to_pe0_level_l = 0 |
---|
| 680 | ENDIF |
---|
| 681 | ELSE |
---|
| 682 | mg_switch_to_pe0_level_l = 0 |
---|
| 683 | maximum_grid_level_l = maximum_grid_level |
---|
| 684 | ENDIF |
---|
| 685 | |
---|
| 686 | ! |
---|
| 687 | !-- Use switch level calculated above only if it is not pre-defined |
---|
| 688 | !-- by user |
---|
| 689 | IF ( mg_switch_to_pe0_level == 0 ) THEN |
---|
| 690 | |
---|
| 691 | IF ( mg_switch_to_pe0_level_l /= 0 ) THEN |
---|
| 692 | mg_switch_to_pe0_level = mg_switch_to_pe0_level_l |
---|
| 693 | maximum_grid_level = maximum_grid_level_l |
---|
| 694 | ENDIF |
---|
| 695 | |
---|
| 696 | ELSE |
---|
| 697 | ! |
---|
| 698 | !-- Check pre-defined value and reset to default, if neccessary |
---|
| 699 | IF ( mg_switch_to_pe0_level < mg_switch_to_pe0_level_l .OR. & |
---|
| 700 | mg_switch_to_pe0_level >= maximum_grid_level_l ) THEN |
---|
| 701 | IF ( myid == 0 ) THEN |
---|
| 702 | PRINT*, '+++ WARNING init_pegrid: mg_switch_to_pe0_level ', & |
---|
| 703 | 'out of range and reset to default (=0)' |
---|
| 704 | ENDIF |
---|
| 705 | mg_switch_to_pe0_level = 0 |
---|
| 706 | ELSE |
---|
| 707 | ! |
---|
| 708 | !-- Use the largest number of possible levels anyway and recalculate |
---|
| 709 | !-- the switch level to this largest number of possible values |
---|
| 710 | maximum_grid_level = maximum_grid_level_l |
---|
| 711 | |
---|
| 712 | ENDIF |
---|
| 713 | ENDIF |
---|
| 714 | |
---|
| 715 | ENDIF |
---|
| 716 | |
---|
| 717 | ALLOCATE( grid_level_count(maximum_grid_level), & |
---|
| 718 | nxl_mg(maximum_grid_level), nxr_mg(maximum_grid_level), & |
---|
| 719 | nyn_mg(maximum_grid_level), nys_mg(maximum_grid_level), & |
---|
| 720 | nzt_mg(maximum_grid_level) ) |
---|
| 721 | |
---|
| 722 | grid_level_count = 0 |
---|
| 723 | nxl_l = nxl; nxr_l = nxr; nys_l = nys; nyn_l = nyn; nzt_l = nzt |
---|
| 724 | |
---|
| 725 | DO i = maximum_grid_level, 1 , -1 |
---|
| 726 | |
---|
| 727 | IF ( i == mg_switch_to_pe0_level ) THEN |
---|
| 728 | #if defined( __parallel ) |
---|
| 729 | ! |
---|
| 730 | !-- Save the grid size of the subdomain at the switch level, because |
---|
| 731 | !-- it is needed in poismg. |
---|
| 732 | !-- Array bounds of the local subdomain grids are gathered on PE0 |
---|
| 733 | ind(1) = nxl_l; ind(2) = nxr_l |
---|
| 734 | ind(3) = nys_l; ind(4) = nyn_l |
---|
| 735 | ind(5) = nzt_l |
---|
| 736 | ALLOCATE( ind_all(5*numprocs), mg_loc_ind(5,0:numprocs-1) ) |
---|
| 737 | CALL MPI_ALLGATHER( ind, 5, MPI_INTEGER, ind_all, 5, & |
---|
| 738 | MPI_INTEGER, comm2d, ierr ) |
---|
| 739 | DO j = 0, numprocs-1 |
---|
| 740 | DO k = 1, 5 |
---|
| 741 | mg_loc_ind(k,j) = ind_all(k+j*5) |
---|
| 742 | ENDDO |
---|
| 743 | ENDDO |
---|
| 744 | DEALLOCATE( ind_all ) |
---|
| 745 | ! |
---|
| 746 | !-- Calculate the grid size of the total domain gathered on PE0 |
---|
| 747 | nxr_l = ( nxr_l-nxl_l+1 ) * pdims(1) - 1 |
---|
| 748 | nxl_l = 0 |
---|
| 749 | nyn_l = ( nyn_l-nys_l+1 ) * pdims(2) - 1 |
---|
| 750 | nys_l = 0 |
---|
| 751 | ! |
---|
| 752 | !-- The size of this gathered array must not be larger than the |
---|
| 753 | !-- array tend, which is used in the multigrid scheme as a temporary |
---|
| 754 | !-- array |
---|
| 755 | subdomain_size = ( nxr - nxl + 3 ) * ( nyn - nys + 3 ) * & |
---|
| 756 | ( nzt - nzb + 2 ) |
---|
| 757 | gathered_size = ( nxr_l - nxl_l + 3 ) * ( nyn_l - nys_l + 3 ) * & |
---|
| 758 | ( nzt_l - nzb + 2 ) |
---|
| 759 | |
---|
| 760 | IF ( gathered_size > subdomain_size ) THEN |
---|
| 761 | IF ( myid == 0 ) THEN |
---|
| 762 | PRINT*, '+++ init_pegrid: not enough memory for storing ', & |
---|
| 763 | 'gathered multigrid data on PE0' |
---|
| 764 | ENDIF |
---|
| 765 | CALL local_stop |
---|
| 766 | ENDIF |
---|
| 767 | #else |
---|
| 768 | PRINT*, '+++ init_pegrid: multigrid gather/scatter impossible ', & |
---|
| 769 | 'in non parallel mode' |
---|
| 770 | CALL local_stop |
---|
| 771 | #endif |
---|
| 772 | ENDIF |
---|
| 773 | |
---|
| 774 | nxl_mg(i) = nxl_l |
---|
| 775 | nxr_mg(i) = nxr_l |
---|
| 776 | nys_mg(i) = nys_l |
---|
| 777 | nyn_mg(i) = nyn_l |
---|
| 778 | nzt_mg(i) = nzt_l |
---|
| 779 | |
---|
| 780 | nxl_l = nxl_l / 2 |
---|
| 781 | nxr_l = nxr_l / 2 |
---|
| 782 | nys_l = nys_l / 2 |
---|
| 783 | nyn_l = nyn_l / 2 |
---|
| 784 | nzt_l = nzt_l / 2 |
---|
| 785 | ENDDO |
---|
| 786 | |
---|
| 787 | ELSE |
---|
| 788 | |
---|
| 789 | maximum_grid_level = 1 |
---|
| 790 | |
---|
| 791 | ENDIF |
---|
| 792 | |
---|
| 793 | grid_level = maximum_grid_level |
---|
| 794 | |
---|
| 795 | #if defined( __parallel ) |
---|
| 796 | ! |
---|
| 797 | !-- Gridpoint number for the exchange of ghost points (y-line for 2D-arrays) |
---|
| 798 | ngp_y = nyn - nys + 1 |
---|
| 799 | |
---|
| 800 | ! |
---|
| 801 | !-- Define a new MPI derived datatype for the exchange of ghost points in |
---|
| 802 | !-- y-direction for 2D-arrays (line) |
---|
| 803 | CALL MPI_TYPE_VECTOR( nxr-nxl+3, 1, ngp_y+2, MPI_REAL, type_x, ierr ) |
---|
| 804 | CALL MPI_TYPE_COMMIT( type_x, ierr ) |
---|
| 805 | CALL MPI_TYPE_VECTOR( nxr-nxl+3, 1, ngp_y+2, MPI_INTEGER, type_x_int, ierr ) |
---|
| 806 | CALL MPI_TYPE_COMMIT( type_x_int, ierr ) |
---|
| 807 | |
---|
| 808 | ! |
---|
| 809 | !-- Calculate gridpoint numbers for the exchange of ghost points along x |
---|
| 810 | !-- (yz-plane for 3D-arrays) and define MPI derived data type(s) for the |
---|
| 811 | !-- exchange of ghost points in y-direction (xz-plane). |
---|
| 812 | !-- Do these calculations for the model grid and (if necessary) also |
---|
| 813 | !-- for the coarser grid levels used in the multigrid method |
---|
| 814 | ALLOCATE ( ngp_yz(maximum_grid_level), type_xz(maximum_grid_level) ) |
---|
| 815 | |
---|
| 816 | nxl_l = nxl; nxr_l = nxr; nys_l = nys; nyn_l = nyn; nzb_l = nzb; nzt_l = nzt |
---|
| 817 | |
---|
| 818 | DO i = maximum_grid_level, 1 , -1 |
---|
| 819 | ngp_yz(i) = (nzt_l - nzb_l + 2) * (nyn_l - nys_l + 3) |
---|
| 820 | |
---|
| 821 | CALL MPI_TYPE_VECTOR( nxr_l-nxl_l+3, nzt_l-nzb_l+2, ngp_yz(i), & |
---|
| 822 | MPI_REAL, type_xz(i), ierr ) |
---|
| 823 | CALL MPI_TYPE_COMMIT( type_xz(i), ierr ) |
---|
| 824 | |
---|
| 825 | nxl_l = nxl_l / 2 |
---|
| 826 | nxr_l = nxr_l / 2 |
---|
| 827 | nys_l = nys_l / 2 |
---|
| 828 | nyn_l = nyn_l / 2 |
---|
| 829 | nzt_l = nzt_l / 2 |
---|
| 830 | ENDDO |
---|
| 831 | #endif |
---|
| 832 | |
---|
| 833 | #if defined( __parallel ) |
---|
| 834 | ! |
---|
| 835 | !-- Setting of flags for inflow/outflow conditions in case of non-cyclic |
---|
| 836 | !-- horizontal boundary conditions. Set variables for extending array u (v) |
---|
| 837 | !-- by one gridpoint on the left/rightmost (northest/southest) processor |
---|
| 838 | IF ( pleft == MPI_PROC_NULL ) THEN |
---|
| 839 | IF ( bc_lr == 'dirichlet/neumann' ) THEN |
---|
| 840 | inflow_l = .TRUE. |
---|
| 841 | ELSEIF ( bc_lr == 'neumann/dirichlet' ) THEN |
---|
| 842 | outflow_l = .TRUE. |
---|
| 843 | ENDIF |
---|
| 844 | ENDIF |
---|
| 845 | |
---|
| 846 | IF ( pright == MPI_PROC_NULL ) THEN |
---|
| 847 | IF ( bc_lr == 'dirichlet/neumann' ) THEN |
---|
| 848 | outflow_r = .TRUE. |
---|
| 849 | ELSEIF ( bc_lr == 'neumann/dirichlet' ) THEN |
---|
| 850 | inflow_r = .TRUE. |
---|
| 851 | ENDIF |
---|
| 852 | uxrp = 1 |
---|
| 853 | ENDIF |
---|
| 854 | |
---|
| 855 | IF ( psouth == MPI_PROC_NULL ) THEN |
---|
| 856 | IF ( bc_ns == 'dirichlet/neumann' ) THEN |
---|
| 857 | outflow_s = .TRUE. |
---|
| 858 | ELSEIF ( bc_ns == 'neumann/dirichlet' ) THEN |
---|
| 859 | inflow_s = .TRUE. |
---|
| 860 | ENDIF |
---|
| 861 | ENDIF |
---|
| 862 | |
---|
| 863 | IF ( pnorth == MPI_PROC_NULL ) THEN |
---|
| 864 | IF ( bc_ns == 'dirichlet/neumann' ) THEN |
---|
| 865 | inflow_n = .TRUE. |
---|
| 866 | ELSEIF ( bc_ns == 'neumann/dirichlet' ) THEN |
---|
| 867 | outflow_n = .TRUE. |
---|
| 868 | ENDIF |
---|
| 869 | vynp = 1 |
---|
| 870 | ENDIF |
---|
| 871 | |
---|
| 872 | ! |
---|
| 873 | !-- Additional MPI derived data type for the exchange of ghost points along x |
---|
| 874 | !-- needed in case of non-cyclic boundary conditions along y on the northmost |
---|
| 875 | !-- processors (for the exchange of the enlarged v array) |
---|
| 876 | IF ( bc_ns /= 'cyclic' .AND. pnorth == MPI_PROC_NULL ) THEN |
---|
| 877 | ngp_yz_p = ( nzt - nzb + 2 ) * ( nyn + vynp - nys + 3 ) |
---|
| 878 | CALL MPI_TYPE_VECTOR( nxr-nxl+3, nzt-nzb+2, ngp_yz_p, & |
---|
| 879 | MPI_REAL, type_xz_p, ierr ) |
---|
| 880 | CALL MPI_TYPE_COMMIT( type_xz_p, ierr ) |
---|
| 881 | ENDIF |
---|
| 882 | #else |
---|
| 883 | IF ( bc_lr == 'dirichlet/neumann' ) THEN |
---|
| 884 | inflow_l = .TRUE. |
---|
| 885 | outflow_r = .TRUE. |
---|
| 886 | uxrp = 1 |
---|
| 887 | ELSEIF ( bc_lr == 'neumann/dirichlet' ) THEN |
---|
| 888 | outflow_l = .TRUE. |
---|
| 889 | inflow_r = .TRUE. |
---|
| 890 | ENDIF |
---|
| 891 | |
---|
| 892 | IF ( bc_ns == 'dirichlet/neumann' ) THEN |
---|
| 893 | inflow_n = .TRUE. |
---|
| 894 | outflow_s = .TRUE. |
---|
| 895 | ELSEIF ( bc_ns == 'neumann/dirichlet' ) THEN |
---|
| 896 | outflow_n = .TRUE. |
---|
| 897 | inflow_s = .TRUE. |
---|
| 898 | vynp = 1 |
---|
| 899 | ENDIF |
---|
| 900 | #endif |
---|
| 901 | |
---|
| 902 | IF ( psolver == 'poisfft_hybrid' ) THEN |
---|
| 903 | CALL poisfft_hybrid_ini |
---|
| 904 | ELSE |
---|
| 905 | CALL poisfft_init |
---|
| 906 | ENDIF |
---|
| 907 | |
---|
| 908 | END SUBROUTINE init_pegrid |
---|