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