Install Intel oneAPI C++ and Fortran compiler

Intel oneAPI is a cross-platform toolset that covers several languages including C, C++, Fortran and Python. Intel oneAPI replaces Intel Parallel Studio. Intel oneAPI including the Fortran compiler is free-to-use and no login is required to download oneAPI.

Refer to the oneAPI install guide to download the oneAPI Fortran compiler for Linux, MacOS or Windows. We suggest using the “online installer” download, which is a small download. The “online” installer can be copied over SSH to your HPC user account for example and installed from the Terminal.

For MacOS and Windows, there is a distinct step you need to do first:

  • MacOS: Install Xcode, then go to developer.apple.com and download and install Command Line Tools for your Xcode version
  • Windows: Install latest Visual Studio Community edition
  1. install the oneAPI Base Toolkit with these options

    • Math Kernel Library (oneMKL)
    • (optional) GDB debugger
  2. Install the oneAPI HPC toolkit with these options:

    • Intel MPI library
    • Intel C++ compiler
    • Intel Fortran compiler

There are slightly distinct usage patterns to access Intel oneAPI compilers on Windows vs. Mac/Linux.

On Windows a Start menu shortcut for a oneAPI command prompt is installed. CMake et al should just find the Intel compiler when in the oneAPI command prompt. Otherwise run setvars.bat as per oneAPI documentation.

Each time you wish to use Intel oneAPI on Linux or MacOS:

source /opt/intel/oneapi/setvars.sh

On MacOS, if upon compiling a C program you get errors like stdio.h isn’t found, or a C++ program wchar.h isn’t found, install Xcode Command Line Tools for the Xcode version currently installed. If the program persists, the problem may be that the Xcode include path may not be in Intel’s scripts. To workaround this issue, look for the Command Line Tools include directory and make a file ~/intel.sh including (check the directory name):

#!/bin/sh

set -o errexit

source /opt/intel/oneapi/setvars.sh

export CFLAGS=-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
export CPPFLAGS=$CFLAGS

export LIBRARY_PATH=$LIBRARY_PATH:/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/usr/lib

export FC=ifort CC=icx CXX=icpx

and source ~/intel.sh to use Intel oneAPI.