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

Locate Runtime Errors

This topic provides some guidelines for locating the cause of exceptions and runtime errors. Intel® Fortran runtime error messages do not usually indicate the exact source location causing the error.

The following compiler options are related to handling errors and exceptions:

  • check

  • traceback

  • fpe

  • warn and nowarn

  • fexceptions (Linux)

  • Compilation Diagnostics Options in the IDE (Windows)

Their effects are described in the following sections.

The check Option

This option generates extra code to catch certain conditions at runtime. It lets you specify a keyword to check for specific conditions.

The keyword bounds generates code to perform compile-time and runtime 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 shape generates code to compare the shapes of the right-hand side and the left-hand side of array assignments, and issues runtime errors when they do not conform.

The keyword uninit generates code for dynamic checks of uninitialized variables. If a variable is read before written, a runtime error routine will be called.

The keywords noformat and nooutput_conversion reduce the severity level of the associated runtime error to allow program continuation.

The keyword pointers generates code to test for disassociated pointers and unallocatable arrays.

The following examples show output messages received when the code was specified using option check[:]pointers.

Examples

The following example shows the message received for an allocatable variable that has not been 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

The following example shows the message received for an 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

The following example shows the message received for a Cray pointer with a 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

This option generates extra information in the object file to provide source file traceback information when a severe error occurs at runtime. This simplifies the task of locating the cause of severe runtime 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 runtime errors, as described in Traceback.

The fpe Option

This option controls the handling of floating-point arithmetic exceptions (IEEE arithmetic) at runtime. 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

These options control compile-time warning messages, which, in some circumstances, can help determine the cause of a runtime error.

Linux fexceptions Option

This option enables C++ exception handling table generation, preventing Fortran routines in mixed-language applications from interfering with exception handling between C++ routines.

Windows Compilation Diagnostics Options in the IDE

The Compilation Diagnostics Options in the IDE control compile-time diagnostic messages. In some circumstances, these messages can help determine the cause of a runtime error.

See Also