Intel® Fortran Compiler

Essential Intel Fortran compiler flags for general software compilation are summarized on this page.

Based on: Intel® Fortran 2023.1 (cpeIntel/23.09 on LANTA)

Reference: Alphabetical Option List



Compiler

Language

Cray compiler wrapper

Underlying Intel compiler

Language

Cray compiler wrapper

Underlying Intel compiler

Fortran

ftn

ifort

Flags / Options

Compilation

Flags / Options

Short description

Flags / Options

Short description

-c

Prevent linking after the object file is generated. This option is useful when compiling more than one targets with common source files.

-cxxlib

Link with the C++ runtime libraries provided by gcc.

-Dname[=value]

(Use with -fpp). Define a macro name that can be associated with an optional value. This is a compile-time version of #define directive. For example, -DMPI=1.

-fpp

Run Fortran preprocessor on source files before compilation. Ref: fpp.

-fuse-ld=name

Use a different linker, i.e., name, instead of the default linker ld. Ref: fuse-ld.

-Idir (Capital i)

Specify an additional directory, i.e., dir, to search for include files.

-lname (Lowercase l)

Employ name library, i.e., libname.so or libname.a, when linking. This option should follows the last object file it applies to.

-Ldir

Search for libraries in dir directory before searching the standard directories. This option is usually placed prior to -lname option.

-module path

Specify the directory path where module
files (.mod) should be placed and searched for.

-o target-name

Specify the name of the output file.

-S

Compile to an assembly file (.s) then stop.

-shared

Produce a dynamic shared object instead of an executable. Usually use with -fPIC.

-static

Prevents linking with shared libraries

-stand val

Follow a Fortran language standard where val are f90, f95, f03, f09 or f18. Alternatively, -std95, -std03, -std09, -std18 can be used. Ref: stand.

Fortran Features & Format

Flags / Options

Short description

Flags / Options

Short description

-coarray[=keyword]

Enable the coarray feature. See Use Coarrays and coarray, Qcoarray.

-convert [keyword]

Specify the format of unformated files containing numerical data. The keyword could be big_edian, little_endian and others. Ref: convert.

-double-size [64 or 128]

Specify the default of KIND for DOUBLE. Default: 64.

-extend-source [72, 80 or 132]

Specify the length of the statement field in a fixed-form source file. Alternatively, -72, -80 and -132 can be used.

-fixed

Indicate that the source files are in fixed format.

-free

Indicate the source files are in free format.

-init[=type,keyword]

Initialize variables of the selected type to an exceptional value such as zero, infinity, NaN and others. Ref: init, Qinit.

-parallel
(ifort only, not in ifx)

Generate multi-threaded code for loops that can be safely executed in parallel. Ref: parallel, Qparallel and par-schedule, Qpar-schedule.

-real-size [32, 64 or 128]

Specify the default of KIND for REAL and COMPLEX. Default: 32.

-traceback

Generate extra information in the object file to provide source file traceback information, that is, when use objdump -h xxx. Ref: traceback.

-no-wrap-margin

Disable the right margin wrapping that occurs in Fortran list-directed output. Ref: wrap-margin (also see ifort's no-wrap-margin works only partially).

Warnings / Errors / Debug

Flags / Options

Short description

Flags / Options

Short description

-debug=keyword

Select the type of debugging information keyword. Some are enabled by default. Ref: https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/debug-linux-and-macos.html and https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/diag-qdiag.html.

-diag-dump

Print all enabled diagnostic messages.

-dryrun

Show the commands but do not execute them.

-g[N]

Generate level N of debugging information, e.g., -g3. Ref: https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/g-002.html.

-syntax-only

Check for syntax errors. No code is generated.

-warn [keyword1],…

Specify diagnostic messages (keyword) to be issued or not issued by the compiler. Ref: https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/warn.html.

-Winline
(ifort only, not in ifx)

Report when a function that is declared as inline is not inlined.

Optimization

Flags / Options

Short description

Flags / Options

Short description

-fast

Equivalent to -O3 -no-prec-div -static -fp-model fast=2

-fast-transcedentals
(ifort only, not in ifx)

Replace calls to transcendental functions with faster but less precise implementations. Ref: https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/fast-transcendentals-qfast-transcendentals.html.

-finline

Inline all functions declared with pragma !DIR$ ATTRIBUTES FORCEINLINE.

-finline-limit=Num

Specify the maximum number of lines Num the function can have to be considered for inlining.

-fltconsistency

Enable improved floating-point consistency. Ref: https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/fltconsistency.html.

-fp-model=keyword

Controls the semantics of floating-point optimization. For example,

  • -fp-model=fast=2 (ifort) or -fp-model=fast (ifx)
    = Enable all aggressive optimizations although it may affect the accuracy or reproducibility of computations. [Default]

  • -fp-model=precise
    = Only enable optimizations that are value-safe.

  • -fp-model=strict
    = Disable optimizations that may violate the IEEE 754 standard.

Ref: https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/fp-model-fp.html.

-fp-speculation=keyword

Specify the mode in which to speculate on floating-point operations.

  • -fp-speculation fast
    = Enable speculation on floating-point operations. [Default]

  • -fp-speculation safe
    = Disable speculation if there is a possibility that the speculation may cause a floating-point exception.

  • -fp-speculation strict
    = Disable speculations on floating-point operations.

Ref: https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/fp-speculation-qfp-speculation.html.

-fprotect-parens

Honor parentheses when floating-point expressions are evaluated for optimizations.

-ip
(ifort only, not in ifx)

Enable interprocedural optimization for single-file compilation. Ref: https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/ip-qip.html.

-ipo

Enable interprocedural optimization between files. Ref: https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/ipo-qipo.html.

-mp1
(ifort only, not in ifx)

Improves floating-point precision and consistency. This option disables fewer optimizations and has less impact on performance than -fltconsistency.

-O[Num]

Specify the code optimization level Num for applications, e.g., -O3. Ref: https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/o-001.html.

-Ofast

Equivalent to -fast and -O3 -static -no-prec-div -fp-model fast=2

-Os

Enable optimizations that do not increase code size; it produces smaller code size than -O2.

-no-prec-div
(ifort only, not in ifx)

Enable division-to-multiplication optimization and others that can give slightly less precise results than full IEEE division.

-no-prec-sqrt
(ifort only, not in ifx)

Enable optimizations that can affect the precision of a square root computation.

-qopt-dynamic-align

Enable dynamic data alignment optimizations, which can improve the performance of some vectorized code, but also increased code size and compile time.

-qopt-prefetch[=Num]
(ifort only, not in ifx)

Enable prefetch insertion optimization of the specified level Num to reduce cache misses. Ref: https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/qopt-prefetch-qopt-prefetch.html and https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/qopt-prefetch-distance-qopt-prefetch-distance.html.

-qopt-report=Num

Enable the generation of a YAML file that includes optimization transformation information with the level of detail Num, e.g., -qopt-report=2. Ref: https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/qopt-report-qopt-report-ifort-only.html or https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/qopt-report-qopt-report-ifx-only.html.

-qopt-report-file=keyword

Specifies where the output for the generated optimization report goes to. keyword can be filename, stderr, or stdout.

-unroll=Num

Specify the maximum number of times Num to unroll loops, e.g., -unroll=8.

-unroll-aggressive
(ifort only, not in ifx)

Disable aggressive, complete unrolling for loops with small constant trip counts.

-no-simd

Disable interpretation of !DIR$ SIMD ... for manual SIMD vectorization, which is enabled by default.

-no-vec

Disable auto vectorization, which is enabled by default at -O2 or higher.

Machine-dependent optimization flags, such as -march=core-avx2, -mtune=core-avx2, -mavx2, and -xHost, should NOT be employed directly. Instead, users should pass them implicitly by loading craype-x86-milan and using Cray compiler wrappers ftn (see).

OpenMP

Flags / Options

Short description

Flags / Options

Short description

-fiopenmp
(ifx only, not in ifort)

Enable OpenMP features. Equivalent to -qopenmp.

-qopenmp

Enable OpenMP features. Equivalent to -fiopenmp.

-qopenmp-link=static

Link to static OpenMP runtime libraries. Default: -qopenmp-link=dynamic.

-fopenmp is now deprecated and will be removed in the future. It could be used, but strongly discouraged for future compatibility.

Intel oneAPI Math Kernel Library (oneMKL)

Flags / Options

Short description

Flags / Options

Short description

-qmkl

Link to the (parallel) oneMKL library. Ref: https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/qmkl-qmkl.html.

-qmkl-ilp64

Link to the (parallel) ILP64 version of the oneMKL library. Ref: https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/qmkl-ilp64-qmkl-ilp64.html.

Others

Flags / Options

Short description

Flags / Options

Short description

-fPIC

Generate position-independent code. Usually used when building shared objects.

-fPIE

Generate position-independent code that can ONLY be linked into executables.

-ftz

Flush subnormal results to zero. Ref: https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/ftz-qftz.html.

-heap-arrays [size]

Put automatic and temporary arrays that are larger than size KB on the heap instead of the stack. Ref: https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/heap-arrays.html.

-mcondional-branch=[keyword]
(ifort only, not in ifx)

Identify code that may be vulnerable to speculative execution side-channel attacks as a result of bad speculation of a conditional branch direction. Ref: https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/mconditional-branch-qconditional-branch.html.

-pie

Link code compiled with -fPIE into an executable.

-pthread

Compile with POSIX thread library for multi-threading support.


Porting from IFORT to IFX

  • IFX does NOT support all flags/options available in IFORT. For example, -diag-dump, -fast-transcedentals, -ip, -mp1, -no-prec-div, -no-prec-sqrt, -parallel, -qopt-prefetch, -Winline and so on.

  • Floating-point behavior of IFX is not the same as IFORT. For example, -assume nan_compares should be used to get IFORT behavior. Please visit Porting Guide for ifort Users to ifx for the most updated details, especially on the -fp-model and -fimf-xxx-xxx options.

  • IFX assumes no integer overflow for better optimizations. The -fno-strict-overflow option should be used to detect integer overflow and obtain IFORT behavior.

  • IFX has a slightly different set of predefined macro and compiler version string format. This possibly causes the IFX compiler to be undetected in some software build systems.

  • Some pragmas/directives are not available in IFX, but they will be implemented in the future.

  • The IFX compiler can link DPC++ object files to use offloaded kernels (SYCL) in a Fortran program. For example, ifx -fsycl host.f90 device.o -lstdc++ -lsycl.

  • For more information, visit Porting Guide for ifort Users to ifx.


References & Further reading