1 |
#include "CPP_OPTIONS.h" |
2 |
|
3 |
SUBROUTINE SCATTER_VECTOR( length, global, local, myThid ) |
4 |
C Scatter elements of a 2-D array from mpi process 0 to all processes. |
5 |
IMPLICIT NONE |
6 |
#include "SIZE.h" |
7 |
#include "EEPARAMS.h" |
8 |
#include "EESUPPORT.h" |
9 |
C mythid - thread number for this instance of the routine. |
10 |
C global,local - working arrays used to transfer 2-D fields |
11 |
INTEGER mythid |
12 |
INTEGER length |
13 |
Real*8 global(length*nPx*nPy) |
14 |
_RL local(length) |
15 |
|
16 |
INTEGER iG,jG,lG, l |
17 |
#ifdef ALLOW_USE_MPI |
18 |
_RL temp(length) |
19 |
INTEGER istatus(MPI_STATUS_SIZE), ierr |
20 |
INTEGER isource, itag, npe |
21 |
INTEGER lbuff |
22 |
#endif /* ALLOW_USE_MPI */ |
23 |
|
24 |
C-- Make everyone wait except for master thread. |
25 |
_BARRIER |
26 |
_BEGIN_MASTER( myThid ) |
27 |
|
28 |
#ifndef ALLOW_USE_MPI |
29 |
|
30 |
DO l=1,length |
31 |
iG=1+(myXGlobalLo-1)/sNx ! Kludge until unstructered tiles |
32 |
jG=1+(myYGlobalLo-1)/sNy ! Kludge until unstructered tiles |
33 |
lG= (jG-1)*nPx*length + (iG-1)*length + l |
34 |
local(l) = global(lG) |
35 |
ENDDO |
36 |
|
37 |
#else /* ALLOW_USE_MPI */ |
38 |
|
39 |
lbuff = length |
40 |
isource = 0 |
41 |
itag = 0 |
42 |
|
43 |
IF( mpiMyId .EQ. 0 ) THEN |
44 |
|
45 |
C-- Process 0 fills-in its local data |
46 |
npe = 0 |
47 |
iG=mpi_myXGlobalLo(npe+1)/sNx+1 |
48 |
jG=mpi_myYGlobalLo(npe+1)/sNy+1 |
49 |
DO l=1,length |
50 |
lG= (jG-1)*nPx*length + (iG-1)*length + l |
51 |
local(l) = global(lG) |
52 |
ENDDO |
53 |
|
54 |
C-- Process 0 sends local arrays to all other processes |
55 |
DO npe = 1, numberOfProcs-1 |
56 |
iG = mpi_myXGlobalLo(npe+1)/sNx+1 |
57 |
jG = mpi_myYGlobalLo(npe+1)/sNy+1 |
58 |
DO l=1,length |
59 |
lG= (jG-1)*nPx*length + (iG-1)*length + l |
60 |
temp(l) = global(lG) |
61 |
ENDDO |
62 |
CALL MPI_SEND (temp, lbuff, MPI_DOUBLE_PRECISION, |
63 |
& npe, itag, MPI_COMM_MODEL, ierr) |
64 |
ENDDO |
65 |
|
66 |
ELSE |
67 |
|
68 |
C-- All proceses except 0 receive local array from process 0 |
69 |
CALL MPI_RECV (local, lbuff, MPI_DOUBLE_PRECISION, |
70 |
& isource, itag, MPI_COMM_MODEL, istatus, ierr) |
71 |
|
72 |
ENDIF |
73 |
|
74 |
#endif /* ALLOW_USE_MPI */ |
75 |
|
76 |
_END_MASTER( myThid ) |
77 |
_BARRIER |
78 |
|
79 |
C-- Fill in edges. |
80 |
cph _EXCH_XY_R8( local, myThid ) |
81 |
|
82 |
RETURN |
83 |
END |