Friday, April 22, 2011

Building AmberTools 1.5 on a 10.4.x Tiger with gcc/gfortran 4.3

I'll be using BASH environment in my examples here although I am a die-hard TCSH fan, I also speak BASH. I envision this document is for first time users who are somehow macports savvy. To learn more about macports, see http://guide.macports.org/ .

The only reason that I am writing something for 10.4.x is that I have a intel-cpu 10.4.x box and "because I can". A very important limit of 10.4.x is that you can only build a gcc/gfortran as new as gcc43. So for a macports user like me, I just do "sudo port install gcc43 gcc_select". (After using macports with different compilers for a while, many people should be able to appreciate how handy gcc_select is...)

Supposed that you downloaded the source code of AmberTools 1.5 with your web-browser, the normal place of the source code archive file was saved is probably your own Downloads folder. ( ~/Downloads )

Now uncompress the archive and put it into the /opt directory. The reason that I chose this path is that I can always remove the whole contents of /opt folder without interfering your daily operations with your Macintosh.

        $ tar jxvf ~/Download/AmberTools-1.5.tar.bz2 -C /opt

SERIAL AmberTools

Add "#include <unistd.h>" to AmberTools/src/ptraj/trajectory.c

        $ cd /opt/amber11/AmberTools/src/ptraj
        $ curl -O http://mjhsieh.github.com/a15_trajectory.patch
        $ patch -p0 < a15_trajectory.patch
Somehow my macports gcc43 doesn't understand off_t inside ptraj/trajectory.c. The situation is quite weird, since off_t is a posix standard, meaning that it should be a default everywhere. (updated: unistd.h is not included in ANSI standard.) Anyway, doing this doesn't hurt. (Updated: The reason that I didn't put this in the source tree was that I don't think 10.4.x tiger is a popular OS of choice for a Mac.)

Set up the environment variable, if these variables have already been set in your .bashrc file, please just verify the values of variable and modify accordingly, and then open a new terminal session.

        $ export AMBERHOME=/opt/amber11
        $ export PATH="$AMBERHOME/bin:$PATH"
        $ export MPI_HOME=$AMBERHOME
        $ echo 'export AMBERHOME=/opt/amber11' >> ~/.bashrc
        $ echo 'export PATH="$AMBERHOME/bin:$PATH"' >> ~/.bashrc
        $ echo 'export MPI_HOME=$AMBERHOME' >> ~/.bashrc
        $ cd /opt/amber11/AmberTools/src
For ambertools with xLEaP, we used default setting.
        $ ./configure gnu
For ambertools without xLEaP, generally good for 10.4.x, since many people probably didn't install the developers' tools with X11 option activated.
        $ ./configure -noX11 gnu

Build the serial AT15

        $ make
(cheering after it finished without problems)

Test the serial build

        $ cd ../test
        $ ./test_at_serial.sh
(cheering after it finished without problems)

Clean the file after the serial build is finished.

        $ cd ../src
        $ make clean

PARALLEL AmberTools

Download the openmpi source code from open-mpi.org
        $ cd ~/Downloads
        $ curl -O http://www.open-mpi.org/software/ompi/v1.4/downloads/openmpi-1.4.3.tar.bz2

Uncompress this source archive

        $ cd /opt/amber11/AmberTools/src
        $ tar jxvf ~/Downloads/openmpi-1.4.3.tar.bz2

Build amber's own openmpi

        $ ./configure_openmpi
(cheering after it finished without problems)

Configure parallel ambertools

        $ ./configure -mpi gnu

Build some parallel components of ambertools

        $ make
(cheering after it finished without problems)

Test

        $ cd ../test
        $ export DO_PARALLEL='mpirun -np 2'
        $ ./test_at_parallel.sh
There you have it!