/[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.13 - (show annotations) (download)
Sat Mar 27 03:51:50 2004 UTC (20 years, 3 months ago) by edhill
Branch: MAIN
CVS Tags: checkpoint57m_post, checkpoint57g_pre, checkpoint57s_post, checkpoint58b_post, checkpoint57b_post, checkpoint57g_post, checkpoint56b_post, checkpoint57y_post, checkpoint54d_post, checkpoint54e_post, checkpoint57r_post, checkpoint57d_post, checkpoint57i_post, checkpoint58, checkpoint55, checkpoint54, checkpoint57, checkpoint56, checkpoint53, checkpoint58f_post, checkpoint57n_post, checkpoint58d_post, checkpoint58a_post, checkpoint57z_post, checkpoint54f_post, checkpoint55i_post, checkpoint58m_post, checkpoint57l_post, checkpoint57t_post, checkpoint55c_post, checkpoint57v_post, checkpoint57f_post, checkpoint53d_post, checkpoint57a_post, checkpoint57h_pre, checkpoint54b_post, checkpoint57h_post, checkpoint52m_post, checkpoint57y_pre, checkpoint55g_post, checkpoint57c_post, checkpoint55d_post, checkpoint58e_post, checkpoint54a_pre, checkpoint53c_post, checkpoint55d_pre, checkpoint57c_pre, checkpoint55j_post, checkpoint54a_post, checkpoint55h_post, checkpoint57e_post, checkpoint55b_post, checkpoint53a_post, checkpoint55f_post, checkpoint53g_post, checkpoint57p_post, checkpint57u_post, checkpoint57q_post, eckpoint57e_pre, checkpoint58k_post, checkpoint56a_post, checkpoint58l_post, checkpoint53f_post, checkpoint57h_done, checkpoint57j_post, checkpoint57f_pre, checkpoint58g_post, checkpoint52n_post, checkpoint53b_pre, checkpoint58h_post, checkpoint56c_post, checkpoint58j_post, checkpoint57a_pre, checkpoint55a_post, checkpoint57o_post, checkpoint57k_post, checkpoint53b_post, checkpoint57w_post, checkpoint58i_post, checkpoint57x_post, checkpoint58c_post, checkpoint53d_pre, checkpoint55e_post, checkpoint54c_post
Changes since 1.12: +2 -2 lines
 o cleanup comments (NO CODE CHANGES) in eesupp for protex
 o the "api reference" framework now builds documentation for:
     eesupp, pkg/generic_advdiff, and pkg/gmredi
 o remove mnc from the default gfd in pkg_groups pending
     further testing on systems where NetCDF is not installed

1 C $Header: /u/gcmpack/MITgcm/eesupp/src/check_threads.F,v 1.12 2003/11/11 23:04: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 RETURN
98 END

  ViewVC Help
Powered by ViewVC 1.1.22