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

Last change on this file since 1804 was 1804, checked in by maronga, 8 years ago

removed parameter file check. update of mrungui for compilation with qt5

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