1 | SUBROUTINE exchange_horiz_2d( ar ) |
---|
2 | |
---|
3 | !------------------------------------------------------------------------------! |
---|
4 | ! Current revisions: |
---|
5 | ! ----------------- |
---|
6 | ! |
---|
7 | ! |
---|
8 | ! Former revisions: |
---|
9 | ! ----------------- |
---|
10 | ! $Id: exchange_horiz_2d.f90 842 2012-02-28 12:37:31Z maronga $ |
---|
11 | ! |
---|
12 | ! 841 2012-02-28 12:29:49Z maronga |
---|
13 | ! Excluded routine from compilation of namelist_file_check |
---|
14 | ! |
---|
15 | ! 707 2011-03-29 11:39:40Z raasch |
---|
16 | ! bc_lr/ns replaced by bc_lr/ns_cyc |
---|
17 | ! |
---|
18 | ! 702 2011-03-24 19:33:15Z suehring |
---|
19 | ! Bugfix in declaration of ar in exchange_horiz_2d_int and number of MPI-blocks |
---|
20 | ! in MPI_SENDRECV(). |
---|
21 | ! |
---|
22 | ! 667 2010-12-23 12:06:00Z suehring/gryschka |
---|
23 | ! Dynamic exchange of ghost points with nbgp, which depends on the advection |
---|
24 | ! scheme. Exchange between left and right PEs is now done with MPI-vectors. |
---|
25 | ! |
---|
26 | ! 73 2007-03-20 08:33:14Z raasch |
---|
27 | ! Neumann boundary conditions at inflow/outflow in case of non-cyclic boundary |
---|
28 | ! conditions |
---|
29 | ! |
---|
30 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
31 | ! |
---|
32 | ! Revision 1.9 2006/05/12 19:15:52 letzel |
---|
33 | ! MPI_REAL replaced by MPI_INTEGER in exchange_horiz_2d_int |
---|
34 | ! |
---|
35 | ! Revision 1.1 1998/01/23 09:58:21 raasch |
---|
36 | ! Initial revision |
---|
37 | ! |
---|
38 | ! |
---|
39 | ! Description: |
---|
40 | ! ------------ |
---|
41 | ! Exchange of lateral (ghost) boundaries (parallel computers) and cyclic |
---|
42 | ! boundary conditions, respectively, for 2D-arrays. |
---|
43 | !------------------------------------------------------------------------------! |
---|
44 | |
---|
45 | USE control_parameters |
---|
46 | USE cpulog |
---|
47 | USE indices |
---|
48 | USE interfaces |
---|
49 | USE pegrid |
---|
50 | |
---|
51 | IMPLICIT NONE |
---|
52 | |
---|
53 | |
---|
54 | REAL :: ar(nysg:nyng,nxlg:nxrg) |
---|
55 | INTEGER :: i |
---|
56 | |
---|
57 | #if ! defined( __check ) |
---|
58 | CALL cpu_log( log_point_s(13), 'exchange_horiz_2d', 'start' ) |
---|
59 | |
---|
60 | #if defined( __parallel ) |
---|
61 | |
---|
62 | ! |
---|
63 | !-- Exchange of lateral boundary values for parallel computers |
---|
64 | IF ( pdims(1) == 1 ) THEN |
---|
65 | |
---|
66 | ! |
---|
67 | !-- One-dimensional decomposition along y, boundary values can be exchanged |
---|
68 | !-- within the PE memory |
---|
69 | ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr) |
---|
70 | ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1) |
---|
71 | |
---|
72 | ELSE |
---|
73 | ! |
---|
74 | !-- Send left boundary, receive right one |
---|
75 | |
---|
76 | CALL MPI_SENDRECV( ar(nysg,nxl), 1, type_y, pleft, 0, & |
---|
77 | ar(nysg,nxr+1), 1, type_y, pright, 0, & |
---|
78 | comm2d, status, ierr ) |
---|
79 | ! |
---|
80 | !-- Send right boundary, receive left one |
---|
81 | CALL MPI_SENDRECV( ar(nysg,nxr+1-nbgp), 1, type_y, pright, 1, & |
---|
82 | ar(nysg,nxlg), 1, type_y, pleft, 1, & |
---|
83 | comm2d, status, ierr ) |
---|
84 | |
---|
85 | |
---|
86 | ENDIF |
---|
87 | |
---|
88 | IF ( pdims(2) == 1 ) THEN |
---|
89 | ! |
---|
90 | !-- One-dimensional decomposition along x, boundary values can be exchanged |
---|
91 | !-- within the PE memory |
---|
92 | ar(nysg:nys-1,:) = ar(nyn-nbgp+1:nyn,:) |
---|
93 | ar(nyn+1:nyng,:) = ar(nys:nys+nbgp-1,:) |
---|
94 | |
---|
95 | ELSE |
---|
96 | ! |
---|
97 | !-- Send front boundary, receive rear one |
---|
98 | |
---|
99 | CALL MPI_SENDRECV( ar(nys,nxlg), 1, type_x, psouth, 0, & |
---|
100 | ar(nyn+1,nxlg), 1, type_x, pnorth, 0, & |
---|
101 | comm2d, status, ierr ) |
---|
102 | ! |
---|
103 | !-- Send rear boundary, receive front one |
---|
104 | CALL MPI_SENDRECV( ar(nyn+1-nbgp,nxlg), 1, type_x, pnorth, 1, & |
---|
105 | ar(nysg,nxlg), 1, type_x, psouth, 1, & |
---|
106 | comm2d, status, ierr ) |
---|
107 | |
---|
108 | ENDIF |
---|
109 | |
---|
110 | #else |
---|
111 | |
---|
112 | ! |
---|
113 | !-- Lateral boundary conditions in the non-parallel case |
---|
114 | IF ( bc_lr_cyc ) THEN |
---|
115 | ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr) |
---|
116 | ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1) |
---|
117 | ENDIF |
---|
118 | |
---|
119 | IF ( bc_ns_cyc ) THEN |
---|
120 | ar(nysg:nys-1,:) = ar(nyn-nbgp+1:nyn,:) |
---|
121 | ar(nyn+1:nyng,:) = ar(nys:nys+nbgp-1,:) |
---|
122 | ENDIF |
---|
123 | |
---|
124 | |
---|
125 | #endif |
---|
126 | |
---|
127 | ! |
---|
128 | !-- Neumann-conditions at inflow/outflow in case of non-cyclic boundary |
---|
129 | !-- conditions |
---|
130 | IF ( inflow_l .OR. outflow_l ) THEN |
---|
131 | DO i=nbgp, 1, -1 |
---|
132 | ar(:,nxl-i) = ar(:,nxl) |
---|
133 | END DO |
---|
134 | END IF |
---|
135 | IF ( inflow_r .OR. outflow_r ) THEN |
---|
136 | DO i=1, nbgp |
---|
137 | ar(:,nxr+i) = ar(:,nxr) |
---|
138 | END DO |
---|
139 | END IF |
---|
140 | IF ( inflow_s .OR. outflow_s ) THEN |
---|
141 | DO i=nbgp, 1, -1 |
---|
142 | ar(nys-i,:) = ar(nys,:) |
---|
143 | END DO |
---|
144 | END IF |
---|
145 | IF ( inflow_n .OR. outflow_n ) THEN |
---|
146 | DO i=1, nbgp |
---|
147 | ar(nyn+i,:) = ar(nyn,:) |
---|
148 | END DO |
---|
149 | END IF |
---|
150 | CALL cpu_log( log_point_s(13), 'exchange_horiz_2d', 'stop' ) |
---|
151 | |
---|
152 | #endif |
---|
153 | END SUBROUTINE exchange_horiz_2d |
---|
154 | |
---|
155 | |
---|
156 | |
---|
157 | SUBROUTINE exchange_horiz_2d_int( ar ) |
---|
158 | |
---|
159 | !------------------------------------------------------------------------------! |
---|
160 | ! Description: |
---|
161 | ! ------------ |
---|
162 | ! Exchange of lateral (ghost) boundaries (parallel computers) and cyclic |
---|
163 | ! boundary conditions, respectively, for 2D integer arrays. |
---|
164 | !------------------------------------------------------------------------------! |
---|
165 | |
---|
166 | USE control_parameters |
---|
167 | USE cpulog |
---|
168 | USE indices |
---|
169 | USE interfaces |
---|
170 | USE pegrid |
---|
171 | |
---|
172 | IMPLICIT NONE |
---|
173 | |
---|
174 | INTEGER :: ar(nysg:nyng,nxlg:nxrg) |
---|
175 | INTEGER :: i |
---|
176 | |
---|
177 | #if ! defined( __check ) |
---|
178 | CALL cpu_log( log_point_s(13), 'exchange_horiz_2d', 'start' ) |
---|
179 | |
---|
180 | #if defined( __parallel ) |
---|
181 | |
---|
182 | ! |
---|
183 | !-- Exchange of lateral boundary values for parallel computers |
---|
184 | IF ( pdims(1) == 1 ) THEN |
---|
185 | |
---|
186 | ! |
---|
187 | !-- One-dimensional decomposition along y, boundary values can be exchanged |
---|
188 | !-- within the PE memory |
---|
189 | ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr) |
---|
190 | ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1) |
---|
191 | |
---|
192 | |
---|
193 | ELSE |
---|
194 | ! |
---|
195 | !-- Send left boundary, receive right one |
---|
196 | CALL MPI_SENDRECV( ar(nysg,nxl), 1, type_y_int, pleft, 0, & |
---|
197 | ar(nysg,nxr+1), 1, type_y_int, pright, 0, & |
---|
198 | comm2d, status, ierr ) |
---|
199 | ! |
---|
200 | !-- Send right boundary, receive left one |
---|
201 | CALL MPI_SENDRECV( ar(nysg,nxr+1-nbgp), 1, type_y_int, pright, 1, & |
---|
202 | ar(nysg,nxlg), 1, type_y_int, pleft, 1, & |
---|
203 | comm2d, status, ierr ) |
---|
204 | |
---|
205 | ENDIF |
---|
206 | |
---|
207 | IF ( pdims(2) == 1 ) THEN |
---|
208 | ! |
---|
209 | !-- One-dimensional decomposition along x, boundary values can be exchanged |
---|
210 | !-- within the PE memory |
---|
211 | ar(nysg:nys-1,:) = ar(nyn+1-nbgp:nyn,:) |
---|
212 | ar(nyn+1:nyng,:) = ar(nys:nys-1+nbgp,:) |
---|
213 | |
---|
214 | |
---|
215 | ELSE |
---|
216 | ! |
---|
217 | !-- Send front boundary, receive rear one |
---|
218 | CALL MPI_SENDRECV( ar(nys,nxlg), 1, type_x_int, psouth, 0, & |
---|
219 | ar(nyn+1,nxlg), 1, type_x_int, pnorth, 0, & |
---|
220 | comm2d, status, ierr ) |
---|
221 | |
---|
222 | ! |
---|
223 | !-- Send rear boundary, receive front one |
---|
224 | CALL MPI_SENDRECV( ar(nyn+1-nbgp,nxlg), 1, type_x_int, pnorth, 1, & |
---|
225 | ar(nysg,nxlg), 1, type_x_int, psouth, 1, & |
---|
226 | comm2d, status, ierr ) |
---|
227 | |
---|
228 | ENDIF |
---|
229 | |
---|
230 | #else |
---|
231 | |
---|
232 | ! |
---|
233 | !-- Lateral boundary conditions in the non-parallel case |
---|
234 | IF ( bc_lr_cyc ) THEN |
---|
235 | ar(:,nxlg:nxl-1) = ar(:,nxr-nbgp+1:nxr) |
---|
236 | ar(:,nxr+1:nxrg) = ar(:,nxl:nxl+nbgp-1) |
---|
237 | ENDIF |
---|
238 | |
---|
239 | IF ( bc_ns_cyc ) THEN |
---|
240 | ar(nysg:nys-1,:) = ar(nyn+1-nbgp:nyn,:) |
---|
241 | ar(nyn+1:nyng,:) = ar(nys:nys-1+nbgp,:) |
---|
242 | ENDIF |
---|
243 | |
---|
244 | #endif |
---|
245 | CALL cpu_log( log_point_s(13), 'exchange_horiz_2d', 'stop' ) |
---|
246 | |
---|
247 | #endif |
---|
248 | END SUBROUTINE exchange_horiz_2d_int |
---|