Search code examples
fortranicccompiler-flags

What does the icc (or mpiicc) -E flag do?


I'm encountering a mystery flag in a build script. It executes a command like

mpiicc -E driver.F90 > driver.tmp.f90

This places a few preprocessor directives at the top of driver.tmp.f90, but is otherwise identical to driver.F90. In this case it looks like this:

# 1 "driver.F90"
# 1 "/usr/include/stdc-predef.h" 1
# 1 "driver.F90" 2

I cannot find a description of the -E flag in the man entry or on Intel's website. So what exactly is this flag doing?


Solution

  • For both Intel and Gnu C compilers the -E flag causes the compiler to run the C preprocessor on the file, and send the output to stdout. From the icc man page

      -E
    
              Causes the preprocessor to send output to stdout.
    
              Arguments:
    
              None
    
              Default:
    
              OFF               Preprocessed source files are output to
                                the compiler.
    
              Description:
    
              This option causes the preprocessor  to  send  output  to
              stdout.  Compilation  stops when the files have been pre-
              processed.
    
              When you specify this option, the compiler's preprocessor
              expands  your source module and writes the result to std-
              out. The preprocessed source contains  #line  directives,
              which  the compiler uses to determine the source file and
              line number.