User and Reference Guide for the Intel® Fortran Compiler 14.0

Invoking the Intel® Fortran Compiler

Requirements Before Using the Command Line on Windows* OS

You typically do not need to set any environment variables prior to using the command line. Each of the Visual Studio* IDE variations has its own Intel® Compiler command-line window, available from the Intel® Parallel Studio XE 2013 program folder. For more information, see Using the Intel® Command-Line Window.

If you would like to use a custom shell instead, the Intel® Fortran Compiler installation includes a batch script that you can run to set environment variables. For more information, see Using the compilervars File to Specify Location of Components.

Requirements Before Using the Command Line on Linux* OS and OS X*

You need to set some environment variables to specify locations for the various components prior to using the command line. The Intel® Fortran Compiler installation includes a shell script for setting environment variables that can run in the terminal window. For more information, see Using the compilervars File to Specify Location of Components.

Using 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* OS 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* OS and OS X*) or link (Windows* OS) to build libraries of object modules. These commands provide syntax instructions at the command line if you request it with the help (Linux* OS and OS X*) or /? (Windows* OS) 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:

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.

Note

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.

Note

Windows* OS systems support characters in Unicode* (multibyte) format; the compiler will process file names containing Unicode* characters.

Syntax Rules

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

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* OS and OS X*) or x.obj (Windows* OS). The c option prevents linking (it does not link the object file into an executable file):

//  (Linux* OS and OS X*)
ifort -c x.for
		//  (Windows* OS)
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* OS and OS X*)
ifort x.o
//  (Windows* OS)
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* OS and OS X*) or a.exe (Windows* OS).

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* OS and OS X*) or /exe (Windows* OS):

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

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

//  (Linux* OS 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* OS)
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* OS):
//  (Windows* OS)
ifort filenames /options 1>both.out 2>&1
     // OR 
ifort filenames /options >both.out 2>&1

Other Methods for using the Command Line Window to Invoke the Compiler

See Also


Submit feedback on this help topic