[667] | 1 | SUBROUTINE exchange_horiz( ar, nbgp_local) |
---|
[1] | 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 | ! |
---|
| 17 | ! Copyright 1997-2012 Leibniz University Hannover |
---|
| 18 | !--------------------------------------------------------------------------------! |
---|
| 19 | ! |
---|
[484] | 20 | ! Current revisions: |
---|
[1] | 21 | ! ----------------- |
---|
[668] | 22 | ! |
---|
[842] | 23 | ! |
---|
[668] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
[708] | 26 | ! $Id: exchange_horiz.f90 1036 2012-10-22 13:43:42Z raasch $ |
---|
[668] | 27 | ! |
---|
[842] | 28 | ! 841 2012-02-28 12:29:49Z maronga |
---|
| 29 | ! Excluded routine from compilation of namelist_file_check |
---|
| 30 | ! |
---|
[710] | 31 | ! 709 2011-03-30 09:31:40Z raasch |
---|
| 32 | ! formatting adjustments |
---|
| 33 | ! |
---|
[708] | 34 | ! 707 2011-03-29 11:39:40Z raasch |
---|
| 35 | ! grid_level directly used as index for MPI data type arrays, |
---|
| 36 | ! bc_lr/ns replaced by bc_lr/ns_cyc |
---|
| 37 | ! |
---|
[690] | 38 | ! 689 2011-02-20 19:31:12z gryschka |
---|
| 39 | ! Bugfix for some logical expressions |
---|
| 40 | ! (syntax was not compatible with all compilers) |
---|
[688] | 41 | ! |
---|
[684] | 42 | ! 683 2011-02-09 14:25:15Z raasch |
---|
| 43 | ! optional synchronous exchange (sendrecv) implemented, code partly reformatted |
---|
| 44 | ! |
---|
[668] | 45 | ! 667 2010-12-23 12:06:00Z suehring/gryschka |
---|
[667] | 46 | ! Dynamic exchange of ghost points with nbgp_local to ensure that no useless |
---|
| 47 | ! ghost points exchanged in case of multigrid. type_yz(0) and type_xz(0) |
---|
| 48 | ! used for normal grid, the remaining types used for the several grid levels. |
---|
| 49 | ! Exchange is done via MPI-Vectors with a dynamic value of ghost points which |
---|
| 50 | ! depend on the advection scheme. Exchange of left and right PEs is 10% faster |
---|
[668] | 51 | ! with MPI-Vectors than without. |
---|
[1] | 52 | ! |
---|
[77] | 53 | ! 75 2007-03-22 09:54:05Z raasch |
---|
| 54 | ! Special cases for additional gridpoints along x or y in case of non-cyclic |
---|
| 55 | ! boundary conditions are not regarded any more |
---|
| 56 | ! |
---|
[3] | 57 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
| 58 | ! |
---|
[1] | 59 | ! Revision 1.16 2006/02/23 12:19:08 raasch |
---|
| 60 | ! anz_yz renamed ngp_yz |
---|
| 61 | ! |
---|
| 62 | ! Revision 1.1 1997/07/24 11:13:29 raasch |
---|
| 63 | ! Initial revision |
---|
| 64 | ! |
---|
| 65 | ! |
---|
| 66 | ! Description: |
---|
| 67 | ! ------------ |
---|
| 68 | ! Exchange of lateral boundary values (parallel computers) and cyclic |
---|
| 69 | ! lateral boundary conditions, respectively. |
---|
| 70 | !------------------------------------------------------------------------------! |
---|
| 71 | |
---|
| 72 | USE control_parameters |
---|
| 73 | USE cpulog |
---|
| 74 | USE indices |
---|
| 75 | USE interfaces |
---|
| 76 | USE pegrid |
---|
| 77 | |
---|
| 78 | IMPLICIT NONE |
---|
| 79 | |
---|
[841] | 80 | |
---|
| 81 | INTEGER :: nbgp_local |
---|
| 82 | REAL, DIMENSION(nzb:nzt+1,nys-nbgp_local:nyn+nbgp_local, & |
---|
| 83 | nxl-nbgp_local:nxr+nbgp_local) :: ar |
---|
| 84 | |
---|
| 85 | #if ! defined( __check ) |
---|
[1] | 86 | #if defined( __parallel ) |
---|
| 87 | INTEGER, DIMENSION(4) :: req |
---|
| 88 | INTEGER, DIMENSION(MPI_STATUS_SIZE,4) :: wait_stat |
---|
| 89 | #endif |
---|
| 90 | |
---|
[841] | 91 | |
---|
[1] | 92 | CALL cpu_log( log_point_s(2), 'exchange_horiz', 'start' ) |
---|
| 93 | |
---|
| 94 | #if defined( __parallel ) |
---|
| 95 | |
---|
| 96 | ! |
---|
[709] | 97 | !-- Exchange of lateral boundary values |
---|
[1] | 98 | IF ( pdims(1) == 1 .OR. mg_switch_to_pe0 ) THEN |
---|
| 99 | ! |
---|
| 100 | !-- One-dimensional decomposition along y, boundary values can be exchanged |
---|
| 101 | !-- within the PE memory |
---|
[707] | 102 | IF ( bc_lr_cyc ) THEN |
---|
[667] | 103 | ar(:,:,nxl-nbgp_local:nxl-1) = ar(:,:,nxr-nbgp_local+1:nxr) |
---|
| 104 | ar(:,:,nxr+1:nxr+nbgp_local) = ar(:,:,nxl:nxl+nbgp_local-1) |
---|
[1] | 105 | ENDIF |
---|
| 106 | |
---|
| 107 | ELSE |
---|
[75] | 108 | |
---|
[683] | 109 | IF ( synchronous_exchange ) THEN |
---|
[1] | 110 | ! |
---|
[683] | 111 | !-- Send left boundary, receive right one (synchronous) |
---|
| 112 | CALL MPI_SENDRECV( & |
---|
[707] | 113 | ar(nzb,nys-nbgp_local,nxl), 1, type_yz(grid_level), pleft, 0, & |
---|
| 114 | ar(nzb,nys-nbgp_local,nxr+1), 1, type_yz(grid_level), pright, 0, & |
---|
| 115 | comm2d, status, ierr ) |
---|
[1] | 116 | ! |
---|
[683] | 117 | !-- Send right boundary, receive left one (synchronous) |
---|
[707] | 118 | CALL MPI_SENDRECV( ar(nzb,nys-nbgp_local,nxr+1-nbgp_local), 1, & |
---|
| 119 | type_yz(grid_level), pright, 1, & |
---|
| 120 | ar(nzb,nys-nbgp_local,nxl-nbgp_local), 1, & |
---|
| 121 | type_yz(grid_level), pleft, 1, & |
---|
| 122 | comm2d, status, ierr ) |
---|
[667] | 123 | |
---|
[683] | 124 | ELSE |
---|
[667] | 125 | |
---|
[683] | 126 | req = 0 |
---|
| 127 | ! |
---|
| 128 | !-- Send left boundary, receive right one (asynchronous) |
---|
[707] | 129 | CALL MPI_ISEND( ar(nzb,nys-nbgp_local,nxl), 1, type_yz(grid_level), & |
---|
| 130 | pleft, 0, comm2d, req(1), ierr ) |
---|
| 131 | CALL MPI_IRECV( ar(nzb,nys-nbgp_local,nxr+1), 1, type_yz(grid_level), & |
---|
| 132 | pright, 0, comm2d, req(2), ierr ) |
---|
[683] | 133 | ! |
---|
| 134 | !-- Send right boundary, receive left one (asynchronous) |
---|
| 135 | CALL MPI_ISEND( ar(nzb,nys-nbgp_local,nxr+1-nbgp_local), 1, & |
---|
[707] | 136 | type_yz(grid_level), pright, 1, comm2d, req(3), ierr ) |
---|
[683] | 137 | CALL MPI_IRECV( ar(nzb,nys-nbgp_local,nxl-nbgp_local), 1, & |
---|
[707] | 138 | type_yz(grid_level), pleft, 1, comm2d, req(4), ierr ) |
---|
[667] | 139 | |
---|
[683] | 140 | CALL MPI_WAITALL( 4, req, wait_stat, ierr ) |
---|
[75] | 141 | |
---|
[683] | 142 | ENDIF |
---|
| 143 | |
---|
[1] | 144 | ENDIF |
---|
| 145 | |
---|
| 146 | |
---|
| 147 | IF ( pdims(2) == 1 .OR. mg_switch_to_pe0 ) THEN |
---|
| 148 | ! |
---|
| 149 | !-- One-dimensional decomposition along x, boundary values can be exchanged |
---|
| 150 | !-- within the PE memory |
---|
[707] | 151 | IF ( bc_ns_cyc ) THEN |
---|
[667] | 152 | ar(:,nys-nbgp_local:nys-1,:) = ar(:,nyn-nbgp_local+1:nyn,:) |
---|
| 153 | ar(:,nyn+1:nyn+nbgp_local,:) = ar(:,nys:nys+nbgp_local-1,:) |
---|
[1] | 154 | ENDIF |
---|
| 155 | |
---|
| 156 | ELSE |
---|
| 157 | |
---|
[683] | 158 | IF ( synchronous_exchange ) THEN |
---|
[1] | 159 | ! |
---|
[683] | 160 | !-- Send front boundary, receive rear one (synchronous) |
---|
| 161 | CALL MPI_SENDRECV( & |
---|
[707] | 162 | ar(nzb,nys,nxl-nbgp_local), 1, type_xz(grid_level), psouth, 0, & |
---|
| 163 | ar(nzb,nyn+1,nxl-nbgp_local), 1, type_xz(grid_level), pnorth, 0, & |
---|
| 164 | comm2d, status, ierr ) |
---|
[683] | 165 | ! |
---|
| 166 | !-- Send rear boundary, receive front one (synchronous) |
---|
[707] | 167 | CALL MPI_SENDRECV( ar(nzb,nyn-nbgp_local+1,nxl-nbgp_local), 1, & |
---|
| 168 | type_xz(grid_level), pnorth, 1, & |
---|
| 169 | ar(nzb,nys-nbgp_local,nxl-nbgp_local), 1, & |
---|
| 170 | type_xz(grid_level), psouth, 1, & |
---|
| 171 | comm2d, status, ierr ) |
---|
[667] | 172 | |
---|
[683] | 173 | ELSE |
---|
| 174 | |
---|
| 175 | req = 0 |
---|
[1] | 176 | ! |
---|
[683] | 177 | !-- Send front boundary, receive rear one (asynchronous) |
---|
[707] | 178 | CALL MPI_ISEND( ar(nzb,nys,nxl-nbgp_local), 1, type_xz(grid_level), & |
---|
| 179 | psouth, 0, comm2d, req(1), ierr ) |
---|
| 180 | CALL MPI_IRECV( ar(nzb,nyn+1,nxl-nbgp_local), 1, type_xz(grid_level), & |
---|
| 181 | pnorth, 0, comm2d, req(2), ierr ) |
---|
[683] | 182 | ! |
---|
| 183 | !-- Send rear boundary, receive front one (asynchronous) |
---|
| 184 | CALL MPI_ISEND( ar(nzb,nyn-nbgp_local+1,nxl-nbgp_local), 1, & |
---|
[707] | 185 | type_xz(grid_level), pnorth, 1, comm2d, req(3), ierr ) |
---|
[683] | 186 | CALL MPI_IRECV( ar(nzb,nys-nbgp_local,nxl-nbgp_local), 1, & |
---|
[707] | 187 | type_xz(grid_level), psouth, 1, comm2d, req(4), ierr ) |
---|
[75] | 188 | |
---|
[683] | 189 | CALL MPI_WAITALL( 4, req, wait_stat, ierr ) |
---|
| 190 | |
---|
| 191 | ENDIF |
---|
| 192 | |
---|
[1] | 193 | ENDIF |
---|
| 194 | |
---|
| 195 | #else |
---|
| 196 | |
---|
| 197 | ! |
---|
| 198 | !-- Lateral boundary conditions in the non-parallel case |
---|
| 199 | IF ( bc_lr == 'cyclic' ) THEN |
---|
[667] | 200 | ar(:,:,nxl-nbgp_local:nxl-1) = ar(:,:,nxr-nbgp_local+1:nxr) |
---|
| 201 | ar(:,:,nxr+1:nxr+nbgp_local) = ar(:,:,nxl:nxl+nbgp_local-1) |
---|
[1] | 202 | ENDIF |
---|
| 203 | |
---|
| 204 | IF ( bc_ns == 'cyclic' ) THEN |
---|
[667] | 205 | ar(:,nys-nbgp_local:nys-1,:) = ar(:,nyn-nbgp_local+1:nyn,:) |
---|
| 206 | ar(:,nyn+1:nyn+nbgp_local,:) = ar(:,nys:nys+nbgp_local-1,:) |
---|
[1] | 207 | ENDIF |
---|
| 208 | |
---|
| 209 | #endif |
---|
| 210 | CALL cpu_log( log_point_s(2), 'exchange_horiz', 'stop' ) |
---|
| 211 | |
---|
[841] | 212 | #endif |
---|
[1] | 213 | END SUBROUTINE exchange_horiz |
---|