How to Use Intel Parallel Studio Compilers (icc and ifort)

From UW-Math Wiki
Jump to navigation Jump to search

The Math Department supports the Intel C++ compiler, icc, and the Intel FORTRAN compiler, ifort. These programs should be available on all department desktop workstations and research machines.

To use these compilers, do the following:

  1. Open a terminal window. Math department workstations have several terminal emulators installed. The default emulator can be opened using Control+Alt+t.
  2. Source a script to set the proper environmental variables for your choice of compiler (see below).
  3. Use either icc or ifort to compile your code. Example, "icc -o HelloWorld helloworld.c"

Tip: The Math Department IT staff strongly suggests you consider using the "make" utility to compile your code. Google "makefile" for more information.

Sourcing a Script To Set Environmental Variables

Before you can use the Intel compilers, you must source a shell script to set environmental variables. If you see an error message that says the compiler was unable to check out a license, that is probably because you did not source the appropriate script. You will have to choose a script based upon your choice of login shell and compiler.

Most users at the Math Department are using bash as their shell. The alternative is tcsh. You can determine which shell you are using by typing, "echo $SHELL" at a command prompt.

The scripts also require you to specify a choice of architecture for the compiler. The choices are ia32 or intel64. You will probably wish to compile your code for the intel64 architecture. While ia32 provides greater portability, the Math Department no longer has any 32-bit machines. Your code will run faster on a 64-bit machine if compiled for the intel64 architecture.

To set environmental variables in the bash shell for the Intel C++ compiler:

  • source /usr/local/intel/iccvars.sh intel64

For the bash shell and the Intel FORTRAN compiler:

  • source /usr/local/intel/ifortvars.sh intel64

To set environmental variables in the tcsh shell for the Intel C++ compiler:

  • source /usr/local/intel/iccvars.csh intel64

For the tcsh shell and the Intel FORTRAN compiler:

  • source /usr/local/intel/ifortvars.csh intel64

Tip: To avoid having to type these commands each time you log into a department workstation or research machine, we suggest you add these commands to the start up script for your shell. For bash, that is .bashrc and for tcsh it is .login.