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

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

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


Revision 1.12 - (show annotations) (download)
Sat Mar 27 03:51:51 2004 UTC (20 years, 2 months ago) by edhill
Branch: MAIN
CVS Tags: checkpoint57m_post, checkpoint57g_pre, checkpoint57s_post, checkpoint58b_post, checkpoint57b_post, checkpoint57g_post, checkpoint56b_post, checkpoint57y_post, checkpoint54d_post, checkpoint54e_post, checkpoint57r_post, checkpoint57d_post, checkpoint57i_post, checkpoint59, checkpoint58, checkpoint55, checkpoint54, checkpoint57, checkpoint56, checkpoint53, checkpoint58f_post, checkpoint57n_post, checkpoint58d_post, checkpoint58a_post, checkpoint57z_post, checkpoint54f_post, checkpoint58y_post, checkpoint58t_post, checkpoint55i_post, checkpoint58m_post, checkpoint57l_post, checkpoint57t_post, checkpoint55c_post, checkpoint57v_post, checkpoint57f_post, checkpoint53d_post, checkpoint60, checkpoint61, checkpoint57a_post, checkpoint57h_pre, checkpoint54b_post, checkpoint58w_post, checkpoint57h_post, checkpoint52m_post, checkpoint57y_pre, checkpoint55g_post, checkpoint58o_post, checkpoint57c_post, checkpoint58p_post, checkpoint58q_post, checkpoint55d_post, checkpoint58e_post, mitgcm_mapl_00, checkpoint54a_pre, checkpoint53c_post, checkpoint55d_pre, checkpoint57c_pre, checkpoint58r_post, checkpoint55j_post, checkpoint54a_post, checkpoint55h_post, checkpoint58n_post, checkpoint57e_post, checkpoint55b_post, checkpoint53a_post, checkpoint59q, checkpoint59p, checkpoint59r, checkpoint59e, checkpoint59d, checkpoint59g, checkpoint59f, checkpoint59a, checkpoint55f_post, checkpoint59c, checkpoint59b, checkpoint59m, checkpoint59l, checkpoint59o, checkpoint59n, checkpoint59i, checkpoint59h, checkpoint59k, checkpoint53g_post, checkpoint57p_post, checkpint57u_post, checkpoint57q_post, eckpoint57e_pre, checkpoint58k_post, checkpoint58v_post, checkpoint56a_post, checkpoint58l_post, checkpoint53f_post, checkpoint57h_done, checkpoint57j_post, checkpoint57f_pre, checkpoint61f, checkpoint58g_post, checkpoint58x_post, checkpoint52n_post, checkpoint53b_pre, checkpoint59j, checkpoint58h_post, checkpoint56c_post, checkpoint58j_post, checkpoint57a_pre, checkpoint55a_post, checkpoint57o_post, checkpoint57k_post, checkpoint53b_post, checkpoint57w_post, checkpoint61e, checkpoint58i_post, checkpoint57x_post, checkpoint58c_post, checkpoint58u_post, checkpoint53d_pre, checkpoint58s_post, checkpoint55e_post, checkpoint61g, checkpoint61d, checkpoint54c_post, checkpoint61b, checkpoint61c, checkpoint61a, checkpoint61l, checkpoint61j, checkpoint61k, checkpoint61h, checkpoint61i
Changes since 1.11: +4 -4 lines
 o cleanup comments (NO CODE CHANGES) in eesupp for protex
 o the "api reference" framework now builds documentation for:
     eesupp, pkg/generic_advdiff, and pkg/gmredi
 o remove mnc from the default gfd in pkg_groups pending
     further testing on systems where NetCDF is not installed

1 C $Header: /u/gcmpack/MITgcm/eesupp/src/global_sum.F,v 1.11 2003/12/15 02:02:38 jmc Exp $
2 C $Name: $
3
4 C-- File global_sum.F: Routines that perform global sum on an array
5 C of thread values.
6 C Contents
7 C o global_sum_r4
8 C o global_sum_r8
9 #include "CPP_EEOPTIONS.h"
10
11 CBOP
12 C !ROUTINE: GLOBAL_SUM_R4
13
14 C !INTERFACE:
15 SUBROUTINE GLOBAL_SUM_R4(
16 U sumPhi,
17 I myThid )
18 IMPLICIT NONE
19 C !DESCRIPTION:
20 C *==========================================================*
21 C | SUBROUTINE GLOBAL\_SUM\_R4
22 C | o Handle sum for real*4 data.
23 C *==========================================================*
24 C | Perform sum an array of one value per thread and then
25 C | sum result of all the processes.
26 C | Notes
27 C | =====
28 C | Within a process only one thread does the sum, each
29 C | thread is assumed to have already summed its local data.
30 C | The same thread also does the inter-process sum for
31 C | example with MPI and then writes the result into a shared
32 C | location. All threads wait until the sum is avaiailable.
33 C *==========================================================*
34
35 C !USES:
36 C == Global data ==
37 #include "SIZE.h"
38 #include "EEPARAMS.h"
39 #include "EESUPPORT.h"
40 #include "GLOBAL_SUM.h"
41
42 C !INPUT/OUTPUT PARAMETERS:
43 C == Routine arguments ==
44 C sumPhi - Result of sum.
45 C myThid - My thread id.
46 Real*4 sumPhi
47 INTEGER myThid
48
49 C !LOCAL VARIABLES:
50 C == Local variables ==
51 C I - Loop counters
52 C mpiRC - MPI return code
53 INTEGER I
54 Real*4 tmp
55 #ifdef ALLOW_USE_MPI
56 INTEGER mpiRC
57 #endif /* ALLOW_USE_MPI */
58 CEOP
59
60 C-- write local sum into array
61 CALL BAR2( myThid )
62 phiGSRS(1,myThid) = sumPhi
63
64 C-- Can not start until everyone is ready
65 CALL BAR2( myThid )
66
67 C-- Sum within the process first
68 _BEGIN_MASTER( myThid )
69 tmp = 0.
70 DO I=1,nThreads
71 tmp = tmp + phiGSRS(1,I)
72 ENDDO
73 sumPhi = tmp
74 #ifdef ALLOW_USE_MPI
75 #ifndef ALWAYS_USE_MPI
76 IF ( usingMPI ) THEN
77 #endif
78 CALL MPI_Allreduce(tmp,sumPhi,1,MPI_REAL,MPI_SUM,
79 & MPI_COMM_MODEL,mpiRC)
80 #ifndef ALWAYS_USE_MPI
81 ENDIF
82 #endif
83 #endif /* ALLOW_USE_MPI */
84 C-- Write solution to place where all threads can see it
85 phiGSRS(1,1) = sumPhi
86
87 _END_MASTER( myThid )
88 C--
89 CALL BAR2( myThid )
90
91 C-- set result for every process
92 sumPhi = phiGSRS(1,1)
93 CALL BAR2( myThid )
94
95 RETURN
96 END
97
98
99 CBOP
100 C !ROUTINE: GLOBAL_SUM_R8
101
102 C !INTERFACE:
103 SUBROUTINE GLOBAL_SUM_R8(
104 U sumPhi,
105 I myThid )
106 IMPLICIT NONE
107 C !DESCRIPTION:
108 C *==========================================================*
109 C | SUBROUTINE GLOBAL\_SUM\_R8
110 C | o Handle sum for real*8 data.
111 C *==========================================================*
112 C | Perform sum an array of one value per thread and then
113 C | sum result of all the processes.
114 C | Notes
115 C | =====
116 C | Within a process only one thread does the sum, each
117 C | thread is assumed to have already summed its local data.
118 C | The same thread also does the inter-process sum for
119 C | example with MPI and then writes the result into a shared
120 C | location. All threads wait until the sum is avaiailable.
121 C *==========================================================*
122
123 C !USES:
124 C === Global data ===
125 #include "SIZE.h"
126 #include "EEPARAMS.h"
127 #include "EESUPPORT.h"
128 #include "GLOBAL_SUM.h"
129
130 C !INPUT/OUTPUT PARAMETERS:
131 C === Routine arguments ===
132 C sumPhi - Result of sum.
133 C myThid - My thread id.
134 Real*8 sumPhi
135 INTEGER myThid
136
137 C !LOCAL VARIABLES:
138 C === Local variables ===
139 C I - Loop counters
140 C mpiRC - MPI return code
141 INTEGER I
142 Real*8 tmp
143 #ifdef ALLOW_USE_MPI
144 INTEGER mpiRC
145 #endif /* ALLOW_USE_MPI */
146 CEOP
147
148 CALL BAR2( myThid )
149 C-- write local sum into array
150 phiGSRL(1,myThid) = sumPhi
151
152 C-- Can not start until everyone is ready
153 C CALL FOOL_THE_COMPILER( phiGSRL )
154 C CALL MS
155 CALL BAR2( myThid )
156 C _BARRIER
157 C _BARRIER
158 C CALL FOOL_THE_COMPILER( phiGSRL )
159
160 C-- Sum within the process first
161 _BEGIN_MASTER( myThid )
162 tmp = 0. _d 0
163 DO I=1,nThreads
164 tmp = tmp + phiGSRL(1,I)
165 ENDDO
166 sumPhi = tmp
167 #ifdef ALLOW_USE_MPI
168 #ifndef ALWAYS_USE_MPI
169 IF ( usingMPI ) THEN
170 #endif
171 CALL MPI_Allreduce(tmp,sumPhi,1,MPI_DOUBLE_PRECISION,MPI_SUM,
172 & MPI_COMM_MODEL,mpiRC)
173 #ifndef ALWAYS_USE_MPI
174 ENDIF
175 #endif
176 #endif /* ALLOW_USE_MPI */
177 C-- Write solution to place where all threads can see it
178 phiGSRL(1,1) = sumPhi
179 _END_MASTER( myThid )
180
181 C-- Do not leave until we are sure that the sum is done
182 C CALL FOOL_THE_COMPILER( phiGSRL )
183 C CALL MS
184 C _BARRIER
185 C _BARRIER
186 CALL BAR2( myThid )
187 C CALL FOOL_THE_COMPILER( phiGSRL )
188
189 C-- set result for every process
190 sumPhi = phiGSRL(1,1)
191 CALL BAR2( myThid )
192
193 RETURN
194 END
195
196 CBOP
197 C !ROUTINE: GLOBAL_SUM_INT
198 C !INTERFACE:
199 SUBROUTINE GLOBAL_SUM_INT(
200 U sumPhi,
201 I myThid )
202 IMPLICIT NONE
203 C !DESCRIPTION:
204 C *==========================================================*
205 C | SUBROUTINE GLOBAL\_SUM\_INT
206 C | o Handle sum for integer data.
207 C *==========================================================*
208 C | Perform sum an array of one value per thread and then
209 C | sum result of all the processes.
210 C | Notes
211 C | =====
212 C | Within a process only one thread does the sum, each
213 C | thread is assumed to have already summed its local data.
214 C | The same thread also does the inter-process sum for
215 C | example with MPI and then writes the result into a shared
216 C | location. All threads wait until the sum is avaiailable.
217 C *==========================================================*
218
219 C !USES:
220 C === Global data ===
221 #include "SIZE.h"
222 #include "EEPARAMS.h"
223 #include "EESUPPORT.h"
224 #include "GLOBAL_SUM.h"
225
226 C !INPUT/OUTPUT PARAMETERS:
227 C === Routine arguments ===
228 C sumPhi - Result of sum.
229 C myThid - My thread id.
230 INTEGER sumPhi
231 INTEGER myThid
232
233 C !LOCAL VARIABLES:
234 C === Local variables ===
235 C I - Loop counters
236 C mpiRC - MPI return code
237 INTEGER I
238 INTEGER tmp
239 #ifdef ALLOW_USE_MPI
240 INTEGER mpiRC
241 #endif /* ALLOW_USE_MPI */
242 CEOP
243
244 _BARRIER
245 C-- write local sum into array
246 phiGSI(1,myThid) = sumPhi
247
248 C-- Can not start until everyone is ready
249 _BARRIER
250
251 C-- Sum within the process first
252 _BEGIN_MASTER( myThid )
253 tmp = 0. _d 0
254 DO I=1,nThreads
255 tmp = tmp + phiGSI(1,I)
256 ENDDO
257 sumPhi = tmp
258 #ifdef ALLOW_USE_MPI
259 #ifndef ALWAYS_USE_MPI
260 IF ( usingMPI ) THEN
261 #endif
262 CALL MPI_Allreduce(tmp,sumPhi,1,MPI_INTEGER,MPI_SUM,
263 & MPI_COMM_MODEL,mpiRC)
264 #ifndef ALWAYS_USE_MPI
265 ENDIF
266 #endif
267 #endif /* ALLOW_USE_MPI */
268 C-- Write solution to place where all threads can see it
269 phiGSI(1,1) = sumPhi
270 _END_MASTER( myThid )
271
272 C-- Do not leave until we are sure that the sum is done
273 _BARRIER
274
275 C-- set result for every process
276 sumPhi = phiGSI(1,1)
277 _BARRIER
278
279 RETURN
280 END

  ViewVC Help
Powered by ViewVC 1.1.22