Lahey/Fujitsu Fortran

-[N]CHK [([a][,e][,s][,u][,x])]


Compile only. Default: -nchk

Specify -chk to generate a fatal runtime error message when substring and array subscripts are out of range, when non common variables are accessed before they are initialized, when array expression shapes do not match, and when procedure arguments do not match in type, attributes, size, or shape.

Note: Commas are optional, but are recommended for readability.

-chk Arguments

Diagnostic Checking Class Option Argument
Arguments a
Array Expression Shape e
Subscripts s
Undefined variables u
Increased (extra) x

Specifying -chk with no arguments is equivalent to specifying -chk (a,e,s,u). Specify -chk with any combination of a, e, s, u and x to activate the specified diagnostic checking class.

Specification of the argument x must be used for compilation of all files of the program, or incorrect results may occur. Do not use with 3rd party compiled modules, objects, or libraries. Specifically, the x argument must be used to compile all USEd modules and to compile program units which set values within COMMONs. Specifying the argument x will force undefined variables checking (u), and will increase the level of checking performed by any other specified arguments.

If -chk (a) is specified in conjunction with -pca , the action of -chk (a) is overridden by the action of -pca In this case, no error is generated when a dummy argument that is associated with a constant actual argument is assigned a new value in the subprogram.

Specifying -chk (u) checks for undefined variables by initializing them with a bit pattern. If that bit pattern is detected in a variable on the right side of an assignment then chances are that the variable was uninitialized. Unfortunately, you can get a false diagnostic if the variable holds a value that is the same as this bit pattern. This behavior can be turned off by not using the u argument to the -chk option.

The values used with -chk (u) are:

Specifying -chk adds to the size of a program and causes it to run more slowly, sometimes as much as an order of magnitude. It forces -trace and removes optimization by forcing -o0. Some of the arguments to the -chk option may severely impact program execution speed, depending on the source code. Eliminating unneeded options will improve speed.

Visual Studio Property

The -chk option corresponds to the Fortran|Debug/Diagnostics|Enable All Runtime Checks property.

Individual checks may be set using one or more of Enable Array Shape Checking, Enable Bounds Checking, Enable Interface Checking, or Enable Undefined Variable Checking. Selecting the Enable All option automatically sets or clears the other options.

Arguments for this property can be set on the property page for the project or source file.


LF95 myprog -chk (a,x)

instructs the compiler to activate increased runtime argument checking and increased undefined variables checking.

The -chk option will not check bounds (s) in the following conditions:

Undefined variables (u) are not checked if:

See Also

Setting Build Options