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

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

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


Revision 1.8 - (hide annotations) (download)
Sun Feb 4 14:38:42 2001 UTC (23 years, 4 months ago) by cnh
Branch: MAIN
CVS Tags: checkpoint38, c37_adj, checkpoint39, checkpoint37, checkpoint36, checkpoint35
Branch point for: pre38
Changes since 1.7: +2 -1 lines
Made sure each .F and .h file had
the CVS keywords Header and Name at its start.
Most had header but very few currently have Name, so
lots of changes!

1 cnh 1.8 C $Header: /u/gcmpack/models/MITgcmUV/eesupp/src/check_threads.F,v 1.7 2001/01/29 20:00:14 heimbach Exp $
2     C $Name: $
3 cnh 1.1
4     #include "CPP_EEOPTIONS.h"
5    
6     CStartOfInterface
7     SUBROUTINE CHECK_THREADS( myThid )
8     C /==========================================================\
9     C | SUBROUTINE CHECK_THREADS |
10     C | o Check that all the threads we need did indeed start. |
11     C |==========================================================|
12     C | This routine is called during the initialisation phase |
13     C | to check whether all the threads have started. |
14     C | It is invoked by every thread and if any thread finds an |
15     C | error it should set its error flag. |
16     C | Notes: |
17     C | Different mechanisms may be required on different |
18     C | platforms to actually perform the check. For example as |
19     C | coded here each thread checks for a semaphore set by the |
20     C | other threads to see if they are running. |
21     C | It is also possible for a system to schedule threads |
22     C | sequentially, unless some system call is made to yield |
23     C | the process. This routine would detect this situation too|
24     C | and allow a programmer to modify this routine and the |
25     C | barrier code to allow threads to be scheduled more |
26     C | appropriately. |
27     C \==========================================================/
28 adcroft 1.4 IMPLICIT NONE
29 cnh 1.1
30     C === Global data ===
31     #include "SIZE.h"
32     #include "EEPARAMS.h"
33     #include "EESUPPORT.h"
34     C === Routine areguments ===
35     C myThid - My thread number
36     INTEGER myThid
37    
38     CEndOfInterface
39    
40     C === Local variables ===
41     C I - Loop counter
42     C numberThreadRunning - Count of number of threads this thread
43     C thinks are running.
44     C nChecks - Number of times checked for all threads. After so
45     C many checks give up and report an error.
46     INTEGER I
47     INTEGER numberThreadsRunning
48     INTEGER nChecks
49     CHARACTER*(MAX_LEN_MBUF) msgBuffer
50     C
51     threadIsRunning(myThid) = .TRUE.
52     nChecks = 0
53    
54     10 CONTINUE
55     numberThreadsRunning = 0
56     nChecks = nChecks + 1
57     DO I = 1, nThreads
58     IF ( threadIsRunning(I) )
59     & numberThreadsRunning = numberThreadsRunning+1
60     ENDDO
61     IF ( nChecks .GT. 10 ) THEN
62     thError(myThid) = .TRUE.
63     eeBootError = .TRUE.
64 adcroft 1.4 WRITE(msgBuffer,'(A,I5,A,I5,A)')
65 cnh 1.1 & 'S/R INI_CHECK_THREADS: Only ',numberThreadsRunning,
66     & ' thread(s), ',nThreads,' are needed for this configuration!'
67     CALL PRINT_ERROR( msgBuffer , myThid)
68     C-- Not enough threads are running so halt the program.
69 cnh 1.3 C I did not want this here but it is the only place I have found that
70 cnh 1.1 C KAP deadlocks if it there are fewer threads than iterations in a BLOCKED(1)
71     C loop. The deadlock appears to be in the routine mppjoin which never
72     C returns. I tried putting the STOP in main or breaking out of the loop in main
73     C but this causes KAP to insert a call to mppjoin - which then deadlocks!
74     IF ( myThid .EQ. 1 ) THEN
75     STOP 'ABNORMAL END: S/R CHECK_THREADS'
76     ENDIF
77     GOTO 11
78     ENDIF
79     IF ( numberThreadsRunning .NE. nThreads ) THEN
80 heimbach 1.7 #ifdef HAVE_SYSTEM
81 adcroft 1.5 #ifndef TARGET_T3E
82 heimbach 1.6 #ifndef TARGET_CRAY_VECTOR
83 cnh 1.1 CALL SYSTEM('sleep 1')
84 heimbach 1.7 #endif
85 heimbach 1.6 #endif
86 adcroft 1.5 #endif
87 cnh 1.1 GOTO 10
88     ENDIF
89     11 CONTINUE
90     C
91     C
92     RETURN
93     END

  ViewVC Help
Powered by ViewVC 1.1.22