Installation

Installing AmberTools 18 on macOS 10.14 (Mojave)

Installing Amber/AmberTools on macOS is not a trivial process. It has become a lot easier then it once was though still demands a little more work than drag-n-drop of a file to the correct folder. Below I present three different ways of installing the current version of AmberTools, the method should be exactly the same for Amber. For now, this only covers the serial version though I have compiled the parallell version as well, though I have to confirm the method for all separate options befor posting them here.

The installation provess will include running commands in the built in command-line, which in macOS is called Terminal(.app) and resides in you Applications folder, in a subfolder called Utilities. You can also find this app by using Spotlight, either by clicking the little magnifying glass icon in the top-right corner or hitting cmd+space on your keyboard, if this shortcut has been activated and enter the search term “Terminal”. When you are supposed to execute commands in Terminal, they will be presented like this:

some command example

There are som “longer” commands where you must “side-scroll” to reveal the entire line. With this explained I think it’s time to get going. I will now explain how to compile AMberTools18/Amber18 with the help of package managers “Homebrew” and “Macports” as well as by using Apples version of the C compiler bundle, clang and a separate fortran compiler. A last important warning, only choose one of these as you will create damaging conflicts if you install more than one package manager and potentially separate compilers from other sources at the same time.

If you run into problems or issues, please use the AMBER Mailing List for help instead of commenting on this page since I cannot regularly maintain the site right now.

Install Xcode and the accompanying Command Line Tools (CLT)

Regardless if you are planning to use MacPorts, Homebrew or Apple GCC and a gfortran compiler of your choice, you must install Xcode. For these instructions, Xcode10 was used, which is conveniently installed from Apple AppStore on your mac. CLT is needed to be able to run commands on the command-line these tools are installed after you’ve installed Xcode by running the following command in the Terminal app.

sudo xcode-select --install

You must also install some additional missing files, run the following command to open a PGK installer that ships with Xcode10 and follow the on screen instructions to install.

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

This is necessary since Apple has elected to deprecate som of the tools that previously shipped with Xcode. Something that will create issues in future installations of AMEBR under the next major release version of Xcode, Xcode11, as this PKG with missing files will no longer be available.

Some of the modules in AMBER uses X.org X Window System for GUI rendering, macOS no longer comes installed with the X11.app that used to cover this so in order for this to work you have to install XQuartz which has replaced X11.app. I still believe that you would receive a pop-up explaining that you have to install XQuarts when you try to use X Window though you might just as well install it directly. Swing by the developers homepage (https://www.xquartz.org/) and follow the instructions.

You should now have installed Xcode and CLT to be able to run commands on the command-line. This is a prerequisite regardless of which method of the ones listed below you end up choosing.

Compile AmberTools18/Amber18 using Homebrew GCC8

  1. Install Homebrew

Homebrew is installed by running a command in the terminal, please visit the developers homepage Homebrew (https://brew.sh/) and confirm the command posted below.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  1. Install Homebrew GCC8 (as of writing, the default version of gcc is gcc8.2) by running this command
brew install gcc
The following eliminates an error with "cannot find <include> file" which otherwise appears later on. Technically, the error stems from Homebrew/macOS still using the system compiler (clang) instead of gcc8, which you’ve just now installed, unless you force the macOS to default to the Homebrew version. You can do this by running the following comamnds:
ln -s /usr/local/bin/gcc-8 /usr/local/bin/gcc
ln -s /usr/local/bin/g++-8 /usr/local/bin/g++
ln -s /usr/local/bin/c++-8 /usr/local/bin/c++

What you are doing is creating links (symlinks) to the correct compilers in the Homebrew executables folder and hence preventing macOS to reverting to clang which is the default c compiler on macOS.

If you, at some later point, want to undo this action you just delete the created link files. This does not damage the OS or the Homebrew installation, they are just links to the original files.

cd /usr/local/bin/
rm gcc g++ c++
  1. Download AmberTools18/amber18 from the developers webpage (http://ambermd.org/), move the archive to and extract the files where you intend to install AMEBR.
mv /[PATH]/[TO]/AmberTools18.tar.bz2 /[PATH]/[TO]/[INSTALL]/[DIRECTORY]/
cd /[PATH]/[TO]/[INSTALL]/[DIRECTORY]/
tar xvf AmberTools18.tar.bz2
  1. Configure and install
export AMBERHOME=/[PATH]/[TO]/amber18
export PATH=${AMBERHOME}:$PATH
export MACOSX_DEPLOYMENT_TARGET='10.14'
cd $AMBERHOME

You should now be ready to compile and install the serial version of AmberTools18/Amber18

./configure -macAccelerate gnu
make install

Assuming nothing went wrong, something was changed, the sun was in zenith, there was shade on the western side of pentagon or something else you should now have a fully working serial version of AmberTools18/Amber18 installed using Homebrew

Compile AmberTools18/Amber18 using MacPorts GCC6/8

  1. You have already installed Xcode (right?), so visit MacPorts webpage (https://www.macports.org/) and follow the instructions to install MacPorts.
  1. Install the GCC package, I chose GCC8 for this instruction though I have also tested with GCC6 and both work. If you prefer GCC6 just replace gcc6 to gcc8 on any places with reference to GCC version. The commands below updates MacPorts and installed ports (programs) if needed and installs gcc8. This, however, does not mean that macOS will use gcc8 so the last command “sets” the default gcc version to use MacPorts gcc8.
sudo port selfupdate
sudo port upgrade outdated
sudo port install gcc8
sudo port select --set gcc mp-gcc8

You can easily undo this. You can control which (for example) gcc versions you have installed by running:

$ port select --list gcc
Available versions for gcc:
    gcc42
    mp-gcc6
    mp-gcc8
    none (active)

The listed “Available version” depends on which versions you have installed through MacPorts. You can select which version to use by “setting” that versions. This is accomplished with the command above and to revert to system version (clang) ju “set” the version to “none”.

sudo port select --set gcc none

None as in “none of MacPorts” version, not as in “use no c compiler”. This works for openmpi/mpich, python and some other ports as well.

  1. Download AmberTools18/amber18 from the developers webpage (http://ambermd.org/), move the archive to and extract the files where you intend to install AMEBR.
mv /[PATH]/[TO]/AmberTools18.tar.bz2 /[PATH]/[TO]/[INSTALL]/[DIRECTORY]/
cd /[PATH]/[TO]/[INSTALL]/[DIRECTORY]/
tar xvf AmberTools18.tar.bz2
  1. Configure and install
export AMBERHOME=/[PATH]/[TO]/amber18
export PATH=${AMBERHOME}:$PATH
export MACOSX_DEPLOYMENT_TARGET='10.14'
cd $AMBERHOME

You should now be ready to compile and install the serial version of AmberTools18/Amber18

./configure -macAccelerate gnu
make install

Assuming nothing went wrong or something was changed, it’s not raining in London, a butterfly landed on that tulip next to that one windmill in the Netherlands or something else you should now have a fully working version serial installation of AmberTools18/Amber18 using MacPorts

Compiling AmberTools18/Amber18 using macOS clang

You’ve already installed Xcode (right?), so you now have a c compiler (clang) though you also need a fortran compiler, something which is not shipped with Xcode. You can acquire this by using any source you want which works, I will provide three different ways. Please note that you should only use one single method!

Alternative 1: MacPorts

Download and install MacPorts och GCC (see “Compiling AmberTools18/Amber18 using MacPorts”), I chose GCC8 and have tested GCC6, both works.

sudo port selfupdate
sudo port upgrade outdated
sudo port install gcc8
sudo port select --set gcc mp-gcc8
Alternative 2: Homebrew

Homebrew is installed bu running the command below in the terminal, please visit Homebrews webpage (https://brew.sh/) and confirm the command.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  1. Install Homebrew GCC8 (the default version as for writing this) by running the following command.
brew install gcc

Since Apple does not supply you with a gfortran compiler, the Homebrew version automatically becomes the default by installing GCC and no links needs to be modified.

Alternative 3: HPC GCC

For this part I chose HPC gfortran-8.1-bin.tar.gz to only install the fortran compiler as I will be using Apple clang for everything else. Download and install gfortran-8.1-bin.tar.gz (http://hpc.sourceforge.net).

cd /[PATH]/[TO]/[DOWNLOAD]/
sudo tar -xvf gfortran-8.1-bin.tar -C /

Everything is installed in /usr/local/. During the extraction provess I received some errors though everything worked as intended anyway so I ignored these for now.

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.
Fortran installation fixed

Regardless of which method from the three above suggestions you chose you should have a working gfortran version installed by now. That means it’s time to move on with configuration and installation of AmberTools18/Amber18.

  1. Download AmberTools18/amber18 from the developers webpage (http://ambermd.org/), move the archive to and extract the files where you intend to install AMEBR.
mv /[PATH]/[TO]/AmberTools18.tar.bz2 /[PATH]/[TO]/[INSTALL]/[DIRECTORY]/
cd /[PATH]/[TO]/[INSTALL]/[DIRECTORY]/
tar xvf AmberTools18.tar.bz2
  1. Configure and install
export AMBERHOME=/[PATH]/[TO]/amber18
export PATH=${AMBERHOME}:$PATH
export MACOSX_DEPLOYMENT_TARGET='10.14'
cd $AMBERHOME

We need to edit some files in order to prevent the compilation breaking with a “cannot find <include> file” error. Which files and what lines needs editing has been derived in discussion with the developers and is not something I figured out myself, and as we are now only “commenting out” some lines, the process is completely reversible so there is no risk that you will be destroying or damaging anything.

vi $AMBERHOME/AmberTools/src/configure2

This opens an editor (VIM, you are of course free to use any editor that you want).

  • To jump to the correct line you just type a “colon” (“shift” + “.” keys), a colon will show up in the bottom left corner. You can now input integers to jump to this line-number, you execute the “jump” by pressing the “enter” (return) key (example: :143).
  • If you want to number the rows in the VIM editor you type a colon and the command “set number” followed by pressing the “enter” key :set number. You hide the numbering again by running :set nonumber if you like.
  • To make changes to the file you first press the “i” key on your keyboard, you should now se -- INSERT -- printed in the bottom left corner, you can now edit the file.
  • When you have performed the required changes you just press the “esc” key, at this point nothing should be printed in the bottom left corner. Press and hold down the “shift” key while pressing the “z” key twice (shift+z+z). The file should now be saved and you should have exited back to the command-line.

Comment out lines 2237-2241 and 2289-2293 (put a # sign as the first character on every row). This means that this:

if [ "$intelmpi" = 'yes' ]; then 
    echo "Intel MPI must be used with Intel compilers."
    exit 1
fi
# mac clang
if [ "$skippython" = 'no' ]; then 
    cpptrajcxxflags="-stdlib=libstdc++ $cpptrajcxxflags"
    cpptrajldflags="-stdlib=libstdc++ -L/usr/lib/"
fi

Should become this:

#if [ "$intelmpi" = 'yes' ]; then 
#    echo "Intel MPI must be used with Intel compilers."
#    exit 1
#fi
## mac clang
#if [ "$skippython" = 'no' ]; then 
#    cpptrajcxxflags="-stdlib=libstdc++ $cpptrajcxxflags"
#    cpptrajldflags="-stdlib=libstdc++ -L/usr/lib/"
#fi

Another file needs to be edited in order to eliminate the error.

vi $AMBERHOME/AmberTools/src/pytraj/setup.py

In this file you need to comment out line 142 in the same manner as before. Hence, we should make this:

extra_compile_args.append('-stdlib=libstdc++')

Look like this:

#extra_compile_args.append('-stdlib=libstdc++')

An earlier way of solving this was to replace libstdc++ mot libc++ on lines 2291-2292 in the configure2 file and line 142 in setup.py. Though I have received notice from the developers that these lines are no longer required. However, both methods work and you choose which ever solution you prefer.

You are now ready to compile and install the serial version of AmberTools18/Amber18

./configure -macAccelerate clang
make install

Assuming that nothing went wrong, that there is no fog in Scotland, that you were standing on one leg throughout the entire process, that the sun was shining on the globe or anything else you should now have a working version of the serial installation of AmberTools18/Amber18 compiled with a version of gfortran and Apples clang.