This topic provides some guidelines for locating the cause of exceptions and run-time errors. Intel® Fortran run-time error messages do not usually indicate the exact source location causing the error. The following compiler options are related to handling errors and exceptions:
The -check [keyword] (Linux* and macOS*) or /check[:keyword] (Windows*) option generates extra code to catch certain conditions at run time.
The keyword bounds generates code to perform compile-time and run-time checks on 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.
The keyword uninit generates code for dynamic checks of uninitialized variables. If a variable is read before written, a run-time error routine will be called.
The keywords noformat and nooutput_conversionreduce the severity level of the associated run-time error to allow program continuation.
The keyword pointers generates code to test for disassociated pointers and unallocatable arrays. The following check[:]pointers option examples result in various output messages.
Example: Allocatable variable not allocated
real, allocatable:: a(:) ! ! A is initially unallocated. To allocate, use: ! ! allocate(a(4)) ! ! Because A is unallocated, the next statement will ! issue an error in applications built with "check pointers". ! a=17 print *,a end Output 1: forrtl: severe (408): fort: (8): Attempt to fetch from allocatable variable A when it is not allocated
Example: Unassociated Pointer
real, pointer:: a(:) allocate(a(5)) a=17 print *,a deallocate(a) ! Once A is deallocated, the next statement ! issues an error in an application built ! with "check pointers". a=20 print *,a end Output 2: 17.00000 17.00000 17.00000 17.00000 17.00000 forrtl: severe (408): fort: (7): Attempt to use pointer A when it is not associated with a target
Example: Cray pointer with zero value
pointer(p,a) real, target:: b ! ! P initially has no address assigned to it. To assign an ! address, use: ! ! p=loc(b) ! ! Because P has no address assigned to it, the next ! statement will issue an error in an application built ! with "check pointers". ! b=17. print *,a end Output 3: forrtl: severe (408): fort: (9): Attempt to use pointee A when its corresponding integer pointer P has the value zero
The traceback option generates extra information in the object file to provide source file traceback information when a severe error occurs at run time. This simplifies the task of locating the cause of severe run-time errors. Without the traceback option, you could try to locate the cause of the error using a map file and the hexadecimal addresses of the stack displayed when a severe error occurs. Certain traceback-related information accompanies severe run-time errors, as described in Traceback.
The fpe option controls the handling of floating-point arithmetic exceptions (IEEE arithmetic) at run time. If you specify the -fpe[:]3 compiler option, all floating-point exceptions are disabled, allowing IEEE exceptional values and program continuation. In contrast, specifying -fpe[:]0 stops execution when an exceptional value (such as a NaN) is generated, when floating overflow or divide by zero occur, or when attempting to use a subnormal number, which usually allows you to localize the cause of the error. It also forces underflow to zero.
The warn and nowarn options control compile-time warning messages, which, in some circumstances, can help determine the cause of a run-time error.
On Linux* and on macOS*, the -fexceptions option enables C++ exception handling table generation, preventing Fortran routines in mixed-language applications from interfering with exception handling between C++ routines.
On Windows*, the Compilation Diagnostics Options in the IDE control compile-time diagnostic messages, which, in some circumstances can help determine the cause of a run-time error.