Table of Contents

Previous: -truncation

Option: usage

Warn about unused or possible uninitialized variables, unused common blocks, undefined or unused statement labels, and unused or undefined subprograms. By default, all warnings are turned on.

This setting provides detailed control over the warnings about possible usage errors. The list consists of keywords separated by commas or colons. Since all warnings are on by default, include a keyword prefixed by no- to turn off a particular warning. There are three special keywords: all to turn on all the warnings about usage, 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, -usage is equivalent to -usage=all, and -nousage is equivalent to -usage=none. These warnings cover four main categories of objects: subprogram dummy arguments, common blocks and variables, subprograms and functions, and local variables. Warnings include undefined items, multiply defined items, unused items, etc. The warning keywords with their meanings are as follows:

a scalar dummy argument is actually the same as another and is (or may be) modified. The Fortran 77 standard (section prohibits modifying an argument that is aliased to another.
a dummy argument which is an array or array element is in the same array as another and is modified. This flag is similar to arg-alias but provides separate control over array arguments. It is harder to tell if aliasing is occurring in the case of arrays, so if ftnchek gives too many false warnings, this flag allows the array-related ones to be turned off without suppressing the warnings for scalars.
a scalar dummy argument is the same as a common variable in the subprogram, and either is modified. This is also prohibited by the Fortran 77 standard. If common checking is not exact (see the -common setting), it is harder to tell if aliasing is occurring, so the warning is given if the variable is anywhere in a common block that is declared by the subprogram.
a dummy argument which is an array or array element is in the same array as a common variable, and either is modified. If common checking is not exact, the variable can be anywhere in a common block that is declared by the subprogram.
a subprogram modifies an argument which is a constant or an expression. Such an action could cause anomalous behavior of the program.
a dummy argument is declared but never used. This is similar to the var-unused keyword described below, but applies only to arguments.
a common block is declared but none of the variables in it are used by any subprogram. This warning is suppressed if the common strictness setting is 0.
a common block may lose the definition of its contents if common blocks are volatile. This option only has an effect if the -common=volatile flag is in effect. See the discussion of the -common setting above.
a common variable is assigned a value, but its value is not used by any subprogram. This warning is suppressed if the common strictness setting is 0.
a common variable's value is used in some subprogram, but is not set anywhere. Unfortunately, ftnchek does not do a thorough enough analysis of the calling sequence to know which routines are called before others. So warnings about this type of error will only be given for cases in which a variable is used in some routine but not set in any other routine. Checking of individual COMMON variables is done only if the -common setting is 3 (variable by variable agreement). This warning is suppressed if the common strictness setting is 0.
a common variable is declared but not used by any subprogram. This warning is suppressed if the common strictness setting is 0.
a variable that is the index of a DO loop is modified by some statement within the range of the loop. The Standard permits an active DO variable to be modified only by the incrementation mechanism of the DO statement.
an external (a subroutine or function) is defined more than once. Definition of an external means providing the body of its source code.
a name is declared in an EXTERNAL statement in some module, but is not defined or used anywhere.
an external is used (invoked) but not defined anywhere. This option is equivalent to the -external flag. If the subprogram is invoked more than once, those invocations will still be checked for consistency.
an external is defined (its subprogram body is present) but it is not used. A subprogram is considered unused even if it is invoked by some other subprogram, if it cannot be called from any thread of execution starting with the main program. The agreement of the subprogram's arguments with its invocations is still checked even if this warning is turned off. If there is no main program, then this warning is issued only if the subprogram is not invoked anywhere. This warning is suppressed in library mode, but library mode has the additional effect of suppressing argument checking for unused routines.
a statement refers to a label that has not been defined.
a statement label is defined, but never referred to.
a local variable is assigned a value, but that value is not used.
a local variable's value may be used before it is assigned. Sometimes ftnchek makes a mistake in the warnings about local variable usage. Usually it errs on the side of giving a warning where no problem exists, but in rare cases it may fail to warn where the problem does exist. See the section on Bugs for examples. If variables are equivalenced, the rule used by ftnchek is that a reference to any variable implies the same reference to all variables it is equivalenced to. For arrays, the rule is that a reference to any array element is treated as a reference to all elements of the array.
a local variable is declared (for instance, in a type declaration) but is not used in the module. Does not apply to dummy arguments: warnings about them are controlled by the keyword arg-unused described above.

Note: In versions of ftnchek prior to 2.10, the -usage flag took a numeric argument instead of a list of options. For the sake of users who may have written scripts invoking ftnchek in this way, the numeric form is still accepted. The numeric setting is composed of three digits. The first digit (hundreds place) controls warnings about subprograms (functions and subroutines), the second digit (tens place) warnings about common blocks and common variables,, and the third digit (ones place) warnings about local variables. Each digit controls warnings according to the convention that a 1 means warn about undefined items and variables that are used before set, a 2 means warn about items that are unused, and a 3 means warn about both types. These numbers are now converted to the appropriate values for the above-listed keywords, except for com-block-volatile, which is not affected by the numeric argument.

See also: -common, -declare, -extern, -library.

Next: -vcg