source: palm/trunk/SOURCE/exchange_horiz_2d.f90 @ 1320

Last change on this file since 1320 was 1320, checked in by raasch, 7 years ago

ONLY-attribute added to USE-statements,
kind-parameters added to all INTEGER and REAL declaration statements,
kinds are defined in new module kinds,
old module precision_kind is removed,
revision history before 2012 removed,
comment fields (!:) to be used for variable explanations added to all variable declaration statements

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