/[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.6 - (hide annotations) (download)
Wed Jun 21 20:44:06 2000 UTC (23 years, 11 months ago) by heimbach
Branch: MAIN
CVS Tags: branch-atmos-merge-freeze, branch-atmos-merge-start, branch-atmos-merge-shapiro, checkpoint33, checkpoint32, checkpoint31, checkpoint30, branch-atmos-merge-zonalfilt, branch-atmos-merge-phase5, branch-atmos-merge-phase4, branch-atmos-merge-phase7, branch-atmos-merge-phase6, branch-atmos-merge-phase1, branch-atmos-merge-phase3, branch-atmos-merge-phase2
Branch point for: branch-atmos-merge
Changes since 1.5: +3 -1 lines
Added #ifdef's for case TARGET_CRAY_VECTOR, defined in genmake. (P.H.)

1 heimbach 1.6 C $Header: /u/gcmpack/models/MITgcmUV/eesupp/src/check_threads.F,v 1.5 2000/03/14 20:28:11 adcroft 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 adcroft 1.5 #ifndef TARGET_T3E
80 heimbach 1.6 #ifndef TARGET_CRAY_VECTOR
81 cnh 1.1 CALL SYSTEM('sleep 1')
82 heimbach 1.6 #endif
83 adcroft 1.5 #endif
84 cnh 1.1 GOTO 10
85     ENDIF
86     11 CONTINUE
87     C
88     C
89     RETURN
90     END

  ViewVC Help
Powered by ViewVC 1.1.22