--- MITgcm/eesupp/src/check_threads.F 1998/10/28 03:11:33 1.3 +++ MITgcm/eesupp/src/check_threads.F 2001/09/21 03:54:34 1.10 @@ -1,50 +1,63 @@ -C $Header: /home/ubuntu/mnt/e9_copy/MITgcm/eesupp/src/check_threads.F,v 1.3 1998/10/28 03:11:33 cnh Exp $ +C $Header: /home/ubuntu/mnt/e9_copy/MITgcm/eesupp/src/check_threads.F,v 1.10 2001/09/21 03:54:34 cnh Exp $ +C $Name: $ #include "CPP_EEOPTIONS.h" +#define HAVE_SYSTEM -CStartOfInterface +CBOP +C !ROUTINE: CHECK_THREADS + +C !INTERFACE: SUBROUTINE CHECK_THREADS( myThid ) -C /==========================================================\ -C | SUBROUTINE CHECK_THREADS | -C | o Check that all the threads we need did indeed start. | -C |==========================================================| -C | This routine is called during the initialisation phase | -C | to check whether all the threads have started. | -C | It is invoked by every thread and if any thread finds an | -C | error it should set its error flag. | -C | Notes: | -C | Different mechanisms may be required on different | -C | platforms to actually perform the check. For example as | -C | coded here each thread checks for a semaphore set by the | -C | other threads to see if they are running. | -C | It is also possible for a system to schedule threads | -C | sequentially, unless some system call is made to yield | -C | the process. This routine would detect this situation too| -C | and allow a programmer to modify this routine and the | -C | barrier code to allow threads to be scheduled more | -C | appropriately. | -C \==========================================================/ + IMPLICIT NONE + +C !DESCRIPTION: +C *========================================================== +C | SUBROUTINE CHECK_THREADS +C | o Check that all the threads we need did indeed start. +C *========================================================== +C | This routine is called during the initialisation phase +C | to check whether all the threads have started. +C | It is invoked by every thread and if any thread finds an +C | error it should set its error flag. +C | Notes: +C | Different mechanisms may be required on different +C | platforms to actually perform the check. For example as +C | coded here each thread checks for a semaphore set by the +C | other threads to see if they are running. +C | It is also possible for a system to schedule threads +C | sequentially, unless some system call is made to yield +C | the process. This routine would detect this situation too +C | and allow a programmer to modify this routine and the +C | barrier code to allow threads to be scheduled more +C | appropriately. +C *========================================================== -C === Global data === +C !USES: +C == Global variables == #include "SIZE.h" #include "EEPARAMS.h" #include "EESUPPORT.h" -C === Routine areguments === -C myThid - My thread number - INTEGER myThid -CEndOfInterface +C !INPUT PARAMETERS: +C == Routine arguments == +C myThid :: My thread number + INTEGER myThid -C === Local variables === -C I - Loop counter -C numberThreadRunning - Count of number of threads this thread -C thinks are running. -C nChecks - Number of times checked for all threads. After so -C many checks give up and report an error. +C !LOCAL VARIABLES: +C == Local variables == +C I :: Loop counter +C numberThreadRunning :: Count of number of threads this thread +C thinks are running. +C nChecks :: Number of times checked for all threads. After so +C many checks give up and report an error. +C msgBuffer :: Temp. for preparing text messages. INTEGER I INTEGER numberThreadsRunning INTEGER nChecks CHARACTER*(MAX_LEN_MBUF) msgBuffer +CEOP + C threadIsRunning(myThid) = .TRUE. nChecks = 0 @@ -59,7 +72,7 @@ IF ( nChecks .GT. 10 ) THEN thError(myThid) = .TRUE. eeBootError = .TRUE. - WRITE(msgBuffer,'(A,I,A,I,A)') + WRITE(msgBuffer,'(A,I5,A,I5,A)') & 'S/R INI_CHECK_THREADS: Only ',numberThreadsRunning, & ' thread(s), ',nThreads,' are needed for this configuration!' CALL PRINT_ERROR( msgBuffer , myThid) @@ -75,11 +88,16 @@ GOTO 11 ENDIF IF ( numberThreadsRunning .NE. nThreads ) THEN +#ifdef HAVE_SYSTEM +#ifndef TARGET_T3E +#ifndef TARGET_CRAY_VECTOR CALL SYSTEM('sleep 1') +#endif +#endif +#endif GOTO 10 ENDIF 11 CONTINUE -C -C + RETURN END