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