Installing g95 or gfortran with MacPorts
(Original blog entry posted on 7/27/09)
Besides a C compiler, AMBER installation requires a FORTRAN 90 compiler, this has been the case since AMBER 8. FORTRAN 90 compilers are not provided by Apple in developer environment therefore FORTRAN developers need to acquire a third party compiler by themselves. AbSoft PRO Fortran, NAG Fortran 90, IBM XL Fortran 9 and Intel Fortran are some fine compilers that require some funding. There are two popular open source licensed FORTRAN 90 compilers, g95 and gfortran. These two compilers originates from the same group of people but the diverged due to the difference of project managing styles. g95 is more conservatively and independently developed while gfortran integrates itself to the mothership -- gcc source tree. G95 has some advanced feature like coarrays, but gfortran does have something g95 doesn't have: OpenMP.
There are many ways to install these open source FORTRAN compilers on Mac OS X, you could build the compilers from the source or just install the binary packages, or from the way between: using porting system to build them automatically.
Before I write anything about the getting the compilers for your Mac OS X, you should at least have installed:
- Apple's Xcode Developer Tools (at least version 3.2 for Snow Leaopard, version 3.1 for Leopard, or 2.4 for Tiger, ), found at the Apple Developer Connection site or on your Mac OS X installation CDs/DVD.
- (You need this for Amber.) The X11 windowing environment (A.K.A. “X11 User”) and its related SDK package (“X11SDK”)
for ports that depend on the functionality they provide to compile and run.
- the “X11 User” package is an optional installation on your system CDs/DVD for Panther and Tiger, enabled through the “Customize” button of the installer, whereas it is included by default on Leopard.
- the “X11 SDK” package from the Xcode installer will be automatically selected if “X11 User” is already installed, so be sure to install that first.
I personally recommend against porting things from the source trees. If you really do have that kind of skills and free time, you can skip this little note of mine, go ahead and do it already!
For the fans of binary packages, you should try the links from hpc.sourceforge.net/ or from MacResearch group, although I normally don't take this path, this is due to my inner geekiness that preventing me from installing 3rd party packages. Nevertheless, I strongly recommend this way to install your tools if you want to get over it fast.
For utilizing the porting system, you got the options of fink and macports. If you are a fan of Ubuntu or Debian Linux, you should try fink first. For me, I chose macports just because I got some friends in the founding team.
Here is how I did it:
- Download the dmg file from http://www.macports.org/install.php, open and mount the dmg and launch the installer by double clicking the pkg file. This requires administrator's permission.
- Read the port(1) manual page and http://guide.macports.org for help, http://www.macports.org/contact.php if you need to get in touch with The MacPorts Project.
$ sudo port install g95
g95 in latest macports repository seems to be broken in Tiger$ sudo port install gcc45 +gfortran
(gcc45 is an experimental version, please use gcc44 for stability.) On Mac OS X 10.4 Tiger, the only choices are gcc43 and gcc42.- Viola!