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

Specify Component Locations

Before you invoke the compiler, you must set certain environment variables that define the location of compiler-related components. Environment variables should be set for each terminal session before you invoke the compiler. If you do not set the variables, the compiler can behave unpredictably. The compiler includes environment configuration scripts to configure your build and development environment variables:

  • On Linux, the file is a shell script called setvars.sh.
  • On Windows, the file is a batch file called setvars.bat.

Set Environment Variables for CLI Development

NOTE:

The Unified Directory Layout was implemented in 2024.0. If you have multiple toolkit versions installed, the Unified layout ensures that your development environment contains the correct component versions for each installed version of the toolkit.

The directory layout used before 2024.0, the Component Directory Layout, is still supported on new and existing installations.

For detailed information about the Unified layout, including how to initialize the environment and advantages with the Unified layout, refer to Use the setvars and oneapi-vars Scripts with Linux.

Compiler environment variables must first be configured if using the compiler from a Command Line Interface (CLI). Environment variables are set up with a script called setvars in the Component Directory Layout or oneapi-vars in the Unified Directory Layout. By default, changes to your environment made by sourcing the setvars.sh or oneapi-vars.sh script apply only to the terminal session in which the environment script was sourced. You must source the script for each new terminal session.

Detailed instructions on using the setvars.sh or oneapi-vars.sh script are found in Use the setvars and oneapi-vars Scripts with Linux.

Optionally use one-time setup for setvars.sh as described in Use Modulefiles with Linux*.

Linux

Set the environment variables before using the compiler by sourcing the shell script setvars.sh. Depending on the shell, you can use the source command or a . (dot) to source the shell script, according to the following rules for a .sh script:

Using source:

source /<install-dir>/setvars.sh <arg1> <arg2> … <argn> 

Example:

source /opt/intel/oneapi/setvars.sh intel64

Using . (dot):

. /<install-dir>/setvars.sh <arg1> <arg2> … <argn>

Example:

. /opt/intel/oneapi/setvars.sh intel64

Use source /<install-dir>/setvars.sh --help for more setvars usage information.

The compiler environment script file accepts an optional target architecture argument <arg>:

  • intel64: Generate code and use libraries for Intel® 64 architecture-based targets.
  • --include-intel-llvm: Adds the Intel Compiler's clang binaries folder (bin-llvm) to the PATH.

If you want the setvars.sh script to run automatically in all of your terminal sessions, add the source setvars.sh command to your startup file. For example, inside your .bash_profile entry for Intel® 64 architecture targets.

If the proper environment variables are not set, errors similar to the following may appear when attempting to execute a compiled program:

./a.out: error while loading shared libraries: 
libimf.so: cannot open shared object file: No such file or directory

Windows

Under normal circumstances, you do not need to run the setvars.bat batch file. The terminal shortcuts in the Windows Start menu, Intel oneAPI command prompt for <target architecture> for Visual Studio <year>, set these variables automatically.

For additional information, see Use the Command Line on Windows.

You need to run the setvars batch file if a command line is opened without using one of the provided Command Prompt menu items in the Start menu, or if you want to use the compiler from a script of your own.

The setvars batch file inserts DLL directories used by the compiler and libraries at the beginning of the existing Path. Because these directories appear first, they are searched before any directories that were part of the original Path provided by Windows (and other applications). This is especially important if the original Path includes directories with files that have the same names as those added by the compiler and libraries.

The setvars batch file takes multiple optional arguments; the following two arguments are recognized for compiler and library initialization:

<install-dir>\setvars.bat [<arg1>] [<arg2>]

Where <arg1> is optional and can be:

  • intel64: Generate code and use libraries for Intel® 64 architecture (host and target).
  • --include-intel-llvm: Adds the Intel Compiler's clang binaries folder (bin-llvm) to the PATH.

The <arg2> is optional. If specified, it is one of the following:

  • vs2022: Microsoft Visual Studio 2022
  • vs2019: Microsoft Visual Studio 2019

If you have more than one edition of Visual Studio installed on your system (example: 2022 Professional and 2022 Enterprise), the automatic search for an installation uses the following precedence (within a specific year):

  • Professional
  • Enterprise
  • Community

The preferred edition can be specified using the VS20??INSTALLDIR environment variables (VS2022INSTALLDIR, VS2019INSTALLDIR, etc.).

If <arg1> is not specified, the script uses the intel64 argument by default. If <arg2> is not specified, the script uses the highest installed version of Microsoft Visual Studio detected during the installation procedure.