File indexing completed on 2018-03-02 18:36:06 UTC
view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
924557e60a Chri*0001 #include "CPP_EEOPTIONS.h"
0002
4c563c2ee9 Chri*0003
0004
0005
0006
924557e60a Chri*0007 SUBROUTINE CHECK_THREADS( myThid )
0008
4c563c2ee9 Chri*0009
0010
b2715cd9c6 Jean*0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
4c563c2ee9 Chri*0030
0031
b2715cd9c6 Jean*0032 IMPLICIT NONE
4c563c2ee9 Chri*0033
924557e60a Chri*0034 #include "SIZE.h"
0035 #include "EEPARAMS.h"
0036 #include "EESUPPORT.h"
0037
4c563c2ee9 Chri*0038
0039
0040
0041 INTEGER myThid
924557e60a Chri*0042
b2715cd9c6 Jean*0043
0044 #ifdef USE_OMP_THREADING
0045 INTEGER OMP_GET_NUM_THREADS
0046 EXTERNAL OMP_GET_NUM_THREADS
0047 #endif
0048
4c563c2ee9 Chri*0049
0050
b2715cd9c6 Jean*0051
4c563c2ee9 Chri*0052
0053
0054
0055
b2715cd9c6 Jean*0056
924557e60a Chri*0057 INTEGER nChecks
b2715cd9c6 Jean*0058 CHARACTER*(MAX_LEN_MBUF) msgBuf
c0add436ef Jean*0059 #ifdef USE_OMP_THREADING
0060 #ifdef ALLOW_USE_MPI
0061 INTEGER myErr, mpiRC
0062 #endif
0063 #else /* USE_OMP_THREADING */
0064 INTEGER I, numberThreadsRunning
0065 #endif /* USE_OMP_THREADING */
4c563c2ee9 Chri*0066
0067
b2715cd9c6 Jean*0068
0069
0070 #ifdef USE_OMP_THREADING
0071
c0add436ef Jean*0072
b2715cd9c6 Jean*0073 IF ( OMP_GET_NUM_THREADS() .NE. nThreads ) THEN
c0add436ef Jean*0074
0075
0076
b2715cd9c6 Jean*0077 WRITE(msgBuf,'(2A,I6)') 'CHECK_THREADS:',
0078 & ' from "eedata", nThreads=', nThreads
0079 CALL PRINT_ERROR( msgBuf, myThid )
0080 WRITE(msgBuf,'(2A,I6)') ' not equal to ',
0081 & 'Env.Var. OMP_NUM_THREADS=', OMP_GET_NUM_THREADS()
0082 CALL PRINT_ERROR( msgBuf, myThid )
c0add436ef Jean*0083 thError(myThid) = .TRUE.
0084 eeBootError = .TRUE.
0085 IF ( myThid.EQ.1 ) THEN
0086
0087 nChecks = 1
0088 #ifdef ALLOW_USE_MPI
0089 IF ( usingMPI ) THEN
0090 myErr = nChecks
0091 CALL MPI_Allreduce( myErr,nChecks,1,MPI_INTEGER,
0092 & MPI_SUM,MPI_COMM_MODEL,mpiRC )
0093 ENDIF
0094 #endif /* ALLOW_USE_MPI */
0095 ENDIF
0096
0097 ELSE
0098
0099
0100 threadIsRunning(myThid) = .TRUE.
0101 IF ( myThid.EQ.1 ) THEN
0102
0103 nChecks = 0
0104 #ifdef ALLOW_USE_MPI
0105 IF ( usingMPI ) THEN
0106 myErr = nChecks
0107 CALL MPI_Allreduce( myErr,nChecks,1,MPI_INTEGER,
0108 & MPI_SUM,MPI_COMM_MODEL,mpiRC )
0109 ENDIF
0110 #endif /* ALLOW_USE_MPI */
0111 IF ( nChecks.NE.0 ) THEN
0112 WRITE(msgBuf,'(A,I5,A)') 'CHECK_THREADS:', nChecks,
0113 & ' error(s) from other Processes'
0114 CALL PRINT_ERROR( msgBuf, myThid )
0115 eeBootError = .TRUE.
0116 ENDIF
0117 ENDIF
0118
0119
0120
b2715cd9c6 Jean*0121 ENDIF
c0add436ef Jean*0122
0123 #else /* ndef USE_OMP_THREADING */
b2715cd9c6 Jean*0124
0125 threadIsRunning(myThid) = .TRUE.
924557e60a Chri*0126 nChecks = 0
b2715cd9c6 Jean*0127
924557e60a Chri*0128 10 CONTINUE
0129 numberThreadsRunning = 0
0130 nChecks = nChecks + 1
0131 DO I = 1, nThreads
0132 IF ( threadIsRunning(I) )
0133 & numberThreadsRunning = numberThreadsRunning+1
0134 ENDDO
0135 IF ( nChecks .GT. 10 ) THEN
0136 thError(myThid) = .TRUE.
0137 eeBootError = .TRUE.
b2715cd9c6 Jean*0138 WRITE(msgBuf,'(A,I5,A,I5,A)')
c0add436ef Jean*0139 & 'CHECK_THREADS: Only ',numberThreadsRunning,
0140 & ' thread(s), ',nThreads,' are needed for this config!'
b2715cd9c6 Jean*0141 CALL PRINT_ERROR( msgBuf, myThid )
924557e60a Chri*0142
46dc4f419b Chri*0143
924557e60a Chri*0144
b2715cd9c6 Jean*0145
924557e60a Chri*0146
0147
0148 IF ( myThid .EQ. 1 ) THEN
0149 STOP 'ABNORMAL END: S/R CHECK_THREADS'
0150 ENDIF
0151 GOTO 11
0152 ENDIF
0153 IF ( numberThreadsRunning .NE. nThreads ) THEN
5b6c0e8b66 Patr*0154 #ifdef HAVE_SYSTEM
924557e60a Chri*0155 CALL SYSTEM('sleep 1')
79f5b9efed Alis*0156 #endif
924557e60a Chri*0157 GOTO 10
0158 ENDIF
0159 11 CONTINUE
aea29c8517 Alis*0160
c0add436ef Jean*0161 #endif /* ndef USE_OMP_THREADING */
0162
8b9104b167 Jean*0163
c0add436ef Jean*0164 IF ( .NOT. eeBootError ) THEN
0165 CALL BAR_CHECK( 1, myThid )
0166 ENDIF
8b9104b167 Jean*0167
924557e60a Chri*0168 RETURN
0169 END