Invoke the Compiler

Requirements Before Using the Command Line

You may need to set certain environment variables before using the command line. For more information, see Specifying the Location of Compiler Components.

Different Compilers and Drivers

The table below provides the different compiler front-end and driver information.

Compiler Notes Linux* Driver Windows* Driver

Intel® Fortran Compiler Classic

A Fortran compiler with full Fortran 2018 support.

ifort ifort

Intel® Fortran Compiler

A Fortran compiler based on the Intel Fortran Compiler Classic (ifort) front-end and runtime libraries, using LLVM back-end technology.

ifx ifx

Use the Intel® Fortran Compiler from the Command Line

You can invoke the Intel® Fortran Compiler on the command line using the ifort command.

Note

For Windows and macOS* systems, you can use the compiler within the IDE.

For more information on using the Microsoft Visual Studio IDE, see Using Microsoft Visual Studio.

The syntax of the ifort command is:

ifort [options]input_file(s)

The ifort command can compile and link projects in one step, or can compile them and then link them as a separate step.

In most cases, a single ifort command invokes the compiler and linker. You can also use ld (Linux and macOS*) or link (Windows) to build libraries of object modules. These commands provide syntax instructions at the command line if you request it with the -help (Linux and macOS*), or the /help or /? (Windows) options.

The ifort command automatically references the appropriate Intel® Fortran runtime Libraries when it invokes the linker. To link one or more object files created by the Intel® Fortran Compiler, you should use the ifort command instead of the link command.

The ifort command invokes a driver program that is the user interface to the compiler and linker. It accepts a list of command options and file names and directs processing for each file. The driver program does the following:

Because the compiler driver calls other software components, they may return error messages. For instance, the linker may return a message if it cannot resolve a global reference. The watch option can help clarify which component is generating an error.

For a complete listing of compiler options, see the Compiler Options reference.

Note

Windows systems support characters in Unicode* (multibyte) format. The compiler processes the file names containing Unicode characters.

Syntax Rules

The following rules apply when specifying ifort on the command line:

Argument

Description

options

An option is specified by one or more letters preceded by a hyphen (-) for Linux and macOS* or a slash (/) for Windows. (You can use a hyphen (-) instead of a slash (/) for Windows, but it is not the preferred method.)

Options cannot be combined with a single slash or hyphen, you must specify the slash or hyphen for each option specified. For example: /1 /c is correct, but /1c is not.

Options can take arguments in the form of file names, strings, letters, and numbers. If a string includes spaces, they must be enclosed in quotation marks.

Some options take arguments in the form of file names, strings, letters, or numbers. Except where otherwise noted, a space between the option and its argument(s) can be entered or combined. For a complete listing of compiler options, see the Compiler Options reference.

Some compiler options are case-sensitive. For example, c and C are two different options.

Option names can be abbreviated, enter as many characters as are needed to uniquely identify the option.

Compiler options remain in effect for the whole compilation unless overridden by a compiler directive.

Certain options accept one or more keyword arguments following the option name on Windows. To specify multiple keywords, you typically specify the option multiple times. However, some options allow comma-separated keywords. For example:

  • Options that use a colon can use an equal sign (=) instead.
  • Standard output and standard error can be redirected to a file, avoiding displaying excess text, which slows down execution. Scrolling text in a terminal window on a workstation can cause an I/O bottleneck (increased elapsed time) and use more CPU time. See the examples in the next section.

Note

Options on the command line apply to all files. In the following example, the -c and -nowarn options apply to both files x.f and y.f:
ifort -c x.f -nowarn y.f

input file(s)

Multiple input_files can be specified, using a space as a delimiter. When a file is not in PATH or working directory, specify the directory path before the file name. The file name extension specifies the type of file. See Understanding File Extensions.

Xlinker (Linux and macOS*) or /link (Windows)

Unless specified with certain options, the command line compiles and links the files you specify. To compile without linking, specify the c option.

All compiler options must precede the -Xlinker (Linux and macOS*) or /link (Windows) options. Options that appear following -Xlinker or /link are passed directly to the linker.

Examples of the ifort Command

The following command compiles x.for, links, and creates an executable file. This command generates a temporary object file, which is deleted after linking:

ifort x.for

The following command compiles x.for and generates the object file x.o (Linux and macOS*) or x.obj (Windows). The c option prevents linking (it does not link the object file into an executable file):

//  (Linux and macOS*)
ifort -c x.for
//  (Windows)
ifort x.for /c

The following command links x.o or x.obj into an executable file. This command automatically links with the default Intel® Fortran libraries:

//  (Linux and macOS*)
ifort x.o
//  (Windows)
ifort x.obj

The following command compiles a.for, b.for, and c.for, creating three temporary object files, then linking the object files into an executable file named a.out (Linux and macOS*) or a.exe (Windows).

ifort a.for b.for c.for

Compile the source files that define modules before the files that reference the modules (in USE statements) when using modules and compile multiple files.

When you use a single ifort command, the order in which files are placed on the command line is significant. For example, if the free-form source file moddef.f90 defines the modules referenced by the file projmain.f90, use the following syntax:

ifort moddef.f90 projmain.f90

To specify a particular name for the executable file, specify the option -o (Linux and macOS*) or /exe (Windows):

//  (Linux and macOS*)
ifort x.for -o myprog.out
//  (Windows)
ifort x.for /exe:myprog.exe

To redirect output to a file and then display the program output (Linux and macOS*):

//  (Linux and macOS*)
myprog > results.lis
more results.lis

To place standard output into file one.out and standard error into file two.out:

//  (Windows)
ifort filenames /options 1>one.out 2>two.out
// OR 
ifort filenames /options >one.out 2>two.out
To place standard output and standard error into a single file both.out (Windows):
//  (Windows)
ifort filenames /options 1>both.out 2>&1
// OR 
ifort filenames /options >both.out 2>&1

Other Methods for Using the Command Line to Invoke the Compiler

See Also