1 | SUBROUTINE transpose_xy( f_in, work1, f_inv, work2, f_out ) |
---|
2 | |
---|
3 | !------------------------------------------------------------------------------! |
---|
4 | ! Actual revisions: |
---|
5 | ! ----------------- |
---|
6 | ! |
---|
7 | ! |
---|
8 | ! Former revisions: |
---|
9 | ! ----------------- |
---|
10 | ! $Log: transpose.f90,v $ |
---|
11 | ! Revision 1.2 2004/04/30 13:12:17 raasch |
---|
12 | ! Switched from mpi_alltoallv to the simpler mpi_alltoall, |
---|
13 | ! all former transpose-routine files collected in this file, enlarged |
---|
14 | ! transposition arrays introduced |
---|
15 | ! |
---|
16 | ! Revision 1.1 2004/04/30 13:08:16 raasch |
---|
17 | ! Initial revision (collection of former routines transpose_xy, transpose_xz, |
---|
18 | ! transpose_yx, transpose_yz, transpose_zx, transpose_zy) |
---|
19 | ! |
---|
20 | ! Revision 1.7 2003/03/16 09:49:53 raasch |
---|
21 | ! Two underscores (_) are placed in front of all define-strings |
---|
22 | ! |
---|
23 | ! Revision 1.6 2001/03/30 07:55:50 raasch |
---|
24 | ! Array bound for work2 is explicitely calculated, all comments and identifiers |
---|
25 | ! translated into English |
---|
26 | ! |
---|
27 | ! Revision 1.5 2001/01/22 08:19:14 raasch |
---|
28 | ! Module test_variables removed |
---|
29 | ! |
---|
30 | ! Revision 1.4 1998/07/06 12:34:22 raasch |
---|
31 | ! + USE test_variables |
---|
32 | ! |
---|
33 | ! Revision 1.3 1997/08/13 13:52:42 raasch |
---|
34 | ! Zeitmessung von MPI_ALLTOALLV |
---|
35 | ! |
---|
36 | ! Revision 1.2 1997/08/11 06:27:31 raasch |
---|
37 | ! Keine Aenderungen |
---|
38 | ! |
---|
39 | ! Revision 1.1 1997/07/24 11:25:18 raasch |
---|
40 | ! Initial revision |
---|
41 | ! |
---|
42 | ! |
---|
43 | ! Description: |
---|
44 | ! ------------ |
---|
45 | ! Transposition of input array (f_in) from x to y. For the input array, all |
---|
46 | ! elements along x reside on the same PE, while after transposition, all |
---|
47 | ! elements along y reside on the same PE. |
---|
48 | !------------------------------------------------------------------------------! |
---|
49 | |
---|
50 | USE cpulog |
---|
51 | USE indices |
---|
52 | USE interfaces |
---|
53 | USE pegrid |
---|
54 | USE transpose_indices |
---|
55 | |
---|
56 | IMPLICIT NONE |
---|
57 | |
---|
58 | INTEGER :: i, j, k, l, m, ys |
---|
59 | |
---|
60 | REAL :: f_in(0:nxa,nys_x:nyn_xa,nzb_x:nzt_xa), & |
---|
61 | f_inv(nys_x:nyn_xa,nzb_x:nzt_xa,0:nxa), & |
---|
62 | f_out(0:nya,nxl_y:nxr_ya,nzb_y:nzt_ya), & |
---|
63 | work1(nys_x:nyn_xa,nzb_x:nzt_xa,0:nxa), work2(nnx*nny*nnz) |
---|
64 | |
---|
65 | #if defined( __parallel ) |
---|
66 | |
---|
67 | ! |
---|
68 | !-- Rearrange indices of input array in order to make data to be send |
---|
69 | !-- by MPI contiguous |
---|
70 | DO k = nzb_x, nzt_xa |
---|
71 | DO j = nys_x, nyn_xa |
---|
72 | DO i = 0, nxa |
---|
73 | work1(j,k,i) = f_in(i,j,k) |
---|
74 | ENDDO |
---|
75 | ENDDO |
---|
76 | ENDDO |
---|
77 | |
---|
78 | ! |
---|
79 | !-- Move data to different array, because memory location of work1 is |
---|
80 | !-- needed further below (work1 = work2) |
---|
81 | DO i = 0, nxa |
---|
82 | DO k = nzb_x, nzt_xa |
---|
83 | DO j = nys_x, nyn_xa |
---|
84 | f_inv(j,k,i) = work1(j,k,i) |
---|
85 | ENDDO |
---|
86 | ENDDO |
---|
87 | ENDDO |
---|
88 | |
---|
89 | ! |
---|
90 | !-- Transpose array |
---|
91 | CALL cpu_log( log_point_s(32), 'mpi_alltoall', 'start' ) |
---|
92 | CALL MPI_ALLTOALL( f_inv(nys_x,nzb_x,0), sendrecvcount_xy, MPI_REAL, & |
---|
93 | work2(1), sendrecvcount_xy, MPI_REAL, & |
---|
94 | comm1dy, ierr ) |
---|
95 | CALL cpu_log( log_point_s(32), 'mpi_alltoall', 'stop' ) |
---|
96 | |
---|
97 | ! |
---|
98 | !-- Reorder transposed array |
---|
99 | m = 0 |
---|
100 | DO l = 0, pdims(2) - 1 |
---|
101 | ys = 0 + l * ( nyn_xa - nys_x + 1 ) |
---|
102 | DO i = nxl_y, nxr_ya |
---|
103 | DO k = nzb_y, nzt_ya |
---|
104 | DO j = ys, ys + nyn_xa - nys_x |
---|
105 | m = m + 1 |
---|
106 | f_out(j,i,k) = work2(m) |
---|
107 | ENDDO |
---|
108 | ENDDO |
---|
109 | ENDDO |
---|
110 | ENDDO |
---|
111 | |
---|
112 | #endif |
---|
113 | |
---|
114 | END SUBROUTINE transpose_xy |
---|
115 | |
---|
116 | |
---|
117 | SUBROUTINE transpose_xz( f_in, work1, f_inv, work2, f_out ) |
---|
118 | |
---|
119 | !------------------------------------------------------------------------------! |
---|
120 | ! Description: |
---|
121 | ! ------------ |
---|
122 | ! Transposition of input array (f_in) from x to z. For the input array, all |
---|
123 | ! elements along x reside on the same PE, while after transposition, all |
---|
124 | ! elements along z reside on the same PE. |
---|
125 | !------------------------------------------------------------------------------! |
---|
126 | |
---|
127 | USE cpulog |
---|
128 | USE indices |
---|
129 | USE interfaces |
---|
130 | USE pegrid |
---|
131 | USE transpose_indices |
---|
132 | |
---|
133 | IMPLICIT NONE |
---|
134 | |
---|
135 | INTEGER :: i, j, k, l, m, xs |
---|
136 | |
---|
137 | REAL :: f_in(0:nxa,nys_x:nyn_xa,nzb_x:nzt_xa), & |
---|
138 | f_inv(nxl:nxra,nys:nyna,1:nza), & |
---|
139 | f_out(1:nza,nys:nyna,nxl:nxra), & |
---|
140 | work1(1:nza,nys:nyna,nxl:nxra), work2(nnx*nny*nnz) |
---|
141 | |
---|
142 | #if defined( __parallel ) |
---|
143 | |
---|
144 | ! |
---|
145 | !-- If the PE grid is one-dimensional along y, the array has only to be |
---|
146 | !-- reordered locally and therefore no transposition has to be done. |
---|
147 | IF ( pdims(1) /= 1 ) THEN |
---|
148 | ! |
---|
149 | !-- Reorder input array for transposition |
---|
150 | m = 0 |
---|
151 | DO l = 0, pdims(1) - 1 |
---|
152 | xs = 0 + l * nnx |
---|
153 | DO k = nzb_x, nzt_xa |
---|
154 | DO j = nys_x, nyn_xa |
---|
155 | DO i = xs, xs + nnx - 1 |
---|
156 | m = m + 1 |
---|
157 | work2(m) = f_in(i,j,k) |
---|
158 | ENDDO |
---|
159 | ENDDO |
---|
160 | ENDDO |
---|
161 | ENDDO |
---|
162 | |
---|
163 | ! |
---|
164 | !-- Transpose array |
---|
165 | CALL cpu_log( log_point_s(32), 'mpi_alltoall', 'start' ) |
---|
166 | CALL MPI_ALLTOALL( work2(1), sendrecvcount_zx, MPI_REAL, & |
---|
167 | f_inv(nxl,nys,1), sendrecvcount_zx, MPI_REAL, & |
---|
168 | comm1dx, ierr ) |
---|
169 | CALL cpu_log( log_point_s(32), 'mpi_alltoall', 'stop' ) |
---|
170 | |
---|
171 | ! |
---|
172 | !-- Reorder transposed array in a way that the z index is in first position |
---|
173 | DO i = nxl, nxra |
---|
174 | DO j = nys, nyna |
---|
175 | DO k = 1, nza |
---|
176 | work1(k,j,i) = f_inv(i,j,k) |
---|
177 | ENDDO |
---|
178 | ENDDO |
---|
179 | ENDDO |
---|
180 | ELSE |
---|
181 | ! |
---|
182 | !-- Reorder the array in a way that the z index is in first position |
---|
183 | DO i = nxl, nxra |
---|
184 | DO j = nys, nyna |
---|
185 | DO k = 1, nza |
---|
186 | work1(k,j,i) = f_in(i,j,k) |
---|
187 | ENDDO |
---|
188 | ENDDO |
---|
189 | ENDDO |
---|
190 | ENDIF |
---|
191 | |
---|
192 | ! |
---|
193 | !-- Move data to output array |
---|
194 | DO i = nxl, nxra |
---|
195 | DO j = nys, nyna |
---|
196 | DO k = 1, nza |
---|
197 | f_out(k,j,i) = work1(k,j,i) |
---|
198 | ENDDO |
---|
199 | ENDDO |
---|
200 | ENDDO |
---|
201 | |
---|
202 | #endif |
---|
203 | |
---|
204 | END SUBROUTINE transpose_xz |
---|
205 | |
---|
206 | |
---|
207 | SUBROUTINE transpose_yx( f_in, work1, f_inv, work2, f_out ) |
---|
208 | |
---|
209 | !------------------------------------------------------------------------------! |
---|
210 | ! Description: |
---|
211 | ! ------------ |
---|
212 | ! Transposition of input array (f_in) from y to x. For the input array, all |
---|
213 | ! elements along y reside on the same PE, while after transposition, all |
---|
214 | ! elements along x reside on the same PE. |
---|
215 | !------------------------------------------------------------------------------! |
---|
216 | |
---|
217 | USE cpulog |
---|
218 | USE indices |
---|
219 | USE interfaces |
---|
220 | USE pegrid |
---|
221 | USE transpose_indices |
---|
222 | |
---|
223 | IMPLICIT NONE |
---|
224 | |
---|
225 | INTEGER :: i, j, k, l, m, ys |
---|
226 | |
---|
227 | REAL :: f_in(0:nya,nxl_y:nxr_ya,nzb_y:nzt_ya), & |
---|
228 | f_inv(nys_x:nyn_xa,nzb_x:nzt_xa,0:nxa), & |
---|
229 | f_out(0:nxa,nys_x:nyn_xa,nzb_x:nzt_xa), & |
---|
230 | work1(0:nxa,nys_x:nyn_xa,nzb_x:nzt_xa), work2(nnx*nny*nnz) |
---|
231 | |
---|
232 | #if defined( __parallel ) |
---|
233 | |
---|
234 | ! |
---|
235 | !-- Reorder input array for transposition |
---|
236 | m = 0 |
---|
237 | DO l = 0, pdims(2) - 1 |
---|
238 | ys = 0 + l * ( nyn_xa - nys_x + 1 ) |
---|
239 | DO i = nxl_y, nxr_ya |
---|
240 | DO k = nzb_y, nzt_ya |
---|
241 | DO j = ys, ys + nyn_xa - nys_x |
---|
242 | m = m + 1 |
---|
243 | work2(m) = f_in(j,i,k) |
---|
244 | ENDDO |
---|
245 | ENDDO |
---|
246 | ENDDO |
---|
247 | ENDDO |
---|
248 | |
---|
249 | ! |
---|
250 | !-- Transpose array |
---|
251 | CALL cpu_log( log_point_s(32), 'mpi_alltoall', 'start' ) |
---|
252 | CALL MPI_ALLTOALL( work2(1), sendrecvcount_xy, MPI_REAL, & |
---|
253 | f_inv(nys_x,nzb_x,0), sendrecvcount_xy, MPI_REAL, & |
---|
254 | comm1dy, ierr ) |
---|
255 | CALL cpu_log( log_point_s(32), 'mpi_alltoall', 'stop' ) |
---|
256 | |
---|
257 | ! |
---|
258 | !-- Reorder transposed array in a way that the x index is in first position |
---|
259 | DO i = 0, nxa |
---|
260 | DO k = nzb_x, nzt_xa |
---|
261 | DO j = nys_x, nyn_xa |
---|
262 | work1(i,j,k) = f_inv(j,k,i) |
---|
263 | ENDDO |
---|
264 | ENDDO |
---|
265 | ENDDO |
---|
266 | |
---|
267 | ! |
---|
268 | !-- Move data to output array |
---|
269 | DO k = nzb_x, nzt_xa |
---|
270 | DO j = nys_x, nyn_xa |
---|
271 | DO i = 0, nxa |
---|
272 | f_out(i,j,k) = work1(i,j,k) |
---|
273 | ENDDO |
---|
274 | ENDDO |
---|
275 | ENDDO |
---|
276 | |
---|
277 | #endif |
---|
278 | |
---|
279 | END SUBROUTINE transpose_yx |
---|
280 | |
---|
281 | |
---|
282 | SUBROUTINE transpose_yxd( f_in, work1, f_inv, work2, f_out ) |
---|
283 | |
---|
284 | !------------------------------------------------------------------------------! |
---|
285 | ! Description: |
---|
286 | ! ------------ |
---|
287 | ! Transposition of input array (f_in) from y to x. For the input array, all |
---|
288 | ! elements along y reside on the same PE, while after transposition, all |
---|
289 | ! elements along x reside on the same PE. |
---|
290 | ! This is a direct transposition for arrays with indices in regular order |
---|
291 | ! (k,j,i) (cf. transpose_yx). |
---|
292 | !------------------------------------------------------------------------------! |
---|
293 | |
---|
294 | USE cpulog |
---|
295 | USE indices |
---|
296 | USE interfaces |
---|
297 | USE pegrid |
---|
298 | USE transpose_indices |
---|
299 | |
---|
300 | IMPLICIT NONE |
---|
301 | |
---|
302 | INTEGER :: i, j, k, l, m, recvcount_yx, sendcount_yx, xs |
---|
303 | |
---|
304 | REAL :: f_in(1:nza,nys:nyna,nxl:nxra), f_inv(nxl:nxra,1:nza,nys:nyna), & |
---|
305 | f_out(0:nxa,nys_x:nyn_xa,nzb_x:nzt_xa), & |
---|
306 | work1(nxl:nxra,1:nza,nys:nyna), work2(nnx*nny*nnz) |
---|
307 | |
---|
308 | #if defined( __parallel ) |
---|
309 | |
---|
310 | ! |
---|
311 | !-- Rearrange indices of input array in order to make data to be send |
---|
312 | !-- by MPI contiguous |
---|
313 | DO k = 1, nza |
---|
314 | DO j = nys, nyna |
---|
315 | DO i = nxl, nxra |
---|
316 | work1(i,k,j) = f_in(k,j,i) |
---|
317 | ENDDO |
---|
318 | ENDDO |
---|
319 | ENDDO |
---|
320 | |
---|
321 | ! |
---|
322 | !-- Move data to different array, because memory location of work1 is |
---|
323 | !-- needed further below (work1 = work2) |
---|
324 | DO j = nys, nyna |
---|
325 | DO k = 1, nza |
---|
326 | DO i = nxl, nxra |
---|
327 | f_inv(i,k,j) = work1(i,k,j) |
---|
328 | ENDDO |
---|
329 | ENDDO |
---|
330 | ENDDO |
---|
331 | |
---|
332 | ! |
---|
333 | !-- Transpose array |
---|
334 | CALL cpu_log( log_point_s(32), 'mpi_alltoall', 'start' ) |
---|
335 | CALL MPI_ALLTOALL( f_inv(nxl,1,nys), sendrecvcount_xy, MPI_REAL, & |
---|
336 | work2(1), sendrecvcount_xy, MPI_REAL, & |
---|
337 | comm1dx, ierr ) |
---|
338 | CALL cpu_log( log_point_s(32), 'mpi_alltoall', 'stop' ) |
---|
339 | |
---|
340 | ! |
---|
341 | !-- Reorder transposed array |
---|
342 | m = 0 |
---|
343 | DO l = 0, pdims(1) - 1 |
---|
344 | xs = 0 + l * nnx |
---|
345 | DO j = nys_x, nyn_xa |
---|
346 | DO k = 1, nza |
---|
347 | DO i = xs, xs + nnx - 1 |
---|
348 | m = m + 1 |
---|
349 | f_out(i,j,k) = work2(m) |
---|
350 | ENDDO |
---|
351 | ENDDO |
---|
352 | ENDDO |
---|
353 | ENDDO |
---|
354 | |
---|
355 | #endif |
---|
356 | |
---|
357 | END SUBROUTINE transpose_yxd |
---|
358 | |
---|
359 | |
---|
360 | SUBROUTINE transpose_yz( f_in, work1, f_inv, work2, f_out ) |
---|
361 | |
---|
362 | !------------------------------------------------------------------------------! |
---|
363 | ! Description: |
---|
364 | ! ------------ |
---|
365 | ! Transposition of input array (f_in) from y to z. For the input array, all |
---|
366 | ! elements along y reside on the same PE, while after transposition, all |
---|
367 | ! elements along z reside on the same PE. |
---|
368 | !------------------------------------------------------------------------------! |
---|
369 | |
---|
370 | USE cpulog |
---|
371 | USE indices |
---|
372 | USE interfaces |
---|
373 | USE pegrid |
---|
374 | USE transpose_indices |
---|
375 | |
---|
376 | IMPLICIT NONE |
---|
377 | |
---|
378 | INTEGER :: i, j, k, l, m, zs |
---|
379 | |
---|
380 | REAL :: f_in(0:nya,nxl_y:nxr_ya,nzb_y:nzt_ya), & |
---|
381 | f_inv(nxl_y:nxr_ya,nzb_y:nzt_ya,0:nya), & |
---|
382 | f_out(nxl_z:nxr_za,nys_z:nyn_za,1:nza), & |
---|
383 | work1(nxl_y:nxr_ya,nzb_y:nzt_ya,0:nya), work2(nnx*nny*nnz) |
---|
384 | |
---|
385 | #if defined( __parallel ) |
---|
386 | |
---|
387 | ! |
---|
388 | !-- Rearrange indices of input array in order to make data to be send |
---|
389 | !-- by MPI contiguous |
---|
390 | DO k = nzb_y, nzt_ya |
---|
391 | DO i = nxl_y, nxr_ya |
---|
392 | DO j = 0, nya |
---|
393 | work1(i,k,j) = f_in(j,i,k) |
---|
394 | ENDDO |
---|
395 | ENDDO |
---|
396 | ENDDO |
---|
397 | |
---|
398 | ! |
---|
399 | !-- Move data to different array, because memory location of work1 is |
---|
400 | !-- needed further below (work1 = work2). |
---|
401 | !-- If the PE grid is one-dimensional along y, only local reordering |
---|
402 | !-- of the data is necessary and no transposition has to be done. |
---|
403 | IF ( pdims(1) == 1 ) THEN |
---|
404 | DO j = 0, nya |
---|
405 | DO k = nzb_y, nzt_ya |
---|
406 | DO i = nxl_y, nxr_ya |
---|
407 | f_out(i,j,k) = work1(i,k,j) |
---|
408 | ENDDO |
---|
409 | ENDDO |
---|
410 | ENDDO |
---|
411 | RETURN |
---|
412 | ELSE |
---|
413 | DO j = 0, nya |
---|
414 | DO k = nzb_y, nzt_ya |
---|
415 | DO i = nxl_y, nxr_ya |
---|
416 | f_inv(i,k,j) = work1(i,k,j) |
---|
417 | ENDDO |
---|
418 | ENDDO |
---|
419 | ENDDO |
---|
420 | ENDIF |
---|
421 | |
---|
422 | ! |
---|
423 | !-- Transpose array |
---|
424 | CALL cpu_log( log_point_s(32), 'mpi_alltoall', 'start' ) |
---|
425 | CALL MPI_ALLTOALL( f_inv(nxl_y,nzb_y,0), sendrecvcount_yz, MPI_REAL, & |
---|
426 | work2(1), sendrecvcount_yz, MPI_REAL, & |
---|
427 | comm1dx, ierr ) |
---|
428 | CALL cpu_log( log_point_s(32), 'mpi_alltoall', 'stop' ) |
---|
429 | |
---|
430 | ! |
---|
431 | !-- Reorder transposed array |
---|
432 | m = 0 |
---|
433 | DO l = 0, pdims(1) - 1 |
---|
434 | zs = 1 + l * ( nzt_ya - nzb_y + 1 ) |
---|
435 | DO j = nys_z, nyn_za |
---|
436 | DO k = zs, zs + nzt_ya - nzb_y |
---|
437 | DO i = nxl_z, nxr_za |
---|
438 | m = m + 1 |
---|
439 | f_out(i,j,k) = work2(m) |
---|
440 | ENDDO |
---|
441 | ENDDO |
---|
442 | ENDDO |
---|
443 | ENDDO |
---|
444 | |
---|
445 | #endif |
---|
446 | |
---|
447 | END SUBROUTINE transpose_yz |
---|
448 | |
---|
449 | |
---|
450 | SUBROUTINE transpose_zx( f_in, work1, f_inv, work2, f_out ) |
---|
451 | |
---|
452 | !------------------------------------------------------------------------------! |
---|
453 | ! Description: |
---|
454 | ! ------------ |
---|
455 | ! Transposition of input array (f_in) from z to x. For the input array, all |
---|
456 | ! elements along z reside on the same PE, while after transposition, all |
---|
457 | ! elements along x reside on the same PE. |
---|
458 | !------------------------------------------------------------------------------! |
---|
459 | |
---|
460 | USE cpulog |
---|
461 | USE indices |
---|
462 | USE interfaces |
---|
463 | USE pegrid |
---|
464 | USE transpose_indices |
---|
465 | |
---|
466 | IMPLICIT NONE |
---|
467 | |
---|
468 | INTEGER :: i, j, k, l, m, xs |
---|
469 | |
---|
470 | REAL :: f_in(1:nza,nys:nyna,nxl:nxra), f_inv(nxl:nxra,nys:nyna,1:nza), & |
---|
471 | f_out(0:nxa,nys_x:nyn_xa,nzb_x:nzt_xa), & |
---|
472 | work1(nxl:nxra,nys:nyna,1:nza), work2(nnx*nny*nnz) |
---|
473 | |
---|
474 | #if defined( __parallel ) |
---|
475 | |
---|
476 | ! |
---|
477 | !-- Rearrange indices of input array in order to make data to be send |
---|
478 | !-- by MPI contiguous |
---|
479 | DO i = nxl, nxra |
---|
480 | DO j = nys, nyna |
---|
481 | DO k = 1,nza |
---|
482 | work1(i,j,k) = f_in(k,j,i) |
---|
483 | ENDDO |
---|
484 | ENDDO |
---|
485 | ENDDO |
---|
486 | |
---|
487 | ! |
---|
488 | !-- Move data to different array, because memory location of work1 is |
---|
489 | !-- needed further below (work1 = work2). |
---|
490 | !-- If the PE grid is one-dimensional along y, only local reordering |
---|
491 | !-- of the data is necessary and no transposition has to be done. |
---|
492 | IF ( pdims(1) == 1 ) THEN |
---|
493 | DO k = 1, nza |
---|
494 | DO j = nys, nyna |
---|
495 | DO i = nxl, nxra |
---|
496 | f_out(i,j,k) = work1(i,j,k) |
---|
497 | ENDDO |
---|
498 | ENDDO |
---|
499 | ENDDO |
---|
500 | RETURN |
---|
501 | ELSE |
---|
502 | DO k = 1, nza |
---|
503 | DO j = nys, nyna |
---|
504 | DO i = nxl, nxra |
---|
505 | f_inv(i,j,k) = work1(i,j,k) |
---|
506 | ENDDO |
---|
507 | ENDDO |
---|
508 | ENDDO |
---|
509 | ENDIF |
---|
510 | |
---|
511 | ! |
---|
512 | !-- Transpose array |
---|
513 | CALL cpu_log( log_point_s(32), 'mpi_alltoall', 'start' ) |
---|
514 | CALL MPI_ALLTOALL( f_inv(nxl,nys,1), sendrecvcount_zx, MPI_REAL, & |
---|
515 | work2(1), sendrecvcount_zx, MPI_REAL, & |
---|
516 | comm1dx, ierr ) |
---|
517 | CALL cpu_log( log_point_s(32), 'mpi_alltoall', 'stop' ) |
---|
518 | |
---|
519 | ! |
---|
520 | !-- Reorder transposed array |
---|
521 | m = 0 |
---|
522 | DO l = 0, pdims(1) - 1 |
---|
523 | xs = 0 + l * nnx |
---|
524 | DO k = nzb_x, nzt_xa |
---|
525 | DO j = nys_x, nyn_xa |
---|
526 | DO i = xs, xs + nnx - 1 |
---|
527 | m = m + 1 |
---|
528 | f_out(i,j,k) = work2(m) |
---|
529 | ENDDO |
---|
530 | ENDDO |
---|
531 | ENDDO |
---|
532 | ENDDO |
---|
533 | |
---|
534 | #endif |
---|
535 | |
---|
536 | END SUBROUTINE transpose_zx |
---|
537 | |
---|
538 | |
---|
539 | SUBROUTINE transpose_zy( f_in, work1, f_inv, work2, f_out ) |
---|
540 | |
---|
541 | !------------------------------------------------------------------------------! |
---|
542 | ! Description: |
---|
543 | ! ------------ |
---|
544 | ! Transposition of input array (f_in) from z to y. For the input array, all |
---|
545 | ! elements along z reside on the same PE, while after transposition, all |
---|
546 | ! elements along y reside on the same PE. |
---|
547 | !------------------------------------------------------------------------------! |
---|
548 | |
---|
549 | USE cpulog |
---|
550 | USE indices |
---|
551 | USE interfaces |
---|
552 | USE pegrid |
---|
553 | USE transpose_indices |
---|
554 | |
---|
555 | IMPLICIT NONE |
---|
556 | |
---|
557 | INTEGER :: i, j, k, l, m, zs |
---|
558 | |
---|
559 | REAL :: f_in(nxl_z:nxr_za,nys_z:nyn_za,1:nza), & |
---|
560 | f_inv(nxl_y:nxr_ya,nzb_y:nzt_ya,0:nya), & |
---|
561 | f_out(0:nya,nxl_y:nxr_ya,nzb_y:nzt_ya), & |
---|
562 | work1(0:nya,nxl_y:nxr_ya,nzb_y:nzt_ya), work2(nnx*nny*nnz) |
---|
563 | |
---|
564 | #if defined( __parallel ) |
---|
565 | |
---|
566 | ! |
---|
567 | !-- If the PE grid is one-dimensional along y, the array has only to be |
---|
568 | !-- reordered locally and therefore no transposition has to be done. |
---|
569 | IF ( pdims(1) /= 1 ) THEN |
---|
570 | ! |
---|
571 | !-- Reorder input array for transposition |
---|
572 | m = 0 |
---|
573 | DO l = 0, pdims(1) - 1 |
---|
574 | zs = 1 + l * ( nzt_ya - nzb_y + 1 ) |
---|
575 | DO j = nys_z, nyn_za |
---|
576 | DO k = zs, zs + nzt_ya - nzb_y |
---|
577 | DO i = nxl_z, nxr_za |
---|
578 | m = m + 1 |
---|
579 | work2(m) = f_in(i,j,k) |
---|
580 | ENDDO |
---|
581 | ENDDO |
---|
582 | ENDDO |
---|
583 | ENDDO |
---|
584 | |
---|
585 | ! |
---|
586 | !-- Transpose array |
---|
587 | CALL cpu_log( log_point_s(32), 'mpi_alltoall', 'start' ) |
---|
588 | CALL MPI_ALLTOALL( work2(1), sendrecvcount_yz, MPI_REAL, & |
---|
589 | f_inv(nxl_y,nzb_y,0), sendrecvcount_yz, MPI_REAL, & |
---|
590 | comm1dx, ierr ) |
---|
591 | CALL cpu_log( log_point_s(32), 'mpi_alltoall', 'stop' ) |
---|
592 | |
---|
593 | ! |
---|
594 | !-- Reorder transposed array in a way that the y index is in first position |
---|
595 | DO k = nzb_y, nzt_ya |
---|
596 | DO i = nxl_y, nxr_ya |
---|
597 | DO j = 0, nya |
---|
598 | work1(j,i,k) = f_inv(i,k,j) |
---|
599 | ENDDO |
---|
600 | ENDDO |
---|
601 | ENDDO |
---|
602 | ELSE |
---|
603 | ! |
---|
604 | !-- Reorder the array in a way that the y index is in first position |
---|
605 | DO k = nzb_y, nzt_ya |
---|
606 | DO i = nxl_y, nxr_ya |
---|
607 | DO j = 0, nya |
---|
608 | work1(j,i,k) = f_in(i,j,k) |
---|
609 | ENDDO |
---|
610 | ENDDO |
---|
611 | ENDDO |
---|
612 | ENDIF |
---|
613 | |
---|
614 | ! |
---|
615 | !-- Move data to output array |
---|
616 | DO k = nzb_y, nzt_ya |
---|
617 | DO i = nxl_y, nxr_ya |
---|
618 | DO j = 0, nya |
---|
619 | f_out(j,i,k) = work1(j,i,k) |
---|
620 | ENDDO |
---|
621 | ENDDO |
---|
622 | ENDDO |
---|
623 | |
---|
624 | #endif |
---|
625 | |
---|
626 | END SUBROUTINE transpose_zy |
---|
627 | |
---|
628 | |
---|
629 | SUBROUTINE transpose_zyd( f_in, work1, f_inv, work2, f_out ) |
---|
630 | |
---|
631 | !------------------------------------------------------------------------------! |
---|
632 | ! Description: |
---|
633 | ! ------------ |
---|
634 | ! Transposition of input array (f_in) from z to y. For the input array, all |
---|
635 | ! elements along z reside on the same PE, while after transposition, all |
---|
636 | ! elements along y reside on the same PE. |
---|
637 | ! This is a direct transposition for arrays with indices in regular order |
---|
638 | ! (k,j,i) (cf. transpose_zy). |
---|
639 | !------------------------------------------------------------------------------! |
---|
640 | |
---|
641 | USE cpulog |
---|
642 | USE indices |
---|
643 | USE interfaces |
---|
644 | USE pegrid |
---|
645 | USE transpose_indices |
---|
646 | |
---|
647 | IMPLICIT NONE |
---|
648 | |
---|
649 | INTEGER :: i, j, k, l, m, ys |
---|
650 | |
---|
651 | REAL :: f_in(1:nza,nys:nyna,nxl:nxra), f_inv(nys:nyna,nxl:nxra,1:nza), & |
---|
652 | f_out(0:nya,nxl_yd:nxr_yda,nzb_yd:nzt_yda), & |
---|
653 | work1(nys:nyna,nxl:nxra,1:nza), work2(nnx*nny*nnz) |
---|
654 | |
---|
655 | #if defined( __parallel ) |
---|
656 | |
---|
657 | ! |
---|
658 | !-- Rearrange indices of input array in order to make data to be send |
---|
659 | !-- by MPI contiguous |
---|
660 | DO i = nxl, nxra |
---|
661 | DO j = nys, nyna |
---|
662 | DO k = 1, nza |
---|
663 | work1(j,i,k) = f_in(k,j,i) |
---|
664 | ENDDO |
---|
665 | ENDDO |
---|
666 | ENDDO |
---|
667 | |
---|
668 | ! |
---|
669 | !-- Move data to different array, because memory location of work1 is |
---|
670 | !-- needed further below (work1 = work2). |
---|
671 | !-- If the PE grid is one-dimensional along x, only local reordering |
---|
672 | !-- of the data is necessary and no transposition has to be done. |
---|
673 | IF ( pdims(2) == 1 ) THEN |
---|
674 | DO k = 1, nza |
---|
675 | DO i = nxl, nxra |
---|
676 | DO j = nys, nyna |
---|
677 | f_out(j,i,k) = work1(j,i,k) |
---|
678 | ENDDO |
---|
679 | ENDDO |
---|
680 | ENDDO |
---|
681 | RETURN |
---|
682 | ELSE |
---|
683 | DO k = 1, nza |
---|
684 | DO i = nxl, nxra |
---|
685 | DO j = nys, nyna |
---|
686 | f_inv(j,i,k) = work1(j,i,k) |
---|
687 | ENDDO |
---|
688 | ENDDO |
---|
689 | ENDDO |
---|
690 | ENDIF |
---|
691 | |
---|
692 | ! |
---|
693 | !-- Transpose array |
---|
694 | CALL cpu_log( log_point_s(32), 'mpi_alltoall', 'start' ) |
---|
695 | CALL MPI_ALLTOALL( f_inv(nys,nxl,1), sendrecvcount_zyd, MPI_REAL, & |
---|
696 | work2(1), sendrecvcount_zyd, MPI_REAL, & |
---|
697 | comm1dy, ierr ) |
---|
698 | CALL cpu_log( log_point_s(32), 'mpi_alltoall', 'stop' ) |
---|
699 | |
---|
700 | ! |
---|
701 | !-- Reorder transposed array |
---|
702 | m = 0 |
---|
703 | DO l = 0, pdims(2) - 1 |
---|
704 | ys = 0 + l * nny |
---|
705 | DO k = nzb_yd, nzt_yda |
---|
706 | DO i = nxl_yd, nxr_yda |
---|
707 | DO j = ys, ys + nny - 1 |
---|
708 | m = m + 1 |
---|
709 | f_out(j,i,k) = work2(m) |
---|
710 | ENDDO |
---|
711 | ENDDO |
---|
712 | ENDDO |
---|
713 | ENDDO |
---|
714 | |
---|
715 | #endif |
---|
716 | |
---|
717 | END SUBROUTINE transpose_zyd |
---|