1 |
jmc |
1.3 |
C $Header: /u/gcmpack/MITgcm/eesupp/src/all_proc_die.F,v 1.2 2009/06/18 22:38:37 jmc Exp $ |
2 |
jmc |
1.1 |
C $Name: $ |
3 |
|
|
|
4 |
|
|
#include "CPP_EEOPTIONS.h" |
5 |
|
|
|
6 |
|
|
CBOP |
7 |
|
|
C !ROUTINE: ALL_PROC_DIE |
8 |
|
|
|
9 |
|
|
C !INTERFACE: |
10 |
|
|
SUBROUTINE ALL_PROC_DIE( myThid ) |
11 |
|
|
|
12 |
|
|
C !DESCRIPTION: |
13 |
|
|
C *==========================================================* |
14 |
|
|
C | SUBROUTINE ALL_PROC_DIE |
15 |
|
|
C | o when all process call this routine, die cleanly: |
16 |
|
|
C | set Error-Flag and call MPI finalise |
17 |
|
|
C *==========================================================* |
18 |
|
|
C | used before a STOP: |
19 |
|
|
C | - Only implemented for MPI multi-proc. |
20 |
|
|
C | - if some Proc do not call this S/R, MPI will hang. |
21 |
|
|
C *==========================================================* |
22 |
|
|
|
23 |
|
|
C !USES: |
24 |
|
|
IMPLICIT NONE |
25 |
|
|
|
26 |
|
|
C == Global variables == |
27 |
|
|
#include "SIZE.h" |
28 |
|
|
#include "EEPARAMS.h" |
29 |
|
|
#include "EESUPPORT.h" |
30 |
|
|
|
31 |
|
|
C !INPUT/OUTPUT PARAMETERS: |
32 |
|
|
C myThid :: my Thread Id number |
33 |
|
|
INTEGER myThid |
34 |
|
|
CEOP |
35 |
|
|
|
36 |
|
|
C !FUNCTIONS |
37 |
|
|
INTEGER ILNBLNK |
38 |
|
|
EXTERNAL ILNBLNK |
39 |
|
|
|
40 |
|
|
C == Local variables == |
41 |
|
|
C msgBuf :: I/O Buffer |
42 |
|
|
CHARACTER*(MAX_LEN_MBUF) msgBuf |
43 |
|
|
#ifdef ALLOW_USE_MPI |
44 |
|
|
C mpiRC :: Error code reporting variable used with MPI. |
45 |
|
|
INTEGER mpiRC |
46 |
|
|
#endif /* ALLOW_USE_MPI */ |
47 |
|
|
|
48 |
|
|
C-- Print message |
49 |
|
|
WRITE(msgBuf,'(A)') 'S/R ALL_PROC_DIE: ending the run' |
50 |
|
|
CALL PRINT_ERROR( msgBuf, myThid ) |
51 |
|
|
|
52 |
|
|
C-- Finishes |
53 |
|
|
eeEndError = .TRUE. |
54 |
|
|
fatalError = .TRUE. |
55 |
|
|
#ifdef ALLOW_USE_MPI |
56 |
|
|
#ifndef ALWAYS_USE_MPI |
57 |
|
|
IF ( usingMPI ) THEN |
58 |
|
|
#endif |
59 |
jmc |
1.3 |
C better to avoid this call if multi-components set-up ; otherwise will |
60 |
|
|
C hang here since procs of other comp. are not calling MPI_finalize now. |
61 |
|
|
IF ( .NOT.( useCoupler |
62 |
|
|
& .OR. useNEST_PARENT |
63 |
|
|
& .OR. useNEST_CHILD ) |
64 |
|
|
& ) THEN |
65 |
jmc |
1.1 |
CALL MPI_FINALIZE ( mpiRC ) |
66 |
|
|
IF ( mpiRC .NE. MPI_SUCCESS ) THEN |
67 |
|
|
WRITE(msgBuf,'(A,I5)') |
68 |
|
|
& 'S/R FIN_PROCS: MPI_FINALIZE return code', mpiRC |
69 |
|
|
CALL PRINT_ERROR( msgBuf, myThid ) |
70 |
|
|
ENDIF |
71 |
jmc |
1.3 |
ENDIF |
72 |
jmc |
1.1 |
#ifndef ALWAYS_USE_MPI |
73 |
|
|
ENDIF |
74 |
|
|
#endif |
75 |
|
|
#endif /* ALLOW_USE_MPI */ |
76 |
|
|
|
77 |
|
|
RETURN |
78 |
|
|
END |