/[MITgcm]/MITgcm/eesupp/src/global_sum.F
ViewVC logotype

Diff of /MITgcm/eesupp/src/global_sum.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.13 by jmc, Thu Apr 23 19:18:14 2009 UTC revision 1.14 by jmc, Wed Jun 10 03:47:03 2009 UTC
# Line 1  Line 1 
1  C $Header$  C $Header$
2  C $Name$  C $Name$
3    
4    #include "CPP_EEOPTIONS.h"
5    
6  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
7  C                        of thread values.  C                        of thread values.
8  C      Contents  C      Contents
# Line 8  C      o GLOBAL_SUM_R4 Line 10  C      o GLOBAL_SUM_R4
10  C      o GLOBAL_SUM_R8  C      o GLOBAL_SUM_R8
11  C      o GLOBAL_SUM_INT  C      o GLOBAL_SUM_INT
12    
13  #include "CPP_EEOPTIONS.h"  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
   
14  CBOP  CBOP
15  C     !ROUTINE: GLOBAL_SUM_R4  C     !ROUTINE: GLOBAL_SUM_R4
16    
# Line 43  C     == Global data == Line 44  C     == Global data ==
44    
45  C     !INPUT/OUTPUT PARAMETERS:  C     !INPUT/OUTPUT PARAMETERS:
46  C     == Routine arguments ==  C     == Routine arguments ==
47  C     sumPhi - Result of sum.  C     sumPhi :: Result of sum.
48  C     myThid - My thread id.  C     myThid :: My thread id.
49        Real*4 sumPhi        Real*4 sumPhi
50        INTEGER myThid        INTEGER myThid
51    
52  C     !LOCAL VARIABLES:  C     !LOCAL VARIABLES:
53  C     == Local variables ==  C     == Local variables ==
54  C     I      - Loop counters  C     I      :: Loop counters
55  C     mpiRC  - MPI return code  C     mpiRC  :: MPI return code
56        INTEGER I        INTEGER I
57        Real*4  tmp        Real*4  tmp
58  #ifdef   ALLOW_USE_MPI  #ifdef   ALLOW_USE_MPI
# Line 60  C     mpiRC  - MPI return code Line 61  C     mpiRC  - MPI return code
61  CEOP  CEOP
62    
63  C--   write local sum into array  C--   write local sum into array
64        CALL BAR2( myThid )        phiGSR4(1,myThid) = sumPhi
       phiGSRS(1,myThid) = sumPhi  
65    
66  C--   Can not start until everyone is ready  C--   Can not start until everyone is ready
67        CALL BAR2( myThid )        CALL BAR2( myThid )
# Line 70  C--   Sum within the process first Line 70  C--   Sum within the process first
70        _BEGIN_MASTER( myThid )        _BEGIN_MASTER( myThid )
71         tmp = 0.         tmp = 0.
72         DO I=1,nThreads         DO I=1,nThreads
73          tmp = tmp + phiGSRS(1,I)          tmp = tmp + phiGSR4(1,I)
74         ENDDO         ENDDO
75         sumPhi = tmp         sumPhi = tmp
76  #ifdef  ALLOW_USE_MPI  #ifdef  ALLOW_USE_MPI
# Line 84  C--   Sum within the process first Line 84  C--   Sum within the process first
84  #endif  #endif
85  #endif /*  ALLOW_USE_MPI */  #endif /*  ALLOW_USE_MPI */
86  C--     Write solution to place where all threads can see it  C--     Write solution to place where all threads can see it
87         phiGSRS(1,1) = sumPhi         phiGSR4(1,0) = sumPhi
88    
89        _END_MASTER( myThid )        _END_MASTER( myThid )
90  C--  C--
91        CALL BAR2( myThid )        CALL BAR2( myThid )
92    
93  C--   set result for every process  C--   set result for every process
94        sumPhi = phiGSRS(1,1)        sumPhi = phiGSR4(1,1)
       CALL BAR2( myThid )  
95    
96        RETURN        RETURN
97        END        END
98    
99    
100    C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
101  CBOP  CBOP
102  C     !ROUTINE: GLOBAL_SUM_R8  C     !ROUTINE: GLOBAL_SUM_R8
103    
# Line 105  C     !INTERFACE: Line 105  C     !INTERFACE:
105        SUBROUTINE GLOBAL_SUM_R8(        SUBROUTINE GLOBAL_SUM_R8(
106       U                       sumPhi,       U                       sumPhi,
107       I                       myThid )       I                       myThid )
108        IMPLICIT NONE  
109  C     !DESCRIPTION:  C     !DESCRIPTION:
110  C     *==========================================================*  C     *==========================================================*
111  C     | SUBROUTINE GLOBAL\_SUM\_R8  C     | SUBROUTINE GLOBAL\_SUM\_R8
# Line 121  C     | location. All threads wait until Line 121  C     | location. All threads wait until
121  C     *==========================================================*  C     *==========================================================*
122    
123  C     !USES:  C     !USES:
124          IMPLICIT NONE
125    
126  C     === Global data ===  C     === Global data ===
127  #include "SIZE.h"  #include "SIZE.h"
128  #include "EEPARAMS.h"  #include "EEPARAMS.h"
# Line 129  C     === Global data === Line 131  C     === Global data ===
131    
132  C     !INPUT/OUTPUT PARAMETERS:  C     !INPUT/OUTPUT PARAMETERS:
133  C     === Routine arguments ===  C     === Routine arguments ===
134  C     sumPhi - Result of sum.  C     sumPhi :: Result of sum.
135  C     myThid - My thread id.  C     myThid :: My thread id.
136        Real*8 sumPhi        Real*8 sumPhi
137        INTEGER myThid        INTEGER myThid
138    
139  C     !LOCAL VARIABLES:  C     !LOCAL VARIABLES:
140  C     === Local variables ===  C     === Local variables ===
141  C     I      - Loop counters  C     I      :: Loop counters
142  C     mpiRC  - MPI return code  C     mpiRC  :: MPI return code
143        INTEGER I        INTEGER I
144        Real*8  tmp        Real*8  tmp
145  #ifdef   ALLOW_USE_MPI  #ifdef   ALLOW_USE_MPI
# Line 145  C     mpiRC  - MPI return code Line 147  C     mpiRC  - MPI return code
147  #endif   /* ALLOW_USE_MPI */  #endif   /* ALLOW_USE_MPI */
148  CEOP  CEOP
149    
       CALL BAR2( myThid )  
150  C--   write local sum into array  C--   write local sum into array
151        phiGSRL(1,myThid) = sumPhi        phiGSR8(1,myThid) = sumPhi
152    
153  C--   Can not start until everyone is ready  C--   Can not start until everyone is ready
154  C     CALL FOOL_THE_COMPILER( phiGSRL )  C     CALL FOOL_THE_COMPILER( phiGSR8 )
155  C     CALL MS  C     CALL MS
156        CALL BAR2( myThid )        CALL BAR2( myThid )
157  C     _BARRIER  C     _BARRIER
158  C     _BARRIER  C     _BARRIER
159  C     CALL FOOL_THE_COMPILER( phiGSRL )  C     CALL FOOL_THE_COMPILER( phiGSR8 )
160    
161  C--   Sum within the process first  C--   Sum within the process first
162        _BEGIN_MASTER( myThid )        _BEGIN_MASTER( myThid )
163         tmp = 0. _d 0         tmp = 0. _d 0
164         DO I=1,nThreads         DO I=1,nThreads
165          tmp = tmp + phiGSRL(1,I)          tmp = tmp + phiGSR8(1,I)
166         ENDDO         ENDDO
167         sumPhi = tmp         sumPhi = tmp
168  #ifdef  ALLOW_USE_MPI  #ifdef  ALLOW_USE_MPI
# Line 175  C--   Sum within the process first Line 176  C--   Sum within the process first
176  #endif  #endif
177  #endif /*  ALLOW_USE_MPI */  #endif /*  ALLOW_USE_MPI */
178  C--     Write solution to place where all threads can see it  C--     Write solution to place where all threads can see it
179          phiGSRL(1,1) = sumPhi         phiGSR8(1,0) = sumPhi
180        _END_MASTER( myThid )        _END_MASTER( myThid )
181    
182  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
183  C     CALL FOOL_THE_COMPILER( phiGSRL )  C     CALL FOOL_THE_COMPILER( phiGSR8 )
184  C     CALL MS  C     CALL MS
185  C     _BARRIER  C     _BARRIER
186  C     _BARRIER  C     _BARRIER
187        CALL BAR2( myThid )        CALL BAR2( myThid )
188  C     CALL FOOL_THE_COMPILER( phiGSRL )  C     CALL FOOL_THE_COMPILER( phiGSR8 )
189    
190  C--   set result for every process  C--   set result for every process
191        sumPhi = phiGSRL(1,1)        sumPhi = phiGSR8(1,0)
       CALL BAR2( myThid )  
192    
193        RETURN        RETURN
194        END        END
195    
196    C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
197  CBOP  CBOP
198  C     !ROUTINE: GLOBAL_SUM_INT  C     !ROUTINE: GLOBAL_SUM_INT
199  C     !INTERFACE:  C     !INTERFACE:
200        SUBROUTINE GLOBAL_SUM_INT(        SUBROUTINE GLOBAL_SUM_INT(
201       U                       sumPhi,       U                       sumPhi,
202       I                       myThid )       I                       myThid )
203        IMPLICIT NONE  
204  C     !DESCRIPTION:  C     !DESCRIPTION:
205  C     *==========================================================*  C     *==========================================================*
206  C     | SUBROUTINE GLOBAL\_SUM\_INT  C     | SUBROUTINE GLOBAL\_SUM\_INT
# Line 215  C     | location. All threads wait until Line 216  C     | location. All threads wait until
216  C     *==========================================================*  C     *==========================================================*
217    
218  C     !USES:  C     !USES:
219          IMPLICIT NONE
220    
221  C     === Global data ===  C     === Global data ===
222  #include "SIZE.h"  #include "SIZE.h"
223  #include "EEPARAMS.h"  #include "EEPARAMS.h"
# Line 223  C     === Global data === Line 226  C     === Global data ===
226    
227  C     !INPUT/OUTPUT PARAMETERS:  C     !INPUT/OUTPUT PARAMETERS:
228  C     === Routine arguments ===  C     === Routine arguments ===
229  C     sumPhi - Result of sum.  C     sumPhi :: Result of sum.
230  C     myThid - My thread id.  C     myThid :: My thread id.
231        INTEGER sumPhi        INTEGER sumPhi
232        INTEGER myThid        INTEGER myThid
233    
234  C     !LOCAL VARIABLES:  C     !LOCAL VARIABLES:
235  C     === Local variables ===  C     === Local variables ===
236  C     I      - Loop counters  C     I      :: Loop counters
237  C     mpiRC  - MPI return code  C     mpiRC  :: MPI return code
238        INTEGER I        INTEGER I
239        INTEGER  tmp        INTEGER  tmp
240  #ifdef   ALLOW_USE_MPI  #ifdef   ALLOW_USE_MPI
# Line 239  C     mpiRC  - MPI return code Line 242  C     mpiRC  - MPI return code
242  #endif   /* ALLOW_USE_MPI */  #endif   /* ALLOW_USE_MPI */
243  CEOP  CEOP
244    
       _BARRIER  
245  C--   write local sum into array  C--   write local sum into array
246        phiGSI(1,myThid) = sumPhi        phiGSI(1,myThid) = sumPhi
247    
# Line 264  C--   Sum within the process first Line 266  C--   Sum within the process first
266  #endif  #endif
267  #endif /*  ALLOW_USE_MPI */  #endif /*  ALLOW_USE_MPI */
268  C--     Write solution to place where all threads can see it  C--     Write solution to place where all threads can see it
269          phiGSI(1,1) = sumPhi         phiGSI(1,0) = sumPhi
270        _END_MASTER( myThid )        _END_MASTER( myThid )
271    
272  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
273        _BARRIER        _BARRIER
274    
275  C--   set result for every process  C--   set result for every process
276        sumPhi = phiGSI(1,1)        sumPhi = phiGSI(1,0)
       _BARRIER  
277    
278        RETURN        RETURN
279        END        END

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.22