Monday, April 26, 2010

Step-by-Step AmberTools 1.4 Installation on Mac OS X 10.5/10.6 with GNU Compilers

Here I am going to write something about the steps to install your own AmberTools 1.4 on your Mac OS X using GNU compilers. Previously we already had several blog entries about installing the compilers, so I am not going to spend too much effort on that issue. Now if you are not sure your Macintosh have the necessary compilers to build AmberTools, please read the previous posts in this blog and find some unix buddies to help. Also this tutorial is based on the assumption that you are using BASH as your default shell. For other shells, please consult your local unix guys or system administrator for equivalent commands.

If you have installed MacPorts but have not yet installed the gfortran:

sudo port install gcc44
sudo port install gcc_select
sudo gcc_select mp-gcc44
If you are using gfortran from fink, please note that you don't have gcc_select, but you can still use following steps to make sure you are using both gcc and gfortran from fink.
  1. Of course, install gfortran with "sudo fink install gfortran".
  2. Check which gcc is default in your environment:
    "which gcc" and "gcc -v" commands.
  3. If the result says "/usr/bin/gcc", and you later encounter this issue you probably need to change the configure script later in the directory of $AMBERHOME/AmberTools/src/ by replacing "gcc" to "gcc-4" and "g++" to "g++-4".

Now here comes the fun part, please make sure that you already downloaded the AmberTools (and also know where did the file you downloaded go!).

  1. We first change the current directory to /usr/local,
    cd /usr/local
  2. and then extract the AmberTools archive you just downloaded, presumably at ~/Downloads/.
    sudo tar xvfj ~/Downloads/AmbeTools-1.4.tar.bz2
  3. And then fix the permission for you can build it without using root privilege:
    sudo chown -R $USER:$GROUP amber11
  4. Run this command and make sure to put this command to your $HOME/.bashrc:
    export AMBERHOME=/usr/local/amber11
  5. Change the current directory to where the configure script is:
    cd amber11/AmberTools/src
  6. Now it would be a good time to modify the configure script if you are required to do that because of this and that. THIS IS NORMALLY NOT NECESSARY.
    perl -pi -e 's/cc=gcc/cc=gcc-4/;s/g++/g++-4/g' configure
  7. Following the manual, do the configuration. This takes about 1~3 minutes to finish.
    ./configure -macAccelerate gnu
  8. And start to build the program:
    make install
    This will take a while, make yourself a cup of tea. If you see any problem or message during the building process that prevent you from finishing, please report it to the Amber mail reflector.
  9. After that, change your current directory to the testing directory:
    cd ../test
  10. And start testing!
    make test

After finish building the AmberTools above, you might want to build a parallel version of some commands. About the decision of whether or not making a parallel version of them, please refer to the AmbetTools manual. If you want to build parallel version of AmberTools 1.4 or even Amber11 in general I'd recommend to build an openmpi software by yourself under the AMBER directory. Here is how to build an openmpi inside AMBER.

  1. First change current directory to the AmberTools source:
    cd $AMBERHOME/AmberTools/src
  2. Important! Clean-up the left-over from previous non-parallel building work.
    make clean
  3. Then download the source code of openmpi from here and extract the files for openmpi.
    tar xvfj ~/Downloads/openmpi-1.4.1.tar.bz2
  4. Now start to build the openmpi:
    ./configure_openmpi gnu
  5. Here comes the tricky part, by default your Mac OS X 10.6/10.5 bundled openmpi with the developer Tools without FORTRAN support (yes, sadly mpif90/mpif77 in the /usr/bin are disabled by Apple.), so you have to make sure $AMBERHOME/bin in the PATH and also it has to be prior to /usr/bin. If you have macports installed, your $PATH in the BASH should look something similar to this:
    bash-3.2$ echo $PATH
    /usr/local/amber11/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/X11/bin
    bash-3.2$ 
  6. Now configure a parallel environment for building parallel commands in AmberTools:
    env MPI_HOME=$AMBERHOME/AmberTools ./configure -mpi -macAccelerate gnu
  7. And then build the things:
    make parallel
  8. Before you do some tests on parallel programs, be advised to turn off the firewall (consider this temporary), since the tests will give you a lot of pop-up prompts if you are using application based firewall rules...
  9. And do some tests:
    cd ../test
    env DO_PARALLEL="mpirun -np 2" make test.parallel

Now you have it! If you still do not know what you are doing, please stop-by the Amber mail reflector and ask us questions and we are more than happy to help!

(Update: if your other compiling activities are broken by gcc_select, for example you no longer are able to build iphone app with Xcode, just do "sudo gcc_select gcc42" to reset the setting.)