/[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.4 - (hide annotations) (download)
Tue May 18 17:39:21 1999 UTC (25 years ago) by adcroft
Branch: MAIN
CVS Tags: checkpoint22, checkpoint23, checkpoint24
Changes since 1.3: +3 -2 lines
Added IMPLICIT NONE where missing and changed formatting from 'I' to 'I5'.

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

  ViewVC Help
Powered by ViewVC 1.1.22