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

ID 767260
Date 3/22/2024
Public

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

Get Started on macOS*

Before You Begin

NOTE:
Starting with the 2024.0 release, macOS is not supported by the ifx compiler.

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

Invoke the Compiler From the Command Line

Invoke the compiler using the following syntax:

ifort [option] file1 [file2...] [/link link_options]

For example: ifort helloworld.f90

Build a Program From the Command Line

Follow the steps below 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 Use the setvars and oneapi-vars Scripts with Linux*.
  4. From the terminal window, issue the following command to compile hello.f90:
    ifort –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!