SURFEX v8.1
General documentation of Surfex
mpl_message_mod.F90
Go to the documentation of this file.
2 
3 !**** MPL_MESSAGE - Prints message
4 
5 ! Purpose.
6 ! --------
7 ! Creates an ASCII message for printing and optionally aborts
8 
9 !** Interface.
10 ! ----------
11 ! CALL MPL_MESSAGE
12 
13 ! Input required arguments :
14 ! -------------------------
15 ! CDMESSAGE- character string for message
16 
17 ! Input optional arguments :
18 ! -------------------------
19 ! KERROR - Error number
20 ! CDSTRING - Optional additional message
21 ! prepended to CDMESSAGE
22 ! LDABORT - forces ABORT if true
23 
24 ! Output required arguments :
25 ! -------------------------
26 ! none
27 
28 ! Output optional arguments :
29 ! -------------------------
30 ! none
31 ! Author.
32 ! -------
33 ! D.Dent, M.Hamrud ECMWF
34 
35 ! Modifications.
36 ! --------------
37 ! Original: 2000-09-01
38 
39 ! ------------------------------------------------------------------
40 
41 USE mpl_mpif
43 USE mpl_abort_mod
44 
45 USE parkind1 ,ONLY : jpim ,jprb
46 
47 PRIVATE
48 
49 PUBLIC mpl_message
50 
51 CONTAINS
52 
53 SUBROUTINE mpl_message(KERROR,CDMESSAGE,CDSTRING,LDABORT)
54 
55 
56 #ifdef USE_8_BYTE_WORDS
57  USE mpi4to8, ONLY : &
58  mpi_error_string => mpi_error_string8
59 #endif
60 
61 
62 IMPLICIT NONE
63 
64 INTEGER(KIND=JPIM),INTENT(IN),OPTIONAL :: KERROR
65 CHARACTER*(*),INTENT(IN) :: CDMESSAGE
66 CHARACTER*(*),INTENT(IN),OPTIONAL :: CDSTRING
67 LOGICAL ,INTENT(IN),OPTIONAL :: LDABORT
68 
69 CHARACTER*(MPI_MAX_ERROR_STRING) :: CLMPI_ERROR
70 CHARACTER*10 :: CLERROR
71 INTEGER(KIND=JPIM) :: IRESULTLEN,IERROR
72 
73 IF(PRESENT(kerror)) THEN
74  WRITE(clerror,'(I10)') kerror
75 ELSE
76  clerror=' '
77 ENDIF
78 IF(PRESENT(cdstring)) THEN
79  WRITE(mpl_unit,'(4A,I8)') cdstring,cdmessage,clerror, &
80  & ' FROM PROCESSOR ',mpl_rank
81 ELSE
82  WRITE(mpl_unit,'(3A,I8)') cdmessage,clerror, &
83  & ' FROM PROCESSOR ',mpl_rank
84 ENDIF
85 
86 IF(PRESENT(kerror)) THEN
87  CALL mpi_error_string(kerror,clmpi_error,iresultlen,ierror)
88  WRITE(mpl_unit,'(2A,I8)') clmpi_error(1:iresultlen),' in process ',mpl_rank
89 ELSE
90  clmpi_error=' '
91  iresultlen=1
92 ENDIF
93 
94 IF(PRESENT(ldabort)) THEN
95  IF(ldabort) THEN
96  WRITE(0,'(2A,I8)') clmpi_error(1:iresultlen),' in process ',mpl_rank
97  CALL mpl_abort('ABORT')
98  ENDIF
99 ENDIF
100 RETURN
101 END SUBROUTINE mpl_message
102 
103 END MODULE mpl_message_mod
subroutine, public mpl_message(KERROR, CDMESSAGE, CDSTRING, LDABORT)
integer, parameter jpim
Definition: parkind1.F90:13
subroutine, public mpl_abort(CDMESSAGE)
integer, parameter jprb
Definition: parkind1.F90:32
integer(kind=jpim) mpl_rank
integer(kind=jpim) mpl_unit