Intel® Fortran Compiler XE 13.1 User and Reference Guides
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* OS and OS X*) or /check[:keyword] (Windows* OS) option generates extra code to catch certain conditions at run time. For example, if you specify the keyword bounds, the debugger will catch and stop at array or character string bounds errors. You can specify the keyword bounds to generate 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 of 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 noformat and nooutput_conversion keywords reduce the severity level of the associated run-time error to allow program continuation. The pointers keyword generates code to test for disassociated pointers and unallocatable arrays.
The following -check pointers (Linux OS and OS X) or /check:pointers (Windows OS) examples result in various output messages.
Example 1: Allocatable variable not allocated
real, allocatable:: a(:) ! allocate(a(4)) ! if a is unallocated, the next statement gets an error 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 2: Pointer not associated
real, pointer:: a(:) allocate(a(5)) a=17 print *,a deallocate(a) ! once a is deallocated, the next statement gets an error 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 3: Cray pointer with zero value
pointer(p,a) real, target:: b ! p=loc(b) ! if integer pointer p has no address assigned to it, ! ! the next statement gets an error 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 (Linux OS and OS X) or /traceback (Windows OS) 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 traceback, 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 Using Traceback Information Overview.
The -fpe (Linux OS and OS X) or /fpe (Windows OS) option controls the handling of floating-point arithmetic exceptions (IEEE arithmetic) at run time. If you specify the -fpe3 (Linux OS and OS X) or /fpe:3 (Windows OS) compiler option, all floating-point exceptions are disabled, allowing IEEE exceptional values and program continuation. In contrast, specifying -fpe0 or /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 denormalized number, which usually allows you to localize the cause of the error. It also forces underflow to zero.
The -warn and -nowarn (Linux OS and OS X) or /warn and /nowarn (Windows OS) options control compile-time warning messages, which, in some circumstances, can help determine the cause of a run-time error.
On Linux OS and on OS X, 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 OS, 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.