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

Last change on this file since 2716 was 2716, checked in by kanani, 6 years ago

Correction of "Former revisions" section

  • Property svn:keywords set to Id
File size: 11.7 KB
RevLine 
[1682]1!> @file exchange_horiz_2d.f90
[2000]2!------------------------------------------------------------------------------!
[2696]3! This file is part of the PALM model system.
[1036]4!
[2000]5! PALM is free software: you can redistribute it and/or modify it under the
6! terms of the GNU General Public License as published by the Free Software
7! Foundation, either version 3 of the License, or (at your option) any later
8! version.
[1036]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!
[2101]17! Copyright 1997-2017 Leibniz Universitaet Hannover
[2000]18!------------------------------------------------------------------------------!
[1036]19!
[484]20! Current revisions:
[1]21! -----------------
[1683]22!
[2001]23!
[1321]24! Former revisions:
25! -----------------
26! $Id: exchange_horiz_2d.f90 2716 2017-12-29 16:35:59Z kanani $
[2716]27! Corrected "Former revisions" section
28!
29! 2696 2017-12-14 17:12:51Z kanani
30! Change in file header (GPL part)
[2696]31! Forcing implemented (MS)
32!
33! 2101 2017-01-05 16:42:31Z suehring
[1321]34!
[2001]35! 2000 2016-08-20 18:09:15Z knoop
36! Forced header and separation lines into 80 columns
37!
[1969]38! 1968 2016-07-18 12:01:49Z suehring
39! 2D-INTEGER exchange adopted for different multigrid level
40!
[1933]41! 1818 2016-04-06 15:53:27Z maronga
42! Initial version of purely vertical nesting introduced.
43!
[1805]44! 1804 2016-04-05 16:30:18Z maronga
45! Removed code for parameter file check (__check)
46!
[1763]47! 1762 2016-02-25 12:31:13Z hellstea
48! Introduction of nested domain feature
49!
[1683]50! 1682 2015-10-07 23:56:08Z knoop
51! Code annotations made doxygen readable
52!
[1349]53! 1348 2014-03-27 18:01:03Z raasch
54! bugfix: bc_lr_cyc and bc_ns_cyc added to ONLY-list
55!
[1321]56! 1320 2014-03-20 08:40:49Z raasch
[1320]57! ONLY-attribute added to USE-statements,
58! kind-parameters added to all INTEGER and REAL declaration statements,
59! kinds are defined in new module kinds,
60! revision history before 2012 removed,
61! comment fields (!:) to be used for variable explanations added to
62! all variable declaration statements
[1]63!
[1093]64! 1092 2013-02-02 11:24:22Z raasch
65! unused variables removed
66!
[1037]67! 1036 2012-10-22 13:43:42Z raasch
68! code put under GPL (PALM 3.9)
69!
[842]70! 841 2012-02-28 12:29:49Z maronga
71! Excluded routine from compilation of namelist_file_check
72!
[1]73! Revision 1.1  1998/01/23 09:58:21  raasch
74! Initial revision
75!
76!
77! Description:
78! ------------
[1682]79!> Exchange of lateral (ghost) boundaries (parallel computers) and cyclic
80!> boundary conditions, respectively, for 2D-arrays.
[1]81!------------------------------------------------------------------------------!
[1682]82 SUBROUTINE exchange_horiz_2d( ar )
83 
[1]84
[1320]85    USE control_parameters,                                                    &
[2696]86        ONLY :  bc_lr_cyc, bc_ns_cyc, force_bound_l, force_bound_n,            &
87                force_bound_r, force_bound_s,                                  &
88                inflow_l, inflow_n, inflow_r, inflow_s,                        &
[1762]89                nest_bound_l, nest_bound_n, nest_bound_r, nest_bound_s,        &
[1348]90                outflow_l, outflow_n, outflow_r, outflow_s
[1320]91               
92    USE cpulog,                                                                &
93        ONLY :  cpu_log, log_point_s
94       
95    USE indices,                                                               &
96        ONLY :  nbgp, nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg
97       
98    USE kinds
99   
[1]100    USE pegrid
101
[1933]102    USE pmc_interface,                                                         &
103        ONLY : nesting_mode
104
105
[1]106    IMPLICIT NONE
107
[841]108
[1682]109    INTEGER(iwp) :: i  !<
[1320]110   
[1682]111    REAL(wp) ::  ar(nysg:nyng,nxlg:nxrg)  !<
[1320]112   
[1]113
114    CALL cpu_log( log_point_s(13), 'exchange_horiz_2d', 'start' )
115
116#if defined( __parallel )
117
118!
119!-- Exchange of lateral boundary values for parallel computers
120    IF ( pdims(1) == 1 )  THEN
121
122!
123!--    One-dimensional decomposition along y, boundary values can be exchanged
124!--    within the PE memory
[702]125       ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr)
126       ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1)
[1]127
128    ELSE
129!
130!--    Send left boundary, receive right one
[667]131
[702]132       CALL MPI_SENDRECV( ar(nysg,nxl), 1, type_y, pleft,  0,                 &
133                          ar(nysg,nxr+1), 1, type_y, pright, 0,               &
[1]134                          comm2d, status, ierr )
135!
136!--    Send right boundary, receive left one
[702]137       CALL MPI_SENDRECV( ar(nysg,nxr+1-nbgp), 1, type_y, pright,  1,         &
138                          ar(nysg,nxlg), 1, type_y, pleft,   1,               &
[1]139                          comm2d, status, ierr )
[702]140                         
141     
[1]142    ENDIF
143
144    IF ( pdims(2) == 1 )  THEN
145!
146!--    One-dimensional decomposition along x, boundary values can be exchanged
147!--    within the PE memory
[702]148       ar(nysg:nys-1,:) = ar(nyn-nbgp+1:nyn,:)
149       ar(nyn+1:nyng,:) = ar(nys:nys+nbgp-1,:)
[1]150
151    ELSE
152!
153!--    Send front boundary, receive rear one
[667]154
[702]155       CALL MPI_SENDRECV( ar(nys,nxlg), 1, type_x, psouth, 0,                 &         
156                          ar(nyn+1,nxlg), 1, type_x, pnorth, 0,               &
[1]157                          comm2d, status, ierr )
158!
159!--    Send rear boundary, receive front one
[702]160       CALL MPI_SENDRECV( ar(nyn+1-nbgp,nxlg), 1, type_x, pnorth, 1,          &
161                          ar(nysg,nxlg), 1, type_x, psouth, 1,                &
[1]162                          comm2d, status, ierr )
[667]163
[1]164    ENDIF
165
166#else
167
168!
169!-- Lateral boundary conditions in the non-parallel case
[707]170    IF ( bc_lr_cyc )  THEN
[702]171       ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr)
172       ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1)
[1]173    ENDIF
174
[707]175    IF ( bc_ns_cyc )  THEN
[702]176       ar(nysg:nys-1,:) = ar(nyn-nbgp+1:nyn,:)
177       ar(nyn+1:nyng,:) = ar(nys:nys+nbgp-1,:)
[1]178    ENDIF
179
[667]180
[1]181#endif
182
[73]183!
[1762]184!-- Neumann-conditions at inflow/outflow/nested boundaries
[1933]185    IF ( nesting_mode /= 'vertical' )  THEN
[2696]186       IF ( inflow_l .OR. outflow_l .OR. nest_bound_l  .OR.  force_bound_l )   &
187       THEN
[1933]188          DO  i = nbgp, 1, -1
189             ar(:,nxl-i) = ar(:,nxl)
190          ENDDO
191       ENDIF
[2696]192       IF ( inflow_r .OR. outflow_r .OR. nest_bound_r  .OR.  force_bound_r )   &
193       THEN
[1933]194          DO  i = 1, nbgp
195             ar(:,nxr+i) = ar(:,nxr)
196          ENDDO
197       ENDIF
[2696]198       IF ( inflow_s .OR. outflow_s .OR. nest_bound_s  .OR.  force_bound_s )   &
199       THEN
[1933]200          DO  i = nbgp, 1, -1
201             ar(nys-i,:) = ar(nys,:)
202          ENDDO
203       ENDIF
[2696]204       IF ( inflow_n .OR. outflow_n .OR. nest_bound_n  .OR.  force_bound_n )   &
205       THEN
[1933]206          DO  i = 1, nbgp
207             ar(nyn+i,:) = ar(nyn,:)
208          ENDDO
209       ENDIF
[1762]210    ENDIF
211
[1]212    CALL cpu_log( log_point_s(13), 'exchange_horiz_2d', 'stop' )
213
214 END SUBROUTINE exchange_horiz_2d
215
216
217
218!------------------------------------------------------------------------------!
219! Description:
220! ------------
[1682]221!> Exchange of lateral (ghost) boundaries (parallel computers) and cyclic
222!> boundary conditions, respectively, for 2D integer arrays.
[1]223!------------------------------------------------------------------------------!
[1682]224 
[1968]225 SUBROUTINE exchange_horiz_2d_int( ar, nys_l, nyn_l, nxl_l, nxr_l, nbgp_local )
[1]226
[1682]227
[1320]228    USE control_parameters,                                                    &
[2696]229        ONLY:  bc_lr_cyc, bc_ns_cyc, grid_level, force_bound_l, force_bound_n, &
230               force_bound_r, force_bound_s, nest_bound_l, nest_bound_n,       &
[1968]231               nest_bound_r, nest_bound_s
[1320]232       
233    USE cpulog,                                                                &
234        ONLY:  cpu_log, log_point_s
[1968]235               
[1320]236    USE kinds
237   
[1]238    USE pegrid
239
240    IMPLICIT NONE
241
[1968]242    INTEGER(iwp) ::  i           !< dummy index to zero-gradient conditions at in/outflow boundaries
243    INTEGER(iwp) ::  nxl_l       !< local index bound at current grid level, left side
244    INTEGER(iwp) ::  nxr_l       !< local index bound at current grid level, right side
245    INTEGER(iwp) ::  nyn_l       !< local index bound at current grid level, north side
246    INTEGER(iwp) ::  nys_l       !< local index bound at current grid level, south side
247    INTEGER(iwp) ::  nbgp_local  !< number of ghost layers to be exchanged
[1]248
[1968]249    INTEGER(iwp), DIMENSION(nys_l-nbgp_local:nyn_l+nbgp_local,                 &
250                            nxl_l-nbgp_local:nxr_l+nbgp_local) ::  ar  !< treated array
251
[1]252    CALL cpu_log( log_point_s(13), 'exchange_horiz_2d', 'start' )
253
254#if defined( __parallel )
255
256!
257!-- Exchange of lateral boundary values for parallel computers
258    IF ( pdims(1) == 1 )  THEN
259
260!
261!--    One-dimensional decomposition along y, boundary values can be exchanged
262!--    within the PE memory
[1968]263       ar(:,nxl_l-nbgp_local:nxl_l-1) = ar(:,nxr_l-nbgp_local+1:nxr_l)
264       ar(:,nxr_l+1:nxr_l+nbgp_local) = ar(:,nxl_l:nxl_l+nbgp_local-1)
[1]265
266    ELSE
267!
268!--    Send left boundary, receive right one
[1968]269       CALL MPI_SENDRECV( ar(nys_l-nbgp_local,nxl_l),   1,                     &
270                          type_y_int(grid_level), pleft,  0,                   &
271                          ar(nys_l-nbgp_local,nxr_l+1), 1,                     &
272                          type_y_int(grid_level), pright, 0,                   &
[1]273                          comm2d, status, ierr )
274!
275!--    Send right boundary, receive left one
[1968]276       CALL MPI_SENDRECV( ar(nys_l-nbgp_local,nxr_l+1-nbgp_local), 1,          &
277                          type_y_int(grid_level), pright, 1,                   &
278                          ar(nys_l-nbgp_local,nxl_l-nbgp_local),   1,          & 
279                          type_y_int(grid_level), pleft,  1,                   &
280                          comm2d, status, ierr )                         
[667]281
[1]282    ENDIF
283
284    IF ( pdims(2) == 1 )  THEN
285!
286!--    One-dimensional decomposition along x, boundary values can be exchanged
287!--    within the PE memory
[1968]288       ar(nys_l-nbgp_local:nys_l-1,:) = ar(nyn_l+1-nbgp_local:nyn_l,:)
289       ar(nyn_l+1:nyn_l+nbgp_local,:) = ar(nys_l:nys_l-1+nbgp_local,:)
[1]290
[667]291
[1]292    ELSE
293!
294!--    Send front boundary, receive rear one
[1968]295       CALL MPI_SENDRECV( ar(nys_l,nxl_l-nbgp_local),   1,                    &
296                          type_x_int(grid_level), psouth, 0,                  &
297                          ar(nyn_l+1,nxl_l-nbgp_local), 1,                    &
298                          type_x_int(grid_level), pnorth, 0,                  &
[702]299                          comm2d, status, ierr )                         
[667]300
[1]301!
302!--    Send rear boundary, receive front one
[1968]303       CALL MPI_SENDRECV( ar(nyn_l+1-nbgp_local,nxl_l-nbgp_local), 1,         &
304                          type_x_int(grid_level), pnorth, 1,                  &
305                          ar(nys_l-nbgp_local,nxl_l-nbgp_local),   1,         &
306                          type_x_int(grid_level), psouth, 1,                  &
[1]307                          comm2d, status, ierr )
[667]308
[1]309    ENDIF
310
311#else
312
313!
314!-- Lateral boundary conditions in the non-parallel case
[707]315    IF ( bc_lr_cyc )  THEN
[1968]316       ar(:,nxl_l-nbgp_local:nxl_l-1) = ar(:,nxr_l-nbgp_local+1:nxr_l)
317       ar(:,nxr_l+1:nxr_l+nbgp_local) = ar(:,nxl_l:nxl_l+nbgp_local-1)
[1]318    ENDIF
319
[707]320    IF ( bc_ns_cyc )  THEN
[1968]321       ar(nys_l-nbgp_local:nys_l-1,:) = ar(nyn_l+1-nbgp_local:nyn_l,:)
322       ar(nyn_l+1:nyn_l+nbgp_local,:) = ar(nys_l:nys_l-1+nbgp_local,:)
[1]323    ENDIF
324
325#endif
[1762]326!
327!-- Neumann-conditions at inflow/outflow/nested boundaries
[2696]328    IF ( nest_bound_l  .OR.  force_bound_l )  THEN
[1968]329       DO  i = nbgp_local, 1, -1
330         ar(:,nxl_l-i) = ar(:,nxl_l)
[1762]331       ENDDO
332    ENDIF
[2696]333    IF ( nest_bound_r  .OR.  force_bound_r )  THEN
[1968]334       DO  i = 1, nbgp_local
335          ar(:,nxr_l+i) = ar(:,nxr_l)
[1762]336       ENDDO
337    ENDIF
[2696]338    IF ( nest_bound_s  .OR.  force_bound_s )  THEN
[1968]339       DO  i = nbgp_local, 1, -1
340         ar(nys_l-i,:) = ar(nys_l,:)
[1762]341       ENDDO
342    ENDIF
[2696]343    IF ( nest_bound_n  .OR.  force_bound_n )  THEN
[1968]344       DO  i = 1, nbgp_local
345         ar(nyn_l+i,:) = ar(nyn_l,:)
[1762]346       ENDDO
347    ENDIF
348
[1]349    CALL cpu_log( log_point_s(13), 'exchange_horiz_2d', 'stop' )
350
351 END SUBROUTINE exchange_horiz_2d_int
Note: See TracBrowser for help on using the repository browser.