/[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.2 by cnh, Thu Apr 23 20:37:29 1998 UTC revision 1.8 by heimbach, Tue Apr 10 22:35:24 2001 UTC
# Line 1  Line 1 
1  C $Header$  C $Header$
2    C $Name$
3    
4  #include "CPP_EEOPTIONS.h"  #include "CPP_EEOPTIONS.h"
5    
6        SUBROUTINE BARRIER_INIT        SUBROUTINE BARRIER_INIT
7          IMPLICIT NONE
8    
9    #include "SIZE.h"
10  #include "EEPARAMS.h"  #include "EEPARAMS.h"
11  #include "EESUPPORT.h"  #include "EESUPPORT.h"
12  #include "BARRIER.h"  #include "BARRIER.h"
# Line 44  C     | coherency over process caches an Line 48  C     | coherency over process caches an
48  C     | Also we have to be a bit careful regarding sequential    |  C     | Also we have to be a bit careful regarding sequential    |
49  C     | consistency - or lack of it. At the moment the code      |  C     | consistency - or lack of it. At the moment the code      |
50  C     | assumes a total store order memory model, which some     |  C     | assumes a total store order memory model, which some     |
51  C     | machines don't have! However, I have yet to find a       |  C     | machines do not have! However, I have yet to find a      |
52  C     | problem with this I think because the tolerances in      |  C     | problem with this I think because the tolerances in      |
53  C     | terms of memory ordering i.e. a little bit of reordering |  C     | terms of memory ordering i.e. a little bit of reordering |
54  C     | probably won't break the barrier mechanism!              |  C     | probably will not break the barrier mechanism!           |
55  C     | On non-cache coherent systems e.g. T3E we need to use    |  C     | On non-cache coherent systems e.g. T3E we need to use    |
56  C     | a library function to do barriers.                       |  C     | a library function to do barriers.                       |
57  C     | Note - The PANIC tests can be removed for working code   |  C     | Note - The PANIC tests can be removed for working code   |
# Line 60  C     |        lines to make your code " Line 64  C     |        lines to make your code "
64  C     |        stopping in these PANIC blocks then something is  |  C     |        stopping in these PANIC blocks then something is  |
65  C     |        wrong with your program and it needs to be fixed. |  C     |        wrong with your program and it needs to be fixed. |
66  C     \==========================================================/  C     \==========================================================/
67    
68    #include "SIZE.h"
69  #include "EEPARAMS.h"  #include "EEPARAMS.h"
70  #include "EESUPPORT.h"  #include "EESUPPORT.h"
71  #include "BARRIER.h"  #include "BARRIER.h"
# Line 75  C     I     - Loop counter Line 81  C     I     - Loop counter
81        INTEGER I        INTEGER I
82    
83  CcnhDebugStarts  CcnhDebugStarts
84  C     IF ( myThid .EQ. 1 ) THEN  C      WRITE(myThid,*) ' Barrier entered '
 C      WRITE(0,*) ' Barrier entered '  
 C     ENDIF  
85  CcnhDebugEnds  CcnhDebugEnds
86    
87  C--   Check that thread number is expected range  C--   Check that thread number is expected range
88        IF ( myThid .LT. 1 .OR. myThid .GT. nThreads ) THEN        IF ( myThid .LT. 1 .OR. myThid .GT. nThreads ) THEN
89         WRITE(0,*) '!!!!!!! PANIC !!!!!!! CATASTROPHIC ERROR'         WRITE(*,*) '!!!!!!! PANIC !!!!!!! CATASTROPHIC ERROR'
90         WRITE(0,*) '!!!!!!! PANIC !!!!!!! in S/R BARRIER  myThid = ', myThid, ' nThreads = ', nThreads         WRITE(*,*) '!!!!!!! PANIC !!!!!!! in S/R BARRIER  myThid = ',
91         &  myThid, ' nThreads = ', nThreads
92         STOP 'ABNROMAL END: S/R BARRIER'         STOP 'ABNROMAL END: S/R BARRIER'
93        ENDIF        ENDIF
94    
95  C--   When every threads key1 is valid thread 1 will open door1.  C--   When every threads key1 is valid thread 1 will open door1.
96        IF ( key1(1,myThid) .EQ. VALID ) THEN        IF ( key1(1,myThid) .EQ. VALID ) THEN
97         WRITE(0,*) '!!!!!!! PANIC !!!!!!! CATASTROPHIC ERROR'         WRITE(*,*) '!!!!!!! PANIC !!!!!!! CATASTROPHIC ERROR'
98         WRITE(0,*) '!!!!!!! PANIC !!!!!!! in S/R BARRIER  myThid = ', myThid, ' key1 already validated'         WRITE(*,*) '!!!!!!! PANIC !!!!!!! in S/R BARRIER  myThid = ',
99         &  myThid, ' key1 already validated'
100         STOP 'ABNROMAL END: S/R BARRIER'         STOP 'ABNROMAL END: S/R BARRIER'
101        ENDIF        ENDIF
102        key1(1,myThid) = VALID        key1(1,myThid) = VALID
# Line 114  C--   Invalidate keys for door1 here as Line 120  C--   Invalidate keys for door1 here as
120    
121  CcnhDebugStarts  CcnhDebugStarts
122  C     IF ( myThid .EQ. 1 ) THEN  C     IF ( myThid .EQ. 1 ) THEN
123  C      WRITE(0,*) ' DOOR1 Opened '  C      WRITE(*,*) ' DOOR1 Opened '
124  C     ENDIF  C     ENDIF
125  CcnhDebugEnds  CcnhDebugEnds
126    
# Line 129  C--   door3 because they have to go thro Line 135  C--   door3 because they have to go thro
135  C--   When every threads key2 is valid thread 1 will open door2.  C--   When every threads key2 is valid thread 1 will open door2.
136  C     Notes  C     Notes
137  C     =====  C     =====
 C      I don't understand memory ordering and sequential consistency.  
138  C     I think that to work with any memory model ( i.e. relaxed,  C     I think that to work with any memory model ( i.e. relaxed,
139  C     partial store, total store) the variables key1, key2 and key3  C     partial store, total store) the variables key1, key2 and key3
140  C     might need to be set to invalid by thread 1.  C     might need to be set to invalid by thread 1.
141  C      C    
142        IF ( key2(1,myThid) .EQ. VALID ) THEN        IF ( key2(1,myThid) .EQ. VALID ) THEN
143         WRITE(0,*) '!!!!!!! PANIC !!!!!!! CATASTROPHIC ERROR'         WRITE(*,*) '!!!!!!! PANIC !!!!!!! CATASTROPHIC ERROR'
144         WRITE(0,*) '!!!!!!! PANIC !!!!!!! in S/R BARRIER  myThid = ', myThid, ' key2 already validated'         WRITE(*,*) '!!!!!!! PANIC !!!!!!! in S/R BARRIER  myThid = ',
145         &  myThid, ' key2 already validated'
146         STOP 'ABNROMAL END: S/R BARRIER'         STOP 'ABNROMAL END: S/R BARRIER'
147        ENDIF        ENDIF
148        key2(1,myThid) = VALID        key2(1,myThid) = VALID
# Line 170  C--   door1 because they have to go thro Line 176  C--   door1 because they have to go thro
176            
177  C--   When every threads key3 is valid thread 1 will open door3.  C--   When every threads key3 is valid thread 1 will open door3.
178        IF ( key3(1,myThid) .EQ. VALID ) THEN        IF ( key3(1,myThid) .EQ. VALID ) THEN
179         WRITE(0,*) '!!!!!!! PANIC !!!!!!! CATASTROPHIC ERROR'         WRITE(*,*) '!!!!!!! PANIC !!!!!!! CATASTROPHIC ERROR'
180         WRITE(0,*) '!!!!!!! PANIC !!!!!!! in S/R BARRIER  myThid = ', myThid, ' key3 already validated'         WRITE(*,*) '!!!!!!! PANIC !!!!!!! in S/R BARRIER  myThid = ',
181         &  myThid, ' key3 already validated'
182         STOP 'ABNROMAL END: S/R BARRIER'         STOP 'ABNROMAL END: S/R BARRIER'
183        ENDIF        ENDIF
184        key3(1,myThid) = VALID        key3(1,myThid) = VALID
# Line 203  C--   door2 because they have to go thro Line 210  C--   door2 because they have to go thro
210        ENDIF        ENDIF
211    
212  CcnhDebugStarts  CcnhDebugStarts
213  C     IF ( myThid .EQ. 1 ) THEN  C      WRITE(myThid,*) ' Barrier exited '
 C      WRITE(0,*) ' Barrier exited '  
 C     ENDIF  
214  CcnhDebugEnds  CcnhDebugEnds
215            
216        RETURN        RETURN

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

  ViewVC Help
Powered by ViewVC 1.1.22