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