Intel® Fortran Compiler 16.0 User and Reference Guide

init, Qinit

Lets you initialize a class of variables to zero or to signaling NaN.

Architecture Restrictions

[Q]init keyword snan: Not available on Intel® 64 architecture targeting the Intel® Xeon Phi™ coprocessor x100 product family (formerly code name Knights Corner)

Syntax

Linux and OS X:

-init=keyword

Windows:

/Qinit:keyword

Arguments

keyword

Specifies the initial value for a class of variables. Possible values are:

[no]arrays

Determines whether the compiler initializes variables that are arrays or scalars. Specifying arrays initializes variables that are arrays or scalars. Specifying noarrays initializes only variables that are scalars. You must also specify either [Q]init snan or [Q]init zero when you specify [Q]init [no]arrays.

[no]snan

Determines whether the compiler initializes to signaling NaN all uninitialized variables of intrinsic type REAL or COMPLEX that are saved, local, automatic, or allocated variables.

[no]zero

Determines whether the compiler initializes to zero all uninitialized variables of intrinsic type REAL, COMPLEX, INTEGER, or LOGICAL that are saved, local, automatic, or allocated variables.

Option /Qinit:[no]zero replaces option /Qzero[-] (Windows*) , and option -init=[no]zero replaces option -[no]zero (Linux* and OS X*).

Default

OFF

No initializations are performed by default if you do not specify any of these options.

Description

This option lets you initialize a class of variables to zero or to signaling NaN.

If you only specify option -init=zero or -init=snan (Linux* and OS X*) or /Qinit:zero or /Qinit:snan (Windows*), it affects only scalar variables. To apply the initialization to arrays as well, you must also specify option -init=arrays (Linux* and OS X*) or Qinit:arrays (Windows*).

If you specify both [Q]init snan and [Q]init zero, then certain variables of REAL and COMPLEX type are initialized to signaling NaN and certain variables of INTEGER and LOGICAL type are initialized to zero.

The following classes of variables are affected by the [Q]init option:

The following are general restrictions for this option:

If you specify [Q]init snan, the floating-point exception handling flags will be set to trap signaling NaN and halt so that when such a value is trapped at run-time, the Fortran library can catch the usage, display an error message about a possible uninitialized variable, display a traceback, and stop execution. You can use the debugger to determine where in your code this uninitialized variable is being referenced when execution stops.

Setting the option [Q]init snan implicitly sets the option fpe 0. A compile time warning will occur if you specify both option fpe 3 and option [Q]init snan on the command line. In this case, fpe 3 is ignored.

Note

If you build with optimization, the compiler may speculate floating-point operations, assuming the default floating-point environment in which floating-point exceptions are masked. When you add [Q]init snan, this speculation may result in exceptions, unrelated to uninitialized variables, that now get trapped. To avoid this, reduce the optimization level to /O1 or /Od (Windows*), or -O1 or -O0 (Linux* and OS X*) when doing uninitialized variable detection.

If you wish to maintain optimization, you should add option [Q]fp-speculation safe to disable speculation when there is a possibility that the speculation may result in a floating-point exception.

On Intel® 64 architecture targeting the Intel® Xeon Phi™ coprocessor x100 product family (formerly code name Knights Corner), you cannot specify [Q]init [no]snan, since trapping signaling snan is not available.

Use option [Q]save if you wish all variables to be specifically marked as SAVE.

IDE Equivalent

Visual Studio: Data > Initialize Variables to Signaling NaN

Data > Initialize Variables to Zero

Data > Initialize Arrays as well as Scalars

Eclipse: None

Xcode: Data > Initialize Variables to Signaling NaN

Data > Initialize Variables to Zero

Data > Initialize Arrays as well as Scalars

Alternate Options

None

Example

The following example shows how to initialize scalars of intrinsic type REAL and COMPLEX to signaling NaN, and scalars of intrinsic type INTEGER and LOGICAL to zero:

-init=snan,zero               ! Linux and OS X systems
/Qinit:snan,zero              ! Windows systems

The following example shows how to initialize scalars and arrays of intrinsic type REAL and COMPLEX to signaling NaN, and scalars and arrays of intrinsic type INTEGER and LOGICAL to zero:

-init=zero -init=snan –init=arrays       ! Linux and OS X systems
/Qinit:zero /Qinit:snan /Qinit:arrays    ! Windows systems

To see an example of how to use option [Q]init for detection of uninitialized floating-point variables at run-time, see the article titled Detection of Uninitialized Floating-point Variables in Intel® Fortran, which is located in https://software.intel.com/articles/detection-of-uninitialized-floating-point-variables-in-intel-fortran

See Also