XERMSG Subroutine

subroutine XERMSG(LIBRAR, SUBROU, MESSG, NERR, LEVEL)

BEGIN PROLOGUE XERMSG PURPOSE Process error messages for SLATEC and other libraries. LIBRARY SLATEC (XERROR) CATEGORY R3C TYPE ALL (XERMSG-A) KEYWORDS ERROR MESSAGE, XERROR AUTHOR Fong, Kirby, (NMFECC at LLNL) DESCRIPTION

XERMSG processes a diagnostic message in a manner determined by the value of LEVEL and the current value of the library error control flag, KONTRL. See subroutine XSETF for details.

LIBRAR   A character constant (or character variable) with the name
     of the library.  This will be 'SLATEC' for the SLATEC
     Common Math Library.  The error handling package is
     general enough to be used by many libraries
     simultaneously, so it is desirable for the routine that
     detects and reports an error to identify the library name
     as well as the routine name.

SUBROU   A character constant (or character variable) with the name
         of the routine that detected the error.  Usually it is the
     name of the routine that is calling XERMSG.  There are
     some instances where a user callable library routine calls
     lower level subsidiary routines where the error is
     detected.  In such cases it may be more informative to
     supply the name of the routine the user called rather than
     the name of the subsidiary routine that detected the
     error.

MESSG    A character constant (or character variable) with the text
     of the error or warning message.  In the example below,
     the message is a character constant that contains a
     generic message.

           CALL XERMSG ('SLATEC', 'MMPY',
          *'THE ORDER OF THE MATRIX EXCEEDS THE ROW DIMENSION',
          *3, 1)

     It is possible (and is sometimes desirable) to generate a
     specific message--e.g., one that contains actual numeric
     values.  Specific numeric values can be converted into
     character strings using formatted WRITE statements into
     character variables.  This is called standard Fortran
     internal file I/O and is exemplified in the first three
     lines of the following example.  You can also catenate
     substrings of characters to construct the error message.
     Here is an example showing the use of both writing to
     an internal file and catenating character strings.

           CHARACTER*5 CHARN, CHARL
           WRITE (CHARN,10) N
           WRITE (CHARL,10) LDA
        10 FORMAT(I5)
           CALL XERMSG ('SLATEC', 'MMPY', 'THE ORDER'//CHARN//
          *   ' OF THE MATRIX EXCEEDS ITS ROW DIMENSION OF'//
          *   CHARL, 3, 1)

     There are two subtleties worth mentioning.  One is that
     the // for character catenation is used to construct the
     error message so that no single character constant is
     continued to the next line.  This avoids confusion as to
     whether there are trailing blanks at the end of the line.
     The second is that by catenating the parts of the message
         as an actual argument rather than encoding the entire
     message into one large character variable, we avoid
     having to know how long the message will be in order to
     declare an adequate length for that large character
     variable.  XERMSG calls XERPRN to print the message using
     multiple lines if necessary.  If the message is very long,
     XERPRN will break it into pieces of 72 characters (as
     requested by XERMSG) for printing on multiple lines.
     Also, XERMSG asks XERPRN to prefix each line with ' *  '
     so that the total line length could be 76 characters.
     Note also that XERPRN scans the error message backwards
     to ignore trailing blanks.  Another feature is that
     the substring '$$' is treated as a new line sentinel
     by XERPRN.  If you want to construct a multiline
     message without having to count out multiples of 72
     characters, just use '$$' as a separator.  '$$'
     obviously must occur within 72 characters of the
     start of each line to have its intended effect since
     XERPRN is asked to wrap around at 72 characters in
     addition to looking for '$$'.

NERR     An integer value that is chosen by the library routine's
     author.  It must be in the range -99 to 999 (three
     printable digits).  Each distinct error should have its
     own error number.  These error numbers should be described
     in the machine readable documentation for the routine.
     The error numbers need be unique only within each routine,
     so it is reasonable for each routine to start enumerating
     errors from 1 and proceeding to the next integer.

LEVEL    An integer value in the range 0 to 2 that indicates the
     level (severity) of the error.  Their meanings are

    -1  A warning message.  This is used if it is not clear
        that there really is an error, but the user's attention
        may be needed.  An attempt is made to only print this
        message once.

     0  A warning message.  This is used if it is not clear
        that there really is an error, but the user's attention
        may be needed.

     1  A recoverable error.  This is used even if the error is
        so serious that the routine cannot return any useful
        answer.  If the user has told the error package to
        return after recoverable errors, then XERMSG will
        return to the Library routine which can then return to
        the user's routine.  The user may also permit the error
        package to terminate the program upon encountering a
        recoverable error.

     2  A fatal error.  XERMSG will not return to its caller
        after it receives a fatal error.  This level should
        hardly ever be used; it is much better to allow the
        user a chance to recover.  An example of one of the few
        cases in which it is permissible to declare a level 2
        error is a reverse communication Library routine that
        is likely to be called repeatedly until it integrates
        across some interval.  If there is a serious error in
        the input such that another step cannot be taken and
        the Library routine is called again without the input
        error having been corrected by the caller, the Library
        routine will probably be called forever with improper
        input.  In this case, it is reasonable to declare the
        error to be fatal.

Each of the arguments to XERMSG is input; none will be modified by
XERMSG.  A routine may make multiple calls to XERMSG with warning
level messages; however, after a call to XERMSG with a recoverable
error, the routine should return to the user.  Do not try to call
XERMSG with a second recoverable error after the first recoverable
error because the error package saves the error number.  The user
can retrieve this error number by calling another entry point in
the error handling package and then clear the error number when
recovering from the error.  Calling XERMSG in succession causes the
old error number to be overwritten by the latest error number.
This is considered harmless for error numbers associated with
warning messages but must not be done for error numbers of serious
errors.  After a call to XERMSG with a recoverable error, the user
must be given a chance to call NUMXER or XERCLR to retrieve or
clear the error number.

REFERENCES R. E. Jones and D. K. Kahaner, XERROR, the SLATEC Error-handling Package, SAND82-0800, Sandia Laboratories, 1982. ROUTINES CALLED FDUMP, J4SAVE, XERCNT, XERHLT, XERPRN, XERSVE REVISION HISTORY (YYMMDD) 880101 DATE WRITTEN 880621 REVISED AS DIRECTED AT SLATEC CML MEETING OF FEBRUARY 1988. THERE ARE TWO BASIC CHANGES. 1. A NEW ROUTINE, XERPRN, IS USED INSTEAD OF XERPRT TO PRINT MESSAGES. THIS ROUTINE WILL BREAK LONG MESSAGES INTO PIECES FOR PRINTING ON MULTIPLE LINES. '' IN XERPRN TO HANDLE BLANK LINES SIMILAR TO THE WAY FORMAT STATEMENTS HANDLE THE / CHARACTER FOR NEW RECORDS. 890706 REVISED WITH THE HELP OF FRED FRITSCH AND REG CLEMENS TO CLEAN UP THE CODING. 890721 REVISED TO USE NEW FEATURE IN XERPRN TO COUNT CHARACTERS IN PREFIX. 891013 REVISED TO CORRECT COMMENTS. 891214 Prologue converted to Version 4.0 format. (WRB) 900510 Changed test on NERR to be -9999999 < NERR < 99999999, but NERR .ne. 0, and on LEVEL to be -2 < LEVEL < 3. Added LEVEL=-1 logic, changed calls to XERSAV to XERSVE, and XERCTL to XERCNT. (RWC) 920501 Reformatted the REFERENCES section. (WRB) END PROLOGUE XERMSG

Arguments

Type IntentOptional Attributes Name
character(len=*) :: LIBRAR
character(len=*) :: SUBROU
character(len=*) :: MESSG
integer :: NERR
integer :: LEVEL

Calls

proc~~xermsg~~CallsGraph proc~xermsg XERMSG proc~xerhlt XERHLT proc~xermsg->proc~xerhlt proc~xersve XERSVE proc~xermsg->proc~xersve proc~fdump FDUMP proc~xermsg->proc~fdump proc~xerprn XERPRN proc~xermsg->proc~xerprn proc~xercnt XERCNT proc~xermsg->proc~xercnt proc~xgetua XGETUA proc~xersve->proc~xgetua proc~xerprn->proc~xgetua

Called by

proc~~xermsg~~CalledByGraph proc~xermsg XERMSG proc~chfev CHFEV proc~chfev->proc~xermsg proc~pchdf PCHDF proc~pchdf->proc~xermsg proc~pchsp PCHSP proc~pchsp->proc~xermsg proc~pchfe PCHFE proc~pchfe->proc~xermsg proc~pchfe->proc~chfev proc~pchsp_95 pchsp_95 proc~pchsp_95->proc~pchsp proc~pchfe_95 PCHFE_95 proc~pchfe_95->proc~pchfe

Contents