CALL MSG_SETR( 'FLUX', FLUX ) CALL MSG_OUT( 'EXAMPLE_RESULT', : 'Emission flux is ^FLUX (erg/cm2/A/s).', : STATUS )
Here, the subroutine MSG_SETR is called to define a token named ``FLUX''
and assign to it the value of the REAL variable FLUX encoded as a character
string.
The token name, immediately preceded by the up-arrow, ``'', escape
character is then included in the given message text.
As the given text is processed, the token is expanded to the string assigned to
the token.
For example, If the variable FLUX in this example has the value 2.4, then the message output to the terminal would be:
Emission flux is 2.4 (erg/cm2/A/s).
There is a set of MSG_SETx subroutines, one subroutine for each of five standard Fortran 77 data types (the Fortran type COMPLEX has not been provided for). Here, x corresponds to the Fortran data type of the value to be assigned to the named message token:
x | Fortran Type |
---|---|
D | DOUBLE PRECISION |
R | REAL |
I | INTEGER |
L | LOGICAL |
C | CHARACTER |
In each case, the calling sequence is of the form:
CALL MSG_SETx( TOKEN, VALUE )
where TOKEN is a character string giving the name chosen by the user and VALUE is a variable or constant of the appropriate type. The numeric subroutines, MSG_SETD, MSG_SETR and MSG_SETI, adopt the most concise format that will represent the value by removing trailing zeros, leading and trailing blanks, and by avoiding the use of exponential notation unless it is necessary. MSG_SETL uses TRUE or FALSE according to the value it is given. MSG_SETC removes trailing blanks from the character string; leading blanks are not removed.
An additional feature of the MSG_SETx routines is that calls to these routines using an existing token will result in the value being appended to the previously assigned token string. Here is the previous example written to exploit this feature of the MSG_SETx routines:
* Local Constants: CHARACTER FUNITS * 12 PARAMETER( FUNITS = ' erg/cm2/A/s' ) ... CALL MSG_SETR( 'FLUX', FLUX ) CALL MSG_SETC( 'FLUX', FUNITS ) CALL MSG_OUT( 'EXAMPLE_RESULT', : 'Emission flux is ^FLUX.', STATUS )
where the CHARACTER variable FUNITS has been assigned the value of an appropriate unit of flux (e.g. erg/cm2/A/s) earlier in the program. Note that repeated calls to the MSG_SETx routines will append values to the token string with no separator, hence a leading space in the FUNITS string is needed to separate the flux value and its units in the expanded message.
The text string associated with a message token (i.e. the token value) may be up to 200 characters long. Token names may be up to 15 characters long and should be valid names: i.e. they should begin with an alphabetic character and continue with alphanumeric or underscore characters. A maximum of 64 uniquely named message tokens may be included in any output message.
No message tokens are defined initially and after each call to MSG_OUT, MSG_OUTIF or MSG_LOAD (or a corresponding ERR routine) all existing tokens are left undefined.
MERS (MSG and ERR) Message and Error Reporting Systems