/[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.9 - (show annotations) (download)
Wed Apr 22 23:06:01 2009 UTC (15 years, 5 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint62c, checkpoint62a, checkpoint62g, checkpoint62f, checkpoint62e, checkpoint62d, checkpoint62k, checkpoint62j, checkpoint62i, checkpoint62h, checkpoint62, checkpoint62b, checkpoint61n, checkpoint61q, checkpoint61o, checkpoint61m, checkpoint61v, checkpoint61w, checkpoint61t, checkpoint61u, checkpoint61r, checkpoint61s, checkpoint61p, checkpoint61z, checkpoint61x, checkpoint61y
Changes since 1.8: +13 -8 lines
write a shorter msg (without the ending blanks)

1 C $Header: /u/gcmpack/MITgcm/eesupp/src/eedie.F,v 1.8 2005/12/22 00:56:49 ce107 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 !FUNCTIONS
29 INTEGER ILNBLNK
30 EXTERNAL ILNBLNK
31
32 C == Local variables ==
33 C msgBuf - I/O Buffer
34 C nThreadsDone - Used to count number of completed threads.
35 C I - Loop counter.
36 CHARACTER*(MAX_LEN_MBUF) msgBuf
37 INTEGER nThreadsDone
38 INTEGER I, L
39 #ifdef ALLOW_USE_MPI
40 C mpiRC - Error code reporting variable used
41 C with MPI.
42 INTEGER mpiRC
43 #endif /* ALLOW_USE_MPI */
44
45 C-- Check that all the threads have ended
46 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
48 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
50 C directives may be available or the compiler itself may have a
51 C bug or you may need a different parallel compiler for main.F
52 nThreadsDone = 0
53 DO I = 1, nThreads
54 IF ( threadIsComplete(I) ) nThreadsDone = nThreadsDone+1
55 ENDDO
56 IF ( nThreadsDone .LT. nThreads ) THEN
57 WRITE(msgBuf,'(A,I5,A,I5,A)')
58 & 'S/R EEDIE: Only ',nThreadsDone,
59 & ' threads have completed, ',nThreads,
60 & ' are expected for this configuration!'
61 L = ILNBLNK(msgBuf)
62 WRITE(*,*) msgBuf(1:L)
63 WRITE(*,*)
64 & 'Possibly you have different setenv PARALLEL and nThreads?'
65 eeEndError = .TRUE.
66 fatalError = .TRUE.
67 ENDIF
68
69 #ifdef USE_LIBHPM
70 CALL F_HPMTERMINATE(myProcId)
71 #endif
72 #ifdef ALLOW_USE_MPI
73 C--
74 C-- MPI style multiple-process termination
75 C-- ======================================
76 #ifndef ALWAYS_USE_MPI
77 IF ( usingMPI ) THEN
78 #endif
79 #ifdef COMPONENT_MODULE
80 IF ( useCoupler) CALL MPI_BARRIER( MPI_COMM_WORLD, mpiRC )
81 #endif
82 CALL MPI_FINALIZE ( mpiRC )
83 IF ( mpiRC .NE. MPI_SUCCESS ) THEN
84 eeEndError = .TRUE.
85 fatalError = .TRUE.
86 WRITE(msgBuf,'(A,I5)')
87 & 'S/R FIN_PROCS: MPI_FINALIZE return code',
88 & mpiRC
89 CALL PRINT_ERROR( msgBuf, 1 )
90 ENDIF
91 C
92 #ifndef ALWAYS_USE_MPI
93 ENDIF
94 #endif
95 #endif /* ALLOW_USE_MPI */
96
97
98 RETURN
99 END

  ViewVC Help
Powered by ViewVC 1.1.22