1 |
C $Header: /u/gcmpack/models/MITgcmUV/eesupp/src/eedie.F,v 1.4 1999/05/18 17:39:21 adcroft Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "CPP_EEOPTIONS.h" |
5 |
|
6 |
CStartOfInterface |
7 |
SUBROUTINE EEDIE |
8 |
C /==========================================================\ |
9 |
C | SUBROUTINE EEDIE | |
10 |
C | o Close execution "environment", particularly perform | |
11 |
C | steps to terminate parallel processing. | |
12 |
C |==========================================================| |
13 |
C | Note: This routine can also be compiled with CPP | |
14 |
C | directives set so that no multi-processing is initialised| |
15 |
C | This is OK and should work fine. | |
16 |
C \==========================================================/ |
17 |
IMPLICIT NONE |
18 |
|
19 |
C == Global variables == |
20 |
#include "SIZE.h" |
21 |
#include "EEPARAMS.h" |
22 |
#include "EESUPPORT.h" |
23 |
CEndOfInterface |
24 |
|
25 |
C == Local variables == |
26 |
C msgBuf - I/O Buffer |
27 |
C nThreadsDone - Used to count number of completed threads. |
28 |
C I - Loop counter. |
29 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
30 |
INTEGER nThreadsDone |
31 |
INTEGER I |
32 |
#ifdef ALLOW_USE_MPI |
33 |
C mpiRC - Error code reporting variable used |
34 |
C with MPI. |
35 |
INTEGER mpiRC |
36 |
#endif /* ALLOW_USE_MPI */ |
37 |
|
38 |
C-- Check that all the threads have ended |
39 |
C No thread should reach this loop before all threads have set |
40 |
C threadIsComplete to TRUE. If they do then either there is a bug |
41 |
C in the code or the behaviour of the parallel compiler directives |
42 |
C are not right for this code. In the latter case different |
43 |
C directives may be available or the compiler itself may have a |
44 |
C bug or you may need a different parallel compiler for main.F |
45 |
nThreadsDone = 0 |
46 |
DO I = 1, nThreads |
47 |
IF ( threadIsComplete(I) ) nThreadsDone = nThreadsDone+1 |
48 |
ENDDO |
49 |
IF ( nThreadsDone .LT. nThreads ) THEN |
50 |
WRITE(msgBuf,'(A,I5,A,I5,A)') |
51 |
& 'S/R EEDIE: Only ',nThreadsDone, |
52 |
& ' threads have completed, ',nThreads, |
53 |
& ' are expected for this configuration!' |
54 |
WRITE(0,*) msgBuf |
55 |
WRITE(0,*) |
56 |
& 'Possibly you have different setenv PARALLEL and nThreads?' |
57 |
eeEndError = .TRUE. |
58 |
fatalError = .TRUE. |
59 |
ENDIF |
60 |
|
61 |
#ifdef ALLOW_USE_MPI |
62 |
C-- |
63 |
C-- MPI style multiple-process termination |
64 |
C-- ====================================== |
65 |
#ifndef ALWAYS_USE_MPI |
66 |
IF ( usingMPI ) THEN |
67 |
#endif |
68 |
CALL MPI_FINALIZE ( mpiRC ) |
69 |
IF ( mpiRC .NE. MPI_SUCCESS ) THEN |
70 |
eeEndError = .TRUE. |
71 |
fatalError = .TRUE. |
72 |
WRITE(msgBuf,'(A,I5)') |
73 |
& 'S/R FIN_PROCS: MPI_FINALIZE return code', |
74 |
& mpiRC |
75 |
CALL PRINT_ERROR( msgBuf, 1 ) |
76 |
ENDIF |
77 |
C |
78 |
#ifndef ALWAYS_USE_MPI |
79 |
ENDIF |
80 |
#endif |
81 |
#endif /* ALLOW_USE_MPI */ |
82 |
|
83 |
|
84 |
RETURN |
85 |
END |