19.5.5. Output Routines

19.5.5.1. MESAGE

      SUBROUTINE MESAGE (COMMAND, MESSAGE)
      CHARACTER*(*) COMMAND, MESSAGE (input)

This subroutine writes the character string MESSAGE. This character string can be written directly to the output file (that is, to standard output), or it can be written into a buffer, which may later be emptied into the output file.

The character string COMMAND determines exactly what is done with MESSAGE.

Usually, COMMAND will be set to ’WRITE’ or ’WRITE-ASIS’. In that case, MESSAGE is written directly to the output file.

COMMAND = ’WRITE’ indicates that MESSAGE will be rearranged to remove redundant spaces, and (if possible) to ensure that no word is broken at the end of a record.

COMMAND = ’WRITE-ASIS’ means that MESSAGE will be written without rearrangement, except that an end-of-record is inserted every LENREC characters. Each call to MESAGE for ’WRITE’ or ’WRITE-ASIS’ starts a new record in the output file.

The buffer has a capacity of 4096 characters. Once it becomes full, any further writes to the buffer will be ignored, until it has been emptied or written to the output file.

Setting COMMAND to be ’BUFF’ or ’BUFF-ASIS’ causes MESSAGE to be written into the buffer (and not the output file).

COMMAND = ’BUFF’ asks for MESSAGE to be rearranged to remove redundant spaces.

COMMAND = ’BUFF-ASIS’ just writes MESSAGE into the buffer without rearrangement.

Each of these calls to MESAGE does not generally insert an end-of-record; when the buffer is finally written to the output file, only the LENREC character-record length is used to determine where records end. However, it is possible to forcibly insert an end-of-record into the buffer, by calling MESAGE with COMMAND = ’BUFF-NL’. For this call the contents of MESSAGE are ignored.

To write the buffer contents to the output file, and empty the buffer, just call MESAGE with COMMAND = ’BUFF-OUT’. Wherever possible, spaces will be inserted to ensure that no word is broken by an end-of-record. MESSAGE will be ignored in this call.

To empty the buffer without writing the contents to the output file, simply set COMMAND = ’BUFF-DEL’. Again, MESSAGE is ignored for this value of COMMAND.

Any other value for COMMAND is treated as ’WRITE’.

Note that the character handling functions described can be used to put numbers into a message. For example:

      CALL MESAGE( 'WRITE', 'Max Temp is '//CFROMR(TMAX)//’ at vertex’//
     & CFROMI(IVX))

For details, see Character Handling.

19.5.5.2. ERRMSG

This routine is used to print out error messages. Output can be buffered to enable the message to be gathered from various substrings.

      SUBROUTINE ERRMSG(MESSAGE)
      CHARACTER*(*) MESSAGE:- Message string to be output directly or buffered.

Simple strings will be written directly. If the first three characters of the message are ‘*B*’ then the following calls to ERRMSG will not output any message but will copy the strings into a buffer. The buffer will be output when a string is passed to ERRMSG with the characters ‘*E*’ as the last three characters. The following sets of calls all produce the same message:

      CALL ERRMSG(‘My name is ‘ // first_name // last_name)
      CALL ERRMSG(‘*B*My name is ‘)
      CALL ERRMSG(first_name)
      CALL ERRMSG(last_name //’*E*’)
      CALL ERRMSG(‘*B*’)
      CALL ERRMSG(‘My name is ‘)
      CALL ERRMSG(first_name)
      CALL ERRMSG(last_name)
      CALL ERRMSG(‘*E*’)

When using the buffer facility, it is strongly recommended that the ‘*B*’ and ‘*E*’ strings be passed as separate calls to ERRMSG as in the last example. Note that the first example might be illegal Fortran if either of the string variables first_name or last_name were declared to be of length *(*) and the second would be illegal if last_name was declared *(*).