Table of Contents

Previous: -list

Option: makedcls

Prepare a neatly-formatted file of declarations of variables, common blocks, and namelist lists, for possible merging into the source code. The declarations are stored in a file of the same name as the source code, but with the extension changed to .dcl. If no declarations are written to the file, it is deleted to reduce clutter from empty files.

If input comes from standard input, instead of a named file, then declarations are written to standard output.

Variables are declared in alphabetical order within each declaration class and type, with integer variables first, because of their later possible use in array dimensions.

PARAMETER statements are an exception to the alphabetical order rule, because the Fortran 77 Standard requires that the expressions defining parameter values refer only to constants and already-defined parameter names. This forces the original source file order of such statements to be preserved in the declaration files.

Explicit declaration of all variables is considered good modern programming practice. By using compiler options to reject undeclared variables, misspelled variable names (or names extending past column 72) can be caught at compile time. Explicit declarations also greatly facilitate changing floating-point precision with filters such as dtoq(1L), dtos(1L), fd2s(1L), fs2d(1L), qtod(1L), and stod(1L). These programs are capable of changing types of explicit floating-point type declarations, intrinsic functions, and constants, but because they do not carry out rigorous lexical and grammatical analysis of the Fortran source code, they cannot provide modified type declarations for undeclared variables. Default setting = 0, turn-on = 1.

Various options for the form of the declarations file are controlled by the list, which consists of keywords separated by commas or colons. There are three special keywords: all to turn on all the options, none to turn them all off, and help to print the list of all the keywords with a brief explanation of each. If list is omitted, -makedcls is equivalent to -makedcls=declarations (i.e. produce the declarations file using the default options), and -nomakedcls is equivalent to -makedcls=none.

For compatibility with previous versions of ftnchek, a numeric form of this setting is also accepted: the list is replaced by a number which is the sum of the numbers in parentheses beside the keywords in the following list. The warning keywords with their meanings are as follows:

declarations (1):
Write a declaration file. (This is implied by any of the other options, and can be omitted if any other options are given.)
undeclared-only (2):
By default, all variables are included in the declaration file. With this option, include only undeclared variables. This setting is useful if you want to check for undeclared variables, since Fortran source files with all variables properly declared will not result in a .dcl file. With this option, common blocks and namelist lists will not be included in the declaration file, since by their nature they cannot be undeclared.
compact (4):
The declarations are normally prettyprinted to line up neatly in common columns, as in the declaration files output by the Extended PFORT Verifier, pfort(1L). This option value selects instead compact output, without column alignment.
use-continuation-lines (8):
Causes continuation lines to be used where permissible. The default is to begin a new declaration on each line. This option is appropriate to use together with compact.
keywords-lowercase (16):
Output Fortran keywords in lowercase, instead of the default uppercase.
vars-and-consts-lowercase (32):
Output variables and constants in lowercase, instead of the default uppercase. Character string constants are not affected by this option.
exclude-sftran3 (64):
Omit declarations of internal integer variables produced by the SFTRAN3 preprocessor, xsf3(1L), as part of the translation of structured Fortran statements to ordinary Fortran. These variables have six-character names of the form NPRddd, NXdddd, N2dddd, and N3dddd, where d is a decimal digit. Because they are invisible in the SFTRAN3 source code, and will change if the SFTRAN3 code is modified, such variables should not be explicitly declared. Instead, they should just assume the default Fortran INTEGER data type based on their initial letter, N.
asterisk-comment (128):
Use an asterisk as the comment character; the default is otherwise 'C'.
comment-char-lowercase (256):
Use 'c' instead of 'C' or '*' as the comment character.
suppress-array-dimensions (512):
Suppress dimensioning of arrays in the generated declarations. This option is for use with code lacking type declarations, to allow the declaration files to be inserted without change into the code. Since the code will have dimension statements already, dimensioning the array variables in the type statements of the declaration file is redundant. This option should be used only in conjunction with option 2 = undeclared-only because otherwise any arrays that were dimensioned in a type statement will lose their dimensioning.
free-form (1024):
Produce declarations in free source form. This mode is automatically used if the input source is free form. Use this option to produce declarations in free form even if the input is in fixed form. Free form declarations are indented only 2 columns instead of 6, use the exclamation mark as the comment character, and indicate continuation lines by an ampersand at the end of the line to be continued.

The declaration files contain distinctive comments that mark the start and end of declarations for each program unit, to facilitate using text editor macros for merging the declarations back into the source code.

The ftnchek distribution includes a program, dcl2inc, which processes declaration files to produce files containing declarations of all COMMON blocks, in a form suitable for use as INCLUDE files. See the dcl2inc(1L) man page for the details of its use.

See also: -mkhtml.

Next: -mkhtml