Showing posts with label AmberTools. Show all posts
Showing posts with label AmberTools. Show all posts

Saturday, April 23, 2011

Building AmberTools 1.5 on a 10.5.x or 10.6.x 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/ .

10.5.x / 10.6.x

Macports gcc45 is a set of stable compilers that you should be trying first. You are also advised to unset MKL_HOME since MKL gives some bad results for certain tests.

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

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
        $ unset MKL_HOME
        (note: "unset" doesn't work on CSH, please use "unsetenv" instead)
        $ echo 'export AMBERHOME=/opt/amber11' >> ~/.bashrc
        $ echo 'export PATH="$AMBERHOME/bin:$PATH"' >> ~/.bashrc
        $ echo 'export MPI_HOME=$AMBERHOME' >> ~/.bashrc
        $ cd /opt/amber11/AmberTools/src

Configure for building serial amber

        $ ./configure -macAccelerate gnu

Build the serial AT15

        $ make

Test the serial build

        $ cd ../test

Clean the file after the serial build is finished.

        $ cd ../src
        $ make clean

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
( If you use TCSH/CSH as your login shell, you'd need to run "rehash" command before continue following procedures. )

Configure parallel ambertools

        $ ./configure -mpi -macAccelerate gnu

Build some parallel components of ambertools

        $ make

Test parallel set

        $ cd ../test
        $ export DO_PARALLEL='mpirun -np 2'
        $ ./test_at_parallel.sh

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!

Saturday, May 15, 2010

Building AmberTools 1.4 with pre-built compilers on Mac OS X 10.6 Snow Leopard

I have been using the pre-built compilers for Amber projects from time to time, but I've never settled down with any of these binary packages. The most obvious reason was that I really like to build it by myself, part of me deep inside my paranoid mind, I was just afraid of pre-built packages.

However when it comes to preparing documentation for the broad range of Amber users, suggesting an solution of requiring users to build compilers themselves seems to be ridiculous in some level a hassle for users. If you want to change the status quo, go to Apple's bugs report website and suggest them to bundle gfortran with Xcode. I can even envision Professors writing letter to Steve Jobs and having a very civilized discussion back and forth.

Before we convince Apple to begin hiring FORTRAN people, for users with limited experience of mac and unix, I can only introduce pre-built binary packages from third-party providers. Now I am going to write down the steps I have tried to work on Amber with a pre-built compiler package. Gaurav Khanna of "HPC on Mac OS X" project has done a great job providing binary packages for Mac community for a long time. To download the package, you can visit the homepage at http://hpc.sf.net and find the download link. My experience on the gfortran-only package was not successful, it failed on linking the fftw and nab. I also failed to finish the configure script with the other "llvm-gfortran-intel-bin.tar.gz" package. So I am going to recommend you to use the gcc+gfortran package.

Here are the steps:

  1. If you already tried MacPorts and fink, you should uninstall them to prevent them interfering your following procedures. (updated: no I am not bad mouthing MacPorts or fink in the previous version of the document, I was trying to be funny.)
  2. If you want to keep your gcc/gfortran from MacPorts, try this:
    sudo gcc_select gcc42
    sudo port deactivate gcc44
    (for more information, do man gcc_select and man port, please.)
  3. If you already install the package of "gfortran-snwleo-intel-bin.tar.gz (Snow Leopard gfortran only)", you should uninstall it. To uninstall it, do
    cd /; tar ztf ~/Downloads/gfortran-snwleo-intel-bin.tar.gz | grep -v -e '/$' -e '/\._' | xargs sudo rm -f
  4. gcc+gfortran binary package "gcc-snwleo-intel-bin.tar.gz (Snow Leopard)" from the same site indeed does work, so you should download that gcc-snwleo-intel-bin.tar.gz file. To install it, do:
    sudo tar zxvf ~/Downloads/gcc-snwleo-intel-bin.tar.gz -C /
    (this will extract the files in /usr/local )
  5. Now it comes to be the tedious part of the work, try to make sure you are running the right compilers when you type gcc and gfortran. First type gcc -v command, if your output looks like this, you are using the right C compiler:
    [localhost:amber11/AmberTools/src] mjhsieh% gcc -v
    Using built-in specs.
    COLLECT_GCC=gcc
    COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin10/4.5.0/lto-wrapper
    Target: x86_64-apple-darwin10
    Configured with: ../gcc-4.5-20100107/configure --enable-languages=fortran --host=x86_64-apple-darwin10 --build=x86_64-apple-darwin10 : (reconfigured) ../gcc-4.5-20100107/configure --enable-languages=fortran,c++ --host=x86_64-apple-darwin10 --build=x86_64-apple-darwin10
    Thread model: posix
    gcc version 4.5.0 20100107 (experimental) (GCC)
  6. If your gfortran -v output looks like this, you are using the right gfortran.
    [localhost:amber11/AmberTools/src] mjhsieh% gfortran -v
    Using built-in specs.
    COLLECT_GCC=gfortran
    COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin10/4.5.0/lto-wrapper
    Target: x86_64-apple-darwin10
    Configured with: ../gcc-4.5-20100107/configure --enable-languages=fortran --host=x86_64-apple-darwin10 --build=x86_64-apple-darwin10 : (reconfigured) ../gcc-4.5-20100107/configure --enable-languages=fortran,c++ --host=x86_64-apple-darwin10 --build=x86_64-apple-darwin10
    Thread model: posix
    gcc version 4.5.0 20100107 (experimental) (GCC)
  7. If they are not what you got, please make sure you have set the correct path environment variable, it should contain "/usr/local/bin"; my path variable looks like this:
    % echo $PATH
    /opt/local/bin:/opt/local/sbin:/opt/intel/Compiler/11.1/084/bin/intel64:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/X11/bin:/Users/mjhsieh/bin
  8. If you still can't have the correct output, ask us in the Amber mail reflector.
  9. start to configure:
    cd /usr/local/amber11
    cd AmberTools/src; ./configure -macAccelerate gnu
  10. If everything printed out looks okay, start building AmberTools by typing make install
  11. Also go to the path where amber11 is at, start the building process:
    cd ../../src; make install
  12. Now you have it, please make sure it passes the test cases in amber11/test and amber11/AmberTools/test.
  13. GOOD LUCK playing AMBER/AMBERTOOLS!
  14. This is my result:
    Finished test suite for AmberTools at Sun May 16 02:58:11 PDT 2010.
    
         318 file comparisons passed
           0 file comparisons failed
           0 tests experienced errors
    
    Finished serial test suite for Amber 11 at Sun May 16 03:53:37 PDT 2010.
    
         492 file comparisons passed
           0 file comparisons failed
           0 tests experienced errors
    
  15. If you are not satisfied with this binary package, do this to uninstall:
    cd /; tar ztf ~/Downloads/gcc-snwleo-intel-bin.tar.gz | grep -v -e '/$' -e '/\._' | xargs sudo rm -f

Thursday, May 06, 2010

AmberTools 1.4 and Amber 11 on Snow Leopard with the Intel compilers

In this post, I describe how to compile and install Amber 11 on Snow Leopard with the Intel compilers. Some suggest that the Intel compilers should be passed over in favour of the GNU compilers for the time being; in my experience, on the whole, the two give comparable output. This post is written as though you have installed the most recent versions of the Intel Mac compilers, which at the time of writing are 11.1.088. For earlier (or later) versions, you will need to modify your paths accordingly. I also assume you have downloaded and installed the Intel compilers. The installation process for these is straightforward, and should in any case be documented by Intel.

  1. Set up the Intel compiler environment. Note: These commands are intended for the Bourne shell and its variants (e.g., bash). If you are using the C shell or a variant (e.g., tcsh), you will need to use the scripts with a .csh extension instead of those ending in .sh. Also, if you are using an ia32 processor instead of a 64-bit processor, the argument to the script should be modified accordingly.
  2. . /opt/intel/Compiler/11.1/088/bin/iccvars.sh intel64
    . /opt/intel/Compiler/11.1/088/bin/ifortvars.sh intel64
  3. If you wish to compile a parallel (MPI) version of Amber and/or AmberTools, download MPICH2 from here. WARNING: While other MPI implementations such as Open MPI exist, some are untested, and Open MPI fails.
  4. Untar the mpich2 installation file:
    tar xzvf mpich2-1.2.1p1.tar.gz
  5. Configure MPICH2 for installation and build it:
    cd mpich2-1.2.1p1 ./configure --prefix=your_chosen_mpich2_directory \ --enable-f77 --enable-f90 --enable-cxx \ CC=icc CXX=icpc F77=ifort F90=ifort
  6. Follow the rest of the MPICH2 installation and testing instructions in the README file.
  7. Make sure that your_chosen_mpich2_directory/bin and your_chosen_mpich2_directory/lib are in your PATH and DYLD_LIBRARY_PATH respectively, and that they are ahead of other possible MPI installations such as the default system MPI.
  8. Follow steps 1 to 5 here. Step 6 should not be necessary.
  9. Configure Amber:
    ./configure intel
  10. Follow steps 8 to 10 here.
  11. If you have also installed Amber 11, go to $AMBERHOME/src and run make there.
  12. Before continuing, we recommend testing the serial executables, as outlined in the AmberTools and Amber documentation.
  13. To build parallel, return to the AmberTools source directory and re-configure:
    ./configure -mpi intel
  14. Clean up the previous object files by running make clean in both the AmberTools and Amber directories.
  15. Make parallel executables by running make parallel in both the AmberTools and Amber directories.
  16. Finally, test the parallel executables, as outlined in the AmberTools and Amber documentation.
If you have any questions, please feel free to direct them to the AMBER mailing list.

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.)

Wednesday, December 23, 2009

Step-by-step procedure of building MacPorts gfortran and AmberTools 1.3 in Mac OS X 10.6

This is what I would do if I got a brand new Mac OS X machine using gfortran to build AmberTools 1.3 on it.

  1. Find the Mac OS X installation CDs/DVD, start to install Xcode Developer Tools.
    If you left it at home, try to download it at the Apple Developer Connection site. Make sure you have installed "Unix Development" (default)
  2. Download the MacPorts Disk Image from the MacPorts' website.
  3. Mount the disk image and install the pkg, running the system's Installer by double-clicking on the pkg contained therein, following the on-screen instructions until completion.
  4. Open a new shell window and do later stuff in this shell, this is to make sure that changes to the environment variables have taken effect.
  5. check if your PATH environment variable really contains /opt/local/bin and /opt/local/sbin by running "echo $PATH"
  6. check upgrades to MacPorts: "sudo port -v selfupdate"
  7. run "sudo port install gcc44"
  8. run "mkdir ${HOME}/bin"(not necessary)
  9. append this line to the end your ~/.bashrc (If you are using CSH/TCSH, you must be very savvy, so you don't need no documentation...
    export PATH=${HOME}/bin:$PATH
  10. run "export PATH=${HOME}/bin:$PATH"
  11. run "ln -s /opt/local/bin/gfortran-mp-4.4 ~/bin/gfortran"
    (Original steps were stupid, try following steps:) run "sudo port install gcc_select; sudo gcc_select mp-gcc44"
  12. Download AmberTools from http://ambermd.org/#AmberTools (Safari will place it to ~/Downloads)
  13. run "tar jxvf ~/Downloads/AmberTools-1.3.tar.bz2 -C ~/", this will extract an amber11 folder in your home directory.
  14. Now it would be a good time to append this line to your ~/.bashrc
    export AMBERHOME=${HOME}/amber11
  15. run "export AMBERHOME=${HOME}/amber11" as well
  16. run "cd ~/amber11/src; ./configure -macAccelerate gnu"
  17. run "make -f Makefile_at" and wait
  18. After "make" stops, check to see if there is any error. If your building process indeed stopped prematurely, report it to the Amber mailing list. Please mention your OS version and compiler you used.
  19. run "cd ~/amber11/test; make -f Makefile_at" to check the testing cases result. Please make sure your environment variable $AMBERHOME is correct before you run the test.

After thought

If you want to use macports without problem after above operation, make sure to "sudo gcc_select" back to gcc42 or llvm-gcc42, or you might encounter some incompatibility with building some certain ports.

Tuesday, October 06, 2009

gcc 4.4 is not happy with sleap's boost source

If by any chance you are using gcc 4.4 to compile sleap under gleap directory, you might encounter problems like this error:

../../ext/boost/mpl/apply_wrap.hpp:81:31: error: missing binary operator before token "("
../../ext/boost/mpl/apply_wrap.hpp:173:31: error: missing binary operator before token "("
....
This is due to some behaviors changes after gcc 4.4 that interpret C preprocessing macro differently. Here is a patch to workaround. We might need to use newer boost for or system's boost lib.

Wednesday, April 09, 2008

AmberTools 1.0 is now available!

(Originally posted on 4/2/08, updated)
GPLed AmberTools 1.0 is now available!
And AmberTools is now under GPL2! Go ahead and check it out!

    Known macintosh-related issues on version 1.0:
  1. sleap crashs when launched (fixed in the current source tree, please wait for software update.)
  2. antechamber crashs during several tests.