5 Using the GENERIC Utility

The GENERIC utility is executed by typing the following command:

  % generic [-t <types>] [-a] [-c <chasiz>] [-s] [-sc <char>] [-u] [-x]
             file1 [file2...]}

Arguments in square brackets are optional and items in angle brackets are descriptive terms for the actual string that would be given. The simplest form of the generic command is:

  % generic prog.gen

which will produce a file called prog.f containing routines for all of the supported data types. Likewise for C

  % generic prog.cgen

will create a file prog.c.

A softlink called fgeneric is also provided to avoid a clash with the IRAF generic preprocessor.

All generic input Fortran files must have a suffix of .gen, or .g<types> where <types> is a list of data types (see option -t below for a list). The latter was introduced to simplify building using GNU tools, and is the recommended naming convention. For C files the file extension should be .cgen.

You can specify multiple input files explicitly or with wild cards. All output Fortran files have a suffix of .f, and output C files have suffix .c.

The generic command accepts the following command-line options.

-t
This must be followed by a list of the data types to be processed. The list should be separated from the -t by a space, and should consist of one or more of the letters a, b, B, c, d, i, l, n, r, w or W. The letters have the following meanings:
a all data types
b BYTE
B unsigned BYTE
c CHARACTER
d DOUBLE PRECISION
i INTEGER
l LOGICAL
n all numeric types (i.e. everything except CHARACTER and LOGICAL)
r REAL
w WORD (i.e. INTEGER*2)
W unsigned WORD

For example, to generate routines for all of the standard Fortran numeric data types, type the command:

  % generic -t dir prog.gen

(Using n instead of dir would generate byte and word versions as well.)

-c
This should be followed by a space and then an integer giving the value of the local character size required. The default value is 200. This value can be specified by the environment variable GENERIC_CHASIZ. If GENERIC_CHASIZ is defined and the -c argument is present, the -c argument takes precedence.
-s
Generate the output in separate files for each data type with the single character type specifier appended to the base name of the file. The default is to generate one output file for each input file. For example, if the input file is sub1.gen and the -t flag is set to dir, then specifying the -s flag will cause output files called sub1d.f, sub1i.f and sub1r.f to be generated. This option is provided as it is usual on Unix systems to have all Fortran routines in separate source files.
-sc
This flag allows the user to specify one or more characters that will be used to separate the base file name from the appended character when generating separate output files for each data type. The -sc should be followed by a space and then the character(s) to be used as the separator. For example, the command:
  % generic -t dir -sc _ func2.gen

will generate files called func2_d.f, func2_i.f and func2_r.f. If the -sc flag is given, then the -s flag can be omitted.

-a
This will cause the ASTERIX tokens to be interpreted as well as the standard ones. Its use is deprecated.
-u
The B and W types substitute ub and uw tokens respectively in the code and in generated filenames. This is for compability with the original VMS version when most generic routines were developed. However, note that the -t values of BW should still be used to obtain unsigned byte and unsigned-word instantiations.
-x
Removes the last x from the file name before generating the names of the output files. This is provided for compatability with early generic files in the VMS era files that had a final x in the name to indicate where the token would be replaced in the instantiated files. In modern usage the trailing x is absent, and this option is not required.

It is possible to specify the list of data types to be processed and the local character size by setting environment variables GENERIC_TYPES and GENERIC_CHASIZ, e.g.

  % setenv GENERIC_TYPES cdilr
  % setenv GENERIC_CHASIZ 300