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