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.