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

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

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

revision 1.1 by cnh, Wed Apr 22 19:15:30 1998 UTC revision 1.13 by edhill, Sat Mar 27 03:51:50 2004 UTC
# Line 1  Line 1 
1  C $Id$  C $Header$
2    C $Name$
3    
4  #include "CPP_EEOPTIONS.h"  #include "CPP_EEOPTIONS.h"
5    
6  CStartOfInterface  CBOP
7    C     !ROUTINE: CHECK_THREADS
8    
9    C     !INTERFACE:
10        SUBROUTINE CHECK_THREADS( myThid )        SUBROUTINE CHECK_THREADS( myThid )
11  C     /==========================================================\        IMPLICIT NONE
12  C     | SUBROUTINE CHECK_THREADS                                 |  
13  C     | o Check that all the threads we need did indeed start.   |  C     !DESCRIPTION:
14  C     |==========================================================|  C     *==========================================================
15  C     | This routine is called during the initialisation phase   |  C     | SUBROUTINE CHECK\_THREADS                                
16  C     | to check whether all the threads have started.           |  C     | o Check that all the threads we need did indeed start.    
17  C     | It is invoked by every thread and if any thread finds an |  C     *==========================================================
18  C     | error it should set its error flag.                      |  C     | This routine is called during the initialisation phase    
19  C     | Notes:                                                   |  C     | to check whether all the threads have started.            
20  C     |  Different mechanisms may be required on different       |  C     | It is invoked by every thread and if any thread finds an  
21  C     | platforms to actually perform the check. For example as  |  C     | error it should set its error flag.                      
22  C     | coded here each thread checks for a semaphore set by the |  C     | Notes:                                                    
23  C     | other threads to see if they are running.                |  C     |  Different mechanisms may be required on different        
24  C     | It is also possible for a system to schedule threads     |  C     | platforms to actually perform the check. For example as  
25  C     | sequentially, unless some system call is made to yield   |  C     | coded here each thread checks for a semaphore set by the  
26  C     | the process. This routine would detect this situation too|  C     | other threads to see if they are running.                
27  C     | and allow a programmer to modify this routine and the    |  C     | It is also possible for a system to schedule threads      
28  C     | barrier code to allow threads to be scheduled more       |  C     | sequentially, unless some system call is made to yield    
29  C     | appropriately.                                           |  C     | the process. This routine would detect this situation too
30  C     \==========================================================/  C     | and allow a programmer to modify this routine and the    
31    C     | barrier code to allow threads to be scheduled more        
32    C     | appropriately.                                            
33    C     *==========================================================
34    
35  C     === Global data ===  C     !USES:
36    C     == Global variables ==
37  #include "SIZE.h"  #include "SIZE.h"
38  #include "EEPARAMS.h"  #include "EEPARAMS.h"
39  #include "EESUPPORT.h"  #include "EESUPPORT.h"
 C     === Routine areguments ===  
 C     myThid - My thread number  
       INTEGER myThid  
40    
41  CEndOfInterface  C     !INPUT PARAMETERS:
42    C     == Routine arguments ==
43    C     myThid :: My thread number
44          INTEGER myThid
45    
46  C     === Local variables ===  C     !LOCAL VARIABLES:
47  C     I - Loop counter  C     == Local variables ==
48  C     numberThreadRunning - Count of number of threads this thread  C     I :: Loop counter
49  C                           thinks are running.  C     numberThreadRunning :: Count of number of threads this thread
50  C     nChecks - Number of times checked for all threads. After so  C                            thinks are running.
51  C               many checks give up and report an error.  C     nChecks   :: Number of times checked for all threads. After so
52    C                  many checks give up and report an error.
53    C     msgBuffer :: Temp. for preparing text messages.
54        INTEGER I        INTEGER I
55        INTEGER numberThreadsRunning        INTEGER numberThreadsRunning
56        INTEGER nChecks        INTEGER nChecks
57        CHARACTER*(MAX_LEN_MBUF) msgBuffer        CHARACTER*(MAX_LEN_MBUF) msgBuffer
58    CEOP
59    
60  C  C
61        threadIsRunning(myThid) = .TRUE.        threadIsRunning(myThid) = .TRUE.
62        nChecks                 = 0        nChecks                 = 0
# Line 59  C Line 71  C
71        IF ( nChecks .GT. 10 ) THEN        IF ( nChecks .GT. 10 ) THEN
72         thError(myThid) = .TRUE.         thError(myThid) = .TRUE.
73         eeBootError     = .TRUE.         eeBootError     = .TRUE.
74         WRITE(msgBuffer,'(A,I,A,I,A)')         WRITE(msgBuffer,'(A,I5,A,I5,A)')
75       &  'S/R INI_CHECK_THREADS: Only ',numberThreadsRunning,       &  'S/R INI_CHECK_THREADS: Only ',numberThreadsRunning,
76       &  ' thread(s), ',nThreads,' are needed for this configuration!'       &  ' thread(s), ',nThreads,' are needed for this configuration!'
77          CALL PRINT_ERROR( msgBuffer , myThid)          CALL PRINT_ERROR( msgBuffer , myThid)
78  C--     Not enough threads are running so halt the program.  C--     Not enough threads are running so halt the program.
79  C       I didn't want this here but it is the only place I have found that  C       I did not want this here but it is the only place I have found that
80  C       KAP deadlocks if it there are fewer threads than iterations in a BLOCKED(1)  C       KAP deadlocks if it there are fewer threads than iterations in a BLOCKED(1)
81  C       loop. The deadlock appears to be in the routine mppjoin which never  C       loop. The deadlock appears to be in the routine mppjoin which never
82  C       returns. I tried putting the STOP in main or breaking out of the loop in main  C       returns. I tried putting the STOP in main or breaking out of the loop in main
# Line 75  C       but this causes KAP to insert a Line 87  C       but this causes KAP to insert a
87         GOTO 11         GOTO 11
88        ENDIF        ENDIF
89        IF ( numberThreadsRunning .NE. nThreads ) THEN        IF ( numberThreadsRunning .NE. nThreads ) THEN
90    #ifdef HAVE_SYSTEM
91         CALL SYSTEM('sleep 1')         CALL SYSTEM('sleep 1')
92    #endif
93         GOTO 10         GOTO 10
94        ENDIF        ENDIF
95     11 CONTINUE     11 CONTINUE
96  C    
 C  
97        RETURN        RETURN
98        END        END
   
 C $Id$  

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.22