4 Features of the GENERIC Utility

 4.1 The KERNEL Tokens
 4.2 The ASTERIX Tokens
 4.3 The Local CHARACTER Size
 4.4 The Fortran Maximum Record Length

4.1 The KERNEL Tokens

The following tokens are recognised by the GENERIC utility:

<T >

To be replaced by a single character representation of the specified type.

<TYPE >

To be replaced by the string used to declare variables of the specified type when they are passed as arguments to the subroutine.

<LTYPE >

To be replaced by the string used to declare variables of the specified type when they are defined as local variables in the subroutine.

<CONST >

To be replaced by the string appended to numeric constants of the specified type.

<HTYPE >

To be replaced by the HDS name for the specified type.

<COMM >

To be replaced by a comment describing the specified type in plain English.

A full table of the translation of these tokens for each variable type is given in Appendix A at the end of this document.

4.2 The ASTERIX Tokens

As well as the kernel tokens, there are an additional set of tokens which will be translated if the -a option is specified with the GENERIC command (see below).

These tokens are available to allow GENERIC to process existing ASTERIX software (SUN/98) which uses them. They are not recommended for use by new software. A list of the ASTERIX tokens is given in Appendix A.

4.3 The Local CHARACTER Size

The <LTYPE> token is used for declaring a variable which is local to the subroutine in which it is used, whereas <TYPE> is used to declare a variable which is passed to the routine as an argument. In practice, the translation for both of these tokens is identical for all types except CHARACTER.

In the CHARACTER type, a variable passed as an argument is declared CHARACTER*(*), but a local variable is declared CHARACTER*<CHASIZ>. <CHASIZ> is replaced by the “local character size.” If not told otherwise, GENERIC will replace <CHASIZ> by 200, making local character variables CHARACTER*200.

It is possible to override this default character size if it is unsuitable. You can define the environment4 variable GENERIC_CHASIZ or you can use the -c flag on the generic command.

4.4 The Fortran Maximum Record Length

The GENERIC utility assumes it is dealing with Fortran 77 source code which cannot go beyond column 72. If the substitution of a token results in a line becoming longer than 72 characters, it will be broken automatically at column 72 and continued on the next line, using a “:” continuation character in column 6 of the next line.

It is recommended that source lines in generic routines be kept well below 72 characters in length to prevent this from happening.

NOTE: Comment lines ( i.e. those beginning ‘C’, ‘c’, ‘D’, ‘d’ or ‘*’) which are longer than 72 characters are unaltered by GENERIC. So are lines of code with an in-line comment ( i.e. those containing a “!” character).

This algorithm is not perfect and it is possible to fool it with end of line comments on long lines or exclamation marks in character strings. However, this seems not to have proven a problem in practice.