Saturday, May 22, 2010

Ubuntu 10.04: Installing the 64-bit Intel Fortran Compiler

OK, let's get take care of this right up front: Warning: This page discusses the installation of free-as-in-beer, but not free-as-in-speech, software. If you want to keep such software off your system, then don't install this compiler. Also note that the license is pretty restrictive, i.e. Non-commercial means you are not getting compensated in any form for the products and services you develop using these Intel® Software Development Products. However, the installation process should work for the commercial version of this compiler.

I first learned to program in Fortran. I still have my original WATFOR/WATFIV textbook, though I later graduated to Fortran 77 and occasionally write some Fortran 90. I still do a lot of things in Fortran 77, just because I'm comfortable writing code starting in column 7.

Now there is an open-source Fortran 77/90/95 compiler, gfortran. It's reasonably fast, portable, nice — did I mention free? But it has a few quirks. For example, one of my old codes has a subroutine second which measures elapsed time. gfortran assumes that I'm calling the intrinsic function second, and bombs the compile because I don't have a proper calling statement. So I have to go in and declare

      external second

in every subroutine that calls my second.

But Intel makes its Linux Fortran compiler free-as-in-beer for non-commercial development. And the 64-bit version of the code includes Intel's optimized Math Kernel Library (MKL). It's a fairly simple registration, and you don't sign over much of your soul. However, in Ubuntu it's a fairly difficult installation. What's more, it changes every time you install a new version of the compiler.

The installation steps for the current compiler and Ubuntu are straightforward, but there's a lot of fine print, and the 64 bit version has a couple of quirks in the install. So let's go over it step by step. Note that I'm only referring to the 64-bit install in all of this. If you're running in 32-bit mode, your mileage will vary.

  1. Register. It's easy. You'll get a link to the download page an a serial number. Save the email, you'll need it.
  2. Download the appropriate tar file. I used the Genuine Intel® 64 bit version. There's another one called IA64, but I didn't try that.
  3. Now set up your machine to compile code. Run:
    sudo apt-get install build-essential gcc g++ rpm ia32-libs
    and either
    sudo apt-get install sun-java6-jre
    which requires you to accept Sun's Java license, or
    sudo apt-get install openjdk-6-jre-headless.
  4. Now you need a package called libstdc++5 which isn't included in Ubuntu. Worse, if you're on a 64 bit machine, you need to install the 32-bit version as well. So click on these
    the 64-bit code, libstdc++5_3.3.6-18_amd64.deb
    the 32-bit code, libstdc++5_3.3.6-18_i386.deb
  5. Install the 64-bit version:
    $ sudo dpkg -i libstdc++5_3.3.6-18_amd64.deb
    $ dpkg --extract libstdc++5_3.3.6-18_i386.deb ./
    $ cd usr/lib
    $ sudo -i
    # cp /usr/lib32
    # cd /usr/lib32
    # ln -s
    # exit
  7. Now we can do the install. Go back and find your Fortran tarball
    $ tar xvzf l_cprof_p_11.1.072_intel64.tgz
    $ cd l_cprof_p_11.1.072_intel64
    $ sudo -i
    # ./
  8. Take all the defaults, and enter your registration number when asked. Note that you'll get some error statements to the effect that you're running this on an unsupported system (Ubuntu) and the option
    1. Skip missing optional pre-requisites [default]
    take that.
  9. Your compiler is now installed in /opt/intel/Compiler/11.1/072/ (the last number will vary), but you're not quite finished.
  10. If you use the bash shell, add the line
    source /opt/intel/Compiler/11.1/072/bin/ intel64
    to your ~/.bashrc file.
  11. If you use the tcsh shell, add the line
    source /opt/intel/Compiler/11.1/072/bin/ifortvars.csh intel64 to your ~/.cshrc file.
  12. Now you're done. Look at man ifort to see how to use the thing.

My preliminary test indicates that the Intel compiler is about 10% faster than gfortran for a fairly CPU intensive calculation, without the MKL. Not all that much faster, really. If you're not doing a lot of serious computations, installing the Intel compiler might not be worth the trouble.


Anonymous said...

thanks for your recipe , it was useful for me.

GS said...

I had a problem with
"sudo -i"
command in section 6. For some reason it made my working directory /root and made the following commands to cause errors. I ended up skipping "sudo -i" and "sudoing" the following 3 commands (like "sudo cp /usr/lib32", etc.).

Very useful and clear instructions. Thanks a lot!

rcjhawk said...

sudo -i

effectively logs you in as root, so you do end up in the /root directory to start. But you can always chdir back to where you came from. When doing a long series of commands I prefer to do one sudo -i rather than prefacing every command with "sudo," but YMMV.

Anonymous said...

Nice instructions! Much clearer than the instructions posted on the Intel website.

Anonymous said...

Very helpful! By the way IA64 is Intel-speak for Itanium-based machines, so most users will NOT want to select that package. Intel64 refers to the 64-bit x86 architecture (also known as AMD64).

Anonymous said...

That worked great! I was actually looking to get libstdc++so5 installed on ubuntu 10.04 as it is required for Symantex Backup Exec remote agent RALUS and without it the agent will not start!
Thanks so Much!

Dust in the Wind said...

this is really useful for me...please let me add for sudo command as follows:

$sudo chmod +x

Frankwa Wawa said...

Thanks for this post, really helpful!

The links to the library are dead. When looking for other links I recommend paying attention to the version of listdc++5 .

The error:
`GLIBC_2.14' not found (required by /usr/lib/

... doesn't mean you have to upgrade glibc, but that you have to pick up a libstdc++5 which have been compiled with an older version of glibc.

In my case, these (hardy) versions worked fine:


rcjhawk said...

Well, to be fair, this is a 3-year-old post. If I ever get around to the much-rumored jump to LMDE, and if I install Intel Fortran there, I'll update the method. However, I've found that for my current needs gfortran works just as well. It compiles elk and Quantum Espresso and runs them decently on Hal, which is all I can ask. Plus it's Open Source.