Visible to Intel only — GUID: GUID-663CCFE6-762A-49BE-B699-99CB27E5C9A8
Visible to Intel only — GUID: GUID-663CCFE6-762A-49BE-B699-99CB27E5C9A8
init, Qinit
Lets you initialize a class of variables to zero or to various numeric exceptional values.
Syntax
Linux: |
-init=keyword [, keyword ] |
Windows: |
/Qinit:keyword [, keyword ] |
Arguments
keyword |
Specifies the initial value for a class of variables. Possible values are:
|
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 one or more of the various numeric exceptional values positive or negative huge, positive or negative Infinity, signaling NaN, or positive or negative tiny.
If you only specify the keyword [minus_]huge, [minus_]infinity, snan, [minus_]tiny, or zero, option [Q]init affects only scalar variables. To apply an initialization to arrays as well, you must also specify the keyword arrays.
If you have specified an ALLOCATE statement and you specify one or more [Q]init keywords, the initializers are applied to the memory that has been allocated by the ALLOCATE statement.
Keywords are applied to the various numeric types in the following order:
For REAL and COMPLEX variables, keywords [minus_]huge, [minus_]infinity, snan, [minus_]tiny, and zero initialize to the specified value.
For INTEGER variables, keywords [minus_]huge and zero initialize to the specified value.
For LOGICAL variables, keyword zero initializes to .FALSE..
The following classes of variables are initialized by the [Q]init option:
Variables of intrinsic numeric type, that is, of type COMPLEX, INTEGER, LOGICAL, or REAL, of any KIND
SAVEd scalar or array variables, not in the main program, that are not initialized in the source code
Local scalars and arrays
Module variables that are not initialized in the source code
Automatic arrays
Integers can be set to zero, huge, or minus_huge.
In a COMPLEX variable, each of the real and imaginary parts is separately initialized as a REAL.
The following are general restrictions for this option:
The keywords [minus_]infinity, snan, and [minus_]tiny only affect certain variables of REAL or COMPLEX type.
You cannot initialize variables in equivalence groups to any of the numeric exceptional values.
In an equivalence group, if no member of that equivalence group has an explicit initialization or a default initialization (in the case of a derived type), a variable in that equivalence group can be initialized to zero but not to any of the numeric exceptional values.
Derived types, arrays of derived types, and their components will not be initialized.
Dummy arguments including adjustable arrays will not be initialized.
Variables in COMMON will not be initialized.
The following spellings all cause the same behavior, that is, they initialize certain numeric arrays and scalars to zero:
[Q]init zero [Q]init arrays
[Q]init arrays [Q]init zero
[Q]init zero, arrays
[Q]init arrays, zero
Combinations of keywords will override each other in a left-to-right fashion as follows:
zero and nozero override each other.
snan and nosnan override each other.
huge and minus_huge override each other.
tiny and minus_tiny override each other.
infinity, minus_infinity, and snan will all override each other.
Because a REAL or COMPLEX variable can be initialized to huge or minus_huge, infinity or minus_infinity, tiny or minus_tiny, snan, or zero, these initializations are applied in the following order:
snan
infinity or minus_infinity
tiny or minus_tiny
huge or minus_huge
zero
Because an INTEGER variable can be initialized to huge or minus_huge, or zero, these initializations are applied in the following order:
huge or minus_huge
zero
For example, if the you specify [Q]init zero, minus_huge, snan when compiling the following program:
program test real X integer K complex C end
The variable X will be initialized with a signaling NaN (snan), variable K will be initialized to the integer value minus_huge, and the real and imaginary parts of variable C will be initialized to a signaling NaN (snan) in each.
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 runtime, 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.
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*) 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.
To avoid possible performance issues, you should only use [Q]init for debugging (for example, [Q]init zero) and checking for uninitialized variables (for example, [Q]init snan).
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
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 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 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 runtime, see the article titled Detection of Uninitialized Floating-point Variables in Intel® Fortran.