GROMACS 4.5.5, OpenMPI 1.6, And FFTW 3.3.2 Compilation Under Mountain Lion (OSX 10.8) With XCode (And A Little Help From Homebrew)

Minus a few glitches easily fixed with the right software, this build wasn't bad at all (and thanks to Adam Lindsay for the title catch).

Now sitting in front of a new Core i7 MacBook Pro, one of the first compilations I wanted to have finished for new projects was GROMACS 4.5.5. As my procedure for compiling GROMACS 3.3.3 had been a highly-traveled page, I wanted to provide a brief summary of my successful 4.5.5 compilation.

A Few Piece Of Info

1. XCode

This used to be disc-download and install, now it's available as a free download from the App Store (1.57 GB download, so plan to do something else while you wait for the download).

2. Homebrew

Having Homebrew installed in Mountain Lion made the installation of FFTW easy and OpenMPI trivial once gfortran was equally trivially installed. Therefore, to make your life easier, I can't recommend a Homebrew installation enough. For additional install tweaks, I followed the following page: gist.github.com/1860902

Installation Procedure

1. Download gromacs 4.5.5

…and place it in your home folder (will go to Downloads most likely, drag it to your home folder for ease of building).

2. Extract into your home holder

…with a double-click, making ~/gromacs-4.5.5.

3. brew install fftw

With the install of Homebrew, you'll simply run the following from a terminal window and produce the following output:

brew install fftw

==> Downloading http://www.fftw.org/fftw-3.3.2.tar.gz
######################################################################## 100.0%
==> ./configure --enable-single --enable-sse --enable-shared --disable-debug 
--prefix=/usr/local/Cellar/fftw/3.3.2 --enable-threads --disable-fortran
==> make install
==> make clean
==> ./configure --enable-sse2 --enable-shared --disable-debug 
--prefix=/usr/local/Cellar/fftw/3.3.2 --enable-threads --disable-fortran
==> make install
==> make clean
==> ./configure --enable-long-double --enable-shared --disable-debug 
--prefix=/usr/local/Cellar/fftw/3.3.2 --enable-threads --disable-fortran
==> make install
/usr/local/Cellar/fftw/3.3.2: 34 files, 13M, built in 2.7 minutes

4. brew install gfortran

If you don't install gfortran FIRST and try to install OpenMPI, you'll get the following error in Homebrew:

==> Downloading http://www.open-mpi.org/software/ompi/v1.6/downloads/openmpi-1.6.tar.bz2
######################################################################## 100.0%
Error: This formula requires a fortran compiler, but we could not find one by
looking at the FC environment variable or searching your PATH for `gfortran`.
Please take one of the following actions:

  - Decide to use the build of gfortran 4.2.x provided by Homebrew using
        `brew install gfortran`

  - Choose another Fortran compiler by setting the FC environment variable:
        export FC=/path/to/some/fortran/compiler
    Using an alternative compiler may produce more efficient code, but we will
    not be able to provide support for build errors.

So don't. Installing gfortran will produce the following:

brew install gfortran

==> Downloading http://r.research.att.com/tools/gcc-42-5666.3-darwin11.pkg
######################################################################## 100.0%
==> Installing gfortran 4.2.4 for XCode 4.2 (build 5666) or higher
==> Caveats
Brews that require a Fortran compiler should not use:
  depends_on 'gfortran'

The preferred method of declaring Fortran support is to use:
  def install
    ...
    ENV.fortran
    ...
  end

==> Summary
/usr/local/Cellar/gfortran/4.2.4-5666.3: 86 files, 72M, built in 39 seconds

5. brew install openmpi

This is what allows you to use all cores on your machine and is not in the default XCode install.

brew install openmpi

==> Downloading http://www.open-mpi.org/software/ompi/v1.6/downloads/openmpi-1.6.tar.bz2
Already downloaded: /Library/Caches/Homebrew/open-mpi-1.6.tar.bz2
==> Using Homebrew-provided fortran compiler.
This may be changed by setting the FC environment variable.

==> ./configure --prefix=/usr/local/Cellar/open-mpi/1.6 --enable-ipv6
==> make all
==> make install
/usr/local/Cellar/open-mpi/1.6: 674 files, 21M, built in 5.9 minutes

6. cd gromacs-4.5.5

7. ./configure –enable-float –enable-mpi

You'll produce output such as found in: 2012august29_gromacs455_configure.txt

You'll also get two odd errors at the end of the ./configure run that do not affect the rest of the procedure:

./configure --enable-float --enable-mpi

...
./configure: line 29242: sort: No such file or directory
./configure: line 29239: sed: No such file or directory

So ignore them.

NOTE: If you've been going by my 3.3.3 procedure and used…

./configure --enable-mpi --enable-double

You'll get the following error when you try to run make:

Making all in include
Making all in .
make[2]: Nothing to be done for `all-am'.
Making all in types
make[2]: Nothing to be done for `all'.

...

/bin/sh https://www.somewhereville.com/libtool --tag=CC   --mode=compile mpicc -DHAVE_CONFIG_H -I. -Ihttps://www.somewhereville.com/src -I/usr/include/libxml2 -Ihttps://www.somewhereville.com/include -DGMXLIBDIR=\"/usr/local/gromacs/share/top\"   -O3 -fomit-frame-pointer -finline-functions -Wall -Wno-unused -msse2 -funroll-all-loops -std=gnu99 -MT genborn_sse2_double.lo -MD -MP -MF .deps/genborn_sse2_double.Tpo -c -o genborn_sse2_double.lo genborn_sse2_double.c
 mpicc -DHAVE_CONFIG_H -I. -Ihttps://www.somewhereville.com/src -I/usr/include/libxml2 -Ihttps://www.somewhereville.com/include -DGMXLIBDIR=\"/usr/local/gromacs/share/top\" -O3 -fomit-frame-pointer -finline-functions -Wall -Wno-unused -msse2 -funroll-all-loops -std=gnu99 -MT genborn_sse2_double.lo -MD -MP -MF .deps/genborn_sse2_double.Tpo -c genborn_sse2_double.c  -fno-common -DPIC -o .libs/genborn_sse2_double.o
genborn_sse2_double.c:931: internal compiler error: Segmentation fault: 11
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
make[3]: *** [genborn_sse2_double.lo] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all] Error 2
make: *** [all-recursive] Error 1

So don't do that, either. The proper flag is the enable-float.

8. make

This will produce the output available for download at: 2012august29_gromacs455_make.txt

9. make install

This will produce the output available for download at: 2012august29_gromacs455_make_install.txt

10. make links

This will produce the short piece of output reproduced below.

cd /usr/local/gromacs/bin && programs=`ls` && cd /usr/local/bin && \
	for i in $programs; do \
	   (test ! -f $i && ln -s /usr/local/gromacs/bin/$i . ; exit 0); \
	done

And with that, you should be able to run all programs from a terminal window.

chown/chmod Your Way To A Backup Free Of The MemeodHelper Error in OSX 10.6.x (Snow Leopard) & A Seagate Vs. Western Digital Experience

UPDATE – 29 September 2010: In my usual policy of *nix-based deference to anything Perry Metzger has to say (other areas, too, but specifically here), I note that my procedure has the potential to mangle whatever is using Memeo (although I've not had anything go bump in the night yet). For those less than interested in the surgery below, your most safest bet is to crack open a Terminal window and sudo cp -R /Users/[you] /Volumes/[Your Backup Drive] (assuming you've activated the root password in OS X, of course). That is all.

There isn't too much of this online so I thought I'd provide my fix. As background, I like the idea of having constant capsules of my MacBook Pro (MBP) sitting on a Time Capsule drive, but I am constantly up-and-running with my MBP and am rarely sitting in front of a machine long enough to let full writes be written to some backup drive (and, as any quantum chemist worth their salt is generating scores of files on an hourly basis, my laptop is constantly undergoing changes). Long story short – I want to spend one hour at my choosing to turn off wireless, close all my open programs, copy my User directory, and paste it onto an external drive. That's it.

Finally upgrading to 10.6.4 (by way of a new 13.3"), my first attempt to backup the first clean copy of the complete migration from my old 15" went all of 20 minutes before the following error popped up on my screen:

The operation can't be completed because you don't have permission to access "MemeodHelper."

There is ONE other mention of this issue and it's present on the Apple Support forum at:

discussions.apple.com/thread.jspa?messageID=11237019&tstart=0

I guess the two of us are the oddballs for not sticking to the OSX program suite.

The solution is to simply change the permissions so that you, the user, DOES have access to read + write this file. I tried a Right Click – Get Info – Sharing & Permissions fix only to discover I DID have Read & Write access. Clearly, I am not the owner of this file. Taking the next proper step…

Applications -> Utilities -> Terminal

cd ~/Library/Application\ Support/Memeo
ls -al

…we see that the permissions set for the MemeodHelper file are as follows:

-r-sr-xr-x

r = read
x = execute
s = domain socket

And that the owner is root (not you). The ownership problem explains the inability to read + write this file. And, I have never seen an "s" in all my days digging around in Terminal (had to look it up to see what it meant. Hail Wikipedia).

This "s" and the missing "w" for you, the user, is the problem. The solution is to allow you (the user) to write and execute this file, which I have chosen to do by simply changing the user ownership and the permissions. The steps are as follows (userid = the userid that shows up for the ".." and "." (shown above this file with an ls -al)):

sudo chown userid MemeodHelper

It will ask for a password – your user password will do.

chmod u+wrx MemeodHelper

This changes the ownership permissions for MemeodHelper.

That's it. You should now be able to copy + paste your User directory (HOME) to another drive. By Firewire 800, I'm copying 220 GB in about 56 minutes, which I cannot complain about. To date (after a week), I've had no machine issues with my change to MemeodHelper and have found no other people having complaints. If you discover something, by all means say something.

And, to continue to discussion, I had the most miserable experience migrating from Seagate FreeAgent USB 2.0 drives used with a Windows XP backup machine to the point that I bought and returned them over 24 hours, with these drives unable to reliably write files larger than 500 MB (and one of the two I bought for my global backup would spontaneously unmount itself. Not cool).

My solution was to spend extra money and pick up Western Digital 2 TB My Book Studio LX (for Mac) USB 2.0/Firewire 800 external drives (and I am using them as Firewire devices). I am presently very happy with this setup.

Compiling Single-Precision And Double-Precision GROMACS 3.3.3 With OpenMPI 1.2.6 Under OSX 10.5 (Leopard)

The following is a cookbook for compiling single-precision and double-precision GROMACS 3.3.3 in OSX 10.5 (specifically on a MacBook Pro, but most likely general to all things running 10.5) with OpenMPI 1.2.6. My hope is that this saves someone several hours of unnecessary work trying to overcome an otherwise unknown incompatibility between MPICH2 and GROMACS 3.3.3 in Leopard (10.5).

The content of this page is a result of an unsuccessful several hours of trying to build GROMACS-MPI versions with MPICH2 1.0.6 and 1.0.7. MPICH2 compiles just fine with standard options, including a successful testing of mpd and mpdtrace. GROMACS 3.3.3 compiles just fine with standard options for both single-precision and double-precision. Compiling GROMACS with MPI support yields an mdrun file that fails in the following manner:

[host:XXXX1] *** Process received signal ***
[host:XXXX1] Signal: Segmentation fault (11)
[host:XXXX1] Signal code: Address not mapped (1)
[host:XXXX1] Failing at address: 0xffffff94
[ 1] [0x00000000, 0xffffff94] (FP-)
[host:XXXX2] *** Process received signal ***
[host:XXXX2] Signal: Bus error (10)
[host:XXXX2] Signal code: (2)
[host:XXXX2] Failing at address: 0x2
[host:XXXX1] *** End of error message ***
[ 1] [0x00000000, 0x00000002] (FP-)
[marlin:XXXX2] *** End of error message ***

This problem, it has been discovered, is remedied by using OpenMPI 1.2.6. Not a proper diagnosis of the MPICH2/GROMACS problem, but my primary concern is getting MPI working in order to use both cores on my MacBook Pro to get calculations running, not fixing software bugs to get someone else's calculations running (when there's an easier fix, anyway).

Installation Procedure

You'll need the following three files (relevant versions and links are subject to change!):

fftw-3.1.2, http://www.fftw.org/

According to the website:

FFTW is a C subroutine library for computing the discrete Fourier transform (DFT) in one or more dimensions, of arbitrary input size, and of both real and complex data (as well as of even/odd data, i.e. the discrete cosine/sine transforms or DCT/DST).

FFTW compiles double-precision libraries by default. You'll need to build single-precision libraries for the single-precision GROMACS install.

gromacs-3.3.3, http://www.gromacs.org/

The newest version. Compilation of version 3.3.2 leads to various problems under OSX 10.5 (undiagnosed here, but certainly reproducible).

openmpi-1.2.6, http://www.open-mpi.org/

This is the MPICH2 replacement (meaning I've used MPICH2 for other programs). Again, I'm not playing favorites on a version-to-version level. On my MacBook Pro running OSX 10.5, OpenMPI does what I need, MPICH2 doesn't.

GROMACS uses MPI to distribute processes between processors. If you don't have GROMACS compiled with MPI, you don't have multi-processor calculations (simple enough). That is to say, the Activity Monitor reads 100% for one processor and residual % for all other processes on the other chip (this was a point of confusion in a few discussions, in case someone wonders why I would bother bringing such a point up).

Associated Notes On Compilation

A few important notes to be aware of for the compilation.

XCode 3.0, http://developer.apple.com/tools/xcode/

If you've not installed XCode 3.0 yet, you should in order to get compilers and libraries installed on your machine. XCode is the official programmer's toolbox under OSX and installs far more than you'll need (but it never hurts). Note that this is a BIG download (1.1 GB) but is a far less taxing route to getting all of the necessary files installed on your machine than relying on (many, many) individual downloads.

Root Access

Running "make install" will install files into core directories that are inaccessible to typical OSX User accounts. Access to these directories (such as /usr/local and /usr/local/lib) is granted only to the root user in OSX, which is not activated by default (and a good thing, too). To turn on root access, go to:

Macintosh HD > Applications > Utilities > Directory Utility

In Directory Utility, go to

Edit > Enable Root User

At build time, you'll want to be logged in as the root user (see below).

No Spaces In Folder Names

This goof also took some time to figure out. Regardless of where you start the program build processes from, you need to make sure your directory names have no spaces between words.

>& FILENAME.txt

>& FILENAME.txt is used to direct output to FILENAME.txt, providing a way to follow each step in the process for error checking and the like. For diagnosis purposes, the files from my build are provided here for the GROMACS work. Click on each name to open the log file.

Installation Process

How to follow the text below:

1. Step in the process (one per program, significant activity)

1a. Text that follows the numeric-alphabetical label is what needs to be typed in at the Terminal window prompt. Descriptive/explanatory text follows below each step.

The installation is assumed to be set up as follows: the GROMACS, OpenMPI, and FFTW .tar files (I suspect downloading will automatically unzip them) exist in a directory on your Desktop (say, INSTALL_DIRECTORY_NAME). Here's the compilation procedure:

1. Open a Terminal (Macintosh HD > Applications > Utilities > Terminal). If you don't have this application on your Dock, I recommend putting it there. You'll certainly be getting some use out of it.

2. The Terminal window defaults to your User directory. First we change our user to root (for full access), then cd into the install directory.

2a. su

(put in root password at prompt)

at prompt, type:

2b. csh
2c. cd Desktop/INSTALL_DIRECTORY_NAME

3. untar the GROMACS, OpenMPI, and FFTW .tar downloads (again, I suspect they will have already been unzipped as part of the download). You'll end up with three new directories in this folder.

3a. tar -xvf fftw-3.1.2.tar
3b. tar -xvf gromacs-3.3.3.tar
3c. tar -xvf openmpi-1.2.6.tar

4. Build FFTW

We'll compile fftw-3.1.2 first. For the single-precision build, the steps are:

4a. cd fftw-3.1.2
4b. ./configure --enable-float --enable-threads >& configure_fftw_single.txt
4c. make >& make_fftw_single.txt
4d. make install >& make_install_fftw_single.txt
4e. make distclean >& make_distclean_fftw_single.txt
4f. cd ..

This series of steps configures (configure), builds (make), moves (install) and cleans up (distclean). The ">&" directs output to the .txt files for diagnosis (all of which you can leave off). To follow step progress, open a new Terminal window, get to the directory of interest and type:

4g. tail -f FILENAME_OF_INTEREST.txt

To build the double-precision version (FFTW default and what you're better off building anyway)

4h. cd fftw-3.1.2
4i. ./configure --enable-threads >& configure_fftw_double.txt
4j. make >& make_fftw_double.txt
4k. make install >& install_fftw_double.txt
4l. make distclean >& distclean_fftw_double.txt
4m. cd ..

5. Build OpenMPI

This build could not be easier. This build will place the OpenMPI 1.2.6 executables into /usr/local/openmpi (in the interest of organization).

5a. cd openmpi-1.2.6
5b. ./configure --prefix=/usr/local/openmpi >& configure_openmpi.txt
5c. make >& make_openmpi.txt
5d. make install >& install_openmpi.txt
5e. make distclean >& distclean_openmpi.txt
5f. cd ..

6. Build GROMACS

The following four builds will yield all four possible combinations of GROMACS (single-precision and double-precision) and MPI (without and with). Do you need four builds of GROMACS? Definitely not. If you're reading this page, you're probably interested only in double-precision and MPI (the last of the four). The four builds listed below were performed for testing purposes only. I only ever use the double-precision MPI version when I'm doing my own work.

Note: Each build included the generation of links to executables that go into /usr/local/bin. Accordingly, all four versions are accessible from the Terminal window without having to specify directories (and each version has individually named files as defined in –program-suffix= ).

GROMACS Single-Precision

This will install a single-precision GROMACS build into /usr/local/gromacs333_single with no specific file suffix.

6a. cd gromacs-3.3.3
6b. ./configure --prefix=/usr/local/gromacs333_single >& gromacs_single_configure.txt
6c. make >& gromacs_single_make.txt
6d. make install >& gromacs_single_install.txt
6e. make links >& gromacs_single_links.txt
6f. make distclean >& gromacs_single_distclean.txt
6g. cd ..

GROMACS Single-Precision With OpenMPI

This will install a single-precision MPI-GROMACS build into /usr/local/gromacs333_single_mpi with the file suffix _mpi.

6h. cd gromacs-3.3.3
6i. ./configure --enable-mpi --program-suffix=_mpi --prefix=/usr/local/gromacs333_single_mpi
>& gromacs_single_mpi_configure.txt
6j. make >& gromacs_single_mpi_make.txt
6k. make install >& gromacs_single_mpi_install.txt
6l. make links >& gromacs_single_mpi_links.txt
6m. make distclean >& gromacs_single_mpi_distclean.txt
6n. cd ..

GROMACS Double-Precision

This will install a double-precision GROMACS build into /usr/local/gromacs333_double with the file suffix _d.

6o. cd gromacs-3.3.3
6p. ./configure --program-suffix=_d --prefix=/usr/local/gromacs333_double --enable-double
>& gromacs_double_configure.txt
6q. make >& gromacs_double_make.txt
6r. make install >& gromacs_double_install.txt
6s. make links >& gromacs_double_links.txt
6t. make distclean >& gromacs_double_distclean.txt
6u. cd ..

GROMACS Double-Precision With OpenMPI

This will install a double-precision MPI-GROMACS build into /usr/local/gromacs333_double_mpi with the file suffix _mpi_d.

6v. cd gromacs-3.3.3
6w. ./configure --enable-mpi --program-suffix=_mpi_d --prefix=/usr/local/gromacs333_double_mpi
--enable-double >& gromacs_double_mpi_configure.txt
6x. make >& gromacs_double_mpi_make.txt
6y. make install >& gromacs_double_mpi_install.txt
6z. make links >& gromacs_double_mpi_links.txt
6aa. make distclean >& gromacs_double_distclean_mpi.txt
6ab. cd ..

Running MPI-GROMACS Calculations (Non-specific)

Running MPI-GROMACS is straightforward, requiring only one additional step and a few changes to how you use grompp and mdrun.

a. mpd &
b. grompp_mpi_d -np 2

-np 2 is added to tell grompp that two processors are being used. mdrun expects the same number of processors as was specified in grompp.

c. mpirun -np 2 /usr/local/gromacs333_double_mpi/bin/mdrun_mpi_d -np 2

mpirun first calls the number of processors to use (-np 2) and then requires specification of the path to the mdrun executable (/usr/local/gromacs333_double_mpi). mdrun requires specifying the number of processors as well (-np 2) as per the specification in grompp.

And Finally…

Like all first draft cookbooks, this might be missing some important spices. If, by any chance, you found this page and have recommendations to improve speed, stability, organization, etc., please drop a line and I'll keep track of modifications.

en.wikipedia.org/wiki/Single_precision
en.wikipedia.org/wiki/Double_precision
www.gromacs.org
www.apple.com/macosx/
en.wikipedia.org/wiki/Mac_OS_X_v10.5
www.apple.com/macbookpro/
www.open-mpi.org/
www.mcs.anl.gov/research/projects/mpich2/
www.gromacs.org/documentation/reference/online/mdrun.html
www-unix.mcs.anl.gov/mpi/
www.fftw.org
en.wikipedia.org/wiki/Activity_monitor
developer.apple.com/tools/xcode/
en.wikipedia.org/wiki/NetInfo_Manager
en.wikipedia.org/wiki/Terminal_(application)
en.wikipedia.org/wiki/Dock_(computing)
en.wikipedia.org/wiki/Tar_file
www.gromacs.org/documentation/reference/online/grompp.html