Free FORTRAN compiler – or one that does not have to be updated all the time

developmentxcode

I have paid some good money to buy the "Intel Parallel Studio XE Composer Edition for Fortran OS X" – The problem is that, whenever the OS changes (i.e., from Lion to Mountain Lion to Mavericks to Yosemite), the compiler needs update, and purchase of a new version. (Unless you buy a maintenance, approx. $300/yr). Also, sometimes a new version is required even when Xcode is updated!

Two questions:

  1. Is there some free FORTRAN compiler or a non-free, which works after updates of Xcode or/and OS?

  2. Is there a way to make it work, even if is was destined for say Mavericks?

Best Answer

re free Fortran compilers

gfortran is part of gcc (gcc stands for GNU Compiler Collection not just the name of GNU's c++ compiler)

Xcode now does not install gcc (even via command line tools) gcc is a link or wrapper to clang

As to installation my first attempt would be via a package manager like Macports or Homebrew or fink.

For macports (others will be similar) install will be

  1. Install macports as per the guide
  2. install gcc with the fortran option sudo port install gcc5
  3. install a select program to allow selection of different gcc versions (in this case there will only be one) sudo port install gcc_select
  4. select the version sudo port select --set gcc mp-gcc5

gfortran is now in /opt/local/bin

Macports should download readymade binaries for this so no wait for a long compile of gcc

If you upgrade the OS Macports will need a complete reinstallation (OK it might work but support and test is only done on a complete reinstallation, previous OS upgrades have definitely needed one the last 1-2 might have worked)

Homebrew instructions are included in this article which also includes other free Fortran compilers and other useful Fortran info.