/[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.2 by cnh, Thu Apr 23 20:37:30 1998 UTC revision 1.10 by mlosch, Sat Sep 25 23:09:54 2010 UTC
# Line 1  Line 1 
1  C $Header$  C $Header$
2    C $Name$
3    
4  #include "CPP_EEOPTIONS.h"  #include "CPP_EEOPTIONS.h"
5    #ifdef USE_LIBHPM
6    # include "f_hpm.h"
7    #endif
8    
9  CStartOfInterface  CBOP
10        SUBROUTINE EEDIE        SUBROUTINE EEDIE
11  C     /==========================================================\  C     *==========================================================*
12  C     | SUBROUTINE EEDIE                                         |  C     | SUBROUTINE EEDIE                                         |
13  C     | o Close execution "environment", particularly perform    |  C     | o Close execution "environment", particularly perform    |
14  C     |   steps to terminate parallel processing.                |  C     |   steps to terminate parallel processing.                |
15  C     |==========================================================|  C     *==========================================================*
16  C     | Note: This routine can also be compiled with CPP         |  C     | Note: This routine can also be compiled with CPP         |
17  C     | directives set so that no multi-processing is initialised|  C     | directives set so that no multi-processing is initialised|
18  C     | This is OK and should work fine.                         |  C     | This is OK and should work fine.                         |
19  C     \==========================================================/  C     *==========================================================*
20          IMPLICIT NONE
21    
22  C     == Global variables ==  C     == Global variables ==
23  #include "SIZE.h"  #include "SIZE.h"
24  #include "EEPARAMS.h"  #include "EEPARAMS.h"
25  #include "EESUPPORT.h"  #include "EESUPPORT.h"
26  CEndOfInterface  CEOP
27    
28    C     !FUNCTIONS
29          INTEGER  ILNBLNK
30          EXTERNAL ILNBLNK
31    
32  C     == Local variables ==  C     == Local variables ==
33  C     msgBuf       - I/O Buffer  C     msgBuf       - I/O Buffer
# Line 26  C     nThreadsDone - Used to count numbe Line 35  C     nThreadsDone - Used to count numbe
35  C     I            - Loop counter.  C     I            - Loop counter.
36        CHARACTER*(MAX_LEN_MBUF) msgBuf        CHARACTER*(MAX_LEN_MBUF) msgBuf
37        INTEGER nThreadsDone        INTEGER nThreadsDone
38        INTEGER I        INTEGER I, L
39  #ifdef ALLOW_USE_MPI  #ifdef ALLOW_USE_MPI
40  C     mpiRC            - Error code reporting variable used  C     mpiRC            - Error code reporting variable used
41  C                        with MPI.  C                        with MPI.
# Line 37  C--   Check that all the threads have en Line 46  C--   Check that all the threads have en
46  C     No thread should reach this loop before all threads have set  C     No thread should reach this loop before all threads have set
47  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
48  C     in the code or the behaviour of the parallel compiler directives  C     in the code or the behaviour of the parallel compiler directives
49  C     are not right for this code. In the latter case different directives  C     are not right for this code. In the latter case different
50  C     may be available or the compiler itself may have a bug or you may  C     directives may be available or the compiler itself may have a
51  C     need a different parallel compiler for main.F  C     bug or you may need a different parallel compiler for main.F
52        nThreadsDone = 0        nThreadsDone = 0
53        DO I = 1, nThreads        DO I = 1, nThreads
54         IF ( threadIsComplete(I) ) nThreadsDone = nThreadsDone+1         IF ( threadIsComplete(I) ) nThreadsDone = nThreadsDone+1
55        ENDDO        ENDDO
56        IF ( nThreadsDone .LT. nThreads ) THEN        IF ( nThreadsDone .LT. nThreads ) THEN
57         WRITE(msgBuf,'(A,I,A,I,A)')         WRITE(msgBuf,'(A,I5,A,I5,A)')
58       & 'S/R EEDIE: Only ',nThreadsDone,       & 'S/R EEDIE: Only ',nThreadsDone,
59       & ' threads have completed, ',nThreads,' are expected for this configuration!'       & ' threads have completed, ',nThreads,
60         WRITE(0,*) msgBuf       & ' are expected for this configuration!'
61         WRITE(0,*) 'Possibly you have different values of setenv PARALLEL and nThreads?'         L = ILNBLNK(msgBuf)
62           WRITE(*,*) msgBuf(1:L)
63           WRITE(*,*)
64         & 'Possibly you have different setenv PARALLEL and nThreads?'
65         eeEndError = .TRUE.         eeEndError = .TRUE.
66         fatalError = .TRUE.         fatalError = .TRUE.
67        ENDIF        ENDIF
68    
69    #ifdef USE_LIBHPM
70          CALL F_HPMTERMINATE(myProcId)
71    #endif
72  #ifdef ALLOW_USE_MPI  #ifdef ALLOW_USE_MPI
73  C--  C--
74  C--   MPI style multiple-process termination  C--   MPI style multiple-process termination
# Line 61  C--   ================================== Line 76  C--   ==================================
76  #ifndef ALWAYS_USE_MPI  #ifndef ALWAYS_USE_MPI
77        IF ( usingMPI ) THEN        IF ( usingMPI ) THEN
78  #endif  #endif
79    #ifdef COMPONENT_MODULE
80           IF ( useCoupler) CALL MPI_BARRIER( MPI_COMM_WORLD, mpiRC )
81    #endif
82    #ifdef ALLOW_OASIS
83           IF ( useOASIS ) CALL OASIS_FINALIZE
84    #endif
85         CALL MPI_FINALIZE  ( mpiRC )         CALL MPI_FINALIZE  ( mpiRC )
86         IF ( mpiRC .NE. MPI_SUCCESS ) THEN         IF ( mpiRC .NE. MPI_SUCCESS ) THEN
87          eeEndError = .TRUE.          eeEndError = .TRUE.
88          fatalError = .TRUE.          fatalError = .TRUE.
89          WRITE(msgBuf,'(A,I)')          WRITE(msgBuf,'(A,I5)')
90       &       'S/R FIN_PROCS: MPI_FINALIZE return code',       &       'S/R FIN_PROCS: MPI_FINALIZE return code',
91       &       mpiRC       &       mpiRC
92          CALL PRINT_ERROR( msgBuf, 1 )          CALL PRINT_ERROR( msgBuf, 1 )

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.22