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

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

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


Revision 1.11 - (show annotations) (download)
Wed Mar 28 20:22:39 2012 UTC (13 years, 3 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint63p, checkpoint63q, checkpoint63r, checkpoint63l, checkpoint63m, checkpoint63n, checkpoint63o
Changes since 1.10: +33 -30 lines
- skip ended threads counting if eeBootError (+ stop with error msg);
- improve error msg (use PRINT_ERROR)

1 C $Header: /u/gcmpack/MITgcm/eesupp/src/eedie.F,v 1.10 2010/09/25 23:09:54 mlosch Exp $
2 C $Name: $
3
4 #include "CPP_EEOPTIONS.h"
5 #ifdef USE_LIBHPM
6 # include "f_hpm.h"
7 #endif
8
9 CBOP
10 SUBROUTINE EEDIE
11 C *==========================================================*
12 C | SUBROUTINE EEDIE |
13 C | o Close execution "environment", particularly perform |
14 C | steps to terminate parallel processing. |
15 C *==========================================================*
16 C | Note: This routine can also be compiled with CPP |
17 C | directives set so that no multi-processing is initialised|
18 C | This is OK and should work fine. |
19 C *==========================================================*
20 IMPLICIT NONE
21
22 C == Global variables ==
23 #include "SIZE.h"
24 #include "EEPARAMS.h"
25 #include "EESUPPORT.h"
26 CEOP
27
28 C == Local variables ==
29 C msgBuf :: I/O Buffer
30 C nThreadsDone :: Used to count number of completed threads.
31 C I :: Loop counter.
32 CHARACTER*(MAX_LEN_MBUF) msgBuf
33 INTEGER nThreadsDone
34 INTEGER I
35 #ifdef ALLOW_USE_MPI
36 C mpiRC :: Error code reporting variable used with MPI.
37 INTEGER mpiRC
38 #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
49 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
51 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
53 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
55 nThreadsDone = 0
56 DO I = 1, nThreads
57 IF ( threadIsComplete(I) ) nThreadsDone = nThreadsDone+1
58 ENDDO
59 IF ( nThreadsDone .LT. nThreads ) THEN
60 WRITE(msgBuf,'(A,I5,A)')
61 & 'S/R EEDIE: Only',nThreadsDone,' threads have completed,'
62 CALL PRINT_ERROR( msgBuf, 1 )
63 WRITE(msgBuf,'(A,I5,A)')
64 & 'S/R EEDIE:',nThreads,' are expected for this config !'
65 CALL PRINT_ERROR( msgBuf, 1 )
66 eeEndError = .TRUE.
67 fatalError = .TRUE.
68 ENDIF
69
70 C-- end if/else eebootError
71 ENDIF
72
73 #ifdef USE_LIBHPM
74 CALL F_HPMTERMINATE(myProcId)
75 #endif
76 #ifdef ALLOW_USE_MPI
77 C--
78 C-- MPI style multiple-process termination
79 C-- ======================================
80 #ifndef ALWAYS_USE_MPI
81 IF ( usingMPI ) THEN
82 #endif
83 #ifdef COMPONENT_MODULE
84 IF ( useCoupler) CALL MPI_BARRIER( MPI_COMM_WORLD, mpiRC )
85 #endif
86 #ifdef ALLOW_OASIS
87 IF ( useOASIS ) CALL OASIS_FINALIZE
88 #endif
89 CALL MPI_FINALIZE ( mpiRC )
90 IF ( mpiRC .NE. MPI_SUCCESS ) THEN
91 eeEndError = .TRUE.
92 fatalError = .TRUE.
93 WRITE(msgBuf,'(A,I5)')
94 & 'S/R FIN_PROCS: MPI_FINALIZE return code',
95 & mpiRC
96 CALL PRINT_ERROR( msgBuf, 1 )
97 ENDIF
98 C
99 #ifndef ALWAYS_USE_MPI
100 ENDIF
101 #endif
102 #endif /* ALLOW_USE_MPI */
103
104 RETURN
105 END

  ViewVC Help
Powered by ViewVC 1.1.22