[1] | 1 | SUBROUTINE exchange_horiz_2d( ar ) |
---|
| 2 | |
---|
[1036] | 3 | !--------------------------------------------------------------------------------! |
---|
| 4 | ! This file is part of PALM. |
---|
| 5 | ! |
---|
| 6 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
| 7 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
| 8 | ! either version 3 of the License, or (at your option) any later version. |
---|
| 9 | ! |
---|
| 10 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
| 11 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
| 12 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
| 13 | ! |
---|
| 14 | ! You should have received a copy of the GNU General Public License along with |
---|
| 15 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
| 16 | ! |
---|
[1310] | 17 | ! Copyright 1997-2014 Leibniz Universitaet Hannover |
---|
[1036] | 18 | !--------------------------------------------------------------------------------! |
---|
| 19 | ! |
---|
[484] | 20 | ! Current revisions: |
---|
[1] | 21 | ! ----------------- |
---|
[1349] | 22 | ! |
---|
[1321] | 23 | ! |
---|
| 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: exchange_horiz_2d.f90 1349 2014-03-27 18:03:27Z witha $ |
---|
| 27 | ! |
---|
[1349] | 28 | ! 1348 2014-03-27 18:01:03Z raasch |
---|
| 29 | ! bugfix: bc_lr_cyc and bc_ns_cyc added to ONLY-list |
---|
| 30 | ! |
---|
[1321] | 31 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 32 | ! ONLY-attribute added to USE-statements, |
---|
| 33 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 34 | ! kinds are defined in new module kinds, |
---|
| 35 | ! revision history before 2012 removed, |
---|
| 36 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 37 | ! all variable declaration statements |
---|
[1] | 38 | ! |
---|
[1093] | 39 | ! 1092 2013-02-02 11:24:22Z raasch |
---|
| 40 | ! unused variables removed |
---|
| 41 | ! |
---|
[1037] | 42 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 43 | ! code put under GPL (PALM 3.9) |
---|
| 44 | ! |
---|
[842] | 45 | ! 841 2012-02-28 12:29:49Z maronga |
---|
| 46 | ! Excluded routine from compilation of namelist_file_check |
---|
| 47 | ! |
---|
[1] | 48 | ! Revision 1.1 1998/01/23 09:58:21 raasch |
---|
| 49 | ! Initial revision |
---|
| 50 | ! |
---|
| 51 | ! |
---|
| 52 | ! Description: |
---|
| 53 | ! ------------ |
---|
| 54 | ! Exchange of lateral (ghost) boundaries (parallel computers) and cyclic |
---|
| 55 | ! boundary conditions, respectively, for 2D-arrays. |
---|
| 56 | !------------------------------------------------------------------------------! |
---|
| 57 | |
---|
[1320] | 58 | USE control_parameters, & |
---|
[1348] | 59 | ONLY : bc_lr_cyc, bc_ns_cyc, inflow_l, inflow_n, inflow_r, inflow_s, & |
---|
| 60 | outflow_l, outflow_n, outflow_r, outflow_s |
---|
[1320] | 61 | |
---|
| 62 | USE cpulog, & |
---|
| 63 | ONLY : cpu_log, log_point_s |
---|
| 64 | |
---|
| 65 | USE indices, & |
---|
| 66 | ONLY : nbgp, nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg |
---|
| 67 | |
---|
| 68 | USE kinds |
---|
| 69 | |
---|
[1] | 70 | USE pegrid |
---|
| 71 | |
---|
| 72 | IMPLICIT NONE |
---|
| 73 | |
---|
[841] | 74 | |
---|
[1320] | 75 | INTEGER(iwp) :: i !: |
---|
| 76 | |
---|
| 77 | REAL(wp) :: ar(nysg:nyng,nxlg:nxrg) !: |
---|
| 78 | |
---|
[1] | 79 | |
---|
[841] | 80 | #if ! defined( __check ) |
---|
[1] | 81 | CALL cpu_log( log_point_s(13), 'exchange_horiz_2d', 'start' ) |
---|
| 82 | |
---|
| 83 | #if defined( __parallel ) |
---|
| 84 | |
---|
| 85 | ! |
---|
| 86 | !-- Exchange of lateral boundary values for parallel computers |
---|
| 87 | IF ( pdims(1) == 1 ) THEN |
---|
| 88 | |
---|
| 89 | ! |
---|
| 90 | !-- One-dimensional decomposition along y, boundary values can be exchanged |
---|
| 91 | !-- within the PE memory |
---|
[702] | 92 | ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr) |
---|
| 93 | ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1) |
---|
[1] | 94 | |
---|
| 95 | ELSE |
---|
| 96 | ! |
---|
| 97 | !-- Send left boundary, receive right one |
---|
[667] | 98 | |
---|
[702] | 99 | CALL MPI_SENDRECV( ar(nysg,nxl), 1, type_y, pleft, 0, & |
---|
| 100 | ar(nysg,nxr+1), 1, type_y, pright, 0, & |
---|
[1] | 101 | comm2d, status, ierr ) |
---|
| 102 | ! |
---|
| 103 | !-- Send right boundary, receive left one |
---|
[702] | 104 | CALL MPI_SENDRECV( ar(nysg,nxr+1-nbgp), 1, type_y, pright, 1, & |
---|
| 105 | ar(nysg,nxlg), 1, type_y, pleft, 1, & |
---|
[1] | 106 | comm2d, status, ierr ) |
---|
[702] | 107 | |
---|
| 108 | |
---|
[1] | 109 | ENDIF |
---|
| 110 | |
---|
| 111 | IF ( pdims(2) == 1 ) THEN |
---|
| 112 | ! |
---|
| 113 | !-- One-dimensional decomposition along x, boundary values can be exchanged |
---|
| 114 | !-- within the PE memory |
---|
[702] | 115 | ar(nysg:nys-1,:) = ar(nyn-nbgp+1:nyn,:) |
---|
| 116 | ar(nyn+1:nyng,:) = ar(nys:nys+nbgp-1,:) |
---|
[1] | 117 | |
---|
| 118 | ELSE |
---|
| 119 | ! |
---|
| 120 | !-- Send front boundary, receive rear one |
---|
[667] | 121 | |
---|
[702] | 122 | CALL MPI_SENDRECV( ar(nys,nxlg), 1, type_x, psouth, 0, & |
---|
| 123 | ar(nyn+1,nxlg), 1, type_x, pnorth, 0, & |
---|
[1] | 124 | comm2d, status, ierr ) |
---|
| 125 | ! |
---|
| 126 | !-- Send rear boundary, receive front one |
---|
[702] | 127 | CALL MPI_SENDRECV( ar(nyn+1-nbgp,nxlg), 1, type_x, pnorth, 1, & |
---|
| 128 | ar(nysg,nxlg), 1, type_x, psouth, 1, & |
---|
[1] | 129 | comm2d, status, ierr ) |
---|
[667] | 130 | |
---|
[1] | 131 | ENDIF |
---|
| 132 | |
---|
| 133 | #else |
---|
| 134 | |
---|
| 135 | ! |
---|
| 136 | !-- Lateral boundary conditions in the non-parallel case |
---|
[707] | 137 | IF ( bc_lr_cyc ) THEN |
---|
[702] | 138 | ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr) |
---|
| 139 | ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1) |
---|
[1] | 140 | ENDIF |
---|
| 141 | |
---|
[707] | 142 | IF ( bc_ns_cyc ) THEN |
---|
[702] | 143 | ar(nysg:nys-1,:) = ar(nyn-nbgp+1:nyn,:) |
---|
| 144 | ar(nyn+1:nyng,:) = ar(nys:nys+nbgp-1,:) |
---|
[1] | 145 | ENDIF |
---|
| 146 | |
---|
[667] | 147 | |
---|
[1] | 148 | #endif |
---|
| 149 | |
---|
[73] | 150 | ! |
---|
| 151 | !-- Neumann-conditions at inflow/outflow in case of non-cyclic boundary |
---|
| 152 | !-- conditions |
---|
[667] | 153 | IF ( inflow_l .OR. outflow_l ) THEN |
---|
| 154 | DO i=nbgp, 1, -1 |
---|
| 155 | ar(:,nxl-i) = ar(:,nxl) |
---|
| 156 | END DO |
---|
| 157 | END IF |
---|
| 158 | IF ( inflow_r .OR. outflow_r ) THEN |
---|
| 159 | DO i=1, nbgp |
---|
| 160 | ar(:,nxr+i) = ar(:,nxr) |
---|
| 161 | END DO |
---|
| 162 | END IF |
---|
| 163 | IF ( inflow_s .OR. outflow_s ) THEN |
---|
| 164 | DO i=nbgp, 1, -1 |
---|
| 165 | ar(nys-i,:) = ar(nys,:) |
---|
| 166 | END DO |
---|
| 167 | END IF |
---|
| 168 | IF ( inflow_n .OR. outflow_n ) THEN |
---|
| 169 | DO i=1, nbgp |
---|
| 170 | ar(nyn+i,:) = ar(nyn,:) |
---|
| 171 | END DO |
---|
| 172 | END IF |
---|
[1] | 173 | CALL cpu_log( log_point_s(13), 'exchange_horiz_2d', 'stop' ) |
---|
| 174 | |
---|
[841] | 175 | #endif |
---|
[1] | 176 | END SUBROUTINE exchange_horiz_2d |
---|
| 177 | |
---|
| 178 | |
---|
| 179 | |
---|
| 180 | SUBROUTINE exchange_horiz_2d_int( ar ) |
---|
| 181 | |
---|
| 182 | !------------------------------------------------------------------------------! |
---|
| 183 | ! Description: |
---|
| 184 | ! ------------ |
---|
| 185 | ! Exchange of lateral (ghost) boundaries (parallel computers) and cyclic |
---|
| 186 | ! boundary conditions, respectively, for 2D integer arrays. |
---|
| 187 | !------------------------------------------------------------------------------! |
---|
| 188 | |
---|
[1320] | 189 | USE control_parameters, & |
---|
| 190 | ONLY: bc_lr_cyc, bc_ns_cyc |
---|
| 191 | |
---|
| 192 | USE cpulog, & |
---|
| 193 | ONLY: cpu_log, log_point_s |
---|
| 194 | |
---|
| 195 | USE indices, & |
---|
| 196 | ONLY: nbgp, nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg |
---|
| 197 | |
---|
| 198 | USE kinds |
---|
| 199 | |
---|
[1] | 200 | USE pegrid |
---|
| 201 | |
---|
| 202 | IMPLICIT NONE |
---|
| 203 | |
---|
[1320] | 204 | INTEGER(iwp) :: ar(nysg:nyng,nxlg:nxrg) !: |
---|
[1] | 205 | |
---|
[841] | 206 | #if ! defined( __check ) |
---|
[1] | 207 | CALL cpu_log( log_point_s(13), 'exchange_horiz_2d', 'start' ) |
---|
| 208 | |
---|
| 209 | #if defined( __parallel ) |
---|
| 210 | |
---|
| 211 | ! |
---|
| 212 | !-- Exchange of lateral boundary values for parallel computers |
---|
| 213 | IF ( pdims(1) == 1 ) THEN |
---|
| 214 | |
---|
| 215 | ! |
---|
| 216 | !-- One-dimensional decomposition along y, boundary values can be exchanged |
---|
| 217 | !-- within the PE memory |
---|
[702] | 218 | ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr) |
---|
| 219 | ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1) |
---|
[1] | 220 | |
---|
[702] | 221 | |
---|
[1] | 222 | ELSE |
---|
| 223 | ! |
---|
| 224 | !-- Send left boundary, receive right one |
---|
[702] | 225 | CALL MPI_SENDRECV( ar(nysg,nxl), 1, type_y_int, pleft, 0, & |
---|
| 226 | ar(nysg,nxr+1), 1, type_y_int, pright, 0, & |
---|
[1] | 227 | comm2d, status, ierr ) |
---|
| 228 | ! |
---|
| 229 | !-- Send right boundary, receive left one |
---|
[702] | 230 | CALL MPI_SENDRECV( ar(nysg,nxr+1-nbgp), 1, type_y_int, pright, 1, & |
---|
| 231 | ar(nysg,nxlg), 1, type_y_int, pleft, 1, & |
---|
[1] | 232 | comm2d, status, ierr ) |
---|
[667] | 233 | |
---|
[1] | 234 | ENDIF |
---|
| 235 | |
---|
| 236 | IF ( pdims(2) == 1 ) THEN |
---|
| 237 | ! |
---|
| 238 | !-- One-dimensional decomposition along x, boundary values can be exchanged |
---|
| 239 | !-- within the PE memory |
---|
[667] | 240 | ar(nysg:nys-1,:) = ar(nyn+1-nbgp:nyn,:) |
---|
| 241 | ar(nyn+1:nyng,:) = ar(nys:nys-1+nbgp,:) |
---|
[1] | 242 | |
---|
[667] | 243 | |
---|
[1] | 244 | ELSE |
---|
| 245 | ! |
---|
| 246 | !-- Send front boundary, receive rear one |
---|
[702] | 247 | CALL MPI_SENDRECV( ar(nys,nxlg), 1, type_x_int, psouth, 0, & |
---|
| 248 | ar(nyn+1,nxlg), 1, type_x_int, pnorth, 0, & |
---|
| 249 | comm2d, status, ierr ) |
---|
[667] | 250 | |
---|
[1] | 251 | ! |
---|
| 252 | !-- Send rear boundary, receive front one |
---|
[702] | 253 | CALL MPI_SENDRECV( ar(nyn+1-nbgp,nxlg), 1, type_x_int, pnorth, 1, & |
---|
| 254 | ar(nysg,nxlg), 1, type_x_int, psouth, 1, & |
---|
[1] | 255 | comm2d, status, ierr ) |
---|
[667] | 256 | |
---|
[1] | 257 | ENDIF |
---|
| 258 | |
---|
| 259 | #else |
---|
| 260 | |
---|
| 261 | ! |
---|
| 262 | !-- Lateral boundary conditions in the non-parallel case |
---|
[707] | 263 | IF ( bc_lr_cyc ) THEN |
---|
[702] | 264 | ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr) |
---|
| 265 | ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1) |
---|
[1] | 266 | ENDIF |
---|
| 267 | |
---|
[707] | 268 | IF ( bc_ns_cyc ) THEN |
---|
[667] | 269 | ar(nysg:nys-1,:) = ar(nyn+1-nbgp:nyn,:) |
---|
| 270 | ar(nyn+1:nyng,:) = ar(nys:nys-1+nbgp,:) |
---|
[1] | 271 | ENDIF |
---|
| 272 | |
---|
| 273 | #endif |
---|
| 274 | CALL cpu_log( log_point_s(13), 'exchange_horiz_2d', 'stop' ) |
---|
| 275 | |
---|
[841] | 276 | #endif |
---|
[1] | 277 | END SUBROUTINE exchange_horiz_2d_int |
---|