Mountain Lions like Fortran

A slow running laptop was a good excuse to play around with a fresh install of OSX 10.8 (Mountain Lion). The implementation of Xcode has been changing over the last few versions, so here are the few straight forward steps required to get command-line Fortran running on your Mac.

1. Download Xcode from the App Store
– Run application to Install
– Xcode Preferences -> Downloads -> Command Line Tools

2. GNU Compilers
– Download 10.8 gcc and gfortran binaries and libraries from
– In terminal run “sudo tar -xvf gcc-mlion.tar -C /”
– Ensure the line “export PATH=/usr/local/bin:$PATH” is in your .bash_profile.

$ gfortran –version
GNU Fortran (GCC) 4.8.0 20120722 (experimental)
$ gcc –version
gcc (GCC) 4.8.0 20120722 (experimental)

3. Intel Compilers (Fortran Composer 2011)
– Install package.
– For install environment choose “Command line install only”.
– If write permission issues arise, run “sudo chmod u+rwx /Users/Shared/Library/Application\ Support/”.
– source /opt/intel/bin/ intel64
– source /opt/intel/mkl/bin/intel64/
– Run once as “sudo ifort” to overcome some permissions issues with the libraries.

$ ifort –version
ifort (IFORT) 12.1.0 20111011

Example Makefile (FHI-AIMS):
FC = ifort
FFLAGS = -O3 -ip
LAPACKBLAS = -L/opt/intel/mkl/lib \
-I/opt/intel/mkl/include -lmkl_intel_lp64 \
-lmkl_sequential -lmkl_core



  1. Jeremy

    Have you noticed any issues with ifort? My compiled binaries do not work if I use ifort on 10.8 w/XCode 4.4. Intel has a blog post saying it isn’t supported yet. Wondering if there is something I am missing.

    • Aron

      No problems here at all, but I don’t make use of any XCode features. Binaries from ifort/mkl compilations work fine (even those compiled on 10.7 and copied over!).

  2. Manfred Meier

    Thanks, this is potentially very good news to me. However I’m stuck at step 3. The Fortran installer asks about the location of the Xcode folder, which isn’t in /Developer any longer in v 4.4.1 but resides as a single file in /Applications. Yet specifying that folder does not help. How can I tell the installer where to look? I have Fortran Composer XE 2011 Update 9 – should I get a more recent one? Thanks for your help!

  3. lzrain

    Thank you for your instructions. I did the first two steps successfully but met a problem installing ifort 12.1.4 on OSX 10.8. It said “Make sure that you have write permissions to…” and then the installation was failed. I tried to use Disk Utility to fix the problem, but it didn’t work…

    • Aron

      The only place that could cause problems is “/Users/Shared/Library/Application\ Support”. By default, it should be writeable, but installing other applications can change this. If you change write permissions for that folder than it should proceed! I will update the guide.

      • lzrain

        Setting write permissions didn’t work. I finally login as root and finished step 3, but there is no fortran compiler in the “build rules” of xcode… Any help will be appreciated.

  4. Fred

    Hey I have installed everything and gfortran works in Terminal. But how do I use it on Xcode 4.4?


  5. anton

    hey, you have a pretty nice blog going, i am having some trouble compiling quantum espresso with ifort 12.1, i am wondering if you could post your linker flags for the mkl libraries. thanks! i’m running a mbp 8,1 from early 2011

  6. Florian PYS

    Hello, I’ve got a problem on the second step. When I extract the gcc archive, I’ve got this message :
    tar: Error opening archive: Failed to open ‘gcc-mlion.tar’

  7. Vasileios

    @Florian PYS make sure you got the filename right. Perhaps it had a different name when you downloaded it.

  8. Pingback: Mountain Lions like OpenMPI « thelostelectron

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s