Installing a more reliable Fortran compiler in your home directory

The GNU Fortran compiler installed on the Astro system has a bug which is exhibited when you use it to build scipy. Fix this by installing the most recent version of gfortran that is packaged and available on the R website. Do not install the version from the HPC on OS X website (or any GCC packages from that site). They are buggy.

By default the R gfortran package installs itself into /usr/local, which you don’t have permission to write to. You should therefore install it in ~/usr/local, or some other directory in your home directory. To do this:

  1. Mount the disk image you download.

  2. cd ~ in Terminal

  3. Run this command:

     pax -zr < /Volumes/GNU\ Fortran\ 4.2.3/gfortran.pkg/Contents/Archive.pax.gz
    

You should now have a directory ~/usr/local full of gfortran-related stuff. Add ~/usr/local/bin to your shell’s PATH. Make sure it appears in the path ahead of /usr/local/bin or you will continue to use the buggy Fortran compiler. If you use Fortran for anything other than compiling scipy then make sure you understand the implications of this.