1 |
ce107 |
1.8 |
C $Header: /u/gcmpack/MITgcm/eesupp/src/eedie.F,v 1.7 2003/12/15 02:02:39 jmc Exp $ |
2 |
jmc |
1.7 |
C $Name: $ |
3 |
cnh |
1.1 |
|
4 |
|
|
#include "CPP_EEOPTIONS.h" |
5 |
ce107 |
1.8 |
#ifdef USE_LIBHPM |
6 |
|
|
# include "f_hpm.h" |
7 |
|
|
#endif |
8 |
cnh |
1.1 |
|
9 |
|
|
CStartOfInterface |
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 |
adcroft |
1.4 |
IMPLICIT NONE |
21 |
cnh |
1.1 |
|
22 |
|
|
C == Global variables == |
23 |
|
|
#include "SIZE.h" |
24 |
|
|
#include "EEPARAMS.h" |
25 |
|
|
#include "EESUPPORT.h" |
26 |
|
|
CEndOfInterface |
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 |
37 |
|
|
C with MPI. |
38 |
|
|
INTEGER mpiRC |
39 |
|
|
#endif /* ALLOW_USE_MPI */ |
40 |
|
|
|
41 |
|
|
C-- Check that all the threads have ended |
42 |
|
|
C No thread should reach this loop before all threads have set |
43 |
|
|
C threadIsComplete to TRUE. If they do then either there is a bug |
44 |
|
|
C in the code or the behaviour of the parallel compiler directives |
45 |
cnh |
1.3 |
C are not right for this code. In the latter case different |
46 |
|
|
C directives may be available or the compiler itself may have a |
47 |
|
|
C bug or you may need a different parallel compiler for main.F |
48 |
cnh |
1.1 |
nThreadsDone = 0 |
49 |
|
|
DO I = 1, nThreads |
50 |
|
|
IF ( threadIsComplete(I) ) nThreadsDone = nThreadsDone+1 |
51 |
|
|
ENDDO |
52 |
|
|
IF ( nThreadsDone .LT. nThreads ) THEN |
53 |
adcroft |
1.4 |
WRITE(msgBuf,'(A,I5,A,I5,A)') |
54 |
cnh |
1.1 |
& 'S/R EEDIE: Only ',nThreadsDone, |
55 |
cnh |
1.3 |
& ' threads have completed, ',nThreads, |
56 |
|
|
& ' are expected for this configuration!' |
57 |
heimbach |
1.6 |
WRITE(*,*) msgBuf |
58 |
|
|
WRITE(*,*) |
59 |
cnh |
1.3 |
& 'Possibly you have different setenv PARALLEL and nThreads?' |
60 |
cnh |
1.1 |
eeEndError = .TRUE. |
61 |
|
|
fatalError = .TRUE. |
62 |
|
|
ENDIF |
63 |
|
|
|
64 |
ce107 |
1.8 |
#ifdef USE_LIBHPM |
65 |
|
|
CALL F_HPMTERMINATE(myProcId) |
66 |
|
|
#endif |
67 |
cnh |
1.1 |
#ifdef ALLOW_USE_MPI |
68 |
|
|
C-- |
69 |
|
|
C-- MPI style multiple-process termination |
70 |
|
|
C-- ====================================== |
71 |
|
|
#ifndef ALWAYS_USE_MPI |
72 |
|
|
IF ( usingMPI ) THEN |
73 |
jmc |
1.7 |
#endif |
74 |
|
|
#ifdef COMPONENT_MODULE |
75 |
|
|
IF ( useCoupler) CALL MPI_BARRIER( MPI_COMM_WORLD, mpiRC ) |
76 |
cnh |
1.1 |
#endif |
77 |
|
|
CALL MPI_FINALIZE ( mpiRC ) |
78 |
|
|
IF ( mpiRC .NE. MPI_SUCCESS ) THEN |
79 |
|
|
eeEndError = .TRUE. |
80 |
|
|
fatalError = .TRUE. |
81 |
adcroft |
1.4 |
WRITE(msgBuf,'(A,I5)') |
82 |
cnh |
1.1 |
& 'S/R FIN_PROCS: MPI_FINALIZE return code', |
83 |
|
|
& mpiRC |
84 |
|
|
CALL PRINT_ERROR( msgBuf, 1 ) |
85 |
|
|
ENDIF |
86 |
|
|
C |
87 |
|
|
#ifndef ALWAYS_USE_MPI |
88 |
|
|
ENDIF |
89 |
|
|
#endif |
90 |
|
|
#endif /* ALLOW_USE_MPI */ |
91 |
|
|
|
92 |
|
|
|
93 |
|
|
RETURN |
94 |
|
|
END |