/[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.14 - (show annotations) (download)
Sat Jul 29 20:58:31 2006 UTC (17 years, 10 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint62v, checkpoint62u, checkpoint62t, checkpoint62c, checkpoint59, checkpoint62s, checkpoint62r, checkpoint62q, checkpoint62p, checkpoint62a, checkpoint62g, checkpoint62f, checkpoint62e, checkpoint62d, checkpoint62k, checkpoint62j, checkpoint62i, checkpoint62h, checkpoint62o, checkpoint62n, checkpoint62m, checkpoint62l, checkpoint62w, checkpoint62z, checkpoint62y, checkpoint62x, checkpoint58y_post, checkpoint58t_post, checkpoint60, checkpoint61, checkpoint62, checkpoint63, checkpoint58w_post, checkpoint58o_post, checkpoint58p_post, checkpoint58q_post, mitgcm_mapl_00, checkpoint63a, checkpoint63b, checkpoint58r_post, checkpoint58n_post, checkpoint59q, checkpoint59p, checkpoint59r, checkpoint59e, checkpoint59d, checkpoint59g, checkpoint59f, checkpoint59a, checkpoint59c, checkpoint59b, checkpoint59m, checkpoint59l, checkpoint59o, checkpoint59n, checkpoint59i, checkpoint59h, checkpoint59k, checkpoint62b, checkpoint58v_post, checkpoint61f, checkpoint58x_post, checkpoint61n, checkpoint59j, checkpoint61q, checkpoint61e, checkpoint58u_post, checkpoint58s_post, checkpoint61g, checkpoint61d, checkpoint61b, checkpoint61c, checkpoint61a, checkpoint61o, checkpoint61l, checkpoint61m, checkpoint61j, checkpoint61k, checkpoint61h, checkpoint61i, checkpoint61v, checkpoint61w, checkpoint61t, checkpoint61u, checkpoint61r, checkpoint61s, checkpoint61p, checkpoint61z, checkpoint61x, checkpoint61y
Changes since 1.13: +4 -1 lines
add the 1rst call to BAR_CHECK

1 C $Header: /u/gcmpack/MITgcm/eesupp/src/check_threads.F,v 1.13 2004/03/27 03:51:50 edhill Exp $
2 C $Name: $
3
4 #include "CPP_EEOPTIONS.h"
5
6 CBOP
7 C !ROUTINE: CHECK_THREADS
8
9 C !INTERFACE:
10 SUBROUTINE CHECK_THREADS( myThid )
11 IMPLICIT NONE
12
13 C !DESCRIPTION:
14 C *==========================================================
15 C | SUBROUTINE CHECK\_THREADS
16 C | o Check that all the threads we need did indeed start.
17 C *==========================================================
18 C | This routine is called during the initialisation phase
19 C | to check whether all the threads have started.
20 C | It is invoked by every thread and if any thread finds an
21 C | error it should set its error flag.
22 C | Notes:
23 C | Different mechanisms may be required on different
24 C | platforms to actually perform the check. For example as
25 C | coded here each thread checks for a semaphore set by the
26 C | other threads to see if they are running.
27 C | It is also possible for a system to schedule threads
28 C | sequentially, unless some system call is made to yield
29 C | the process. This routine would detect this situation too
30 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 !USES:
36 C == Global variables ==
37 #include "SIZE.h"
38 #include "EEPARAMS.h"
39 #include "EESUPPORT.h"
40
41 C !INPUT PARAMETERS:
42 C == Routine arguments ==
43 C myThid :: My thread number
44 INTEGER myThid
45
46 C !LOCAL VARIABLES:
47 C == Local variables ==
48 C I :: Loop counter
49 C numberThreadRunning :: Count of number of threads this thread
50 C thinks are running.
51 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
55 INTEGER numberThreadsRunning
56 INTEGER nChecks
57 CHARACTER*(MAX_LEN_MBUF) msgBuffer
58 CEOP
59
60 C
61 threadIsRunning(myThid) = .TRUE.
62 nChecks = 0
63
64 10 CONTINUE
65 numberThreadsRunning = 0
66 nChecks = nChecks + 1
67 DO I = 1, nThreads
68 IF ( threadIsRunning(I) )
69 & numberThreadsRunning = numberThreadsRunning+1
70 ENDDO
71 IF ( nChecks .GT. 10 ) THEN
72 thError(myThid) = .TRUE.
73 eeBootError = .TRUE.
74 WRITE(msgBuffer,'(A,I5,A,I5,A)')
75 & 'S/R INI_CHECK_THREADS: Only ',numberThreadsRunning,
76 & ' thread(s), ',nThreads,' are needed for this configuration!'
77 CALL PRINT_ERROR( msgBuffer , myThid)
78 C-- Not enough threads are running so halt the program.
79 C I did not want this here but it is the only place I have found that
80 C KAP deadlocks if it there are fewer threads than iterations in a BLOCKED(1)
81 C loop. The deadlock appears to be in the routine mppjoin which never
82 C returns. I tried putting the STOP in main or breaking out of the loop in main
83 C but this causes KAP to insert a call to mppjoin - which then deadlocks!
84 IF ( myThid .EQ. 1 ) THEN
85 STOP 'ABNORMAL END: S/R CHECK_THREADS'
86 ENDIF
87 GOTO 11
88 ENDIF
89 IF ( numberThreadsRunning .NE. nThreads ) THEN
90 #ifdef HAVE_SYSTEM
91 CALL SYSTEM('sleep 1')
92 #endif
93 GOTO 10
94 ENDIF
95 11 CONTINUE
96
97 C-- check barrier synchronization: 1rst (initial) call.
98 CALL BAR_CHECK( 1, myThid )
99
100 RETURN
101 END

  ViewVC Help
Powered by ViewVC 1.1.22