Thursday, January 01, 2004

Fortran Compiler

Every computer needs a good Fortran compiler (YMMV). Fedora comes with the g77 compiler as part of the gcc package, but it doesn't produce very efficient code, though it is useful for checking proper Fortran 77 syntax.

Fortunately there is the Intel Fortran Compiler (and debugger) for Linux. When you go to the site, it looks like you have to pay for the compiler, except for a short-lived demo version. However, if you click on the link that says "Free evaluation download" and scroll down to the middle of that page, you'll see a link that says "non-commercial unsupported version". (There is a similarly-licensed c++ compiler, as well.) You'll see that the compiler is free in that "the non-commercial license means the compiler cannot be used to produce products for resale or commercial use."

Go down to the bottom of the page, take the survey, read the license agreement, and register. Eventually you'll get an email from Intel which has your license code, and will tell you where to download the source.

Installation isn't to hard. The code comes in a tar file with a set of RPMs and installation scripts. Run the installation script as root. It will ask you where your license is. It will also ask for any flags you want to pass to the rpm program to install the RPM files. Give in the flag --nodeps, otherwise you won't get a clean install.

After the installation is finished, take the contents of /opt/intel_fc_80/bin/ifortvars.csh into your ~/.cshrc file, if you are using the tcsh or csh shell, or put /opt/intel_fc_80/bin/ into your ~/.bashrc or ~/.kshrc file if you are using the bash or ksh shell, respectively. This will set up the environmental variables to find the Fortran libraries.

Finally, you can compile your code. I use the following flags to compile the standard "hello world" program: $ ifort -vms -tpp6 -WB hello.f -o hello to compile the executable hello from the source code hello.f. Note that ifort defaults to optimized code, so you don't need the -O flag. To turn optimization off, use -O0. The other flags are what I used for the 7.0 version of the compiler, they work in 8.0 but I don't know if they are necessary. I do know that 8.0 is not as fussy about extensions to the Fortran standards as 7.0 was. 7.0 would flag everything, 8.0 flags nothing, at least with these options.

I'll put up timing information when I get things properly set up.