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)
Compiler
Language | Cray compiler wrapper | Underlying Intel compiler |
---|---|---|
Fortran | ftn | ifort |
The underlying compiler can be changed to the new LLVM-based Intel Fortran compiler ifx
by executing module swap intel intel-oneapi
(after loading cpeIntel
or PrgEnv-intel
).
Also see https://thaisc.atlassian.net/wiki/spaces/~6278ba6723d61e006fc39e39/pages/edit-v2/518160385#Porting-from-IFORT-to-IFX and https://www.intel.com/content/www/us/en/developer/articles/guide/porting-guide-for-ifort-to-ifx.html.
Flags / Options
Compilation
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 | Run Fortran preprocessor on source files before compilation. Ref: https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/fpp.html. |
-fuse-ld=name | Use a different linker, i.e., name, instead of the default linker |
-Idir | Specify an additional directory, i.e., dir, to search for include files. |
-lname | 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 |
-o target-name | Specify the name of the output file. |
-S | Compile to an assembly file ( |
-shared | Produce a dynamic shared object instead of an executable. Usually use with |
-static | Prevents linking with shared libraries |
-stand val | Follow a Fortran language standard where val are f90, f95, f03, f09 or f18. Alternatively, |
Fortran Features & Format
Flags / Options | Short description |
---|---|
-coarray[=keyword] | Enable the coarray feature. See https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/use-coarrays.html and https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/coarray-qcoarray.html. |
-convert [keyword] | Specify the format of unformated files containing numerical data. The keyword could be big_edian, little_endian and others. Ref: https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/convert.html. |
-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: https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/init-qinit.html. |
-parallel | Generate multi-threaded code for loops that can be safely executed in parallel. Ref: https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/parallel-qparallel.html and https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/par-schedule-qpar-schedule.html. |
-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 |
-no-wrap-margin | Disable the right margin wrapping that occurs in Fortran list-directed output. Ref: https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/wrap-margin.html (also see https://stackoverflow.com/questions/24492202/iforts-no-wrap-margin-works-only-partially). |
Warnings / Errors / Debug
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 |
-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 | Report when a function that is declared as inline is not inlined. |
Optimization
Flags / Options | Short description |
---|---|
-fast | Equivalent to |
-fast-transcedentals | 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 |
-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-speculation=keyword | Specify the mode in which to speculate on floating-point operations.
|
-fprotect-parens | Honor parentheses when floating-point expressions are evaluated for optimizations. |
-ip | 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 | Improves floating-point precision and consistency. This option disables fewer optimizations and has less impact on performance than |
-O[Num] | Specify the code optimization level |
-Ofast | Equivalent to |
-Os | Enable optimizations that do not increase code size; it produces smaller code size than |
-no-prec-div | Enable division-to-multiplication optimization and others that can give slightly less precise results than full IEEE division. |
-no-prec-sqrt | 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] | 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-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-aggressive | Disable aggressive, complete unrolling for loops with small constant trip counts. |
-no-simd | Disable interpretation of |
-no-vec | Disable auto vectorization, which is enabled by default at |
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 |
---|---|
-fiopenmp | Enable OpenMP features. Equivalent to |
-qopenmp | Enable OpenMP features. Equivalent to |
-qopenmp-link=static | Link to static OpenMP runtime libraries. Default: |
-fopenmp
is now deprecated and will be removed in the future. It could be used, but strongly discouraged for future compatibility.
The current Intel compilers do NOT support OpenMP offloading to NVIDIA GPU. (Ref)
Intel oneAPI Math Kernel Library (oneMKL)
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. |
Users can use
MKLROOT
environment variable to specify the path to the MKL library.Execute
module unload cray-libsci
to avoid using cray-libsci.Also visit https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-link-line-advisor.html
Others
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. |
-mcondiional-branch=[keyword] | 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 |
-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 getIFORT
behavior. Please visit https://www.intel.com/content/www/us/en/developer/articles/guide/porting-guide-for-ifort-to-ifx.html 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 obtainIFORT
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 https://www.intel.com/content/www/us/en/developer/articles/guide/porting-guide-for-ifort-to-ifx.html.