1 |
C $Header$ |
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 |
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) |
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 |
|
97 |
C |
C-- check barrier synchronization: 1rst (initial) call. |
98 |
|
CALL BAR_CHECK( 1, myThid ) |
99 |
|
|
100 |
RETURN |
RETURN |
101 |
END |
END |