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

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

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


Revision 1.7 - (show annotations) (download)
Mon Jan 29 20:00:14 2001 UTC (23 years, 3 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint34
Changes since 1.6: +3 -1 lines
Exchange routines extended for correct reverse modei simulation.
mdsio_gl.F added for read/write of tiled data by single processor.

1 C $Header: /u/ralf/cvs/ecco_env/eesupp/src/check_threads.F,v 1.3 2000/10/23 16:31:48 heimbach Exp $
2
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 IMPLICIT NONE
28
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 WRITE(msgBuffer,'(A,I5,A,I5,A)')
64 & '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 C I did not want this here but it is the only place I have found that
69 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 #ifdef HAVE_SYSTEM
80 #ifndef TARGET_T3E
81 #ifndef TARGET_CRAY_VECTOR
82 CALL SYSTEM('sleep 1')
83 #endif
84 #endif
85 #endif
86 GOTO 10
87 ENDIF
88 11 CONTINUE
89 C
90 C
91 RETURN
92 END

  ViewVC Help
Powered by ViewVC 1.1.22