Table of Contents

Previous: -columns


Option: common

-common=list
This setting controls the strictness of checking of COMMON blocks. By default, all warnings except volatile are turned on.

The list consists of keywords separated by commas or colons. Since most of these 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, 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, -common is equivalent to -common=dimensions,exact,length,type, and -nocommon is equivalent to -common=none. The warning keywords with their meanings are as follows:

dimensions:
corresponding arrays in each declaration of a block must agree in size and number of dimensions. This option only has an effect when used together with exact.
exact:
the comparison of two blocks is done variable-by-variable rather than simply requiring agreement between corresponding storage locations. Use this if all declarations of a given COMMON block are supposed to be identical, which is a good programming practice.
length:
warn if different declarations of the same block are not equal in total length. The Fortran 77 Standard requires each named common block, but not blank common, to be the same length in all modules of the program.
type:
in each declaration of a given COMMON block, corresponding memory locations (words or bytes) must agree in data type. If used together with exact, this will require that corresponding variables agree in data type.
volatile:
Assume that COMMON blocks are volatile.

Many Fortran programmers assume that variables, whether local or in COMMON, are static, i.e. that once assigned a value, they retain that value permanently until assigned a different value by the program. However, in fact the Fortran 77 Standard does not require this to be the case. Local variables may become undefined between activations of a module in which they are declared. Similarly, COMMON blocks may become undefined if no module in which they are declared is active. (The technical term for entities with this behavior is ``automatic'', but ftnchek uses the word ``volatile'' since it is clearer to the nonspecialist.) Only COMMON blocks declared in a SAVE statement, or declared in the main program or in a block data subprogram remain defined as long as the program is running. Variables and COMMON blocks that can become undefined at some point are called volatile.

If the -common=volatile flag is turned on, ftnchek will warn you if it finds a volatile COMMON block. If, at the same time, the -usage=com-block-volatile option is turned on (which is the default), ftnchek will try to check whether such a block can lose its defined status between activations of the modules where it is declared. ftnchek does not do a very good job of this: the rule used is to see whether the block is declared in two separated subtrees of the call tree. For instance, this would be the case if two modules, both called from the main program, shared a volatile COMMON block. A block can also become undefined between two successive calls of the same subprogram, but ftnchek is not smart enough to tell whether a subprogram can be called more than once, so this case is not checked for.

The -common=volatile flag does not affect the way ftnchek checks the usage of local variables.

For compatibility with previous versions of ftnchek, a numeric form of this setting is also accepted: the list is replaced by a number from 0 to 3. A value of 0 turns all the warnings off, 1 or greater turns on type, 2 or greater turns on length, and 3 turns on dimensions and exact also. The numeric form cannot turn on the volatile option.

See also: -library, -usage.


Next: -crossref