Finally, I get to start writing about using Fortran on a Mac! In this post, I’ll give a short survey of the Fortran compilers that are available on the Mac. In the next, I plan to compare their performance on one of my codes. Compiler availability has never been better for Mac Fortran users. In the pre-Intel days there might have been only one or two Fortran compilers available at any given time.
Today there are six to choose from. Two of these are free; four are commercial products. And since Macs have been multi-core and multiprocessor for several years, we can now write HPC parallel programs using MPI or OpenMP that run on our desktops. GPU programming, the hot topic of the day, is also possible with a couple of the compilers. The six Fortran compilers for the Mac are:.
Absoft Pro Fortran. GNU gfortran. g95. Intel ifort. NAG nagfor.
PGI pgfortran I'd like to thank the Absoft, NAG and PGI folks for the trial versions of their compilers, which allowed me to support them in FTranProjectBuilder. The Free Fortran Compilers The two free Fortran compilers, gfortran and g95, run on Macs. The free gfortran is part of the gnu compiler suite and can be downloaded from Installation is painless using a standard package installer. The compiler is easy to use and runs great. I was a little apprehensive about using a compiler that is as young as it is, but those fears were unfounded.
The compiler has many of my favorite Fortran 2003 and 2008 features implemented, plus it has OpenMP support. A full list of those features can be found at After only a few weeks, I’ve decided that I really like using gfortran for my less computationally expensive problems. It is simple to set up and use. The free g95 compiler can be downloaded from. Unlike gfortran, g95 installation does not use a standard installer, and requires one to go into Terminal.app for some command line magic. But it is not too bad. I first unpacked the.tar file that I downloaded in new a directory.
Then I navigated to that directory in Terminal.app. Finally, I had to insert a symbolic link by typing sudo ln -s $PWD/g95-install/bin/i686-apple-darwin10.3.0-g95 /usr/bin/g95 (for the current version) to put a link in the standard directories. That completed the installation. The current binaries date to August of 2010, which seems a bit old to me. The g95 web site notes that some parts of the 2003 standard have been implemented, but I didn’t find a list of what those parts were.
A dating to the end of 2011 that presents which 2003 features have been implemented for the g95 compiler and others can be found at. The Commercial Fortran Compilers Four commercial compilers are available for the Mac.
The jump to a commercial compiler means support for questions, precompiled libraries like LAPACK and specialized “performance libraries,” e.g. For vector and parallel processing. The prices that I quote below for each compiler are for a single user license. Except for the nagfor compiler, the prices are directly from the companys' web sites. ($699 Commercial/$299 Academic) Absoft's is the granddaddy of Fortran compilers on the Mac. They had the first “real” Fortran compiler for the Mac.
I still have a 400K disk for the compiler that I bought for my Fat Mac right after the compiler came out of Beta in 1985. Over the years, Absoft has continued to support the Mac with compilers under various names, including “Microsoft Fortran”. The Absoft compiler installs with a standard package installer and weighs in at a hefty 685 Mb. (It comes with a lot of goodies.) The tools install in the Applications directory rather than the standard /usr/bin. For that reason, environment variables need to be set for UNIX tools to find them.
Part of the standard installation recommends having those variables installed for command line access. The license management is unobtrusive and just requires typing in the license key during the installation process. Absoft’s is the only Fortran compiler for the Mac that comes with an IDE. For awhile in the past, the IDE was a native Mac app. For the last few years, however, Absoft has been supplying a “cross platform” IDE, implemented in Qt.
Although touted as a feature, cross-platform means that menu items are not in their usual places and operations like drag and drop and saving don’t work as expected. For those reasons and more, I haven’t used the new version much. Absoft’s compiler has full F90/95 support plus support for OpenMP. The included BLAS and LAPACK libraries mean that one does not have to download, compile and link those oneself. F2003 support, however, appears to be very limited, especially compared to the other compilers, including the free ones.
($699 Commercial/$280 Academic/$49 Student) Mac users got to use the ifort compiler once Apple switched to Intel CPUs. Like the other commercial compilers, ifort packs a punch with the MKL library, BLAS, LAPACK and vector operations. On my codes, this compiler gives the best performance, up to three times faster than gfortran.
Hp pavilion dv1000 sata driver for mac. For high performance computing the compiler supports MPI, OpenMP, OpenCL and coarrays. The compiler has support for nearly all the F2003 features and some of the F2008 ones. Of particular note is the incredible student price.
For the performance gains that it gives over the free compilers, buying ifort should be a no-brainer for a student. Installation is done with a standard installer. Like Absoft’s approach, license management is taken care of by typing in the license key during the installation process. The compiler is installed in a standard location in /opt. Ifort does not have its own IDE, but does integrate with Xcode. The ifort compiler can be extremely complex to use. It supports a huge number of options and environment variables.
Whereas, for example, running a program in parallel using OpenMP with the gfortran compiler is a simple matter of compiling with the proper compiler flags, the ifort compiler requires several environment variables to be set, too. To help figure out what options to set for a given build, Intel has a where you can select options from pulldown menus and it will list the linker and compiler options.