Get Started with the Intel® Fortran Compiler Classic and Intel® Fortran Compiler

ID 767260
Date 6/24/2024
Public

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

Get Started on Linux*

Before You Begin

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*.

NOTE:

The conda package for the Intel® Fortran Compiler runtime no longer has a runtime dependency on the Intel® MPI Library, which is needed to enable Coarrays. If you maintain a conda package that has a runtime dependency on the Intel Fortran Compiler runtime and your application uses the Intel MPI Library, you need to explicitly add the impi_rt conda package for the Intel MPI Library to the list of runtime dependencies in your project’s meta.yaml file.

Invoke the Compiler From the Command Line

Invoke the compiler on the command line using the following syntax:

{ifx|ifort} [option] file1 [file2...] [/link link_options]

For example:

ifx hello.f90

Build a Program From the Command Line

Use the following steps to test your compiler installation and build a program.

  1. Use a text editor to create a file called hello.f90 with the following contents:
    print *, "Hello, world!"
    end
  2. Open a terminal window.
  3. If you are not using one-time setup for setvars.sh, set environment variables by sourcing setvars:

    Component Directory Layout

    source <install-dir>/setvars.sh

    Unified Directory Layout

    source <install-dir>/<toolkit-version>/oneapi-vars.sh
    For information about the <install-dir> location for Component or Unified layout on system-wide or private installations, refer to Using the setvars and oneapi-vars Scripts with Linux*.
  4. From the terminal window, issue the following command to compile hello.f90:
    ifx –o hello hello.f90
  5. Now you have an executable called hello, which can be run and will give immediate feedback.
    hello
    Which outputs:
    Hello, world!