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