1 |
C $Header$ |
C $Header$ |
2 |
C $Name$ |
C $Name$ |
3 |
|
|
4 |
|
#include "CPP_EEOPTIONS.h" |
5 |
|
|
6 |
C-- File global_sum_tile.F: Routines that perform global sum |
C-- File global_sum_tile.F: Routines that perform global sum |
7 |
C on a tile array |
C on a tile array |
8 |
C Contents |
C Contents |
9 |
C o global_sum_tile_rl |
C o GLOBAL_SUM_TILE_RL |
10 |
C o global_sum_tile_rs <- not yet coded |
C o GLOBAL_SUM_TILE_RS <- not yet coded |
|
#include "CPP_EEOPTIONS.h" |
|
11 |
|
|
12 |
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
13 |
CBOP |
CBOP |
14 |
C !ROUTINE: GLOBAL_SUM_TILE_RL |
C !ROUTINE: GLOBAL_SUM_TILE_RL |
15 |
|
|
18 |
I phiTile, |
I phiTile, |
19 |
O sumPhi, |
O sumPhi, |
20 |
I myThid ) |
I myThid ) |
21 |
IMPLICIT NONE |
|
22 |
C !DESCRIPTION: |
C !DESCRIPTION: |
23 |
C *==========================================================* |
C *==========================================================* |
24 |
C | SUBROUTINE GLOBAL\_SUM\_TILE\_RL |
C | SUBROUTINE GLOBAL\_SUM\_TILE\_RL |
29 |
C *==========================================================* |
C *==========================================================* |
30 |
|
|
31 |
C !USES: |
C !USES: |
32 |
|
IMPLICIT NONE |
33 |
|
|
34 |
C == Global data == |
C == Global data == |
35 |
#include "SIZE.h" |
#include "SIZE.h" |
36 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
55 |
INTEGER bi,bj |
INTEGER bi,bj |
56 |
#ifdef ALLOW_USE_MPI |
#ifdef ALLOW_USE_MPI |
57 |
#ifdef GLOBAL_SUM_SEND_RECV |
#ifdef GLOBAL_SUM_SEND_RECV |
58 |
INTEGER biG, bjG, npe |
INTEGER biG, bjG, npe, np1 |
59 |
INTEGER lbuff, idest, itag, ready_to_receive |
INTEGER lbuff, idest, itag, ready_to_receive |
60 |
INTEGER istatus(MPI_STATUS_SIZE), ierr |
INTEGER istatus(MPI_STATUS_SIZE), ierr |
61 |
Real*8 localBuf (nSx,nSy) |
Real*8 localBuf (nSx,nSy) |
70 |
Real*8 sumAllP |
Real*8 sumAllP |
71 |
CEOP |
CEOP |
72 |
|
|
73 |
C- note(jmc): do not see why we need this Barrier here + the one at the end ; |
C this barrier is not necessary: |
74 |
C however a) both are present in the standard version of global_sum ; |
c CALL BAR2( myThid ) |
|
C b) with OpenMP on hugo, does not work if both are commented out |
|
|
CALL BAR2( myThid ) |
|
75 |
|
|
76 |
C-- write local sum into shared-buffer array |
C-- write local sum into shared-buffer array |
77 |
DO bj = myByLo(myThid), myByHi(myThid) |
DO bj = myByLo(myThid), myByHi(myThid) |
108 |
ELSE |
ELSE |
109 |
|
|
110 |
C-- Process 0 fills-in its local data |
C-- Process 0 fills-in its local data |
111 |
npe = 0 |
np1 = 1 |
112 |
DO bj=1,nSy |
DO bj=1,nSy |
113 |
DO bi=1,nSx |
DO bi=1,nSx |
114 |
biG = (mpi_myXGlobalLo(npe+1)-1)/sNx+bi |
biG = (mpi_myXGlobalLo(np1)-1)/sNx+bi |
115 |
bjG = (mpi_myYGlobalLo(npe+1)-1)/sNy+bj |
bjG = (mpi_myYGlobalLo(np1)-1)/sNy+bj |
116 |
globalBuf(biG,bjG) = shareBufGSR8(bi,bj) |
globalBuf(biG,bjG) = shareBufGSR8(bi,bj) |
117 |
ENDDO |
ENDDO |
118 |
ENDDO |
ENDDO |
127 |
& npe, itag, MPI_COMM_MODEL, istatus, ierr) |
& npe, itag, MPI_COMM_MODEL, istatus, ierr) |
128 |
|
|
129 |
C-- Process 0 gathers the local arrays into a global array. |
C-- Process 0 gathers the local arrays into a global array. |
130 |
|
np1 = npe + 1 |
131 |
DO bj=1,nSy |
DO bj=1,nSy |
132 |
DO bi=1,nSx |
DO bi=1,nSx |
133 |
biG = (mpi_myXGlobalLo(npe+1)-1)/sNx+bi |
biG = (mpi_myXGlobalLo(np1)-1)/sNx+bi |
134 |
bjG = (mpi_myYGlobalLo(npe+1)-1)/sNy+bj |
bjG = (mpi_myYGlobalLo(np1)-1)/sNy+bj |
135 |
globalBuf(biG,bjG) = localBuf(bi,bj) |
globalBuf(biG,bjG) = localBuf(bi,bj) |
136 |
ENDDO |
ENDDO |
137 |
ENDDO |
ENDDO |
182 |
#endif /* not (GLOBAL_SUM_SEND_RECV & ALLOW_USE_MPI) */ |
#endif /* not (GLOBAL_SUM_SEND_RECV & ALLOW_USE_MPI) */ |
183 |
|
|
184 |
C-- Write solution to shared buffer (all threads can see it) |
C-- Write solution to shared buffer (all threads can see it) |
185 |
shareBufGSR8(1,1) = sumAllP |
c shareBufGSR8(1,1) = sumAllP |
186 |
|
phiGSR8(1,0) = sumAllP |
187 |
|
|
188 |
_END_MASTER( myThid ) |
_END_MASTER( myThid ) |
189 |
C-- Everyone wait for Master thread to be ready |
C-- Everyone wait for Master thread to be ready |
190 |
CALL BAR2( myThid ) |
CALL BAR2( myThid ) |
191 |
|
|
192 |
C-- set result for every threads |
C-- set result for every threads |
193 |
sumPhi = shareBufGSR8(1,1) |
c sumPhi = shareBufGSR8(1,1) |
194 |
|
sumPhi = phiGSR8(1,0) |
195 |
|
|
196 |
C- note(jmc): do not see why we need this Barrier here (see comment @ the top) |
C-- A barrier was needed here to prevent thread 1 to modify shareBufGSR8(1,1) |
197 |
CALL BAR2( myThid ) |
C (as it would in the following call to this S/R) before all threads get |
198 |
|
C their global-sum result out. |
199 |
|
C No longer needed since a dedicated shared var. is used to share the output |
200 |
|
c CALL BAR2( myThid ) |
201 |
|
|
202 |
RETURN |
RETURN |
203 |
END |
END |