Skip to main content
⚠ INFORMATION
This page was translated by an AI (LLM) with a cursory human check and is awaiting full review.

Intel Compiler Options (Fortran, C/C++)

We will only detail some of the options offered by the Intel compilers here. We invite you to consult the ifort and icc manuals available on Jean Zay (commands man ifort and man icc) for detailed information on all available options.

Optimisation Options

The -O option (uppercase letter O) is used to manage code optimisation. You can specify the desired optimisation level by adding an integer value (0, 1, 2 or 3). The -O0 option (uppercase letter O followed by zero) disables all compiler optimisations. The -O option (uppercase letter O alone) is equivalent to -O2; it is also the default optimisation level.

warning

From level 3 onwards, the program semantics may be altered. For example: (2.*3.1)*4.2 may be interpreted as 2.*(3.1*4.2). Therefore, be very careful with the results of your computations: from -O3 onwards, it is necessary to validate the results of your model by comparing them with an execution performed with moderate or no optimisation.

Optimisation OptionsComments
-O0No optimisation performed.
-O1Some optimisations moderately speed up computations.
-O2 or -O (default)Optimisation level including vectorisation, inlining, loop unrolling, inter-procedural optimisation within each source file, etc.
-O3More aggressive optimisations than in -O2 with prefetching, loop transformations, code duplication, ...
-O3 -xHostEnables AVX2 and partial AVX512 vectorisation. It triggers a more exhaustive analysis of data dependencies and may increase compilation time.
-O3 -xHost -qopt-zmm-usage=highFully enables AVX512 vectorisation. It triggers a more exhaustive analysis of data dependencies and may increase compilation time.

It is possible that your code does not give the same results in -O3 as in -O2. You can then obtain an intermediate optimisation level by adding the -fp-model option followed by a keyword (for example -O3 -fp-model precise).

Optimisation OptionsComments
-O3 -fp-model strictThe optimisations performed ensure the precision of floating-point calculations (strictest level). Additionally, exception handling is enabled.
-O3 -fp-model strict -fp-model no-exceptAs above, but without exception handling.
-O3 -fp-model preciseEnsures the precision of floating-point calculations. There is no exception handling.
-O3 -fp-model precise -fp-model exceptAs above, but with exception handling.
-O3 -fp-model fast=1 or -O3 -fp-model fastAllows more aggressive optimisations that may alter the precision of floating-point calculations. May provide better performance, but cannot be combined with exception handling (-fp-model except).
-O3 -fp-model fast=2The code may be even faster and less precise than with -fp-model fast=1. Cannot be combined with exception handling (-fp-model except).
note

Currently, the -fast option is equivalent to the options: -ipo -O3 -no-prec-div -xHost -static. To obtain an executable, it is necessary to remove the -static option. As we advise against specifying the -fast option in isolation, use: -ipo -O3 -no-prec-div -xHost.

Memory Options

Memory OptionsComments
-autoLocal variables declared within a program unit without the SAVE attribute and not initialised will be allocated in the execution stack (stack) upon entry to this unit. This option reduces the size of the executable (DATA and BSS static areas). Local variables must be explicitly valued; otherwise, they have an undefined value (the -ftrapuv option allows detection of uninitialised variables). By default, -auto-scalar is enabled (only scalar local variables are allocated in the stack). The opposite option is -save, where all local variables inherit the SAVE attribute and are statically allocated in the BSS area and initialised to a null value.
-mcmodel=smallThe memory space reserved for code (TXT area) and data (DATA and BSS areas) is limited to 2 GB. This value is sufficient in most cases and guarantees the best performance.
-mcmodel=medium -shared-intelOnly the memory space reserved for code (TXT area) is limited to 2 GB, with no restriction for data. Performance may be slightly degraded. This option is necessary if you use static and global data (such as static arrays) whose size exceeds 2 GB. Note that the -shared-intel option must also be specified.
-mcmodel=large -shared-intelThere is no restriction on the memory space reserved for code or data. Performance may be slightly degraded. Note that the -shared-intel option must also be specified.
note

The -mcmodel=medium -shared-intel options must be added to both the compilation and the link editing; otherwise, you will receive messages like:

relocation truncated to fit: R_X86_64_PC32 against symbol ...

These messages may appear when using large static arrays, for example.

Diagnostic Options

During compilation, some options allow you to retrieve certain diagnostic messages on the standard output or in a file:

Listing OptionComments
-qopt-report=[n]Generates, on the standard output, a report of the transformations related to optimisation (inlining, vectorisation, loop unrolling, etc.). n is optional and can be 0, 1, 2 or 3 (default 2). The higher the n, the more detailed the report.
-opt-report-file=filenameGenerates a report in the file specified by filename. In this case, it is no longer necessary to specify the -qopt-report option.
-qopt-report-phase=phase -qopt-reportCombination of two options to generate a report of the optimisations performed by the phase element of the optimiser. phase can be:
ipo : Interprocedural Optimizer phase;
hlo : High Level Optimizer phase;
hpo : High Performance Optimizer phase;
ilo : Intermediate Language Scalar Optimizer phase;
pgo : Profile Guided Optimization phase;
openmp : OpenMP;
par : Auto-parallelisation;
vec : Vectorisation;
all : All optimizer phases.

Examples:

ifort -O3 -qopt-report=3 prog.f90
ifort -O3 -qopt-report-file=my_report_file prog.f90
ifort -O3 -qopt-report=3 -qopt-report-phase=par -parallel prog.f90
icc -O3 -qopt-report=3 prog.c
icc -O3 -qopt-report-file=my_report_file prog.c
icc -O3 -qopt-report=3 -qopt-report-phase=par -parallel prog.c

Debugging Options for Fortran and C/C++ Compilers

In a debugging phase, the following options can be used with both the Fortran compiler and the C/C++ compiler. We invite you to consult the compiler help on Jean Zay (commands man ifort and man icc) for more information.

Debugging OptionComments
-gGenerates the symbol table (line numbers, variables, ...). This table can be exploited by a debugger. This option preserves the explicitly requested optimisation level (-O1, -O2 or -O3). Without explicitly specified optimisation, all optimisation is disabled (-g is equivalent to -g -O0).
-debug
or -debug full
or -debug all
Generates complete debugging information. Recommended with -g and a specific optimisation level (-O1, -O2 or -O3). For example: -g -O2 -debug.
-tracebackProvides more information when an error occurs during execution. This option is also set with -g.
-ftrapuvInitialises local variables in the stack with aberrant values (very large integer, invalid address). Allows detection of uninitialised variables by causing an error during execution. Also sets the -g option.
-check uninit (Fortran)
-check=uninit (C)
Detects at execution if scalar variables of intrinsic type (integer, real, complex, logical) and without the SAVE attribute are not initialised.
-fp-stack-checkAllows an exception to be generated as soon as a function call returns an incorrect value.
-no-ftzThe -ftz option is enabled by default with the optimisations -O1, -O2, and -O3. It sets very small denormalised numbers to zero during execution, which can produce incorrect results. The -no-ftz option allows this functionality to be disabled and these underflows to be detected.

Debugging Options for the Fortran Compiler

With the Fortran compiler, you can also use the following options:

Debugging OptionComments
-debug-parameters allGenerates debugging information for variables of type PARAMETER. This is necessary to see the values of PARAMETER with a debugger.
-heap-arraysPlaces all temporary or automatic arrays in the heap instead of the stack if the latter is too small.
-init=arrays,snanForces all uninitialised intrinsic type variables and arrays to NaN. This option implies -fpe0. To avoid exceptions that are not related to uninitialised variables, it is recommended to reduce the optimisation level to -O1 or -O0. Alternatively, you can use -fp-speculation=safe for the detection of uninitialised variables.
-fpe-all=0 -no-ftz -tracebackThis combination of options stops execution as soon as an exception (overflow, underflow, division by zero, invalid operation, etc.) occurs. It indicates at which level of the code it occurred. The control is performed in each subroutine, unlike the -fpe0 option which only acts on the main program.
-check boundsDetects at compilation and execution if an array is addressed outside its bounds (bound checking).
-check pointersDetects at execution if a pointer is initialised or not, if an allocatable array is allocated or not when using pointers.
-check allEnables the two options listed above simultaneously.
-warn declarationsGenerates messages signalling all undeclared variables (as if the source code contained a IMPLICIT NONE).
-warn interfacesGenerates messages signalling inconsistencies between the calls and the definitions of each subroutine and each function of the code. Note that the compiler generates an interface block for each of them (implicit -gen-interfaces option).
-warn truncated_sourceFor fixed-format files, the compiler will issue a message if a line of the source exceeds the maximum allowed length (default: 72 characters).
Note that this length can be increased to a maximum of 132 characters with the -extend_source option.
-warn all or -warnGenerates various warning messages simultaneously (including those mentioned above).
-stand f08Warnings are generated if the Fortran 2008 standard is not respected.

Debugging Options for the C/C++ Compiler

With the C/C++ compiler, you can also use the following option:

Debugging OptionComments
-check-pointers=rwAllows detection at execution of invalid memory accesses when using pointers. This includes the use of arrays, whether they have been dynamically allocated or not.

Examples:

ifort -g -debug -fpe-all=0 -no-ftz -traceback -fp-stack-check -check all -warn all -stand f08 my_prog.f90
icc -g -debug -no-ftz -traceback -fp-stack-check -check=uninit -check-pointers=rw my_prog.c

List of Enabled Options for the Fortran Compiler

The list of options enabled by default by the Intel compiler may change over time and depending on the context in which the compiler is called. Therefore, it is possible that with different versions, a compilation that you launch on the same code with the same options will generate an executable that does not produce exactly the same results. It is therefore useful to generate a listing of the compilation of a source file using the -list option:

ifort -list prog.f90

This command creates the prog.lst file in the same directory as the source file. By default, it contains:

  • the content of the files included via the INCLUDE instruction,
  • the list of symbols for each subroutine,
  • the list of compilation options.

The -show mot-clef option allows you to restrict the action of the -list option:

  • -show noinclude removes the content of the files included via the INCLUDE instruction,
  • -show nomap removes the list of symbols for each subroutine,
  • -show nooptions removes the list of compilation options.

Size of Different Fortran Base Types

Variables declared using the default types INTEGER, REAL or COMPLEX are allocated memory based on 4-byte words. The optional KIND=n parameter indicated after the type in the source code allows you to influence this size; this is the most explicit and safest way to do so.

There are also compilation options that allow you to globally modify the length of variables, but we strongly advise against using them for portability reasons:

  • the equivalent options do not work the same way on different platforms,
  • it is very easy to forget these options when compiling your code or sharing it with someone else; in this case, the execution results are incorrect!

To allow for some punctual tests, these options are as follows:

  • -integer-size 16/32/64 forces the memory allocation of integers and logicals declared with the type INTEGER or LOGICAL (without specification of the KIND=n parameter) on 2/4/8 byte words (4 by default);
  • -real-size 32/64/128 : entities declared with the type REAL or COMPLEX (without specification of the KIND=n parameter) are promoted respectively to 4, 8 and 16 bytes.

Reading or Writing an IEEE Big-Endian Binary File in Fortran

Jean Zay is a Linux machine: by default, it generates little-endian Fortran binary files. To write or read an IEEE big-endian binary file in Fortran, you must use the F_UFMTENDIAN environment variable. To read a binary file written in big-endian (for example, from our old IBM Power6 Vargas) on unit 12:

ifort -o prog_big_endian prog_big_endian.f90
export F_UFMTENDIAN=big:12
./prog_big_endian
note

If you do not specify a logical unit number, then the variable operates on all units. Consequently, all files are considered to have the same format (big-endian in this example):

ifort -o prog_big_endian prog_big_endian.f90
export F_UFMTENDIAN=big
./prog_big_endian

It is possible to specify several logical units; here, units 12, 15 and all those from 20 to 30:

export F_UFMTENDIAN="big:12,15,20-30"
./prog_big_endian
warning

In the case of a direct access file, the record size, indicated during the OPEN of the file in the source code using the RECL keyword, is interpreted in 4-byte words. To specify this record size directly in bytes during the OPEN, you must compile with the -assume byterecl option:

ifort -assume byterecl -o prog_big_endian prog_big_endian.f90
export F_UFMTENDIAN=big:12
./prog_big_endian

Your opinion matters!

To give your feedback, report an error, or suggest an improvement, click here:

quick anonymous questionnaire

This questionnaire is temporary and will take less than a minute, so take the opportunity!