AMBER Archive (2007)

Subject: AMBER: Successful compile on Mac OSX + Intel compilers

From: Viv Kendon (V.Kendon_at_leeds.ac.uk)
Date: Fri Aug 03 2007 - 07:28:56 CDT


Dear Amber folk,

Since I didn't find details of what's needed to compile
Amber on OSX when I googled, I thought I'd submit what
worked for me, in case it helps others. Please note, I am
not running amber myself, I have a summer project student
who is using it, and it seems to be working very nicely on
my spiffy new Mac Pro 8 core 3.0GHz machine.

I have three sets of successful compiles to report:
All three have separate details for sander and pmemd, and
all are for parallel compilation...the serial compile of
sander is fairly straightforward.

1. Mac Pro dual core PPC using gcc and lammpi

2. Mac pro Intel using gcc and lammpi

3. Mac Pro Intel using ifort (Intel) and openmpi

Please watch out for line-wraps in the config file
sections...

1. Mac Pro dual core PPC using gcc and lammpi:

uname -a
Darwin quince.leeds.ac.uk 8.10.0 Darwin Kernel Version
8.10.0: Wed May 23 16:50:59 PDT 2007;
root:xnu-792.21.3~1/RELEASE_PPC Power Macintosh powerpc
PowerMac7,3 Darwin

gcc --version
powerpc-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer,
Inc. build 5367)

a) fftw3, lammpi and g95 have been installed using fink
(http://finkproject.org) in the standard location /sw, and
/sw/bin/init.sh used to update PATH to include /sw/bin.

b) AMBERHOME=/Applications/amber9
    MPI_HOME=/sw

c) ./configure -lam g95 nearly works, you have to edit
config.h to set
AMBERBUILDFLAGS=-I/sw/include -I/sw/include/lammpi

then the build goes through but I couldn't get all the
parallel tests work because lam plays up if you don't
lamclean it after failures.

d) pmemd is harder work, this is the config.h that worked:

MATH_DEFINES =
MATH_LIBS =
FFT_INCLUDEDIR = /sw/include
FFT_LIBDIR = /sw/lib
FFT_DEFINES = -DFFTW_FFT
FFT_INCLUDE = -I$(FFT_INCLUDEDIR)
FFT_LIBS = -L$(FFT_LIBDIR) -lfftw3
NETCDF_HOME =
NETCDF_DEFINES =
NETCDF_MOD =
NETCDF_LIBS =
MPI_HOME = /sw
MPI_DEFINES = -DMPI
MPI_INCLUDE = -I$(MPI_HOME)/include/lammpi
MPI_LIBDIR = $(MPI_HOME)/lib/lammpi
MPI_LIBS = -L$(MPI_LIBDIR) -llamf77mpi -lmpi -llam -ldl -lpthread
DIRFRC_DEFINES = -DDIRFRC_EFS -DDIRFRC_NOVEC
CPP = /usr/bin/cpp
CPPFLAGS = -traditional -P
F90_DEFINES =

F90 = g95
MODULE_SUFFIX = mod
F90FLAGS = -c -fno-second-underscore -I/sw/include
F90_OPT_DBG = -g
F90_OPT_LO = -O1
F90_OPT_MED = -O2
F90_OPT_HI = -O3
F90_OPT_DFLT = $(F90_OPT_HI)

CC = gcc
CFLAGS = -O3 -bind_at_load

LOAD = g95
LOADFLAGS =
LOADLIBS =

I did try to make a config_data file to generate this but
didn't manage to get it completely right.

2. Mac pro Intel using gcc and lammpi
uname -a
Darwin spider.leeds.ac.uk 8.10.1 Darwin Kernel Version
8.10.1: Wed May 23 16:33:00 PDT 2007;
root:xnu-792.22.5~1/RELEASE_I386 i386 i386 MacPro2,1 Darwin

gcc --version
i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer,
Inc. build 5367)

Exactly the same instructions as for a PPC Mac Pro also
work. I actually did it slightly differently, after
  ./configure -lam g95 I added
-I/sw/include/lammpi to get

  FPPFLAGS= -I/sw/include -I/sw/include/lammpi -P -DMPI
-xassembler-with-cpp $(AMBERBUILDFLAGS)

3. Mac pro Intel using Intel ifort.

This was tougher. I wanted to have everything compiled with
the Intel compilers (they give something like a factor 2
speed up over gcc). The Intel compilers install in /opt, so
I chose to put everything else there too, so the two
versions (g95 and ifort) could co-exist.

This is the first time I've used the Intel compilers, so I
know only the barest minimum. First set your path to have
the icc and ifort compilers near the front, using the
provided scripts in /opt/intel/fce/10.0.016/bin/ifortvars.sh
(for example, for the 64 bit ifort).

a) Compiling fftw-3.1.2 into /opt/fftw3 was non-trivial
using the intel compilers. I had to disable a test in the
configure script:

case "${ax_cv_c_compiler_vendor}" in
    intel) # Stop icc from defining __GNUC__
          { echo "$as_me:$LINENO: checking whether C compiler
accepts
-no-gcc" >&

to stop it adding the -no-gcc flag to everything, and I used
the following options

./configure --prefix=/opt/fftw3 \
     --enable-threads --with-openmpi --enable-shared \
     CC="icc -std=c99 " CFLAGS=" -m64 -O3 -bind_at_load -ansi_alias " \
     CPP=/usr/bin/cpp CPPFLAGS=" -I/opt/openmpi/include "\
     CXX=icpc CXXFLAGS="-g -O2 " \
     F77=ifort FFLAGS="-g " \
     LDFLAGS=" -L/opt/openmpi/lib -L/opt/intel/fce/10.0.016/lib
-L/opt/intel/cce/10.0.016/lib "

I don't know how many of these are necessary or optimal, but
it worked.

Compiling openmpi wasn't so bad, used the following
./configure --enable-static --prefix=/opt/openmpi \
CC=icc CXX=icpc F77=ifort FC=ifort

b) AMBERHOME=/opt/amber9
    MPI_HOME=/opt/openmpi

c) ./configure ifort_x86_64 for the serial build needs the
    following edits:
    gcc -> icc
    cpp -> fpp
    cpp -traditional -> fpp

    and for the parallel build
    ./configure -openmpi ifort_x86_64
    you have to do the same edits plus
    AMBERBUILDFLAGS=-I/opt/openmpi/include

c) pmemd: I made an interconnect.openmpi:

MPI_DEFINES = -DMPI
MPI_INCLUDE = -I$(MPI_HOME)/include
MPI_LIBDIR = $(MPI_HOME)/lib
MPI_LINK_FLAGS = $(shell /opt/openmpi/bin/mpicc --showme:link)
MPI_LIBS = -L$(MPI_LIBDIR) $(MPI_LINK_FLAGS)

and a macintel_em64t.ifort, but I had to hack the script to
recognise the new platform:

diff configure configure.orig
389d388
< $platform = macintel_em64t -o \

I am not giving you the contents of macintel_em64t.ifort
because it still needs edits to config.h to make it work
(which I assume can be copied back, but I haven't done it).
Instead, here is the working config.h

MATH_DEFINES =
MATH_LIBS =
FFT_DEFINES = -DFFTW_FFT
FFT_INCLUDEdir = /opt/fftw3/include
FFT_LIBDIR = /opt/fftw3/lib
FFT_INCLUDE = -I$(FFT_INCLUDEDIR)
FFT_LIBS = -L$(FFT_LIBDIR) -lfftw3
NETCDF_HOME =
NETCDF_DEFINES =
NETCDF_MOD =
NETCDF_LIBS =
MPI_HOME = /opt/openmpi
MPI_DEFINES = -DMPI
MPI_INCLUDE = -I$(MPI_HOME)/include
MPI_LIBDIR = $(MPI_HOME)/lib
MPI_LINK_FLAGS = $(shell /opt/openmpi/bin/mpif77 --showme:link)
MPI_LIBS = -L$(MPI_LIBDIR) $(MPI_LINK_FLAGS)
DIRFRC_DEFINES = -DDIRFRC_EFS -DDIRFRC_COMTRANS
-DDIRFRC_NOVEC
CPP = fpp
CPPFLAGS = -P -I/opt/fftw3/include
F90_DEFINES =

F90 = ifort
MODULE_SUFFIX = mod
F90FLAGS = -c -auto -I/opt/openmpi/include
-I/opt/fftw3/include
F90_OPT_DBG = -g -traceback
F90_OPT_LO = -O0
F90_OPT_MED = -O2
F90_OPT_HI = -ip -O3
F90_OPT_DFLT = $(F90_OPT_HI)

CC = icc
CFLAGS = -O3 -bind_at_load

LOAD = ifort
LOADFLAGS = -bind_at_load -L/opt/intel/fce/10.0.016/lib

Notice I haven't managed to use the MKL even though I have
them installed. I will work on this, but on a Mac these
libraries come as a framework, which is rather different
from linux, and I couldn't figure out how to make them link
properly. Also note the hard-coded /opt/openmpi that could
be replaced with $MPI_HOME if you try this yourself with the
mpi in another place.

I hope this is useful to someone out there, and am happy to
have suggestions for improvements to what I've managed.

cheers,
-- Viv
------------------------------------------------
Dr Viv Kendon V.Kendon_at_leeds.ac.uk
Quantum Information tel: 0113 343 3858
Physics & Astronomy University of Leeds
          http://quantum.leeds.ac.uk/~viv
-----------------------------------------------------------------------
The AMBER Mail Reflector
To post, send mail to amber_at_scripps.edu
To unsubscribe, send "unsubscribe amber" to majordomo_at_scripps.edu