Intel® Fortran Compiler 16.0 User and Reference Guide
You may need to set certain environment variables before using the command line. For more information, see Specifying Location of Compiler Components with compilervars File.
You can invoke the Intel® Fortran Compiler on the command line using the ifort command.
For Windows* and OS X* systems, you can also use the compiler from within the integrated development environment (IDE).
For more information on using the Visual Studio* IDE, see Using Microsoft Visual Studio*. For information on using the Xcode* IDE, see Using Xcode*.
The syntax of the ifort command is:
ifort [options]input_file(s)
The ifort command can compile and link projects in one step or compile them then link them as a separate step.
In most cases, a single ifort command will invoke both the compiler and linker. You can also use ld (Linux* and OS X*) 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 OS X*) or /? (Windows*) option.
The ifort command automatically references the appropriate Intel® Fortran Run-Time 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:
Calls the Intel® Fortran 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 driver calls other software components, error messages may be returned by other components. 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.
The compiler recognizes Language Extensions for Offloading in the source program by default and builds a heterogeneous binary that runs on both the target and host when any are present. If your program includes these language extensions and you do not want to build a heterogeneous binary, specify the -no-offload compiler option. For more information, see the Programming for Intel® MIC Architecture: Heterogeneous Programming section and the -no-offload compiler option.
Windows* systems support characters in Unicode* (multibyte) format; the compiler will process file names containing Unicode* characters.
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 OS X* or a slash (/) for Windows*. (You can use a hyphen (-) instead of a slash (/) for Windows*, but this 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 filenames, strings, letters, and numbers. If a string includes spaces, they must be enclosed in quotation marks. Some options take arguments in the form of filenames, 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:
NoteOptions 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) |
Multipleinput_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 filename extension specifies the type of file. See Understanding File Extensions. |
Xlinkker (Linux* and OS X*) or /link (Windows*) |
Unless specified with certain options, the command line will both compile and link the files you specify. To compile without linking, specify the c option. All compiler options must precede the -Xlinker (Linux* and OS X*) or /link (Windows*) options. Options that appear following -Xlinker or /link are passed directly to the linker. |
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 OS X*) or x.obj (Windows*). The c option prevents linking (it does not link the object file into an executable file):
// (Linux* and OS X*) 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 OS X*) 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 OS X*) 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 OS X*) or /exe (Windows*):
// (Linux* and OS X*) 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 OS X*):
// (Linux* and OS X*) 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.outTo 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
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 Using Makefiles to Compile Your Application.
Using the devenv command from the Command Line (Windows* only): Use devenv to set various options for the integrated development environment (IDE) as well as 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: Use a .bat file to consistently execute the compiler with a desired set of options instead of retyping the command each time you need to recompile.