1 |
C $Header: $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "CPP_EEOPTIONS.h" |
5 |
|
6 |
CBOP |
7 |
C !ROUTINE: STOP_IF_ERROR |
8 |
|
9 |
C !INTERFACE: |
10 |
SUBROUTINE STOP_IF_ERROR( errFlag, errMsg, myThid ) |
11 |
|
12 |
C !DESCRIPTION: |
13 |
C *==========================================================* |
14 |
C | SUBROUTINE STOP_IF_ERROR |
15 |
C | o stop every Processes if flag is true |
16 |
C *==========================================================* |
17 |
C | Presently, gathering of error signal involves a |
18 |
C | global_sum which could degrade performance if called too |
19 |
C | many times. A potentially faster method (not implemented): |
20 |
C | only the proc(s) in error send a non-blocking error signal |
21 |
C | to everybody; however, this requires to check for error |
22 |
C | signal reception before doing any communication. |
23 |
C *==========================================================* |
24 |
|
25 |
C !USES: |
26 |
IMPLICIT NONE |
27 |
|
28 |
C == Global variables == |
29 |
#include "SIZE.h" |
30 |
#include "EEPARAMS.h" |
31 |
#include "EESUPPORT.h" |
32 |
|
33 |
C !INPUT/OUTPUT PARAMETERS: |
34 |
C errFlag :: stop if this logical flag is true |
35 |
C errMsg :: error message to print in case it stops |
36 |
C myThid :: my Thread Id number |
37 |
LOGICAL errFlag |
38 |
CHARACTER*(*) errMsg |
39 |
INTEGER myThid |
40 |
CEOP |
41 |
|
42 |
C !FUNCTIONS |
43 |
INTEGER ILNBLNK |
44 |
EXTERNAL ILNBLNK |
45 |
|
46 |
C == Local variables == |
47 |
C msgBuf :: I/O Buffer |
48 |
C errCount :: error counter |
49 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
50 |
INTEGER errCount |
51 |
#ifdef ALLOW_USE_MPI |
52 |
C mpiRC :: Error code reporting variable used with MPI. |
53 |
INTEGER mpiRC |
54 |
#endif /* ALLOW_USE_MPI */ |
55 |
|
56 |
C-- Collect error from all Threads and Procs |
57 |
errCount = 0 |
58 |
IF ( errFlag ) THEN |
59 |
errCount = 1 |
60 |
ENDIF |
61 |
CALL GLOBAL_SUM_INT( errCount, myThid ) |
62 |
|
63 |
IF ( errCount.GE.1 ) THEN |
64 |
C-- Print message |
65 |
IF ( errFlag ) CALL PRINT_ERROR( errMsg, myThid ) |
66 |
WRITE(msgBuf,'(A,I5,A)') |
67 |
& 'occurs', errCount, ' time(s) among all Threads and Procs' |
68 |
CALL PRINT_ERROR( msgBuf, myThid ) |
69 |
C-- Finishes |
70 |
eeEndError = .TRUE. |
71 |
fatalError = .TRUE. |
72 |
#ifdef ALLOW_USE_MPI |
73 |
#ifndef ALWAYS_USE_MPI |
74 |
IF ( usingMPI ) THEN |
75 |
#endif |
76 |
CALL MPI_FINALIZE ( mpiRC ) |
77 |
IF ( mpiRC .NE. MPI_SUCCESS ) THEN |
78 |
WRITE(msgBuf,'(A,I5)') |
79 |
& 'S/R FIN_PROCS: MPI_FINALIZE return code', mpiRC |
80 |
CALL PRINT_ERROR( msgBuf, myThid ) |
81 |
ENDIF |
82 |
#ifndef ALWAYS_USE_MPI |
83 |
ENDIF |
84 |
#endif |
85 |
#endif /* ALLOW_USE_MPI */ |
86 |
STOP 'ABNORMAL END: S/R STOP_IF_ERROR' |
87 |
ENDIF |
88 |
|
89 |
RETURN |
90 |
END |