1 |
C $Header$ |
C $Header$ |
2 |
|
C $Name$ |
3 |
|
|
4 |
C-- File global_sum.F: Routines that perform global sum on an array |
C-- File global_sum.F: Routines that perform global sum on an array |
5 |
C of thread values. |
C of thread values. |
32 |
#include "SIZE.h" |
#include "SIZE.h" |
33 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
34 |
#include "EESUPPORT.h" |
#include "EESUPPORT.h" |
35 |
|
#include "GLOBAL_SUM.h" |
36 |
|
|
37 |
C == Routine arguments == |
C == Routine arguments == |
38 |
C sumPhi - Result of sum. |
C sumPhi - Result of sum. |
42 |
CEndOfInterface |
CEndOfInterface |
43 |
|
|
44 |
C == Local variables == |
C == Local variables == |
|
C phi - Array to be summed. |
|
45 |
C I - Loop counters |
C I - Loop counters |
46 |
C mpiRC - MPI return code |
C mpiRC - MPI return code |
|
Real*4 phi(lShare4,MAX_NO_THREADS) |
|
47 |
INTEGER I |
INTEGER I |
48 |
Real*4 tmp |
Real*4 tmp |
49 |
#ifdef ALLOW_USE_MPI |
#ifdef ALLOW_USE_MPI |
51 |
#endif /* ALLOW_USE_MPI */ |
#endif /* ALLOW_USE_MPI */ |
52 |
|
|
53 |
C-- write local sum into array |
C-- write local sum into array |
54 |
phi(1,myThid) = sumPhi |
CALL BAR2( myThid ) |
55 |
|
phiGSRS(1,myThid) = sumPhi |
56 |
|
|
57 |
C-- Can not start until everyone is ready |
C-- Can not start until everyone is ready |
58 |
_BARRIER |
CALL BAR2( myThid ) |
59 |
|
|
60 |
C-- Sum within the process first |
C-- Sum within the process first |
61 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
62 |
tmp = 0. |
tmp = 0. |
63 |
DO I=1,nThreads |
DO I=1,nThreads |
64 |
tmp = tmp + phi(1,I) |
tmp = tmp + phiGSRS(1,I) |
65 |
ENDDO |
ENDDO |
66 |
sumPhi = tmp |
sumPhi = tmp |
67 |
#ifdef ALLOW_USE_MPI |
#ifdef ALLOW_USE_MPI |
75 |
#endif |
#endif |
76 |
#endif /* ALLOW_USE_MPI */ |
#endif /* ALLOW_USE_MPI */ |
77 |
C-- Write solution to place where all threads can see it |
C-- Write solution to place where all threads can see it |
78 |
phi(1,1) = sumPhi |
phiGSRS(1,1) = sumPhi |
79 |
|
|
80 |
_END_MASTER( myThid ) |
_END_MASTER( myThid ) |
81 |
C-- |
C-- |
82 |
_BARRIER |
CALL BAR2( myThid ) |
83 |
|
|
84 |
C-- set result for every process |
C-- set result for every process |
85 |
sumPhi = phi(1,1) |
sumPhi = phiGSRS(1,1) |
86 |
|
CALL BAR2( myThid ) |
87 |
|
|
88 |
RETURN |
RETURN |
89 |
END |
END |
113 |
#include "SIZE.h" |
#include "SIZE.h" |
114 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
115 |
#include "EESUPPORT.h" |
#include "EESUPPORT.h" |
116 |
|
#include "GLOBAL_SUM.h" |
117 |
|
|
118 |
C === Routine arguments === |
C === Routine arguments === |
119 |
C sumPhi - Result of sum. |
C sumPhi - Result of sum. |
123 |
CEndOfInterface |
CEndOfInterface |
124 |
|
|
125 |
C === Local variables === |
C === Local variables === |
|
C phi - Array to be summed. |
|
126 |
C I - Loop counters |
C I - Loop counters |
127 |
C mpiRC - MPI return code |
C mpiRC - MPI return code |
|
Real*8 phi(lShare8,MAX_NO_THREADS) |
|
128 |
INTEGER I |
INTEGER I |
129 |
Real*8 tmp |
Real*8 tmp |
130 |
#ifdef ALLOW_USE_MPI |
#ifdef ALLOW_USE_MPI |
131 |
INTEGER mpiRC |
INTEGER mpiRC |
132 |
#endif /* ALLOW_USE_MPI */ |
#endif /* ALLOW_USE_MPI */ |
133 |
|
|
134 |
|
CALL BAR2( myThid ) |
135 |
C-- write local sum into array |
C-- write local sum into array |
136 |
phi(1,myThid) = sumPhi |
phiGSRL(1,myThid) = sumPhi |
137 |
|
|
138 |
C-- Can not start until everyone is ready |
C-- Can not start until everyone is ready |
139 |
_BARRIER |
C CALL FOOL_THE_COMPILER( phiGSRL ) |
140 |
|
C CALL MS |
141 |
|
CALL BAR2( myThid ) |
142 |
|
C _BARRIER |
143 |
|
C _BARRIER |
144 |
|
C CALL FOOL_THE_COMPILER( phiGSRL ) |
145 |
|
|
146 |
C-- Sum within the process first |
C-- Sum within the process first |
147 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
148 |
tmp = 0. _d 0 |
tmp = 0. _d 0 |
149 |
DO I=1,nThreads |
DO I=1,nThreads |
150 |
tmp = tmp + phi(1,I) |
tmp = tmp + phiGSRL(1,I) |
151 |
ENDDO |
ENDDO |
152 |
sumPhi = tmp |
sumPhi = tmp |
153 |
#ifdef ALLOW_USE_MPI |
#ifdef ALLOW_USE_MPI |
161 |
#endif |
#endif |
162 |
#endif /* ALLOW_USE_MPI */ |
#endif /* ALLOW_USE_MPI */ |
163 |
C-- Write solution to place where all threads can see it |
C-- Write solution to place where all threads can see it |
164 |
phi(1,1) = sumPhi |
phiGSRL(1,1) = sumPhi |
165 |
_END_MASTER( myThid ) |
_END_MASTER( myThid ) |
166 |
|
|
167 |
C-- Do not leave until we are sure that the sum is done |
C-- Do not leave until we are sure that the sum is done |
168 |
_BARRIER |
C CALL FOOL_THE_COMPILER( phiGSRL ) |
169 |
|
C CALL MS |
170 |
|
C _BARRIER |
171 |
|
C _BARRIER |
172 |
|
CALL BAR2( myThid ) |
173 |
|
C CALL FOOL_THE_COMPILER( phiGSRL ) |
174 |
|
|
175 |
C-- set result for every process |
C-- set result for every process |
176 |
sumPhi = phi(1,1) |
sumPhi = phiGSRL(1,1) |
177 |
|
CALL BAR2( myThid ) |
178 |
|
|
179 |
RETURN |
RETURN |
180 |
END |
END |
202 |
#include "SIZE.h" |
#include "SIZE.h" |
203 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
204 |
#include "EESUPPORT.h" |
#include "EESUPPORT.h" |
205 |
|
#include "GLOBAL_SUM.h" |
206 |
|
|
207 |
C === Routine arguments === |
C === Routine arguments === |
208 |
C sumPhi - Result of sum. |
C sumPhi - Result of sum. |
212 |
CEndOfInterface |
CEndOfInterface |
213 |
|
|
214 |
C === Local variables === |
C === Local variables === |
|
C phi - Array to be summed. |
|
215 |
C I - Loop counters |
C I - Loop counters |
216 |
C mpiRC - MPI return code |
C mpiRC - MPI return code |
|
INTEGER phi(lShare8,MAX_NO_THREADS) |
|
217 |
INTEGER I |
INTEGER I |
218 |
INTEGER tmp |
INTEGER tmp |
219 |
#ifdef ALLOW_USE_MPI |
#ifdef ALLOW_USE_MPI |
220 |
INTEGER mpiRC |
INTEGER mpiRC |
221 |
#endif /* ALLOW_USE_MPI */ |
#endif /* ALLOW_USE_MPI */ |
222 |
|
|
223 |
|
_BARRIER |
224 |
C-- write local sum into array |
C-- write local sum into array |
225 |
phi(1,myThid) = sumPhi |
phiGSI(1,myThid) = sumPhi |
226 |
|
|
227 |
C-- Can not start until everyone is ready |
C-- Can not start until everyone is ready |
228 |
_BARRIER |
_BARRIER |
231 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
232 |
tmp = 0. _d 0 |
tmp = 0. _d 0 |
233 |
DO I=1,nThreads |
DO I=1,nThreads |
234 |
tmp = tmp + phi(1,I) |
tmp = tmp + phiGSI(1,I) |
235 |
ENDDO |
ENDDO |
236 |
sumPhi = tmp |
sumPhi = tmp |
237 |
#ifdef ALLOW_USE_MPI |
#ifdef ALLOW_USE_MPI |
245 |
#endif |
#endif |
246 |
#endif /* ALLOW_USE_MPI */ |
#endif /* ALLOW_USE_MPI */ |
247 |
C-- Write solution to place where all threads can see it |
C-- Write solution to place where all threads can see it |
248 |
phi(1,1) = sumPhi |
phiGSI(1,1) = sumPhi |
249 |
_END_MASTER( myThid ) |
_END_MASTER( myThid ) |
250 |
|
|
251 |
C-- Do not leave until we are sure that the sum is done |
C-- Do not leave until we are sure that the sum is done |
252 |
_BARRIER |
_BARRIER |
253 |
|
|
254 |
C-- set result for every process |
C-- set result for every process |
255 |
sumPhi = phi(1,1) |
sumPhi = phiGSI(1,1) |
256 |
|
_BARRIER |
257 |
|
|
258 |
RETURN |
RETURN |
259 |
END |
END |