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