Get Started

  • 2022.1
  • 04/11/2022
  • Public Content

Get Started on Linux*

Before You Begin

Before you can use this tool, you must first set the environment variables by sourcing the environment script using the initialization utility to initialize all the tools in one step:
  1. Determine your installation directory,
    <install_dir>
    :
    1. If your compiler was installed in the default location by a root user or sudo user, the compiler will be installed under
      <install root>/compiler/<version>/
      .
    2. For non-root users, your home directory under
      intel/
      is used. In this case,
      <install_dir>
      will be
      $HOME/intel/
      .
    3. For cluster or enterprise users, your admin team may have installed the compilers on a shared network file system. Check with your local admin staff for the location of installation (
      <install_dir>
      ).
  2. Source the environment-setting script for your shell:
    1. bash:
      source <install root>/compiler/env/setvars.sh
    2. csh/tcsh:
      source <install root>/compiler/env/setvars.csh

Use the Command Line

Use the command below to invoke the compiler from the command line.
  • ifort helloworld.f90
  • ifx helloworld.f90

Build a Program

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!” end
  2. From a command window, issue the following command to define the compiler using the C-SHELL.
    /usrs/users/me$ source <install root>/compiler/env/vars.csh intel64
    Or issue the following command using a BASH-style shell:
    /usrs/users/me$ source <install root>/compiler/env/vars.sh intel64
    This command adds the compiler directors to PATH and updates LD_LIBRARY_PATH to make it easier to run a Fortran program. This particular configuration defaults the compiler to generating 64-bit objects. That can be overridden using command line options.
    The command to invoke the setup script must be done in any command window where you want to use an Intel® Fortran Compiler. Alternatively, the command can be added to a
    .cshrc
    ,
    .bashrc,
    or other shell startup file.
  3. From the command window, issue the following command:
    /usrs/users/me$ ifort –o hello hello.f90
    /usrs/users/me$ ifx –o hello hello.f90
  4. Now you have an executable called "hello", which can be run and will give immediate feedback.
/usrs/users/me$ hello hello!
Fortran supports parallel processing by replicating images and allowing inter-image communication. This is done using coarrays, described in Intel® Fortran Compiler Tutorial: Using Coarray Fortran. Even though the "hello" program used above does not contain any coarray data, it can still be run as a coarray program.
The coarrays feature is only available for
ifort
. It is not available for
ifx
.
/usrs/users/me$ ifort –o hello–coarray -coarray-num-images=4 hello.f90 /usrs/users/me$ hello hello! hello! hello! hello!
/usrs/users/me$ ifx –o hello–coarray -coarray-num-images=4 hello.f90 /usrs/users/me$ hello hello! hello! hello! hello!

Next Steps

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.