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

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

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

revision 1.8 by heimbach, Tue Apr 10 22:35:24 2001 UTC revision 1.9 by cnh, Fri Sep 21 03:54:34 2001 UTC
# Line 3  C $Name$ Line 3  C $Name$
3    
4  #include "CPP_EEOPTIONS.h"  #include "CPP_EEOPTIONS.h"
5    
6    CBOP
7    C     !ROUTINE: BARRIER_INIT
8    
9    C     !INTERFACE:
10        SUBROUTINE BARRIER_INIT        SUBROUTINE BARRIER_INIT
11        IMPLICIT NONE        IMPLICIT NONE
12    
13    C     !DESCRIPTION:
14    C     *=====================================================================*
15    C     | SUBROUTINE BARRIER_INIT
16    C     | o Setup global barrier data structures.
17    C     *=====================================================================*
18    C     | Initialise global barrier data structures that can be used in
19    C     | conjunction with MPI or that can also be used to create
20    C     *=====================================================================*
21    
22    C     !USES:
23    C     == Global variables ==
24  #include "SIZE.h"  #include "SIZE.h"
25  #include "EEPARAMS.h"  #include "EEPARAMS.h"
26  #include "EESUPPORT.h"  #include "EESUPPORT.h"
27  #include "BARRIER.h"  #include "BARRIER.h"
28    
29  C     === Local Variables ===  C     !LOCAL VARIABLES:
30    C     == Local Variables ==
31    C     I :: Loop counter
32        INTEGER I        INTEGER I
33    CEOP
34    
35        DO I=1,nThreads        DO I=1,nThreads
36         key1(1,I) = INVALID         key1(1,I) = INVALID
# Line 25  C     === Local Variables === Line 43  C     === Local Variables ===
43    
44        RETURN        RETURN
45        END        END
46    
47    CBOP
48    C     !ROUTINE: BARRIER
49    
50    C     !INTERFACE:
51        SUBROUTINE BARRIER( myThid )        SUBROUTINE BARRIER( myThid )
52        IMPLICIT NONE        IMPLICIT NONE
 C  
 C     /==========================================================\  
 C     | SUBROUTINE BARRIER                                       |  
 C     | o Barrier routine that uses "busy waiting".              |  
 C     |==========================================================|  
 C     | This routine provides a pure fortran mechanism to        |  
 C     | synchronise multiple threads in a multi-threaded code.   |  
 C     | No thread can leave this routine before all the threads  |  
 C     | have entered it.                                         |  
 C     | Notes                                                    |  
 C     | =====                                                    |  
 C     | The door and key variables are assumed to have been      |  
 C     | initialized once an initial state of key = INVALID       |  
 C     | and door = SHUT.                                         |  
 C     | We use the routine FOOL_THE_COMPILER to stop compilers   |  
 C     | generating code which might simply set and test a        |  
 C     | register value. Shared-memory systems only maintain      |  
 C     | coherency over process caches and not registers.         |  
 C     | Also we have to be a bit careful regarding sequential    |  
 C     | consistency - or lack of it. At the moment the code      |  
 C     | assumes a total store order memory model, which some     |  
 C     | machines do not have! However, I have yet to find a      |  
 C     | problem with this I think because the tolerances in      |  
 C     | terms of memory ordering i.e. a little bit of reordering |  
 C     | probably will not break the barrier mechanism!           |  
 C     | On non-cache coherent systems e.g. T3E we need to use    |  
 C     | a library function to do barriers.                       |  
 C     | Note - The PANIC tests can be removed for working code   |  
 C     |        I have left them in without an ifdef option       |  
 C     |        because without them programming errors can       |  
 C     |        lead to infinitely spinning code. If you are      |  
 C     |        confident that your code is OK then removing      |  
 C     |        them may increase performance. Do not remove these|  
 C     |        lines to make your code "work" If the code is     |  
 C     |        stopping in these PANIC blocks then something is  |  
 C     |        wrong with your program and it needs to be fixed. |  
 C     \==========================================================/  
53    
54    C     !DESCRIPTION:
55    C     *==========================================================*
56    C     | SUBROUTINE BARRIER                                      
57    C     | o Barrier routine that uses "busy waiting".              
58    C     *==========================================================*
59    C     | This routine provides a pure fortran mechanism to        
60    C     | synchronise multiple threads in a multi-threaded code.    
61    C     | No thread can leave this routine before all the threads  
62    C     | have entered it.                                          
63    C     | Notes                                                    
64    C     | =====                                                    
65    C     | The door and key variables are assumed to have been      
66    C     | initialized once an initial state of key = INVALID        
67    C     | and door = SHUT.                                          
68    C     | We use the routine FOOL_THE_COMPILER to stop compilers    
69    C     | generating code which might simply set and test a        
70    C     | register value. Shared-memory systems only maintain      
71    C     | coherency over process caches and not registers.          
72    C     | Also we have to be a bit careful regarding sequential    
73    C     | consistency - or lack of it. At the moment the code      
74    C     | assumes a total store order memory model, which some      
75    C     | machines do not have! However, I have yet to find a      
76    C     | problem with this I think because the tolerances in      
77    C     | terms of memory ordering i.e. a little bit of reordering  
78    C     | probably will not break the barrier mechanism!            
79    C     | On non-cache coherent systems e.g. T3E we need to use    
80    C     | a library function to do barriers.                        
81    C     | Note - The PANIC tests can be removed for working code    
82    C     |        I have left them in without an ifdef option        
83    C     |        because without them programming errors can        
84    C     |        lead to infinitely spinning code. If you are      
85    C     |        confident that your code is OK then removing      
86    C     |        them may increase performance. Do not remove these
87    C     |        lines to make your code "work" If the code is      
88    C     |        stopping in these PANIC blocks then something is  
89    C     |        wrong with your program and it needs to be fixed.  
90    C     *==========================================================*
91    
92    C     !USES:
93    C     == Global variables ==
94  #include "SIZE.h"  #include "SIZE.h"
95  #include "EEPARAMS.h"  #include "EEPARAMS.h"
96  #include "EESUPPORT.h"  #include "EESUPPORT.h"
97  #include "BARRIER.h"  #include "BARRIER.h"
98    
99  C     === Routine arguments ===  C     !INPUT PARAMETERS:
100    C     == Routine arguments ==
101        INTEGER myThid        INTEGER myThid
102    
103    C     !LOCAL VARIABLES:
104  C     === Local variables ===  C     === Local variables ===
105  C     nDone - Counter for number of threads that have  C     nDone :: Counter for number of threads that have
106  C             completed a section.  C              completed a section.
107  C     I     - Loop counter  C     I     :: Loop counter
108        INTEGER nDone        INTEGER nDone
109        INTEGER I        INTEGER I
110    CEOP
111    
112  CcnhDebugStarts  CcnhDebugStarts
113  C      WRITE(myThid,*) ' Barrier entered '  C      WRITE(myThid,*) ' Barrier entered '

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.22