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. |
6 |
C Contents |
C Contents |
7 |
C o global_sum_r4 |
C o GLOBAL_SUM_R4 |
8 |
C o global_sum_r8 |
C o GLOBAL_SUM_R8 |
9 |
|
C o GLOBAL_SUM_INT |
10 |
|
|
11 |
#include "CPP_EEOPTIONS.h" |
#include "CPP_EEOPTIONS.h" |
12 |
|
|
13 |
CBOP |
CBOP |
14 |
C !ROUTINE: GLOBAL_SUM_R4 |
C !ROUTINE: GLOBAL_SUM_R4 |
15 |
|
|
16 |
C !INTERFACE: |
C !INTERFACE: |
17 |
SUBROUTINE GLOBAL_SUM_R4( |
SUBROUTINE GLOBAL_SUM_R4( |
18 |
U sumPhi, |
U sumPhi, |
19 |
I myThid ) |
I myThid ) |
20 |
IMPLICIT NONE |
|
21 |
C !DESCRIPTION: |
C !DESCRIPTION: |
22 |
C *==========================================================* |
C *==========================================================* |
23 |
C | SUBROUTINE GLOBAL\_SUM\_R4 |
C | SUBROUTINE GLOBAL\_SUM\_R4 |
24 |
C | o Handle sum for real*4 data. |
C | o Handle sum for real*4 data. |
25 |
C *==========================================================* |
C *==========================================================* |
26 |
C | Perform sum an array of one value per thread and then |
C | Perform sum an array of one value per thread and then |
27 |
C | sum result of all the processes. |
C | sum result of all the processes. |
28 |
C | Notes |
C | Notes: |
29 |
C | ===== |
C | Within a process only one thread does the sum. |
30 |
C | Within a process only one thread does the sum, each |
C | The same thread also does the inter-process sum for |
31 |
C | thread is assumed to have already summed its local data. |
C | example with MPI and then writes the result into a shared |
32 |
C | The same thread also does the inter-process sum for |
C | location. All threads wait until the sum is avaiailable. |
|
C | example with MPI and then writes the result into a shared |
|
|
C | location. All threads wait until the sum is avaiailable. |
|
33 |
C *==========================================================* |
C *==========================================================* |
34 |
|
|
35 |
C !USES: |
C !USES: |
36 |
|
IMPLICIT NONE |
37 |
|
|
38 |
C == Global data == |
C == Global data == |
39 |
#include "SIZE.h" |
#include "SIZE.h" |
40 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
96 |
|
|
97 |
RETURN |
RETURN |
98 |
END |
END |
99 |
|
|
100 |
|
|
101 |
CBOP |
CBOP |
102 |
C !ROUTINE: GLOBAL_SUM_R8 |
C !ROUTINE: GLOBAL_SUM_R8 |
103 |
|
|
104 |
C !INTERFACE: |
C !INTERFACE: |
105 |
SUBROUTINE GLOBAL_SUM_R8( |
SUBROUTINE GLOBAL_SUM_R8( |
106 |
U sumPhi, |
U sumPhi, |
107 |
I myThid ) |
I myThid ) |
108 |
IMPLICIT NONE |
IMPLICIT NONE |
109 |
C !DESCRIPTION: |
C !DESCRIPTION: |
110 |
C *==========================================================* |
C *==========================================================* |
111 |
C | SUBROUTINE GLOBAL\_SUM\_R8 |
C | SUBROUTINE GLOBAL\_SUM\_R8 |
112 |
C | o Handle sum for real*8 data. |
C | o Handle sum for real*8 data. |
113 |
C *==========================================================* |
C *==========================================================* |
114 |
C | Perform sum an array of one value per thread and then |
C | Perform sum an array of one value per thread and then |
115 |
C | sum result of all the processes. |
C | sum result of all the processes. |
116 |
C | Notes |
C | Notes: |
117 |
C | ===== |
C | Within a process only one thread does the sum. |
118 |
C | Within a process only one thread does the sum, each |
C | The same thread also does the inter-process sum for |
119 |
C | thread is assumed to have already summed its local data. |
C | example with MPI and then writes the result into a shared |
120 |
C | The same thread also does the inter-process sum for |
C | location. All threads wait until the sum is avaiailable. |
|
C | example with MPI and then writes the result into a shared |
|
|
C | location. All threads wait until the sum is avaiailable. |
|
121 |
C *==========================================================* |
C *==========================================================* |
122 |
|
|
123 |
C !USES: |
C !USES: |
196 |
CBOP |
CBOP |
197 |
C !ROUTINE: GLOBAL_SUM_INT |
C !ROUTINE: GLOBAL_SUM_INT |
198 |
C !INTERFACE: |
C !INTERFACE: |
199 |
SUBROUTINE GLOBAL_SUM_INT( |
SUBROUTINE GLOBAL_SUM_INT( |
200 |
U sumPhi, |
U sumPhi, |
201 |
I myThid ) |
I myThid ) |
202 |
IMPLICIT NONE |
IMPLICIT NONE |
203 |
C !DESCRIPTION: |
C !DESCRIPTION: |
204 |
C *==========================================================* |
C *==========================================================* |
205 |
C | SUBROUTINE GLOBAL\_SUM\_INT |
C | SUBROUTINE GLOBAL\_SUM\_INT |
206 |
C | o Handle sum for integer data. |
C | o Handle sum for integer data. |
207 |
C *==========================================================* |
C *==========================================================* |
208 |
C | Perform sum an array of one value per thread and then |
C | Perform sum an array of one value per thread and then |
209 |
C | sum result of all the processes. |
C | sum result of all the processes. |
210 |
C | Notes |
C | Notes: |
211 |
C | ===== |
C | Within a process only one thread does the sum. |
212 |
C | Within a process only one thread does the sum, each |
C | The same thread also does the inter-process sum for |
213 |
C | thread is assumed to have already summed its local data. |
C | example with MPI and then writes the result into a shared |
214 |
C | The same thread also does the inter-process sum for |
C | location. All threads wait until the sum is avaiailable. |
|
C | example with MPI and then writes the result into a shared |
|
|
C | location. All threads wait until the sum is avaiailable. |
|
215 |
C *==========================================================* |
C *==========================================================* |
216 |
|
|
217 |
C !USES: |
C !USES: |
248 |
|
|
249 |
C-- Sum within the process first |
C-- Sum within the process first |
250 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
251 |
tmp = 0. _d 0 |
tmp = 0 |
252 |
DO I=1,nThreads |
DO I=1,nThreads |
253 |
tmp = tmp + phiGSI(1,I) |
tmp = tmp + phiGSI(1,I) |
254 |
ENDDO |
ENDDO |