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