Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/22/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

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 Specify the Location of Compiler Components.

Compiler Drivers

The Intel® Fortran Compiler Classic and Intel® Fortran Compiler each have a driver:

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 Compiler from the Command Line

Invoke the compiler on the using the ifort or ifx command. This page uses ifx as an example.

The syntax of the ifx command is:

ifx [option]input_file

The ifx 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 ifx command invokes the compiler and linker. You can also use ld (Linux) 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), or the /help or /? (Windows) options.

The ifx command automatically references the appropriate runtime libraries when it invokes the linker. To link one or more object files created by the compiler, you should use the ifx command instead of the link command.

The ifx 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:

  • Calls the compiler to process Fortran files.
  • Passes the linker options to the linker.
  • Passes object files created by the compiler to the linker.
  • Passes libraries to the linker.
  • Calls the linker or librarian to create the executable or library file.

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 Alphabetical Option List.

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 ifx on the command line:

Argument

Description

options

An option is specified by one or more letters preceded by a hyphen (-) for Linux 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 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.

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:

ifx -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) 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 /link (Windows) options. -Xlinker can be used anywhere on the command line, only single options/files can be specified after -Xlinker. Options that appear following -Xlinker or /link are passed directly to the linker.

Examples of the ifx Command

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

ifx x.for

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

Linux

ifx -c x.for

Windows

ifx x.for /c

This command links x.o or x.obj into an executable file. This command automatically links with the default libraries:

Linux

ifx x.o

Windows

ifx x.obj

This 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) or a.exe (Windows).

ifx 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 ifx 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:

ifx moddef.f90 projmain.f90

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

Linux

ifx x.for -o myprog.out

Windows

ifx x.for /exe:myprog.exe

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

myprog > results.lis
more results.lis

To place standard output into file one.out and standard error into file two.out (Windows only):

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

Other Methods for Using the Command Line to Invoke the Compiler

  • Using makefiles from the Command Line: Use makefiles to specify a number of files with various paths and to save this information for multiple compilations. For more information on using makefiles, see Use Makefiles to Compile Your Application.
  • Using the devenv Command from the Command Line (Windows only): Use devenv to set various options for the IDE, and to build, clean, and debug projects from the command line. For more information on the devenv command, see the devenv description in the Microsoft Visual Studio documentation.
  • Using a Batch File from the Command Line: Create and use a .bat file to execute the compiler with a desired set of options instead of retyping the command each time you need to recompile.