Post

Fortran compiler flags correspondence

Cheat sheet for flags of Fortran compilers from different vendors.

Fortran compiler flags correspondence

Compiler vendors checked here

  • gfortran: Fortran compiler for the GCC project.
  • ifort: Intel’s classical Fortran compiler.
  • ifx: Intel’s new Fortran compiler based on LLVM.

List of selected flags

Usagegfortranifortifx
Inter-procedure optimization-flto-ip-ipo
Backtrace generation-fbacktrace-tracebackas ifort
Check out-of-bounds-fcheck=bounds-check boundsas ifort
Check uninitialized variables-Wuninitialized1-check uninitas ifort
Check pointer issues-fcheck=pointer-check pointersas ifort
Use single byte as record length unitn/a2-assume bytereclas ifort
Adhere to value-safe optimizations for f.p. computations-fno-fast-math-fp-model preciseas ifort
Enable stack overflow security checksas ifort-fstack-protectoras ifort
Enable overflow/divide-by-zero/invalid f.p. exceptions-ffpe-trap=invalid,zero,overflow-fpe0as ifort
Implicit initialization to signaling NaN-finit-real=snan3-init=snanas ifort
Control whether to implicitly initialize arraysn/a-init=arrays4as ifort

Remarks

When compiling FHI-aims with mpiifx, a segmentation fault happens during the compilation of elpa_impl.f90 in ELPA with -ipo switched on. In a thread about ifort in the Intel forum, Jim Dempsey pointed out that this can happen for large project. It is also discussed in the Fortran Discourse.


  1. It warns instead of quit with error. Implicitly switched on with -fcheck=all↩︎

  2. gfortran always uses 1 byte as record length unit. ifort/ifx uses 4-byte unit by default unless -assume byterecl is specified. ↩︎

  3. It also applies to real and imaginary parts of complex type. ↩︎

  4. Must work with -init=snan or -init=zero to specify the initial value. ↩︎

This post is licensed under CC BY 4.0 by the author.

Comments powered by Disqus.