GROMACS is an optimised molecular dynamics code, primarily used for simulating the behaviour of proteins. To compile GROMACS you need, well, some compilers. I install gcc using . Note that this requires you to . Then it is easy to install
gcc version 4.9 by
sudo port install gcc49
(and yes, I know about , but I still find has more of the things I want than brew). So, once you’ve done a bit of preparation, on a Mac is easy. Once you’ve downloaded the source code tar ball.
tar xvf gromacs-5.0.2.tar.gz
cmake .. -DGMX_BUILD_OWN_FFTW=ON -DCMAKE_INSTALL_PREFIX='/usr/local/gromacs/5.0.2/‘
sudo make install
Note that this will install it in
/usr/local/gromacs/5.0.2 so you can keep multiple versions on the same machine and swap between them in a sane way by sourcing the
GMRXC file, for example
Adding MPI support on a Mac is trickier. This appears mainly to be because the
gcc compilers from MacPorts (or clang from Xcode) don’t appear to support OpenMPI. You will know because when you run the
cmake command you get a load of failures starting about ten lines down, such as
-- Performing Test OpenMP_FLAG_DETECTED - Failure
I managed to get a working version using the following approach; it is likely there are better (if you know, please leave a comment), but it has the virtue of working. First we need to install OpenMPI.
sudo port install openmpi
Now we need a compiler that supports OpenMPI. If you dig around in the MacPorts tree you can find some.
sudo port install openmpi-devel-gcc49
Finally, we can follow the steps above (I just
mkdir build-mpi subfolder in the above source folder and then
cd to it), but now we need a (slightly) complex cmake instruction
cmake .. -DGMX_BUILD_OWN_FFTW=ON
This is only going to build an MPI version of
mdrun (which makes sense) and will install
mdrun_mpi alongside the regular compiled binaries we did first. We have to tell cmake what all the new fancy compilers are called and, unfortunately, these don’t support AVX SIMD instructions so we have to fall back to SSE4.1. Experience suggests this doesn’t impact performance as much as you might think. Now you can run things like on your workstation!