1 | SUBROUTINE exchange_horiz( ar, nbgp_local) |
---|
2 | |
---|
3 | !------------------------------------------------------------------------------! |
---|
4 | ! Current revisions: |
---|
5 | ! ----------------- |
---|
6 | ! |
---|
7 | ! |
---|
8 | ! Former revisions: |
---|
9 | ! ----------------- |
---|
10 | ! 686 2011-02-20 13:45:08Z gryschka $ |
---|
11 | ! bugfix: Replaced "==" by ".EQ." in case of logical expression |
---|
12 | ! |
---|
13 | ! 683 2011-02-09 14:25:15Z raasch |
---|
14 | ! optional synchronous exchange (sendrecv) implemented, code partly reformatted |
---|
15 | ! |
---|
16 | ! 667 2010-12-23 12:06:00Z suehring/gryschka |
---|
17 | ! Dynamic exchange of ghost points with nbgp_local to ensure that no useless |
---|
18 | ! ghost points exchanged in case of multigrid. type_yz(0) and type_xz(0) |
---|
19 | ! used for normal grid, the remaining types used for the several grid levels. |
---|
20 | ! Exchange is done via MPI-Vectors with a dynamic value of ghost points which |
---|
21 | ! depend on the advection scheme. Exchange of left and right PEs is 10% faster |
---|
22 | ! with MPI-Vectors than without. |
---|
23 | ! |
---|
24 | ! 75 2007-03-22 09:54:05Z raasch |
---|
25 | ! Special cases for additional gridpoints along x or y in case of non-cyclic |
---|
26 | ! boundary conditions are not regarded any more |
---|
27 | ! |
---|
28 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
29 | ! |
---|
30 | ! Revision 1.16 2006/02/23 12:19:08 raasch |
---|
31 | ! anz_yz renamed ngp_yz |
---|
32 | ! |
---|
33 | ! Revision 1.1 1997/07/24 11:13:29 raasch |
---|
34 | ! Initial revision |
---|
35 | ! |
---|
36 | ! |
---|
37 | ! Description: |
---|
38 | ! ------------ |
---|
39 | ! Exchange of lateral boundary values (parallel computers) and cyclic |
---|
40 | ! lateral boundary conditions, respectively. |
---|
41 | !------------------------------------------------------------------------------! |
---|
42 | |
---|
43 | USE control_parameters |
---|
44 | USE cpulog |
---|
45 | USE indices |
---|
46 | USE interfaces |
---|
47 | USE pegrid |
---|
48 | |
---|
49 | IMPLICIT NONE |
---|
50 | |
---|
51 | #if defined( __parallel ) |
---|
52 | INTEGER, DIMENSION(4) :: req |
---|
53 | INTEGER, DIMENSION(MPI_STATUS_SIZE,4) :: wait_stat |
---|
54 | #endif |
---|
55 | INTEGER :: i, nbgp_local |
---|
56 | REAL, DIMENSION(nzb:nzt+1,nys-nbgp_local:nyn+nbgp_local, & |
---|
57 | nxl-nbgp_local:nxr+nbgp_local) :: ar |
---|
58 | |
---|
59 | CALL cpu_log( log_point_s(2), 'exchange_horiz', 'start' ) |
---|
60 | |
---|
61 | ! |
---|
62 | !-- In the Poisson multigrid solver arrays with coarser grids are used. |
---|
63 | !-- Set i appropriately, because the coarser grids have different |
---|
64 | !-- MPI datatypes type_xz, type_yz. |
---|
65 | IF ( exchange_mg .EQ. .TRUE. ) THEN |
---|
66 | i = grid_level |
---|
67 | ELSE |
---|
68 | i = 0 |
---|
69 | END IF |
---|
70 | |
---|
71 | #if defined( __parallel ) |
---|
72 | |
---|
73 | ! |
---|
74 | !-- Exchange of lateral boundary values for parallel computers |
---|
75 | IF ( pdims(1) == 1 .OR. mg_switch_to_pe0 ) THEN |
---|
76 | ! |
---|
77 | !-- One-dimensional decomposition along y, boundary values can be exchanged |
---|
78 | !-- within the PE memory |
---|
79 | IF ( bc_lr == 'cyclic' ) THEN |
---|
80 | ar(:,:,nxl-nbgp_local:nxl-1) = ar(:,:,nxr-nbgp_local+1:nxr) |
---|
81 | ar(:,:,nxr+1:nxr+nbgp_local) = ar(:,:,nxl:nxl+nbgp_local-1) |
---|
82 | ENDIF |
---|
83 | |
---|
84 | ELSE |
---|
85 | |
---|
86 | IF ( synchronous_exchange ) THEN |
---|
87 | ! |
---|
88 | !-- Send left boundary, receive right one (synchronous) |
---|
89 | CALL MPI_SENDRECV( & |
---|
90 | ar(nzb,nys-nbgp_local,nxl), 1, type_yz(i), pleft, 0, & |
---|
91 | ar(nzb,nys-nbgp_local,nxr+1), 1, type_yz(i), pright, 0, & |
---|
92 | comm2d, status, ierr ) |
---|
93 | ! |
---|
94 | !-- Send right boundary, receive left one (synchronous) |
---|
95 | CALL MPI_SENDRECV( & |
---|
96 | ar(nzb,nys-nbgp_local,nxr+1-nbgp_local), 1, type_yz(i), pright, 1, & |
---|
97 | ar(nzb,nys-nbgp_local,nxl-nbgp_local), 1, type_yz(i), pleft, 1, & |
---|
98 | comm2d, status, ierr ) |
---|
99 | |
---|
100 | ELSE |
---|
101 | |
---|
102 | req = 0 |
---|
103 | ! |
---|
104 | !-- Send left boundary, receive right one (asynchronous) |
---|
105 | CALL MPI_ISEND( ar(nzb,nys-nbgp_local,nxl), 1, type_yz(i), pleft, & |
---|
106 | 0, comm2d, req(1), ierr ) |
---|
107 | CALL MPI_IRECV( ar(nzb,nys-nbgp_local,nxr+1), 1, type_yz(i), pright, & |
---|
108 | 0, comm2d, req(2), ierr ) |
---|
109 | ! |
---|
110 | !-- Send right boundary, receive left one (asynchronous) |
---|
111 | CALL MPI_ISEND( ar(nzb,nys-nbgp_local,nxr+1-nbgp_local), 1, & |
---|
112 | type_yz(i), pright, 1, comm2d, req(3), ierr ) |
---|
113 | CALL MPI_IRECV( ar(nzb,nys-nbgp_local,nxl-nbgp_local), 1, & |
---|
114 | type_yz(i), pleft, 1, comm2d, req(4), ierr ) |
---|
115 | |
---|
116 | CALL MPI_WAITALL( 4, req, wait_stat, ierr ) |
---|
117 | |
---|
118 | ENDIF |
---|
119 | |
---|
120 | ENDIF |
---|
121 | |
---|
122 | |
---|
123 | IF ( pdims(2) == 1 .OR. mg_switch_to_pe0 ) THEN |
---|
124 | ! |
---|
125 | !-- One-dimensional decomposition along x, boundary values can be exchanged |
---|
126 | !-- within the PE memory |
---|
127 | IF ( bc_ns == 'cyclic' ) THEN |
---|
128 | ar(:,nys-nbgp_local:nys-1,:) = ar(:,nyn-nbgp_local+1:nyn,:) |
---|
129 | ar(:,nyn+1:nyn+nbgp_local,:) = ar(:,nys:nys+nbgp_local-1,:) |
---|
130 | ENDIF |
---|
131 | |
---|
132 | ELSE |
---|
133 | |
---|
134 | IF ( synchronous_exchange ) THEN |
---|
135 | ! |
---|
136 | !-- Send front boundary, receive rear one (synchronous) |
---|
137 | CALL MPI_SENDRECV( & |
---|
138 | ar(nzb,nys,nxl-nbgp_local), 1, type_xz(i), psouth, 0, & |
---|
139 | ar(nzb,nyn+1,nxl-nbgp_local), 1, type_xz(i), pnorth, 0, & |
---|
140 | comm2d, status, ierr ) |
---|
141 | ! |
---|
142 | !-- Send rear boundary, receive front one (synchronous) |
---|
143 | CALL MPI_SENDRECV( & |
---|
144 | ar(nzb,nyn-nbgp_local+1,nxl-nbgp_local), 1, type_xz(i), pnorth, 1, & |
---|
145 | ar(nzb,nys-nbgp_local,nxl-nbgp_local), 1, type_xz(i), psouth, 1, & |
---|
146 | comm2d, status, ierr ) |
---|
147 | |
---|
148 | ELSE |
---|
149 | |
---|
150 | req = 0 |
---|
151 | ! |
---|
152 | !-- Send front boundary, receive rear one (asynchronous) |
---|
153 | CALL MPI_ISEND( ar(nzb,nys,nxl-nbgp_local), 1, type_xz(i), psouth, & |
---|
154 | 0, comm2d, req(1), ierr ) |
---|
155 | CALL MPI_IRECV( ar(nzb,nyn+1,nxl-nbgp_local), 1, type_xz(i), pnorth, & |
---|
156 | 0, comm2d, req(2), ierr ) |
---|
157 | ! |
---|
158 | !-- Send rear boundary, receive front one (asynchronous) |
---|
159 | CALL MPI_ISEND( ar(nzb,nyn-nbgp_local+1,nxl-nbgp_local), 1, & |
---|
160 | type_xz(i), pnorth, 1, comm2d, req(3), ierr ) |
---|
161 | CALL MPI_IRECV( ar(nzb,nys-nbgp_local,nxl-nbgp_local), 1, & |
---|
162 | type_xz(i), psouth, 1, comm2d, req(4), ierr ) |
---|
163 | |
---|
164 | CALL MPI_WAITALL( 4, req, wait_stat, ierr ) |
---|
165 | |
---|
166 | ENDIF |
---|
167 | |
---|
168 | ENDIF |
---|
169 | |
---|
170 | #else |
---|
171 | |
---|
172 | ! |
---|
173 | !-- Lateral boundary conditions in the non-parallel case |
---|
174 | IF ( bc_lr == 'cyclic' ) THEN |
---|
175 | ar(:,:,nxl-nbgp_local:nxl-1) = ar(:,:,nxr-nbgp_local+1:nxr) |
---|
176 | ar(:,:,nxr+1:nxr+nbgp_local) = ar(:,:,nxl:nxl+nbgp_local-1) |
---|
177 | ENDIF |
---|
178 | |
---|
179 | IF ( bc_ns == 'cyclic' ) THEN |
---|
180 | ar(:,nys-nbgp_local:nys-1,:) = ar(:,nyn-nbgp_local+1:nyn,:) |
---|
181 | ar(:,nyn+1:nyn+nbgp_local,:) = ar(:,nys:nys+nbgp_local-1,:) |
---|
182 | ENDIF |
---|
183 | |
---|
184 | #endif |
---|
185 | CALL cpu_log( log_point_s(2), 'exchange_horiz', 'stop' ) |
---|
186 | |
---|
187 | |
---|
188 | END SUBROUTINE exchange_horiz |
---|