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

Diff of /MITgcm/eesupp/src/eedie.F

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

revision 1.9 by jmc, Wed Apr 22 23:06:01 2009 UTC revision 1.12 by jmc, Sat Sep 1 22:43:55 2012 UTC
# Line 25  C     == Global variables == Line 25  C     == Global variables ==
25  #include "EESUPPORT.h"  #include "EESUPPORT.h"
26  CEOP  CEOP
27    
 C     !FUNCTIONS  
       INTEGER  ILNBLNK  
       EXTERNAL ILNBLNK  
   
28  C     == Local variables ==  C     == Local variables ==
29  C     msgBuf       - I/O Buffer  C     msgBuf       :: I/O Buffer
30  C     nThreadsDone - Used to count number of completed threads.  C     nThreadsDone :: Used to count number of completed threads.
31  C     I            - Loop counter.  C     I            :: Loop counter.
32        CHARACTER*(MAX_LEN_MBUF) msgBuf        CHARACTER*(MAX_LEN_MBUF) msgBuf
33        INTEGER nThreadsDone        INTEGER nThreadsDone
34        INTEGER I, L        INTEGER I
35  #ifdef ALLOW_USE_MPI  #ifdef ALLOW_USE_MPI
36  C     mpiRC            - Error code reporting variable used  C     mpiRC        :: Error code reporting variable used with MPI.
 C                        with MPI.  
37        INTEGER mpiRC        INTEGER mpiRC
38  #endif /* ALLOW_USE_MPI */  #endif /* ALLOW_USE_MPI */
39    
40          IF ( eeBootError ) THEN
41    C--   Skip ended threads counting if earlier error was found
42            WRITE(msgBuf,'(2A)')
43         &   'EEDIE: earlier error in multi-proc/thread setting'
44            CALL PRINT_ERROR( msgBuf, 1 )
45            fatalError = .TRUE.
46    
47          ELSE
48  C--   Check that all the threads have ended  C--   Check that all the threads have ended
49  C     No thread should reach this loop before all threads have set  C     No thread should reach this loop before all threads have set
50  C     threadIsComplete to TRUE. If they do then either there is a bug  C     threadIsComplete to TRUE. If they do then either there is a bug
51  C     in the code or the behaviour of the parallel compiler directives  C     in the code or the behaviour of the parallel compiler directives
52  C     are not right for this code. In the latter case different  C     are not right for this code. In the latter case different
53  C     directives may be available or the compiler itself may have a  C     directives may be available or the compiler itself may have a
54  C     bug or you may need a different parallel compiler for main.F  C     bug or you may need a different parallel compiler for main.F
55        nThreadsDone = 0          nThreadsDone = 0
56        DO I = 1, nThreads          DO I = 1, nThreads
57         IF ( threadIsComplete(I) ) nThreadsDone = nThreadsDone+1           IF ( threadIsComplete(I) ) nThreadsDone = nThreadsDone+1
58        ENDDO          ENDDO
59        IF ( nThreadsDone .LT. nThreads ) THEN          IF ( nThreadsDone .LT. nThreads ) THEN
60         WRITE(msgBuf,'(A,I5,A,I5,A)')           WRITE(msgBuf,'(A,I5,A)')
61       & 'S/R EEDIE: Only ',nThreadsDone,       &    'S/R EEDIE: Only',nThreadsDone,' threads have completed,'
62       & ' threads have completed, ',nThreads,           CALL PRINT_ERROR( msgBuf, 1 )
63       & ' are expected for this configuration!'           WRITE(msgBuf,'(A,I5,A)')
64         L = ILNBLNK(msgBuf)       &    'S/R EEDIE:',nThreads,' are expected for this config !'
65         WRITE(*,*) msgBuf(1:L)           CALL PRINT_ERROR( msgBuf, 1 )
66         WRITE(*,*)           eeEndError = .TRUE.
67       & 'Possibly you have different setenv PARALLEL and nThreads?'           fatalError = .TRUE.
68         eeEndError = .TRUE.          ENDIF
69         fatalError = .TRUE.  
70    C--   end if/else eebootError
71        ENDIF        ENDIF
72    
73  #ifdef USE_LIBHPM  #ifdef USE_LIBHPM
74        CALL F_HPMTERMINATE(myProcId)        CALL F_HPMTERMINATE(myProcId)
75  #endif  #endif
76    
77  #ifdef ALLOW_USE_MPI  #ifdef ALLOW_USE_MPI
78  C--  C- Note: since MPI_INIT is always called, better to also always terminate MPI
79    C        (even if usingMPI=F) --> comment out test on usingMPI
80    c     IF ( usingMPI ) THEN
81    
82  C--   MPI style multiple-process termination  C--   MPI style multiple-process termination
83  C--   ======================================  C--   ======================================
 #ifndef ALWAYS_USE_MPI  
       IF ( usingMPI ) THEN  
 #endif  
84  #ifdef COMPONENT_MODULE  #ifdef COMPONENT_MODULE
85         IF ( useCoupler) CALL MPI_BARRIER( MPI_COMM_WORLD, mpiRC )         IF ( useCoupler) CALL MPI_BARRIER( MPI_COMM_WORLD, mpiRC )
86  #endif  #endif
87    #ifdef ALLOW_OASIS
88           IF ( useOASIS ) CALL OASIS_FINALIZE
89    #endif
90         CALL MPI_FINALIZE  ( mpiRC )         CALL MPI_FINALIZE  ( mpiRC )
91         IF ( mpiRC .NE. MPI_SUCCESS ) THEN         IF ( mpiRC .NE. MPI_SUCCESS ) THEN
92          eeEndError = .TRUE.          eeEndError = .TRUE.
# Line 88  C--   ================================== Line 96  C--   ==================================
96       &       mpiRC       &       mpiRC
97          CALL PRINT_ERROR( msgBuf, 1 )          CALL PRINT_ERROR( msgBuf, 1 )
98         ENDIF         ENDIF
 C  
 #ifndef ALWAYS_USE_MPI  
       ENDIF  
 #endif  
 #endif /* ALLOW_USE_MPI */  
99    
100    c     ENDIF
101    #endif /* ALLOW_USE_MPI */
102    
103        RETURN        RETURN
104        END        END

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.12

  ViewVC Help
Powered by ViewVC 1.1.22