[1682] | 1 | !> @file exchange_horiz_2d.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 | ! |
---|
[484] | 19 | ! Current revisions: |
---|
[1] | 20 | ! ----------------- |
---|
[1683] | 21 | ! |
---|
[1805] | 22 | ! |
---|
[1321] | 23 | ! Former revisions: |
---|
| 24 | ! ----------------- |
---|
| 25 | ! $Id: exchange_horiz_2d.f90 1933 2016-06-13 07:12:51Z maronga $ |
---|
| 26 | ! |
---|
[1933] | 27 | ! 1818 2016-04-06 15:53:27Z maronga |
---|
| 28 | ! Initial version of purely vertical nesting introduced. |
---|
| 29 | ! |
---|
[1805] | 30 | ! 1804 2016-04-05 16:30:18Z maronga |
---|
| 31 | ! Removed code for parameter file check (__check) |
---|
| 32 | ! |
---|
[1763] | 33 | ! 1762 2016-02-25 12:31:13Z hellstea |
---|
| 34 | ! Introduction of nested domain feature |
---|
| 35 | ! |
---|
[1683] | 36 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 37 | ! Code annotations made doxygen readable |
---|
| 38 | ! |
---|
[1349] | 39 | ! 1348 2014-03-27 18:01:03Z raasch |
---|
| 40 | ! bugfix: bc_lr_cyc and bc_ns_cyc added to ONLY-list |
---|
| 41 | ! |
---|
[1321] | 42 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 43 | ! ONLY-attribute added to USE-statements, |
---|
| 44 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 45 | ! kinds are defined in new module kinds, |
---|
| 46 | ! revision history before 2012 removed, |
---|
| 47 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 48 | ! all variable declaration statements |
---|
[1] | 49 | ! |
---|
[1093] | 50 | ! 1092 2013-02-02 11:24:22Z raasch |
---|
| 51 | ! unused variables removed |
---|
| 52 | ! |
---|
[1037] | 53 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 54 | ! code put under GPL (PALM 3.9) |
---|
| 55 | ! |
---|
[842] | 56 | ! 841 2012-02-28 12:29:49Z maronga |
---|
| 57 | ! Excluded routine from compilation of namelist_file_check |
---|
| 58 | ! |
---|
[1] | 59 | ! Revision 1.1 1998/01/23 09:58:21 raasch |
---|
| 60 | ! Initial revision |
---|
| 61 | ! |
---|
| 62 | ! |
---|
| 63 | ! Description: |
---|
| 64 | ! ------------ |
---|
[1682] | 65 | !> Exchange of lateral (ghost) boundaries (parallel computers) and cyclic |
---|
| 66 | !> boundary conditions, respectively, for 2D-arrays. |
---|
[1] | 67 | !------------------------------------------------------------------------------! |
---|
[1682] | 68 | SUBROUTINE exchange_horiz_2d( ar ) |
---|
| 69 | |
---|
[1] | 70 | |
---|
[1320] | 71 | USE control_parameters, & |
---|
[1348] | 72 | ONLY : bc_lr_cyc, bc_ns_cyc, inflow_l, inflow_n, inflow_r, inflow_s, & |
---|
[1762] | 73 | nest_bound_l, nest_bound_n, nest_bound_r, nest_bound_s, & |
---|
[1348] | 74 | outflow_l, outflow_n, outflow_r, outflow_s |
---|
[1320] | 75 | |
---|
| 76 | USE cpulog, & |
---|
| 77 | ONLY : cpu_log, log_point_s |
---|
| 78 | |
---|
| 79 | USE indices, & |
---|
| 80 | ONLY : nbgp, nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg |
---|
| 81 | |
---|
| 82 | USE kinds |
---|
| 83 | |
---|
[1] | 84 | USE pegrid |
---|
| 85 | |
---|
[1933] | 86 | USE pmc_interface, & |
---|
| 87 | ONLY : nesting_mode |
---|
| 88 | |
---|
| 89 | |
---|
[1] | 90 | IMPLICIT NONE |
---|
| 91 | |
---|
[841] | 92 | |
---|
[1682] | 93 | INTEGER(iwp) :: i !< |
---|
[1320] | 94 | |
---|
[1682] | 95 | REAL(wp) :: ar(nysg:nyng,nxlg:nxrg) !< |
---|
[1320] | 96 | |
---|
[1] | 97 | |
---|
| 98 | CALL cpu_log( log_point_s(13), 'exchange_horiz_2d', 'start' ) |
---|
| 99 | |
---|
| 100 | #if defined( __parallel ) |
---|
| 101 | |
---|
| 102 | ! |
---|
| 103 | !-- Exchange of lateral boundary values for parallel computers |
---|
| 104 | IF ( pdims(1) == 1 ) THEN |
---|
| 105 | |
---|
| 106 | ! |
---|
| 107 | !-- One-dimensional decomposition along y, boundary values can be exchanged |
---|
| 108 | !-- within the PE memory |
---|
[702] | 109 | ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr) |
---|
| 110 | ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1) |
---|
[1] | 111 | |
---|
| 112 | ELSE |
---|
| 113 | ! |
---|
| 114 | !-- Send left boundary, receive right one |
---|
[667] | 115 | |
---|
[702] | 116 | CALL MPI_SENDRECV( ar(nysg,nxl), 1, type_y, pleft, 0, & |
---|
| 117 | ar(nysg,nxr+1), 1, type_y, pright, 0, & |
---|
[1] | 118 | comm2d, status, ierr ) |
---|
| 119 | ! |
---|
| 120 | !-- Send right boundary, receive left one |
---|
[702] | 121 | CALL MPI_SENDRECV( ar(nysg,nxr+1-nbgp), 1, type_y, pright, 1, & |
---|
| 122 | ar(nysg,nxlg), 1, type_y, pleft, 1, & |
---|
[1] | 123 | comm2d, status, ierr ) |
---|
[702] | 124 | |
---|
| 125 | |
---|
[1] | 126 | ENDIF |
---|
| 127 | |
---|
| 128 | IF ( pdims(2) == 1 ) THEN |
---|
| 129 | ! |
---|
| 130 | !-- One-dimensional decomposition along x, boundary values can be exchanged |
---|
| 131 | !-- within the PE memory |
---|
[702] | 132 | ar(nysg:nys-1,:) = ar(nyn-nbgp+1:nyn,:) |
---|
| 133 | ar(nyn+1:nyng,:) = ar(nys:nys+nbgp-1,:) |
---|
[1] | 134 | |
---|
| 135 | ELSE |
---|
| 136 | ! |
---|
| 137 | !-- Send front boundary, receive rear one |
---|
[667] | 138 | |
---|
[702] | 139 | CALL MPI_SENDRECV( ar(nys,nxlg), 1, type_x, psouth, 0, & |
---|
| 140 | ar(nyn+1,nxlg), 1, type_x, pnorth, 0, & |
---|
[1] | 141 | comm2d, status, ierr ) |
---|
| 142 | ! |
---|
| 143 | !-- Send rear boundary, receive front one |
---|
[702] | 144 | CALL MPI_SENDRECV( ar(nyn+1-nbgp,nxlg), 1, type_x, pnorth, 1, & |
---|
| 145 | ar(nysg,nxlg), 1, type_x, psouth, 1, & |
---|
[1] | 146 | comm2d, status, ierr ) |
---|
[667] | 147 | |
---|
[1] | 148 | ENDIF |
---|
| 149 | |
---|
| 150 | #else |
---|
| 151 | |
---|
| 152 | ! |
---|
| 153 | !-- Lateral boundary conditions in the non-parallel case |
---|
[707] | 154 | IF ( bc_lr_cyc ) THEN |
---|
[702] | 155 | ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr) |
---|
| 156 | ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1) |
---|
[1] | 157 | ENDIF |
---|
| 158 | |
---|
[707] | 159 | IF ( bc_ns_cyc ) THEN |
---|
[702] | 160 | ar(nysg:nys-1,:) = ar(nyn-nbgp+1:nyn,:) |
---|
| 161 | ar(nyn+1:nyng,:) = ar(nys:nys+nbgp-1,:) |
---|
[1] | 162 | ENDIF |
---|
| 163 | |
---|
[667] | 164 | |
---|
[1] | 165 | #endif |
---|
| 166 | |
---|
[73] | 167 | ! |
---|
[1762] | 168 | !-- Neumann-conditions at inflow/outflow/nested boundaries |
---|
[1933] | 169 | IF ( nesting_mode /= 'vertical' ) THEN |
---|
| 170 | IF ( inflow_l .OR. outflow_l .OR. nest_bound_l ) THEN |
---|
| 171 | DO i = nbgp, 1, -1 |
---|
| 172 | ar(:,nxl-i) = ar(:,nxl) |
---|
| 173 | ENDDO |
---|
| 174 | ENDIF |
---|
| 175 | IF ( inflow_r .OR. outflow_r .OR. nest_bound_r ) THEN |
---|
| 176 | DO i = 1, nbgp |
---|
| 177 | ar(:,nxr+i) = ar(:,nxr) |
---|
| 178 | ENDDO |
---|
| 179 | ENDIF |
---|
| 180 | IF ( inflow_s .OR. outflow_s .OR. nest_bound_s ) THEN |
---|
| 181 | DO i = nbgp, 1, -1 |
---|
| 182 | ar(nys-i,:) = ar(nys,:) |
---|
| 183 | ENDDO |
---|
| 184 | ENDIF |
---|
| 185 | IF ( inflow_n .OR. outflow_n .OR. nest_bound_n ) THEN |
---|
| 186 | DO i = 1, nbgp |
---|
| 187 | ar(nyn+i,:) = ar(nyn,:) |
---|
| 188 | ENDDO |
---|
| 189 | ENDIF |
---|
[1762] | 190 | ENDIF |
---|
| 191 | |
---|
[1] | 192 | CALL cpu_log( log_point_s(13), 'exchange_horiz_2d', 'stop' ) |
---|
| 193 | |
---|
| 194 | END SUBROUTINE exchange_horiz_2d |
---|
| 195 | |
---|
| 196 | |
---|
| 197 | |
---|
| 198 | !------------------------------------------------------------------------------! |
---|
| 199 | ! Description: |
---|
| 200 | ! ------------ |
---|
[1682] | 201 | !> Exchange of lateral (ghost) boundaries (parallel computers) and cyclic |
---|
| 202 | !> boundary conditions, respectively, for 2D integer arrays. |
---|
[1] | 203 | !------------------------------------------------------------------------------! |
---|
[1682] | 204 | |
---|
| 205 | SUBROUTINE exchange_horiz_2d_int( ar ) |
---|
[1] | 206 | |
---|
[1682] | 207 | |
---|
[1320] | 208 | USE control_parameters, & |
---|
[1762] | 209 | ONLY: bc_lr_cyc, bc_ns_cyc, nest_bound_l, nest_bound_n, nest_bound_r, & |
---|
| 210 | nest_bound_s |
---|
[1320] | 211 | |
---|
| 212 | USE cpulog, & |
---|
| 213 | ONLY: cpu_log, log_point_s |
---|
| 214 | |
---|
| 215 | USE indices, & |
---|
| 216 | ONLY: nbgp, nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg |
---|
| 217 | |
---|
| 218 | USE kinds |
---|
| 219 | |
---|
[1] | 220 | USE pegrid |
---|
| 221 | |
---|
| 222 | IMPLICIT NONE |
---|
| 223 | |
---|
[1762] | 224 | INTEGER(iwp) :: i |
---|
[1682] | 225 | INTEGER(iwp) :: ar(nysg:nyng,nxlg:nxrg) !< |
---|
[1] | 226 | |
---|
| 227 | CALL cpu_log( log_point_s(13), 'exchange_horiz_2d', 'start' ) |
---|
| 228 | |
---|
| 229 | #if defined( __parallel ) |
---|
| 230 | |
---|
| 231 | ! |
---|
| 232 | !-- Exchange of lateral boundary values for parallel computers |
---|
| 233 | IF ( pdims(1) == 1 ) THEN |
---|
| 234 | |
---|
| 235 | ! |
---|
| 236 | !-- One-dimensional decomposition along y, boundary values can be exchanged |
---|
| 237 | !-- within the PE memory |
---|
[702] | 238 | ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr) |
---|
| 239 | ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1) |
---|
[1] | 240 | |
---|
[702] | 241 | |
---|
[1] | 242 | ELSE |
---|
| 243 | ! |
---|
| 244 | !-- Send left boundary, receive right one |
---|
[702] | 245 | CALL MPI_SENDRECV( ar(nysg,nxl), 1, type_y_int, pleft, 0, & |
---|
| 246 | ar(nysg,nxr+1), 1, type_y_int, pright, 0, & |
---|
[1] | 247 | comm2d, status, ierr ) |
---|
| 248 | ! |
---|
| 249 | !-- Send right boundary, receive left one |
---|
[702] | 250 | CALL MPI_SENDRECV( ar(nysg,nxr+1-nbgp), 1, type_y_int, pright, 1, & |
---|
| 251 | ar(nysg,nxlg), 1, type_y_int, pleft, 1, & |
---|
[1] | 252 | comm2d, status, ierr ) |
---|
[667] | 253 | |
---|
[1] | 254 | ENDIF |
---|
| 255 | |
---|
| 256 | IF ( pdims(2) == 1 ) THEN |
---|
| 257 | ! |
---|
| 258 | !-- One-dimensional decomposition along x, boundary values can be exchanged |
---|
| 259 | !-- within the PE memory |
---|
[667] | 260 | ar(nysg:nys-1,:) = ar(nyn+1-nbgp:nyn,:) |
---|
| 261 | ar(nyn+1:nyng,:) = ar(nys:nys-1+nbgp,:) |
---|
[1] | 262 | |
---|
[667] | 263 | |
---|
[1] | 264 | ELSE |
---|
| 265 | ! |
---|
| 266 | !-- Send front boundary, receive rear one |
---|
[702] | 267 | CALL MPI_SENDRECV( ar(nys,nxlg), 1, type_x_int, psouth, 0, & |
---|
| 268 | ar(nyn+1,nxlg), 1, type_x_int, pnorth, 0, & |
---|
| 269 | comm2d, status, ierr ) |
---|
[667] | 270 | |
---|
[1] | 271 | ! |
---|
| 272 | !-- Send rear boundary, receive front one |
---|
[702] | 273 | CALL MPI_SENDRECV( ar(nyn+1-nbgp,nxlg), 1, type_x_int, pnorth, 1, & |
---|
| 274 | ar(nysg,nxlg), 1, type_x_int, psouth, 1, & |
---|
[1] | 275 | comm2d, status, ierr ) |
---|
[667] | 276 | |
---|
[1] | 277 | ENDIF |
---|
| 278 | |
---|
| 279 | #else |
---|
| 280 | |
---|
| 281 | ! |
---|
| 282 | !-- Lateral boundary conditions in the non-parallel case |
---|
[707] | 283 | IF ( bc_lr_cyc ) THEN |
---|
[702] | 284 | ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr) |
---|
| 285 | ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1) |
---|
[1] | 286 | ENDIF |
---|
| 287 | |
---|
[707] | 288 | IF ( bc_ns_cyc ) THEN |
---|
[667] | 289 | ar(nysg:nys-1,:) = ar(nyn+1-nbgp:nyn,:) |
---|
| 290 | ar(nyn+1:nyng,:) = ar(nys:nys-1+nbgp,:) |
---|
[1] | 291 | ENDIF |
---|
| 292 | |
---|
| 293 | #endif |
---|
[1762] | 294 | ! |
---|
| 295 | !-- Neumann-conditions at inflow/outflow/nested boundaries |
---|
| 296 | IF ( nest_bound_l ) THEN |
---|
| 297 | DO i = nbgp, 1, -1 |
---|
| 298 | ar(:,nxl-i) = ar(:,nxl) |
---|
| 299 | ENDDO |
---|
| 300 | ENDIF |
---|
| 301 | IF ( nest_bound_r ) THEN |
---|
| 302 | DO i = 1, nbgp |
---|
| 303 | ar(:,nxr+i) = ar(:,nxr) |
---|
| 304 | ENDDO |
---|
| 305 | ENDIF |
---|
| 306 | IF ( nest_bound_s ) THEN |
---|
| 307 | DO i = nbgp, 1, -1 |
---|
| 308 | ar(nys-i,:) = ar(nys,:) |
---|
| 309 | ENDDO |
---|
| 310 | ENDIF |
---|
| 311 | IF ( nest_bound_n ) THEN |
---|
| 312 | DO i = 1, nbgp |
---|
| 313 | ar(nyn+i,:) = ar(nyn,:) |
---|
| 314 | ENDDO |
---|
| 315 | ENDIF |
---|
| 316 | |
---|
[1] | 317 | CALL cpu_log( log_point_s(13), 'exchange_horiz_2d', 'stop' ) |
---|
| 318 | |
---|
| 319 | END SUBROUTINE exchange_horiz_2d_int |
---|