Saturday, April 08, 2006

Ubuntu: Installing Intel Fortran

As noted previously, I need a good Fortran compiler for this computer, and the best free (as in beer) compiler is the one from Intel. The problem is that Intel delivers its compiler in a set of (Oh, the Horror!) RPMs. So we need to do a bit of a conversion process.

There are basically two options:

  1. Set up your system to install RPMs (installing the alien package does this anyway), and install away. This isn't a particularly nice way of doing things, but it probably works.
  2. Convert the RPM to DEB format, and install that way. This lets you tweak the system a little bit.

I went the second way. The method is explained here, but it's based on a Debian installation guide, and I'll summarize it here.

We assume that you're going to install the 9.0 version of the compiler.

  1. Register with Intel if you haven't already. You'll get a file in email, called noncommercial_for_l#GarbageString#.lic. Save it someplace. Save the email as well, because it also contains your license number if you need a backup.
  2. Download the package. This also includes a debugger and versions of the compiler and debugger for 64 bit machines. We'll leave these installs as an exercise for the reader.
  3. Download the make_deb_9 script, and save in the same directory as your Fortran RPM.
  4. Open a terminal window, cd to the directory with your RPM and make_deb_9 file, and run the following, entering your password where required:
    $ sudo alien -k intel-ifort9-9.0-031_i386.rpm
    $ sudo ./make_deb_9 intel-ifort9_9.0-031_i386.deb
    $ sudo dpkg -i intel-ifort9_9.0-031_i386.deb
    
  5. Change to the directory where you saved your Intel License file and run
    $ sudo cp noncommercial_for*.lic /opt/intel/fc/9.0/licenses
  6. Add the contents of /opt/intel/fc/9.0/bin/ifortvars.csh to your file ~/.chsrc, if you use csh or tcsh shells. If you run bash, (or sh, which is aliased to bash), add /opt/intel/fc/9.0/bin/ifortvars.sh to your ~/.bashrc file. If you're comfortable doing it, you can edit the contents of these files to fit in better with your system.
  7. Open a new terminal window (this makes sure that all of the statements in the ifortvars script get started properly). cd to a directory with a Fortran program. Picking exactly which options you use to compile is something of an art form, but I find that this works:
    $ ifort -O3 -axN -ip -WB -Vaxlib program.f -o program
    
    creating an executable called program from program.f

And so far it all works. Hope it works for you, too.

Note added 8 Dec 2006: You need the alien step above, which I forgot to include. Note that Intel is now up to the 9.1 compiler. This requires a bit of editing of the make_deb_9 file to make the directory structure right. In the current version I have to change all references of 9.0 to 9.1.036, but that obviously depends on the build you download.

1 comments:

Anonymous said...

If I do
sudo alien -k intel-icce8-8.1-037.i386.rpm

I get the following error

Package build failed. Here's the log:
dh_testdir
dh_testdir
dh_testroot
dh_clean -k -d
dh_installdirs
dh_installdocs
dh_installchangelogs
find . -maxdepth 1 -mindepth 1 -not -name debian -print0 | \
xargs -0 -r -i cp -a {} debian/intel-icce8
dh_compress
dh_makeshlibs
objdump: debian/intel-icce8/opt/intel_cce_80/lib/libcxaguard.so: File format not recognized
objdump: debian/intel-icce8/opt/intel_cce_80/lib/libcprts.so: File format not recognized
objdump: debian/intel-icce8/opt/intel_cce_80/lib/libunwind.so: File format not recognized
objdump: debian/intel-icce8/opt/intel_cce_80/lib/libcxa.so: File format not recognized
dh_installdeb
dh_shlibdeps
dpkg-shlibdeps: warning: format of `NEEDED libirc.so' not recognized
dpkg-shlibdeps: warning: format of `NEEDED libirc.so' not recognized
dpkg-shlibdeps: warning: unable to find dependency information for shared library libstdc++ (soname 5, path libstdc++.so.5, dependency field Depends)
dpkg-shlibdeps: warning: unable to find dependency information for shared library libstdc++ (soname 5, path libstdc++.so.5, dependency field Depends)
dpkg-shlibdeps: warning: unable to find dependency information for shared library libstdc++ (soname 5, path libstdc++.so.5, dependency field Depends)
dpkg-shlibdeps: warning: unable to find dependency information for shared library libstdc++ (soname 5, path libstdc++.so.5, dependency field Depends)
dpkg-shlibdeps: warning: unable to find dependency information for shared library libstdc++ (soname 5, path libstdc++.so.5, dependency field Depends)
dpkg-shlibdeps: warning: unable to find dependency information for shared library libstdc++ (soname 5, path libstdc++.so.5, dependency field Depends)
dpkg-shlibdeps: warning: unable to find dependency information for shared library libstdc++ (soname 5, path libstdc++.so.5, dependency field Depends)
dh_gencontrol
dpkg-gencontrol: error: current build architecture amd64 does not appear in package's list (i386)
dh_gencontrol: command returned error code 65280
make: *** [binary-arch] Error 1
find: intel-icce8-8.1: No such file or directory