AmberTools19 – macOS 10.14.4 – Xcode 10.2.1

Installing Amber/AmberTools on macOS has become much easier though is not to be considered completely trivial. Below different methods are presented to install the current version of AmberTools, where the method should be the same for Amber.

After the latest update of Xcode to 10.2.1, problems started emerging when trying to use a compiler other than clang. It is now once again possible to use gcc as long as you are using the latest and patched version of whichever gcc version you choose.

This will require you to install some things and run some commands through the built in “command interpreter” which on macOS is called Terminal(.app). You find this app in your Applications folder, in a sub folder called Utilities or by using Spotlight, the litle magnifying glass in the top right corner of the screen (alternatively through the keyboard shortcut cmd+space on your keyboard, assuming this is active) and search for “Terminal”. When you are expected to run commands in the terminal, they will be presented in this manner:

some command example

Some commands might require you to “side-scroll” to see the entire sequence as they might continue “off screen”. With this explained I think it is time to get started. I will now explain how to compile AmberTools19(/Amber18) with the package manager “Homebrew” and the Apple version of the C compiler package clang. Earlier I have offered instructions for using “MacPorts” och binary distributed versions of HPC gcc/gfortran. However, not having enough time and a more acute lack of a stable and available virtual machine with macOS for testing I have had to limit myself somewhat. The process should still be the same regardless of the source one chooses for gcc/gfortran. Remember, only chose one source of installing compilers from as you may accidentally cause conflicts of installing more than one package manager or from more than one source of binaries at once.

If you run into issues I refer you to the AMBER mailing list for help rather than trying to comment here as I am not updating this page regularly enough to be able to help in any reasonable amount of time.

Installing Xcode and accompanying Command Line Tools

Regardless of which package manager or gcc source you select, you need to install Xcode. For this “how-to”, Xcode 10.2.1 was used and you should install this software using the AppStore on your Mac. Command Line Tools (CLT) is needed to run commands and compile using the terminal and is installed after Xcode has been installed by executing the following command in the Terminal(.app).

sudo xcode-select --install

The step below might no longer be necessary with the latest updates of the amber code though I’ll leave it here since I have installed these headers on my machine already and have yet had time to investigate if this makes a difference. Hence, you might need to install some missing header files by running the following command, opening a PKG installer which is shipped with Xcode10. Follow the on-screen instructions to install.

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

This step was necessary for AmberTools18 as Apple retired some tools that previously came with Xcode.

Some modules of the Amber package uses X Window System for dealing with GUIs, support for this is no longer the default in macOS in the form of the old so in order for this to work you need to install XQuartz which has replaced I believe you still recieve a popup explaining that you need to install XQuarts when trying to use X11 though you might just as well install the software directly. Visit the developer website at and follow the instructions.

Now you should have installed Xcode and CLT to be able to run commands and compile code with Terminal(.app) and potentially also XQuartz.

Compiling AmberTools19(/Amber18) with macOS clang

You’ve already installed Xcode (right?) so you now have a working C compiler (clang). Now you need a fortran compiler, as this is not shipped with Xcode. You can procure this using any method you chose which works. I use the homebrew package manager. In previous versions of these write-ups I have offered three different ways of obtaining these and installing amber using them and I will leave the outline in this guide as well despite the fact that I have not tested all three alternatives with the latest version of AmberTools. Please note that you should only select one method!

Alternative 1: Homebrew

Homebrew is installed by running a command in the Terminal(.app), please visit the Homebrew website ( and confirm the command. This is the only validated method at the time.

/usr/bin/ruby -e "$(curl -fsSL"

Then proceed to install Homebrew GCC 9.1.0 (currently the default version) by running this command:

brew install gcc

Since Apple does not supply a version of gfortran, the homebrew version of gfortran will automatically become the default global version by installing gcc. No links, edits or exports are needed.

Alternative 2: MacPorts

Download and install MacPorts and GCC. I have previously evaluated gcc versions 6-8 though not with the latest version of AmberTools. I am unsure if there is a gcc version 9 available from MacPorts as of writing this.

sudo port selfupdate
sudo port upgrade outdated
sudo port install gcc8
sudo port select --set gcc mp-gcc8
Alternative 3: HPC GCC

Where I have previously chosen HPC gfortran-8.1-bin.tar.gz from to only install the fortran compiler as I now intend to use Apple clang for the rest. I have not validated that this method currently works with the latest updates of macOS and AmberTools. There is no version 9 available as of writing this.

sudo tar -xvf gfortran-8.1-bin.tar -C /

Everything is installed in /usr/local/. During this process I recieved error messages though the installation worked as intended anyway so I did not dig deeper into this:

x usr/local/: Can't set user=0/group=0 for usr/local Failed to set file flags
tar: Error exit delayed from previous errors.

You should now have a working installation of gfortran and it is time to move on with the configuration and installation of AmberTools19(/Amber18).

Download AmberTools19(/Amber18) from the developer website (, move the compressed file and then extract the archive in the location where you intend to install AmberTools(/Amber).

mv /[PATH]/[TO]/AmberTools19.tar.bz2 /[PATH]/[TO]/[INSTALL]/[DIRECTORY]/
tar xvf AmberTools19.tar.bz2

Configure and install:

tar xvf AmberTools19.tar.bz2
export AMBERHOME=/Users/guolaa/SOFTWARE/amber18/
./configure -macAccelerate clang
make install

After a decent amount of time you should be greeted with something along the lines of:

Installation of AmberTools19 serial is complete at Sat Apr 27 20:39:52 CEST 2019.

You are also presented with a very wise suggestion to add a line of code to you .profile/.bashrc/.cshrc or similar, you should follow this suggestion as it will make you life a lot easier working with amber. For me, using SH/BASH (the macOS default) I execute this command:

echo “test -f /path/to/amber18/ && source /path/to/SOFTWARE/amber18/” >> $HOME/.profile

You can then elect to “restart” your terminal session by closing the window and opening it again, reading the content of this file again. Alternatively you execute the following command:

source $HOME/.profile

After the successful installation of AmberTools(/Amber) you should run through the tests to make sure everything is running smoothly under the hood. You start these test by executing the following:

make test

Check that everything looks OK and that no major errors or issues were identified. You should now have a working serial version of AmberTools19 installed and ready to go. This time we’ll also cover the installation of the parallel version.

make clean
./configure -macAccelerate -mpi clang
make install

Assuming everything ran smoothly this should, after some time, end with a message similar to:

Installation of AmberTools19 MPI is complete at Sat Apr 27 21:54:55 CEST 2019.

You are supposed to download and install openMPI 4.0.1 from source using a script found in $AMBERHOME/AmberTools/src called configure_openmpi. I did not manage to get this to work with macOS clang however it is supposedly accomplished running the commands outlined below. On any other system than macOS, the number of cores is likely found issuing another command then sysctl:

brew unlink open-mpi # Assuming homebrew installation present
cd $AMBERHOME/AmberTools/src
tar xvf openmpi-4.0.1.tar.gz
nps=$(sysctl -h hw.ncpu | awk {'print $2'}) # Number of cores assigned to nps
./configure_openmpi -np $nps gnu # Configure with nps cores
# Linux systems can directly use $(nproc) and skip sysctl

The last step that remains seems to be to install openMPI support for cpptraj to read and write NetCDF files in parallel. I did not manage to do this using clang so for this option, see the GCC instructions below. This is what the commands should look like:

make clean
./configure -macAccelerate -openmp clang

However, this produces the following error for me:

OpenMP and clang are not currently compatible
Configure failed due to the errors above!

Compiling AmberTools19(/Amber18) with Homebrew GCC

Assuming that you have already installed Xcode and CLT (otherwise go back to the start and take care of this right now) we shall now install AmberTools19(/Amber18) using Homebrew GCC 9.

The first thing you need to do is to give the Homebrew versions of gcc compilers priority over macOS clang alternatives. Even if you installed gcc 9 through homebrew, gcc will still be clang when you try to compile code using “gcc“. If this is a project of your own you can always just refer to gcc as gcc-9however this will not help is now as AmberTools(/Amber) will look for “gcc”. One simple way to reversibly accomplish this is to use symbolic/soft links:

ln -s /usr/local/bin/gcc-9 /usr/local/bin/gcc
ln -s /usr/local/bin/g++-9 /usr/local/bin/g++
ln -s /usr/local/bin/c++-9 /usr/local/bin/c++

Creating links in /usr/local/bin with correct names according to the OS. You might need to “exit” the terminal to reset the session and make sure that the correct compilers have priority. Running:

which gcc

Should now return /usr/local/bin instead of /usr/bin, then you are set to go!

Once you no longer want these alternatives to be the default, just remove the links accordingly:

rm /usr/local/bin/gcc
rm /usr/local/bin/g++
rm /usr/local/bin/c++

Assuming that you’ve downloaded AmberTools19 from the developers webpage and moved the compressed archive to the location where you want to install AmberTools19(/Amber18) you make your way through the filesystem in a Terminal(.app) session and execute the following commands:

tar xvf AmberTools19.tar.bz2
export AMBERHOME=/Users/guolaa/SOFTWARE/amber18/
./configure -macAccelerate gnu
make install

After a while you should see something along the lines of:

Installation of AmberTools19 serial is complete at Sat Apr 27 15:20:30 CEST 2019.

After a successful installation you should run through the tests to see that everything is churning along correctly:

make test

If this does not generate any larger problems you now have a functioning serial version of AmberTools19(/Amber18) installed and ready for use. I have previously terminated the write-up here though as I’ve made the decision to cut down on the alternatives for compilers I have instead provided information regarding the parallel installation as well. For this I elected to use the script ($AMBERHOME/AmberTools/src/configure_openmpi) which is available to help with the installatoin of opemMPI as the version provided by homebrew is built for clang and not gcc and I did not have the energy to build it from source by myself. You’ll get through these steps by doing the following:

brew unlink open-mpi # If installed with homebrew
cd $AMBERHOME/AmberTools/src
tar xvf openmpi-4.0.1.tar.gz
nps=$(sysctl -h hw.ncpu | awk {'print $2'}) # Works on macOS
./configure_openmpi -np $nps gnu
# Linux systems can replace $nps with $(nproc) and skip sysctl

You might need to reset you terminal session to make sure the correct openMPI installation is found (exit).

make clean
./configure -macAccelerate -mpi gnu
make install

After some waiting and pacing you should se something similar to:

Installation of AmberTools19 MPI is complete at Sat Apr 27 18:56:43 CEST 2019.

So assuming everything went well it is now time to runs some tests, this does not work for me. Potentially this depends on the fact that I’m using a work computer though what happens is that I get bombarded with “Allow network access” pop-ups for every test and some other annoying things. Theoretically, this is what you should do:

export DO_PARALLEL="mpirun -np X"
make test

Replacing “X” with the number outputted by sysctl -h hw.ncpu | awk {'print $2'} to use all cores available.

Remaining is to install openMPI support for cpptraj to deal with NetCDF files in parallel, which is accomplished with the following command:

./configure -macAccelerate -openmp gnu
make install

After some more waiting:

Installation of AmberTools19 OpenMP is complete at Sat Apr 27 19:12:53 CEST 20

Again, you should run some tests though I am not able to do this as my OS does not allow me to run them. You should by now have a working parallel version of AmberTools19(/AMber18) ready for use.