Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/22/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

check

Checks for certain conditions at runtime.

Syntax

Linux:

-check [keyword[, keyword...]]

-nocheck

Windows:

/check[:keyword[, keyword...]]

/nocheck

Arguments

keyword

Specifies the conditions to check. Possible values are:

none

Disables all check options.

[no]arg_temp_created

Determines whether checking occurs for actual arguments copied into temporary storage before routine calls.

[no]assume

Determines whether checking occurs to test that the scalar-logical-expression in the ASSUME directive is true, or that the addresses in the ASSUME_ALIGNED directive are aligned on the specified byte boundaries.

[no]bounds

Determines whether checking occurs for array subscript and character substring expressions.

[no]contiguous

Determines whether the compiler checks pointer contiguity at pointer-assignment time.

[no]format

Determines whether checking occurs for the data type of an item being formatted for output.

[no]output_conversion

Determines whether checking occurs for the fit of data items within a designated format descriptor field.

[no]pointers

Determines whether checking occurs for certain disassociated or uninitialized pointers or unallocated allocatable objects.

[no]shape

Determines whether array conformance checking is performed.

[no]stack

Determines whether checking occurs on the stack frame.

[no]teams

Determines whether the runtime system diagnoses non-standard coarray team usage.

[no]udio_iostat

Determines whether conformance checking occurs when user-defined derived type input/output routines are executed.

[no]uninit

Determines whether checking occurs for uninitialized variables.

all

Enables all check options.

CAUTION:

Files compiled with option check all should also be linked with this same option, or the link step may fail.

Default

nocheck

No checking is performed for runtime failures. Note that if option vms is specified, the defaults are check format and check output_conversion.

Description

This option checks for certain conditions at runtime.

Option

Description

check none

Disables all check options (same as nocheck).

check arg_temp_created

Enables runtime checking on whether actual arguments are copied into temporary storage before routine calls. If a copy is made at runtime, an informative message is displayed.

check assume

Enables runtime checking on whether the scalar-logical-expression in the ASSUME directive is true and that the addresses in the ASSUME_ALIGNED directive are aligned on the specified byte boundaries. If the test is .FALSE., a runtime error is reported and the execution terminates.

check bounds

Enables compile-time and runtime checking for array subscript and character substring expressions. An error is reported if the expression is outside the dimension of the array or the length of the string.

For array bounds, each individual dimension is checked. For arrays that are dummy arguments, only the lower bound is checked for a dimension whose upper bound is specified as * or where the upper and lower bounds are both 1.

For some intrinsics that specify a DIM= dimension argument, such as LBOUND, an error is reported if the specified dimension is outside the declared rank of the array being operated upon.

Once the program is debugged, omit this option to reduce executable program size and slightly improve runtime performance.

It is recommended that you do bounds checking on unoptimized code. If you use option check bounds on optimized code, it may produce misleading messages because registers (not memory locations) are used for bounds values.

check contiguous

Tells the compiler to check pointer contiguity at pointer-assignment time. This will help prevent programming errors such as assigning contiguous pointers to non-contiguous objects.

check format

Issues the runtime FORVARMIS fatal error when the data type of an item being formatted for output does not match the format descriptor being used (for example, a REAL*4 item formatted with an I edit descriptor).

With check noformat, the data item is formatted using the specified descriptor unless the length of the item cannot accommodate the descriptor (for example, it is still an error to pass an INTEGER*2 item to an E edit descriptor).

check output_conversion

Issues the runtime OUTCONERR continuable error message when a data item is too large to fit in a designated format descriptor field without loss of significant digits. Format truncation occurs, the field is filled with asterisks (*), and execution continues.

check pointers

Enables runtime checking for disassociated or uninitialized Fortran pointers, unallocated allocatable objects, and integer pointers that are uninitialized.

check shape

Enables compile-time and runtime array conformance checking in contexts where it is required by the standard. These include the right-hand and left-hand side of intrinsic and elemental defined assignment, the operands of intrinsic and elemental defined binary operations, two or more array arguments to ELEMENTAL procedures, the ARRAY= and MASK= arguments to intrinsic procedures as required, and the arguments to the intrinsic module procedures IEEE_SET_FLAG and IEEE_SET_HALTING_MODE.

In an ALLOCATE statement with array bounds specified for an allocate-object and with SOURCE=source specified, the allocate-object must conform with source.

Note that you can specify a setting in the warn option to choose whether array conformance violations are diagnosed with errors or warnings.

check stack

Enables checking on the stack frame. The stack is checked for buffer overruns and buffer underruns. This option also enforces local variables initialization and stack pointer verification.

This option disables optimization and overrides any optimization level set by option O.

check teams

Enables checking for non-standard coarray team usage. For example, ifort permits the TEAM argument to NUM_IMAGES to be a type TEAM_TYPE variable which describes a team that is not the current or an ancestor of the current team. Similarly, ifort permits the TEAM_NUMBER specifier in an image selector to specify a value of -1 indicating the initial team. Such behavior is not permitted by the standard.

When check teams is specified, a message is generated each time a non-standard coarray extension is detected.

check uninit

ifort (Linux and Windows):

Enables runtime checking for uninitialized variables. If a variable is read before it is written, a runtime error routine will be called. Only local scalar variables of intrinsic type INTEGER, REAL, COMPLEX, and LOGICAL without the SAVE attribute are checked.

To detect uninitialized arrays or array elements, see option [Q]init or see the article titled Detection of Uninitialized Floating-point Variables in Intel® Fortran.

ifx (Linux):

Uses the LLVM Memory Sanitizer (MSAN) to enable run-time checking on uninitialized stack- or heap-allocated variables. If such a variable is read before it is written at runtime, a MSAN message that details the call stack of the read instruction and the call stack of the allocation instruction of the variable will be issued. The program terminates right after a MSAN message is issued.

To get source information about the call stacks in a MSAN message, do the following:

  1. Compile your program with option -g1 or above. For example:

    ifx -check uninit -g1 myprog.f90 -o myprog.exe
  2. Run your program with the MSAN_SYMBOLIZER_PATH environment variable set to the executable llvm-symbolizer in your compiler installation. For example:

    MSAN_SYMBOLIZER_PATH=${ONEAPI_ROOT}/compiler/latest/linux/bin-llvm/llvm-symbolizer myprog.exe

If you specify option -check uninit, you cannot also specify option -static.

To ensure that the required runtime libraries are linked and correctly initialized, specify option -check uninit in the link command if any part of the object file is compiled with this option.

NOTE:

For MSAN to be accurate, your whole program, including the library code used by the program, needs to be compiled with option -check uninit (or its equivalent if it is not a Fortran source file, such as option -fsanitize=memory for C/C++); otherwise, you may get false positive reports on uninitialized variables.

Since every Fortran program links by default with the static Fortran runtime library and the runtime library’s dependencies, ifx provides a set of those memory-sanitized static libraries in the compiler installation and uses them when you link your Fortran program with option -check uninit.

No memory-sanitized dynamic Fortran runtime library is provided in the installation.

Consequently, if you link your program with option -check uninit and specify option -shared-intel to force the use of the dynamic Fortran runtime library, your final executable will be linked with the regular, unsanitized dynamic Fortran runtime library. You may then see false positive MSAN messages when you run this executable.

Therefore, for option -check uninit to be effective, do not link your program with option -shared-intel.

For more information on the Memory Sanitizer, see: https://clang.llvm.org/docs/MemorySanitizer.html.

CAUTION:

Files compiled with option check uninit should also be linked with this same option, or the link step may fail.

NOTE:

Option -check uninit only applies to host compilation. When offloading is enabled, it does not impact device-specific compilation. Offloading can only be enabled when using ifx.

ifx (Windows):

This setting is not currently available on Windows because the Memory Sanitizer is not supported on Windows.

check all

Enables all check options. This is the same as specifying check with no keyword.

This option disables optimization and overrides any optimization level set by option O.

To get more detailed location information about where an error occurred, use option traceback.

IDE Equivalent

Visual Studio: Run-time > Runtime Error Checking (/nocheck, /check:all)

Run-time > Check Array and String Bounds (/check:bounds)

Run-time > Check Uninitialized Variables (/check:uninit)

Run-time > Check Edit Descriptor Data Type (/check:format)

Run-time > Check Edit Descriptor Data Size (/check:output_conversion)

Run-time > Check For Actual Arguments Using Temporary Storage (/check:arg_temp_created)

Run-time > Check Array Conformance (/check:shape)

Run-time > Check For Null Pointers and Allocatable Array References (/check:pointers)

Alternate Options

check none

Linux: -nocheck

Windows: /nocheck

check bounds

Linux: -CB

Windows: /CB

check shape

Linux: -CS

Windows: /CS

check uninit

Linux: -CU

Windows: /RTCu, /CU

check all

Linux: -check, -C

Windows: /check, /C

See Also