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

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

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


Revision 1.10 - (hide annotations) (download)
Fri Sep 21 03:54:35 2001 UTC (22 years, 7 months ago) by cnh
Branch: MAIN
CVS Tags: checkpoint46n_post, checkpoint51k_post, checkpoint47e_post, checkpoint44e_post, checkpoint46l_post, checkpoint46g_pre, checkpoint47c_post, release1_p13_pre, checkpoint50c_post, checkpoint46f_post, checkpoint52d_pre, checkpoint48e_post, checkpoint50c_pre, checkpoint44f_post, checkpoint46b_post, checkpoint43a-release1mods, checkpoint51o_pre, ecco_c50_e32, ecco_c50_e33, ecco_c50_e30, ecco_c50_e31, release1_p13, checkpoint51l_post, checkpoint48i_post, checkpoint46l_pre, chkpt44d_post, checkpoint51, checkpoint50, checkpoint52, release1_p8, release1_p9, checkpoint50d_post, release1_p1, release1_p2, release1_p3, release1_p4, release1_p5, release1_p6, release1_p7, checkpoint50b_pre, checkpoint44e_pre, checkpoint51f_post, release1_b1, ecco_c51_e34d, ecco_c51_e34e, ecco_c51_e34f, ecco_c51_e34g, ecco_c51_e34a, ecco_c51_e34b, ecco_c51_e34c, checkpoint48b_post, checkpoint43, checkpoint51d_post, checkpoint48c_pre, checkpoint47d_pre, checkpoint51t_post, checkpoint51n_post, release1_chkpt44d_post, checkpoint51s_post, checkpoint47a_post, checkpoint48d_pre, checkpoint51j_post, checkpoint47i_post, release1_p11, checkpoint51n_pre, checkpoint47d_post, icebear5, icebear4, icebear3, icebear2, checkpoint46d_pre, checkpoint48d_post, release1-branch_tutorials, checkpoint48f_post, checkpoint45d_post, checkpoint52b_pre, checkpoint46j_pre, checkpoint51l_pre, chkpt44a_post, checkpoint44h_pre, checkpoint48h_post, checkpoint51q_post, ecco_c50_e29, checkpoint51b_pre, checkpoint46a_post, checkpoint47g_post, checkpoint52b_post, checkpoint52c_post, checkpoint46j_post, checkpoint51h_pre, checkpoint46k_post, ecco_c50_e28, chkpt44c_pre, checkpoint48a_post, checkpoint45a_post, checkpoint50f_post, checkpoint50a_post, checkpoint50f_pre, ecco_c44_e19, ecco_c44_e18, ecco_c44_e17, ecco_c44_e16, release1_p12, release1_p10, release1_p16, release1_p17, release1_p14, release1_p15, checkpoint47j_post, ecco_c50_e33a, branch-exfmods-tag, checkpoint44g_post, branchpoint-genmake2, checkpoint46e_pre, checkpoint51r_post, checkpoint48c_post, checkpoint45b_post, checkpoint46b_pre, checkpoint51i_post, release1-branch-end, release1_final_v1, checkpoint51b_post, checkpoint51c_post, checkpoint46c_pre, checkpoint46, checkpoint47b_post, checkpoint44b_post, ecco_c51_e34, checkpoint46h_pre, checkpoint46m_post, checkpoint46a_pre, checkpoint50g_post, checkpoint45c_post, ecco_ice2, ecco_ice1, checkpoint44h_post, checkpoint46g_post, release1_p12_pre, checkpoint52a_pre, ecco_c44_e22, checkpoint50h_post, checkpoint50e_pre, checkpoint50i_post, ecco_c44_e25, checkpoint51i_pre, checkpoint47f_post, checkpoint50e_post, chkpt44a_pre, checkpoint46i_post, ecco_c44_e23, ecco_c44_e20, ecco_c44_e21, ecco_c44_e26, ecco_c44_e27, ecco_c44_e24, checkpoint46c_post, ecco-branch-mod1, ecco-branch-mod2, ecco-branch-mod3, ecco-branch-mod4, ecco-branch-mod5, branch-netcdf, checkpoint50d_pre, checkpoint46e_post, release1_beta1, checkpoint51e_post, checkpoint44b_pre, checkpoint42, checkpoint41, checkpoint47, checkpoint44, checkpoint45, checkpoint48, checkpoint49, checkpoint46h_post, checkpoint51o_post, checkpoint51f_pre, chkpt44c_post, checkpoint48g_post, checkpoint47h_post, checkpoint52a_post, checkpoint44f_pre, checkpoint51g_post, ecco_c52_e35, checkpoint46d_post, checkpoint50b_post, release1-branch_branchpoint, checkpoint51m_post, checkpoint51a_post, checkpoint51p_post, checkpoint51u_post
Branch point for: c24_e25_ice, branch-exfmods-curt, release1_final, release1-branch, branch-genmake2, release1, branch-nonh, tg2-branch, ecco-branch, release1_50yr, netcdf-sm0, icebear, checkpoint51n_branch, release1_coupled
Changes since 1.9: +71 -50 lines
Starting to bring comments up to date and format comments
for document extraction of "prototypes".

1 cnh 1.10 C $Header: /u/gcmpack/models/MITgcmUV/eesupp/src/global_sum.F,v 1.9 2001/05/29 14:01:36 adcroft Exp $
2 adcroft 1.9 C $Name: $
3 cnh 1.1
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 cnh 1.10 CBOP
12     C !ROUTINE: GLOBAL_SUM_R4
13    
14     C !INTERFACE:
15 cnh 1.1 SUBROUTINE GLOBAL_SUM_R4(
16 adcroft 1.6 U sumPhi,
17 cnh 1.1 I myThid )
18 adcroft 1.6 IMPLICIT NONE
19 cnh 1.10 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 cnh 1.1
35 cnh 1.10 C !USES:
36 cnh 1.1 C == Global data ==
37     #include "SIZE.h"
38     #include "EEPARAMS.h"
39     #include "EESUPPORT.h"
40 adcroft 1.9 #include "GLOBAL_SUM.h"
41 cnh 1.1
42 cnh 1.10 C !INPUT/OUTPUT PARAMETERS:
43 cnh 1.1 C == Routine arguments ==
44     C sumPhi - Result of sum.
45     C myThid - My thread id.
46     Real*4 sumPhi
47     INTEGER myThid
48    
49 cnh 1.10 C !LOCAL VARIABLES:
50 cnh 1.1 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 cnh 1.10 CEOP
59 cnh 1.1
60 adcroft 1.6 C-- write local sum into array
61 adcroft 1.9 CALL BAR2( myThid )
62     phiGSRS(1,myThid) = sumPhi
63 adcroft 1.6
64 cnh 1.4 C-- Can not start until everyone is ready
65 adcroft 1.9 CALL BAR2( myThid )
66 cnh 1.1
67     C-- Sum within the process first
68     _BEGIN_MASTER( myThid )
69     tmp = 0.
70     DO I=1,nThreads
71 adcroft 1.9 tmp = tmp + phiGSRS(1,I)
72 cnh 1.1 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 adcroft 1.6 & MPI_COMM_WORLD,mpiRC)
80 cnh 1.1 #ifndef ALWAYS_USE_MPI
81     ENDIF
82     #endif
83     #endif /* ALLOW_USE_MPI */
84 adcroft 1.6 C-- Write solution to place where all threads can see it
85 adcroft 1.9 phiGSRS(1,1) = sumPhi
86 adcroft 1.6
87 cnh 1.1 _END_MASTER( myThid )
88     C--
89 adcroft 1.9 CALL BAR2( myThid )
90 adcroft 1.6
91     C-- set result for every process
92 adcroft 1.9 sumPhi = phiGSRS(1,1)
93     CALL BAR2( myThid )
94 adcroft 1.6
95 cnh 1.1 RETURN
96     END
97    
98    
99 cnh 1.10 CBOP
100     C !ROUTINE: GLOBAL_SUM_R8
101    
102     C !INTERFACE:
103 cnh 1.1 SUBROUTINE GLOBAL_SUM_R8(
104 adcroft 1.6 U sumPhi,
105 cnh 1.1 I myThid )
106 cnh 1.10 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 cnh 1.1
123 cnh 1.10 C !USES:
124 cnh 1.1 C === Global data ===
125     #include "SIZE.h"
126     #include "EEPARAMS.h"
127     #include "EESUPPORT.h"
128 adcroft 1.9 #include "GLOBAL_SUM.h"
129 cnh 1.1
130 cnh 1.10 C !INPUT/OUTPUT PARAMETERS:
131 cnh 1.1 C === Routine arguments ===
132     C sumPhi - Result of sum.
133     C myThid - My thread id.
134     Real*8 sumPhi
135     INTEGER myThid
136    
137 cnh 1.10 C !LOCAL VARIABLES:
138 cnh 1.1 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 cnh 1.10 CEOP
147 cnh 1.1
148 adcroft 1.9 CALL BAR2( myThid )
149 adcroft 1.6 C-- write local sum into array
150 adcroft 1.9 phiGSRL(1,myThid) = sumPhi
151 adcroft 1.6
152 cnh 1.4 C-- Can not start until everyone is ready
153 adcroft 1.9 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 cnh 1.1
160     C-- Sum within the process first
161     _BEGIN_MASTER( myThid )
162     tmp = 0. _d 0
163     DO I=1,nThreads
164 adcroft 1.9 tmp = tmp + phiGSRL(1,I)
165 cnh 1.1 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 heimbach 1.7 & MPI_COMM_WORLD,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 adcroft 1.9 phiGSRL(1,1) = sumPhi
179 heimbach 1.7 _END_MASTER( myThid )
180    
181     C-- Do not leave until we are sure that the sum is done
182 adcroft 1.9 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 heimbach 1.7
189     C-- set result for every process
190 adcroft 1.9 sumPhi = phiGSRL(1,1)
191     CALL BAR2( myThid )
192 heimbach 1.7
193     RETURN
194     END
195 cnh 1.10
196     CBOP
197     C !ROUTINE: GLOBAL_SUM_INT
198     C !INTERFACE:
199 heimbach 1.7 SUBROUTINE GLOBAL_SUM_INT(
200     U sumPhi,
201     I myThid )
202     IMPLICIT NONE
203 cnh 1.10 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 heimbach 1.7
219 cnh 1.10 C !USES:
220 heimbach 1.7 C === Global data ===
221     #include "SIZE.h"
222     #include "EEPARAMS.h"
223     #include "EESUPPORT.h"
224 adcroft 1.9 #include "GLOBAL_SUM.h"
225 heimbach 1.7
226 cnh 1.10 C !INPUT/OUTPUT PARAMETERS:
227 heimbach 1.7 C === Routine arguments ===
228     C sumPhi - Result of sum.
229     C myThid - My thread id.
230     INTEGER sumPhi
231     INTEGER myThid
232    
233 cnh 1.10 C !LOCAL VARIABLES:
234 heimbach 1.7 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 cnh 1.10 CEOP
243 heimbach 1.7
244 adcroft 1.9 _BARRIER
245 heimbach 1.7 C-- write local sum into array
246 adcroft 1.9 phiGSI(1,myThid) = sumPhi
247 heimbach 1.7
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 adcroft 1.9 tmp = tmp + phiGSI(1,I)
256 heimbach 1.7 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 adcroft 1.6 & MPI_COMM_WORLD,mpiRC)
264 cnh 1.1 #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 adcroft 1.9 phiGSI(1,1) = sumPhi
270 cnh 1.1 _END_MASTER( myThid )
271    
272 cnh 1.4 C-- Do not leave until we are sure that the sum is done
273 cnh 1.1 _BARRIER
274 adcroft 1.6
275     C-- set result for every process
276 adcroft 1.9 sumPhi = phiGSI(1,1)
277     _BARRIER
278 adcroft 1.6
279 cnh 1.1 RETURN
280     END

  ViewVC Help
Powered by ViewVC 1.1.22