#!/bin/sh #set -xv # Store the command command=`echo "$0 $*" | sed -e "s/configure2/configure/"` # configure script for Amber and AmberTools: creates config.h #------------------------------------------------------------------------------ # set up usage statement: #------------------------------------------------------------------------------ usage(){ cat< Specify a particular Python interpreter to use for Python programs. Must be Python2.4-Python2.7 --with-netcdf Specify a separate NetCDF build to use. The NetCDF must have both C and Fortran interfaces. -netcdfstatic Force separate NetCDF build to link statically. Some influential environment variables: MKL_HOME If present, will link in Intel's MKL libraries (intel, gnu) GOTO If present, and neither macAccelerate nor MKL_HOME is set, will use this location for the GotoBLAS2 library. SSE_TYPES CPU types for which auto-dispatch code will be produced (Intel compilers version 11 and higher). Known valid options are SSE2, SSE3, SSSE3, SSE4.1 and SSE4.2. Multiple options (comma separated) are permitted. XTRA_FLIBS Add extra Fortran libraries that may be required when linking. =============================================================================== EOD exit 0; } check_amberhome() { if [ -z "$AMBERHOME" ]; then echo "" echo "Your AMBERHOME environment variable is not set! It should be set to" echo "$1 NOT doing so may cause errors when you compile." exit 1 elif [ ! -d $AMBERHOME ]; then echo "" echo "Your AMBERHOME environment variable is set to $AMBERHOME -- this does" echo "not appear to be a directory. It should be set to $1 NOT doing so may" echo "cause errors when you compile" exit 1 elif [ ! "$AMBERHOME" = "$1" -a ! "$AMBERHOME" = "${1}/" ]; then #try checking the inode incase there is a problem with symlinks if [ `stat -c "%i" $AMBERHOME` != `stat -c "%i" ${1}` ]; then echo "" echo "ERROR: AMBERHOME is expected to be $ambhome but it is currently" echo "$AMBERHOME This will cause problems!" exit 1 fi fi } #echoes the command string modified to remove specific flags that may #or may not be present and/or adds new flags to the string. The first #argument is a string of white space delimited flags to remove (order #doesn't matter) and the second arguments is a white space delimited #string of the flags to add (order is preserved). For example, if the #command is # ./configure -mpi -rism -cuda -cuda_SPXP -nosse -mpi gnu #using # new_command=`mod_command_args '-rism -mpi -cuda -openmp' '-nofftw3 '` #will set $new_command to # ./configure -nofftw3 -cuda_SPXP -nosse gnu mod_command_args() { #replace white space in first argument with '\|' and add escaped parentheses delete=`echo $1 | sed -e 's/ \+/\\\|/g' -e 's/\(.*\)/\\\(\1\\\)/'` if [ "$delete" != '\(\)' ]; then delete="$delete " fi add=$2 #delete the flags in the $delete list. Note the white space #ensure we don't remove part of another flag. Then insert the add #list at the first occurance of whitespace echo `echo $command | sed -e "s/$delete//g" -e "s/ / $add /"` } # Used for test-compiling NetCDF with C and Fortran compilers. # cc, fc, netcdfinc, netcdfflagc, and netcdfflagf must be set. # If 'verbose' is specified complain about failures, otherwise be silent. test_netcdf_compile() { status=0 # Test NetCDF C cat > testp.c < #include "netcdf.h" int main() { printf("%s\n",nc_strerror(0)); printf("Testing\n"); return 0; } EOF $cc $cflags $netcdfinc -o testp$suffix testp.c $netcdfflagc > /dev/null 2> compile.err if [ ! -e "testp$suffix" ] ; then status=1 else ./testp$suffix | grep "Testing" > /dev/null status=$? fi if [ $status -gt 0 ] ; then if [ "$1" = "verbose" ] ; then echo "Error: Could not compile with NetCDF C interface." #echo " $cc $cflags $netcdfinc -o testp$suffix testp.c $netcdfflagc" echo " Compile error follows:" cat compile.err echo "" fi return 1 fi /bin/rm ./testp$suffix testp.c compile.err # Test NetCDF Fortran cat > testp.f90 < /dev/null 2> compile.err if [ ! -e "testp$suffix" ] ; then status=1 else ./testp$suffix | grep "testing a Fortran program" > /dev/null status=$? fi if [ $status -gt 0 ] ; then if [ "$1" = "verbose" ] ; then echo "Error: Could not compile with NetCDF Fortran interface." # echo " $fc $fflags $netcdfinc -o testp$suffix testp.f90 $netcdfflagf" echo " Compile error follows:" cat compile.err echo "" fi return 1 fi /bin/rm ./testp$suffix testp.f90 compile.err return 0 } # Test for the presence of /bin/csh, since it's needed for installation if [ ! -x /bin/csh ]; then echo "Error: /bin/csh not found on your system! Install csh or tcsh and rerun" echo " configure." exit 1 fi #------------------------------------------------------------------------------ # Process commandline configuration options: #------------------------------------------------------------------------------ mpi='no' intelmpi='no' mpinab='' cuda_SPFP='no' cuda_SPXP='no' cuda_DPFP='no' mic='no' mic_native='no' mic_offload='no' openmp='no' sse='yes' gotolib='no' compiler='unspecified' processor=`uname -m` os=`uname -sr | awk -F . '{print $1}'` static='no' gnucompat='no' ar='ar rv $(EMPTY)' ranlib=ranlib suffix='' cygwin='no' hasfc='no' noX11='false' bintraj='yes' netcdfstatic='no' lfs='yes' rism='default' make_xleap='install_xleap' lm='-lm' m4='m4' ldflags='' fpp="cpp -traditional -P" fppflags="" freeformat_flag='' macAccelerate='no' gnuld='yes' crayxt5='no' ld='ld ' ldout=' -o ' objsuffix='.o' localmv='mv' localrm='rm' localcp='cp' installtype='serial' mtkpp='install_mtkpp' debug='no' optimise='yes' is_mac='no' python='' netcdf_dir='' amber='amber' pbsaflag='-DFFTW' mdgx='yes' build_emil='yes' amberphenix='no' #------------------------------------------------------------------------------ # Architecture specific: #------------------------------------------------------------------------------ if [ "$processor" = "em64t" -o "$processor" = "x86_64" ] ; then x86_64='yes' else x86_64='no' fi #------------------------------------------------------------------------------ # Checking Arguments: #------------------------------------------------------------------------------ if [ $# -lt 1 ]; then usage; fi while [ $# -gt 0 ]; do case "$1" in -mpi) mpi='yes'; mpinab='mpi';mtkpp='' ;; -intelmpi) mpi='yes'; intelmpi='yes'; mpinab='mpi';mtkpp='' ;; -cuda) cuda_SPFP='yes';rism='no';pbsaflag='';mdgx='no';mtkpp='' ;; -cuda_SPFP) cuda_SPFP='yes';rism='no';pbsaflag='';mdgx='no';mtkpp='' ;; -cuda_SPXP) cuda_SPXP='yes';rism='no';pbsaflag='';mdgx='no';mtkpp='' ;; -cuda_DPFP) cuda_DPFP='yes';rism='no';pbsaflag='';mdgx='no';mtkpp='' ;; -mic) mic='yes';; -mic_native) mic='yes';; -mic_offload) mic_offload='yes';mpi='yes';intelmpi='yes';mpinab='mpi';mtkpp='';; -rism) rism='yes' ;; -norism) rism='no' ;; -openmp) openmp='yes' ;; -cygwin) cygwin='yes'; lfs='no'; mtkpp=''; ;; -nosse) sse='no';; -nolfs) lfs='no';; -static) static='yes';; -noX11) noX11="true";; -netcdfstatic) netcdfstatic='yes' ;; -macAccelerate) macAccelerate='yes';; -crayxt5) crayxt5='yes';; -nomtkpp) mtkpp='';; -debug) debug='yes'; optimise='no';; -noopt) optimise='no';; -noemil) build_emil='no';; -nofftw3) rism='no'; pbsaflag=''; mdgx='no' ;; -lio) lio='yes' ;; --with-python) shift; python="$1";; --with-netcdf) shift; netcdf_dir="$1";; --no-updates) ;; -h|-H|--h|--hel|--help|-help) usage;; --full|--full-|--full-h|--full-he|--full-hel|--full-help) full_usage;; -*) echo "Error: unknown flag: $1" echo " Type './configure -help' for options." exit 1;; *) if [ $# -gt 1 ]; then echo "Error: unknown compiler: $1" echo " Type './configure -help' for options." exit 1 fi compiler=$1 ;; esac shift done #------------------------------------------------------------------------------- # Check for incompatiblities with mic #------------------------------------------------------------------------------- if [ "$compiler" != "intel" ]; then if [ "$mic" = 'yes' -o "$mic_offload" = 'yes' ]; then echo "ERROR: Xeon Phi support requires the Intel compiler! " exit 1 fi fi if [ "$cuda_SPFP" = 'yes' -o "$cuda_SPXP" = 'yes' -o "$cuda_DPFP" = 'yes' ]; then if [ $mic = 'yes' -o "$mic_offload" = 'yes' ]; then echo "ERROR: Xeon Phi and cuda are mutually exclusive." exit 1 fi fi #------------------------------------------------------------------------------- # See if we have Amber so we know if we should set it up or not #------------------------------------------------------------------------------- # Here we check the existence of the Amber Makefile to see if we # should build Amber as well if [ ! -f ../../src/Makefile ]; then amber='' fi #------------------------------------------------------------------------------- # Platform specific: #------------------------------------------------------------------------------- if [ `uname -s|awk '{print $1}'` = "Darwin" ]; then is_mac='yes' static='no' osx_version=`/usr/bin/sw_vers -productVersion | awk '{print $1}'` case "$osx_version" in *10\.6*) x86_64='yes' ;; *) ;; esac osx_cpu=`/usr/bin/machine | awk '{print $1}'` case "$osx_cpu" in ppc*) sse='no' fpp="/usr/bin/cpp -traditional -P" ;; *) ;; esac elif [ $macAccelerate = 'yes' ]; then echo "This is not a Macintosh, disabling -macAccelerate." macAccelerate='no' fi ld_version=`ld -v 2>&1 | awk '{print $1}'` case "$ld_version" in *GNU*) gnuld='yes';; *) gnuld='no' ;; esac #------------------------------------------------------------------------------ # Set up defaults that work for most machines: #------------------------------------------------------------------------------ workdir=`pwd` AMBERTOOLSHOME=`dirname $workdir` ambhome=`dirname $AMBERTOOLSHOME` check_amberhome $ambhome mklinc='' if [ $macAccelerate = 'no' ]; then if [ -z "$MKL_HOME" ]; then mkl='no' if [ -z "$GOTO" ]; then gotolib='no' else gotolib='yes' echo "Using GotoBLAS2 routines in $GOTO" fi else mkl='yes' fppflags="$fppflags -DMKL" mklinc="-I$MKL_HOME/include" fi fi # Note: ambercflags and ambercxxflags should only be passed # to code written and/or maintained by the Amber developers # e.g. not to fftw3, netcdf, boost, etc. cc=cc cflags= cnooptflags= coptflags=-O ambercflags= cplusplus=CC cxxflags= cxxnooptflags= cxxoptflags=-O ambercxxflags= fc_cxx_link_flag="-lstdc++" pycflags= nabflags= free_format=-FR # C versions, if compiled from source: flibs="-larpack -llapack -lblas " # Fortran versions, if compiled from source: flibsf="-larpack -llapack -lblas " omp_flag= mpi_flag= lex=flex flibs_mkl= lapack=install blas=install f2c=skip ucpp=install cpp="ucpp -l" #----------------------------------- # skip building of xleap? #----------------------------------- if [ "$noX11" = "true" ]; then make_xleap="skip_xleap" fi if [ -d /usr/X11R6/lib ]; then xhome='/usr/X11R6' elif [ -d /usr/lib/x86_64-linux-gnu ]; then xhome='/usr' elif [ -f /usr/lib/i386-linux-gnu/libX11.a ]; then xhome='/usr' elif [ -f /usr/lib/libX11.a -o -f /usr/lib/libX11.so \ -o -f /usr/lib/libX11.dll.a \ -o -f /usr/lib64/libX11.a -o -f /usr/lib64/libX11.so ]; then xhome='/usr' else echo "Could not find the X11 libraries; you may need to edit config.h" echo " to set the XHOME and XLIBS variables." fi xlibs="-L$xhome/lib" if [ "$x86_64" = 'yes' ]; then xlibs="-L$xhome/lib64 $xlibs" fi if [ -d /usr/lib/x86_64-linux-gnu ]; then xlibs="-L/usr/lib/x86_64-linux-gnu $xlibs" fi #-------------------------------------------------------------------------- # Check if the X11 library files for XLEaP are present: #-------------------------------------------------------------------------- if [ "$noX11" = "false" ]; then if [ -r "$xhome/lib/libXt.a" -o -r "$xhome/lib/libXt.dll.a" \ -o -r /usr/lib/x86_64-linux-gnu/libXt.a \ -o -r /usr/lib/x86_64-linux-gnu/libXt.so \ -o -r /usr/lib/i386-linux-gnu/libXt.a \ -o -r /usr/lib/i386-linux-gnu/libXt.so \ -o -r /usr/lib/libXt.so \ -o -r /usr/lib64/libXt.so \ -o -r /usr/X11/lib/libXt.dylib \ -o "$x86_64" = 'yes' -a -r "$xhome/lib64/libXt.a" ] then empty_statement= else echo "ERROR: the X11 libraries are not in the usual location !" echo " To search for them try the command: locate libXt" echo " On new Fedora OS's install the libXt-devel libXext-devel" echo " libX11-devel libICE-devel libSM-devel packages." echo " On old Fedora OS's install the xorg-x11-devel package." echo " On RedHat OS's install the XFree86-devel package." echo " On Ubuntu OS's install the xorg-dev package." echo " To build Amber without XLEaP, re-run configure with '-noX11:" echo " `mod_command_args '' '-noX11'`" exit 1 fi if [ -d /usr/include/X11/extensions -o $is_mac = "yes" ] then empty_statement= elif [ "$is_mac" = "no" ]; then echo "ERROR: the X11 extensions headers are not in the usual location!" echo " To search for them try the command: locate X11/extensions" echo " On new Fedora OSes install libXext-devel" echo " On RedHat OSes install libXext-devel" echo " To build Amber without XLEaP, re-run configure with '-noX11:" echo " `mod_command_args '' '-noX11'`" exit 1 fi fi #------------------------------------------------------------------------------ # Find the version of Python we're going to use. Start by looking for 2.7 and # work your way down to 2.4. Standard systems label them via python2.x. If we # can't find any of those, just use "which python" if its version is sufficient #------------------------------------------------------------------------------ # Loop through all allowed pythons (we don't allow python3, since that's not # backwards-compatible). Only do this if we didn't specify one to configure if [ -z $python ]; then printf "Searching for python2... " for ver in 'python2.7' 'python2.6' 'python2.5' 'python2.4'; do if [ ! -z `which $ver 2>/dev/null` ]; then python=`which $ver` if [ -x $python ]; then echo "Found $ver: $python" break fi # This is in case `which` dumped garbage to us python='' fi done # If none of those worked, just look for "python" and make sure # it's a good version if [ -z $python ]; then python=`which python` if [ -z $python ]; then echo "Could not find any Python interpreter installed on your system." echo "No programs written in Python (MMPBSA.py, parmed.py, etc.) will" echo "work." python='' else ver=`$python -V | awk '{print $2}'` case $ver in 2.4*) echo "Using $python: version $ver" ;; 2.5*) echo "Using $python: version $ver" ;; 2.6*) echo "Using $python: version $ver" ;; 2.7*) echo "Using $python: version $ver" ;; *) echo "Only found $python. Version $ver is not supported." echo "Python programs will not work unless you install a version" echo "of Python2 version Python 2.4 to 2.7." python='' ;; esac fi fi else # Check that the Python requested exists if [ ! -x $python ]; then echo "--with-python $python : $python cannot be found and/or run" exit 1 fi # Now test that it's at least python(-like) $python -c "print 'Hello world'" 2>/dev/null | (grep "Hello world" 2>&1 > /dev/null) if [ $? -ne 0 ]; then echo "Could not run Python $python" exit 1 fi echo "Using requested Python: $python" fi #------------------------------------------------------------------------------ # Filter out situations in which MTK++ should not be built #------------------------------------------------------------------------------ if [ "$crayxt5" = 'yes' -a "$mtkpp" = 'install_mtkpp' ]; then echo "Note: MTK++ is not compatible with the '-crayxt5' flag" mktpp='' fi if [ ! -d mtkpp ]; then mtkpp='' fi #------------------------------------------------------------------------------ # -nofftw3 is the default for MPI #------------------------------------------------------------------------------ if [ "$mpi" = 'yes' -a "$rism" != 'yes' ]; then rism='no' pbsaflag='' fi #------------------------------------------------------------------------------ # Determine which type of installation we're doing #------------------------------------------------------------------------------ if [ "$cuda_SPFP" = 'yes' -o "$cuda_SPXP" = 'yes' -o "$cuda_DPFP" = 'yes' ]; then if [ "$mpi" = 'yes' ]; then installtype='cuda_parallel' else installtype='cuda' fi elif [ "$mic" = 'yes' ]; then if [ "$mpi" = 'yes' ]; then installtype='mic_parallel' else installtype='mic' fi elif [ "$mic_offload" = 'yes' ]; then installtype='mic_offload' elif [ "$mpi" = 'yes' ]; then installtype='parallel' elif [ "$openmp" = 'yes' ]; then installtype='openmp' else installtype='serial' fi #------------------------------------------------------------------------------ # Check for cuda incompatibilities or missing files: #------------------------------------------------------------------------------ if [ "$cuda_SPFP" = 'yes' -o "$cuda_SPXP" = 'yes' -o "$cuda_DPFP" = 'yes' ]; then if [ -z "$CUDA_HOME" ]; then echo "Error: CUDA_HOME is not set. This must point to your NVIDIA tools installation" exit 1 fi if [ ! "$compiler" = "gnu" -a ! "$compiler" = "intel" ]; then echo "Error: NVIDIA cuda compilation works only with gnu or Intel compilers" exit 1 fi if [ ! -x "$CUDA_HOME/bin/nvcc" ]; then echo "Error: nvcc cuda compiler not found in $CUDA_HOME/bin/" exit 1 fi #Check for mixing of cuda with cuda_SPXP or cuda_DPFP debugging options. #cuda = SPFP mixed single/double/fixed-point precision (default) #cuda_SPFP = SPFP mixed single/double/fixed-point precision (default) #cuda_SPXP = SPXP hybrid single/double precision (debug option!) #cuda_DPFP = DPFP double precision only (debug option!) if [ "$cuda_SPFP" = 'yes' ]; then if [ "$cuda_SPXP" = 'yes' -o "$cuda_DPFP" = 'yes' ]; then echo "Error: specification of -cuda, -cuda_SPXP and -cuda_DPFP are mutually exclusive" exit 1 fi fi if [ "$cuda_SPXP" = 'yes' ]; then if [ "$cuda_SPFP" = 'yes' -o "$cuda_DPFP" = 'yes' ]; then echo "Error: specification of -cuda, -cuda_SPXP and -cuda_DPFP are mutually exclusive" exit 1 fi fi if [ "$cuda_DPFP" = 'yes' ]; then if [ "$cuda_SPFP" = 'yes' -o "$cuda_SPXP" = 'yes' ]; then echo "Error: specification of -cuda, -cuda_SPXP and -cuda_DPFP are mutually exclusive" exit 1 fi fi nvcc="$CUDA_HOME/bin/nvcc" sm35flags='-gencode arch=compute_35,code=sm_35' sm30flags='-gencode arch=compute_30,code=sm_30' sm20flags='-gencode arch=compute_20,code=sm_20' nvccflags="$sm20flags $sm30flags" cudaversion=`$nvcc --version | grep 'release' | cut -d' ' -f5 | cut -d',' -f1` if [ "$cudaversion" = "5.0" -o "$cudaversion" = "5.5" -o "$cudaversion" = "6.0" -o "$cudaversion" = "6.5" ]; then echo "CUDA Version $cudaversion detected" else echo "Error: Unsupported CUDA version $cudaversion detected." echo "AMBER requires CUDA version == 5.0 .or. 5.5 .or. 6.0 .or. 6.5" exit 1 fi nvcc="$nvcc $nvccflags" fi #------------------------------------------------------------------------------ # Case statement identifying the architecture/compilers: #------------------------------------------------------------------------------ case "$compiler" in #################### gcc ####### gnu) if [ "$mpi" = 'yes' ]; then ld=' mpif90 ' else ld=' gfortran ' fi if [ "$intelmpi" = 'yes' ]; then echo "Intel MPI must be used with the Intel compilers." exit 1 fi flibs_arch="-lgfortran -w" flibsf_arch= cc=gcc cflags= ambercflags="" cplusplus=g++ cxxflags= ambercxxflags="" fc=gfortran fflags= staticflag='-static' # If -noopt has been requested, force lack of optimisation; # otherwise, use the default levels. Since cflags, cxxflags # and fflags are used everywhere, and *optflags and # *nooptflags are not (some parts of Amber and AmberTools use # neither *optflags nor *nooptflags), we'll put -O0 in cflags # and so forth instead. if [ "$optimise" = 'no' ]; then cflags="$cflags -O0" cnooptflags="" coptflags="" cxxflags="$cxxflags -O0" cxxnooptflags="" cxxoptflags="" fflags="$fflags -O0" fnooptflags="" foptflags="" else cnooptflags= coptflags="-O3" cxxnooptflags= cxxoptflags="-O3" fnooptflags="-O0" foptflags="-O3" fi # Debugging options if [ "$debug" = 'yes' ]; then cflags="$cflags -g" cxxflags="$cxxflags -g" fflags="$fflags -g" fi echo "" echo "Obtaining the gnu suite version:" echo " $cc -v" gnu_version=`$cc -v 2>&1 | grep ' version ' | cut -d' ' -f3` echo "The version is $gnu_version" gnu_majorversion=`echo $gnu_version | cut -d'.' -f1` gnu_minorversion=`echo $gnu_version | cut -d'.' -f2` if [ $gnu_majorversion -ge 4 -a $gnu_minorversion -ge 2 -a "$optimise" = "yes" ]; then if [ $sse = 'yes' ]; then if [ $x86_64 = 'yes' ]; then #-mfpmath=sse is default for x86_64, no need to specific it coptflags="$coptflags -mtune=native" foptflags="$foptflags -mtune=native" else # i386 needs to be told to use sse prior to using -mfpmath=sse coptflags="$coptflags -mtune=native -msse -mfpmath=sse" foptflags="$foptflags -mtune=native -msse -mfpmath=sse" fi fi fcreal8="-fdefault-real-8" else fcreal8="-fdefault-real-8" fi # if gcc <= 4.2, fftw3 is not compiled and pbsa fft solver and rism # are disabled if [ "$rism" != 'no' -o -n "$pbsaflag" ]; then if ( [ $gnu_majorversion -ge 4 ] && [ $gnu_minorversion -le 2 ] ) \ || [ $gnu_majorversion -le 3 ]; then echo "ERROR: RISM and PBSA FFT solver require version 4.3 or higher of the GNU compiler." echo " Please re-run configure with the '-nofftw3' flag to use this compiler:" echo " `mod_command_args '-rism' '-nofftw3'`" exit 1 fi fi if [ "$openmp" = 'yes' ]; then omp_flag="-fopenmp -DOPENMP" flibs_arch="$flibs_arch -fopenmp" flibsf_arch="$flibsf_arch -fopenmp" # DRR - Currently MKL is statically linked by default, which appears # only to work for intel compilers. if [ "$mkl" = 'yes' ] ; then echo "ERROR: Currently MKL + OpenMP only supported for intel compilers." echo " Please unset MKL_HOME." exit 1 fi fi if [ "$cygwin" = 'yes' ]; then cflags="$cflags -DCYGWIN" fppflags="$fppflags -DCYGWIN" suffix=".exe" lm="" fi freeformat_flag=-ffree-form #PMEMD Specifics pmemd_fpp_flags='-DPUBFFT' pmemd_foptflags="$foptflags" pmemd_coptflags="$coptflags" #CUDA Specifics if [ "$cuda_SPFP" = 'yes' -o "$cuda_SPXP" = 'yes' -o "$cuda_DPFP" = 'yes' ]; then pmemd_cu_includes='-I$(CUDA_HOME)/include -IB40C -IB40C/KernelCommon' pmemd_cu_defines='-DCUDA' pmemd_cu_libs='./cuda/cuda.a -L$(CUDA_HOME)/lib64 -L$(CUDA_HOME)/lib -lcurand -lcufft -lcudart -lstdc++' if [ "$optimise" = 'no' ]; then nvcc="$nvcc -use_fast_math -O0 " else nvcc="$nvcc -use_fast_math -O3 " fi if [ "$mpi" = 'yes' -a "$intelmpi" = 'no' ]; then if [ "$intelmpi" = 'no' ]; then mpi_inc=`(mpicc -show 2>&1) | awk 'BEGIN{i=0} {while (i < NF) {if ( substr($i, 1, 2) == "-I" ) {printf("%s ", $i);}; i++;}}'` fi pmemd_cu_includes="$pmemd_cu_includes $mpi_inc" pmemd_cu_defines="$pmemd_cu_defines -DMPI -DMPICH_IGNORE_CXX_SEEK" pmemd_coptflags="$coptflags -DMPICH_IGNORE_CXX_SEEK" fi fi if [ "$cuda_SPFP" = 'yes' ]; then pmemd_cu_defines="$pmemd_cu_defines -Duse_SPFP" fi if [ "$cuda_SPXP" = 'yes' ]; then pmemd_cu_defines="$pmemd_cu_defines -Duse_SPXP" fi if [ "$cuda_DPFP" = 'yes' ]; then pmemd_cu_defines="$pmemd_cu_defines -Duse_DPFP" fi ;; #################### icc ####### intel) # following appears to work on Intel compilers version 11,2013.. flibs_arch="-lifport -lifcore" flibsf_arch= cc=icc cflags= ambercflags="" cplusplus=icpc cxxflags= ambercxxflags="" fc=ifort fflags= freeformat_flag='-FR' staticflag='-static' # If -noopt has been requested, force lack of optimisation; # otherwise, use the default levels. Since cflags, cxxflags # and fflags are used everywhere, and *optflags and # *nooptflags are not (some parts of Amber and AmberTools use # neither *optflags nor *nooptflags), we'll put -O0 in cflags # and so forth instead. if [ "$optimise" = 'no' ]; then cflags="$cflags -O0" cnooptflags="" coptflags="" cxxflags="$cxxflags -O0" cxxnooptflags="" cxxoptflags="" fflags="$fflags -O0" fnooptflags="" foptflags="" else cnooptflags= coptflags="-ip -O3" cxxnooptflags= cxxoptflags="-O3" fnooptflags="-O0" foptflags="-ip -O3" fi # Debugging options if [ "$debug" = 'yes' ]; then cflags="$cflags -g -debug all" cxxflags="$cxxflags -g -debug all" fflags="$fflags -g -debug all" fi # Test Intel compiler versions for optimisation flags. Note that the # output of "icc -v" goes onto STDERR. # C compiler version icc_version=`$cc -v 2>&1` icc_version=`echo $icc_version | sed -e 's/\..*//g' -e 's/^Version //g' -e 's/^icc version //g'` if [ -z "`which icc 2>/dev/null`" ]; then echo "icc could not be found!" exit 1 fi echo " Detected icc version $icc_version" # Test Intel compiler versions for optimisation flags. Note that the # output of "ifort -v" goes onto STDERR. ifort_version=`$fc -v 2>&1` ifort_version=`echo $ifort_version | sed -e 's/\..*//g' -e 's/^Version //g' -e 's/^ifort version //g'` if [ -z "`which ifort 2>/dev/null`" ]; then echo "ifort could not be found!" exit 1 fi echo " Detected ifort version $ifort_version" # DRR - Add flags necessary for correct compilation with intel version >= 11 # JMS - This flag actually seems to kill icpc 12.1.0. Removing these flags fixes # compilation for Intel v12.1.0 and still works for Intel v11.1.069 if [ "$icc_version" -ge 11 ] ; then # cxxflags="-std=c++0x $cxxflags" # ambercxxflags="-std=c++0x $ambercxxflags" ldflags="-shared-intel " fi #RISM and PBSA FFT solver require ISO_C_BINDING support if [ "$rism" != 'no' -o -n "$pbsaflag" ]; then if [ "$icc_version" -le 9 ] ; then echo "ERROR: RISM and PBSA FFT solver require version 10 or higher of the Intel compiler." echo " Please re-run configure with the '-nofftw3' flag to use this compiler:" echo " `mod_command_args '-rism' '-nofftw3'`" exit 1 fi fi #mic is cross compiled so can't use -xHost if [ "$mic" = 'no' ]; then if [ "$icc_version" -ge 11 -a "$optimise" = "yes" -a "$mpi" = "no" ] ; then coptflags="$coptflags -xHost" fi if [ "$ifort_version" -ge 11 -a "$optimise" = "yes" -a "$mpi" = "no" ] ; then foptflags="$foptflags -xHost" fi fi #mic requires intel compiler suite 2012 or later if [ "$mic" = 'yes' -o "$mic_offload" = 'yes' ]; then if [ "$ifort_version" -lt 12 -o "$icc_version" -lt 12 ] ; then echo "ERROR: -mic_native or -mic_offload requires Intel Compiler Suite v2012 or later." exit 1 fi mpss_version=`micinfo 2>&1 | grep "MPSS" | cut -d ":" -f2` if [ -z "$mpss_version" ] ; then echo "ERROR: -mic_native or -mic_offload requires MPSS to be installed." exit 1 fi echo " Detected MPSS version $mpss_version" fi if [ "$openmp" = 'yes' ]; then omp_flag="-openmp -DOPENMP" #if [ "$ifort_version" -lt 11 ] ; then flibs_arch="$flibs_arch -openmp" flibsf_arch="$flibsf_arch -openmp" #fi fi if [ "$sse" = 'yes' ]; then # Preface $coptflags with -ip coptflags="-ip $coptflags" # Within coptflags, use -O3, unless optimisations have been # disabled using -noopt if [ "$optimise" = 'yes' ]; then coptflags=`echo $coptflags | sed -e 's/ -O[012] / -O3 /g'` fi # For both coptflags and foptflags, use the appropriate settings # for the sse flags (compiler version dependent). if [ "$icc_version" -ge 11 ] ; then if [ -n "$SSE_TYPES" ] ; then coptflags="$coptflags -ax$SSE_TYPES" fi else coptflags="$coptflags -axSTPW" fi if [ "$ifort_version" -ge 11 ] ; then if [ -n "$SSE_TYPES" ] ; then foptflags="$foptflags -ax$SSE_TYPES" fi else foptflags="$foptflags -axSTPW" fi flibs_arch="$flibs_arch -lsvml" flibsf_arch="$flibsf_arch -lsvml" fi if [ "$mpi" = 'yes' ]; then if [ "$intelmpi" = 'yes' ]; then ld=' mpiifort ' else ld=' mpif90 ' fi else ld=' ifort ' fi if [ $icc_version -lt 11 ]; then ldflags="$ldflags -lsvml" fi #PMEMD Specifics pmemd_fpp_flags='-DPUBFFT' if [ "$optimise" = 'no' ]; then pmemd_coptflags='-O0' pmemd_foptflags='-O0' else # RCW Removed 10/5/2010 - Causes issues building in parallel since -fast always implies -static. #pmemd_foptflags='-fast' #pmemd_coptflags='-fast' # BPR: Note: -fast implies the use of these flags: # # Intel 11 # -------- # Mac: -ipo -O3 -mdynamic-no-pic -no-prec-div -static -xHost # IA-64 Linux: -ipo -O3 -static # IA-32/Intel-64 Linux: -ipo -O3 -no-prec-div -static -xHost # # Intel 10 # -------- # Mac: -ipo -O3 -mdynamic-no-pic -no-prec-div -static -xP (ifort), # -ipo -O3 -mdynamic-no-pic -no-prec-div (icc) # IA-64 Linux: -ipo -O3 -static # IA-32/Intel-64 Linux: -ipo -O3 -no-prec-div -static -xP if [ "$is_mac" = 'yes' ]; then if [ "$icc_version" -ge 11 ]; then pmemd_coptflags='-ipo -O3 -mdynamic-no-pic -no-prec-div -xHost' else pmemd_coptflags='-ipo -O3 -mdynamic-no-pic -no-prec-div' fi if [ "$ifort_version" -ge 11 ]; then pmemd_foptflags='-ipo -O3 -mdynamic-no-pic -no-prec-div -xHost' else pmemd_foptflags='-ipo -O3 -mdynamic-no-pic -no-prec-div' fi else if [ "$mic" = 'yes' ]; then pmemd_coptflags='-ip -O3 -no-prec-div' pmemd_foptflags='-ip -O3 -no-prec-div' elif [ "$mic_offload" = 'yes' ]; then pmemd_coptflags='-ip -O3 -no-prec-div -xHost' pmemd_foptflags='-ip -O3 -no-prec-div -xHost' else if [ "$icc_version" -ge 11 ]; then pmemd_coptflags='-ipo -O3 -no-prec-div -xHost' else pmemd_coptflags='-ipo -O3 -no-prec-div -axSTPW' fi if [ "$ifort_version" -ge 11 ]; then pmemd_foptflags='-ipo -O3 -no-prec-div -xHost' else pmemd_foptflags='-ipo -O3 -no-prec-div -axSTPW' fi fi fi fi #XEON PHI Specifics if [ "$mic" = 'yes' ]; then pmemd_foptflags="$pmemd_foptflags -mmic" pmemd_coptflags="$pmemd_coptflags -mmic" #Emil library uses cxxflags so we have to override that as well cxxoptflags="$cxxoptflags -mmic" fi if [ "$mic_offload" = 'yes' ]; then pmemd_foptflags="$pmemd_foptflags -DMIC_offload -openmp -opt-streaming-cache-evict=0 -fimf-precision=low -fimf-domain-exclusion=15" pmemd_coptflags="$pmemd_coptflags -DMIC_offload -openmp -opt-streaming-cache-evict=0 -fimf-precision=low -fimf-domain-exclusion=15" #Emil library uses cxxflags so we have to override that as well cxxoptflags="$cxxoptflags -DMIC_offload -opt-streaming-cache-evict=0 -fimf-precision=low -fimf-domain-exclusion=15" fi #CUDA Specifics if [ "$cuda_SPFP" = 'yes' -o "$cuda_SPXP" = 'yes' -o "$cuda_DPFP" = 'yes' ]; then # -ipo (multi-file Interprocedural Optimizations optimizations) causes issues with # CUDA c code linking. Leave at a single-file IPO for the moment MJW pmemd_coptflags=`echo $pmemd_coptflags | sed -e 's/ipo/ip/g'` pmemd_foptflags=`echo $pmemd_foptflags | sed -e 's/ipo/ip/g'` pmemd_cu_includes='-I$(CUDA_HOME)/include -IB40C -IB40C/KernelCommon' pmemd_cu_defines='-DCUDA' pmemd_cu_libs='./cuda/cuda.a -L$(CUDA_HOME)/lib64 -L$(CUDA_HOME)/lib -lcurand -lcufft -lcudart -lstdc++' if [ "$optimise" = 'yes' ]; then nvcc="$nvcc -use_fast_math -O3 " else nvcc="$nvcc -use_fast_math -O0 " fi if [ "$mpi" = 'yes' ]; then mpi_inc=`(mpicc -show 2>&1) | awk 'BEGIN{i=0} {while (i < NF) {if ( substr($i, 1, 2) == "-I" ) {printf("%s ", $i);}; i++;}}'` pmemd_cu_includes="$pmemd_cu_includes $mpi_inc" pmemd_cu_defines="$pmemd_cu_defines -DMPI -DMPICH_IGNORE_CXX_SEEK" pmemd_coptflags="$pmemd_coptflags -DMPICH_IGNORE_CXX_SEEK" fi fi if [ "$cuda_SPFP" = 'yes' ]; then pmemd_cu_defines="$pmemd_cu_defines -Duse_SPFP" fi if [ "$cuda_SPXP" = 'yes' ]; then pmemd_cu_defines="$pmemd_cu_defines -Duse_SPXP" fi if [ "$cuda_DPFP" = 'yes' ]; then pmemd_cu_defines="$pmemd_cu_defines -Duse_DPFP" fi ;; #################### Portland group ####### pgi) if [ "$mpi" = 'yes' ]; then ld=' mpif90 ' else ld=' pgf90 ' fi if [ "$intelmpi" = 'yes' ]; then echo "Intel MPI requires the intel compilers." exit 1 fi flibs_arch="-pgf90libs" flibsf_arch= cc=pgcc mtkpp='' # PGI won't compile MTK++; see bug 219. cflags= cplusplus=pgCC cxxflags= fc_cxx_link_flag="-pgcpplibs" fc=pgf90 fflags= freeformat_flag='-Mfree' staticflag='-Bstatic' # If -noopt has been requested, force lack of optimisation; # otherwise, use the default levels. Since cflags, cxxflags # and fflags are used everywhere, and *optflags and # *nooptflags are not (some parts of Amber and AmberTools use # neither *optflags nor *nooptflags), we'll put -O0 in cflags # and so forth instead. if [ $optimise = 'no' ]; then cflags="$cflags -O0" cnooptflags="" coptflags="" cxxflags="$cxxflags -O0" cxxnooptflags="" cxxoptflags="" fflags="$fflags -O0" fnooptflags="" foptflags="" else cnooptflags= coptflags="-O2" cxxnooptflags= cxxoptflags="-O2" fnooptflags="-O1" foptflags="-fast -O3" fi echo "" echo "Obtaining the PGI suite version:" echo " $cc -V" pgi_version=`$cc -V 2>&1 | grep '^pgcc ' | cut -d' ' -f2` echo "The version is $pgi_version" pgi_majorversion=`echo $pgi_version | cut -d'.' -f1` pgi_minorversion=`echo $pgi_version | cut -d'.' -f2` pgi_minorversion=`echo $pgi_minorversion | cut -d'-' -f1` pgi_dashversion=`echo $pgi_version | cut -d'-' -f2` #RISM and PBSA FFT solver require ISO_C_BINDING support if [ "$rism" != 'no' -o -n "$pbsaflag" ]; then if [ "$pgi_majorversion" -le 8 ] ; then echo "ERROR: RISM and PBSA FFT solver require version 9.0-4 or higher of the PGI compiler." echo " Please re-run configure with the '-nofftw3' flag to use this compiler:" echo " `mod_command_args '-rism' '-nofftw3'`" exit 1 elif [ "$pgi_majorversion" -ge 9 -a "$pgi_minorversion" \ -eq 0 -a "$pgi_dashversion" -le 3 ] ; then echo "ERROR: RISM and PBSA FFT solver require version 9.0-4 or higher of the PGI compiler." echo " Please re-run configure with the '-nofftw3' flag to use this compiler:" echo " `mod_command_args '-rism' '-nofftw3'`" exit 1 fi fi # Debugging options if [ "$debug" = 'yes' ]; then cflags="$cflags -g" cxxflags="$cxxflags -g" fflags="$fflags -g" fi if [ "$openmp" = 'yes' ]; then echo "Warning: OpenMP is not yet well tested for pgi." omp_flag="-mp -DOPENMP" flibs_arch="$flibs_arch -mp" fi if [ "$sse" = 'yes' ]; then foptflags="$foptflags -fastsse" fi if [ "$cuda_SPFP" = "yes" -o "$cuda_SPXP" = "yes" -o "$cuda_DPFP" = "yes" ]; then echo "ERROR: cuda is not available for pgi." echo " Please re-run configure without CUDA flags to use this compiler:" echo " `mod_command_args '-cuda -cuda_SPXP -cuda_DPFP' ''`" exit 1 fi #PMEMD Specifics pmemd_fpp_flags='-DPUBFFT' if [ "$crayxt5" = 'yes' ]; then pmemd_foptflags='-O4 -fastsse -Munroll -Mnoframe -Mscalarsse -Mvect=sse -Mcache_align' else pmemd_foptflags=$foptflags fi pmemd_coptflags=$coptflags ;; #################### cray ####### cray) if [ "$crayxt5" = 'yes' ]; then echo "Error: '-crayxt5' flag not compatible with 'cray' compiler target." exit 1 fi ld='ftn' flibs_arch="" flibsf_arch= cc=cc cflags= ambercflags="" cplusplus=CC cxxflags= ambercxxflags="" fc=ftn fflags="" staticflag='-static' if [ "$openmp" = 'yes' ]; then # DRR - Currently MKL is statically linked by default, which appears # only to work for intel compilers. if [ "$mkl" = 'yes' ] ; then echo "ERROR: Currently MKL + OpenMP only supported for intel compilers." echo " Please unset MKL_HOME." exit 1 fi omp_flag="-DOPENMP" #flibs_arch="$flibs_arch -fopenmp" #flibsf_arch="$flibsf_arch -fopenmp cray_omp_flag="" else # OMP is enabled by default. Disable. cray_omp_flag="-h noomp" fi # If -noopt has been requested, force lack of optimisation; # otherwise, use the default levels. Since cflags, cxxflags # and fflags are used everywhere, and *optflags and # *nooptflags are not (some parts of Amber and AmberTools use # neither *optflags nor *nooptflags), we'll put -O0 in cflags # and so forth instead. # NOTE: In order for GNU-like defines to work (e.g. # -D_FILE_OFFSET_BITS etc.) cray compilers need '-h gnu'. # Also, the fortran compile requires '-emf' to force # the build of module files with all-lowecase names. if [ "$optimise" = 'no' ]; then cflags="$cflags -O0 $cray_omp_flag -h gnu" cnooptflags="" coptflags="" cxxflags="$cxxflags -O0 $cray_omp_flag -h gnu" cxxnooptflags="" cxxoptflags="" fflags="$fflags -O0 $cray_omp_flag -emf" fnooptflags="" foptflags="" else # cray compilers have equivalent of -O3 on by default cflags="$cflags $cray_omp_flag -h gnu" cnooptflags="" coptflags="" cxxflags="$cxxflags $cray_omp_flag -h gnu" cxxnooptflags="" cxxoptflags="" fflags="$fflags $cray_omp_flag -emf" fnooptflags="" foptflags="" fi # Debugging options if [ "$debug" = 'yes' ]; then cflags="$cflags -g" cxxflags="$cxxflags -g" fflags="$fflags -g" fi echo "" echo "Obtaining the cray suite version:" echo " $cc -V" cray_version=`$cc -V 2>&1 | grep ' Version ' | cut -d' ' -f5` echo "The version is $cray_version" cray_majorversion=`echo $cray_version | cut -d'.' -f1` cray_minorversion=`echo $cray_version | cut -d'.' -f2` # Set alignment of fortran compiler fcreal8="-s real64" # For now, fftw3 is not compiled and pbsa fft solver and rism are disabled if [ "$rism" != 'no' -o -n "$pbsaflag" ]; then echo "ERROR: RISM and PBSA FFT solver currently not built with cray compilers." echo " Please re-run configure with the '-nofftw3' flag to use this compiler:" echo " `mod_command_args '-rism' '-nofftw3'`" exit 1 fi if [ "$cygwin" = 'yes' ]; then echo "ERROR: cygwin not supported with cray compilers." exit 1 fi freeformat_flag="-f free" #PMEMD Specifics # PMEMD right now with cray requires external FFTW3 library cat > conftest.f90 < /dev/null status=$? if [ $status -gt 0 ]; then echo "Error: FFTW3 library not found." echo " Ensure FFTW3 library can be found by your compiler." echo " On cray systems this can usually be done with 'module load fftw'" exit 1 fi echo "OK" /bin/rm -f conftest.f90 conftest$objsuffix conftest$suffix #pmemd_fpp_flags='-DPUBFFT' pmemd_fpp_flags='-DFFTW_FFT' pmemd_foptflags="$foptflags $cray_omp_flag -emf" pmemd_coptflags="$coptflags $cray_omp_flag -h gnu" #CUDA Specifics if [ "$cuda_SPFP" = 'yes' -o "$cuda_SPXP" = 'yes' -o "$cuda_DPFP" = 'yes' ]; then pmemd_cu_includes='-I$(CUDA_HOME)/include -IB40C -IB40C/KernelCommon' pmemd_cu_defines='-DCUDA' pmemd_cu_libs='./cuda/cuda.a -L$(CUDA_HOME)/lib64 -L$(CUDA_HOME)/lib -lcurand -lcufft -lcudart -lstdc++' if [ "$optimise" = 'no' ]; then nvcc="$nvcc -use_fast_math -O0 " else nvcc="$nvcc -use_fast_math -O3 " fi if [ "$mpi" = 'yes' ]; then mpi_inc=`(mpicc -show 2>&1) | awk 'BEGIN{i=0} {while (i < NF) {if ( substr($i, 1, 2) == "-I" ) {printf("%s ", $i);}; i++;}}'` pmemd_cu_includes="$pmemd_cu_includes $mpi_inc" pmemd_cu_defines="$pmemd_cu_defines -DMPI -DMPICH_IGNORE_CXX_SEEK" pmemd_coptflags="$coptflags -DMPICH_IGNORE_CXX_SEEK" fi if [ "$intelmpi" = 'yes' ]; then echo "Intel MPI requires the intel compilers." exit 1 fi fi if [ "$cuda_SPFP" = 'yes' ]; then pmemd_cu_defines="$pmemd_cu_defines -Duse_SPFP" fi if [ "$cuda_SPXP" = 'yes' ]; then pmemd_cu_defines="$pmemd_cu_defines -Duse_SPXP" fi if [ "$cuda_DPFP" = 'yes' ]; then pmemd_cu_defines="$pmemd_cu_defines -Duse_DPFP" fi ;; #################### open64 #### open64x) if [ "$openmp" = 'yes' ]; then echo "ERROR: '-openmp' is not compatible with this compiler" echo " Please re-run configure without the '-openmp' flag to use this compiler:" echo " `mod_command_args '-openmp' ''`" exit 1 elif [ "$cygwin" = 'yes' ]; then echo "ERROR: '-cygwin' is not compatible with this compiler" echo " Please re-run configure without the '-cygwin' flag to use this compiler:" echo " `mod_command_args '-cygwin' ''`" exit 1 elif [ "$rism" != 'no' ]; then echo "ERROR: RISM is not compatible with this compiler" echo " Please re-run configure with the '-norism' flag to use this compiler:" echo " `mod_command_args '-rism' '-norism'`" exit 1 else echo "open64 setting is experimental." fi if [ "$cuda_SPFP" = 'yes' -o "$cuda_SPXP" = 'yes' -o "$cuda_DPFP" = 'yes' ]; then echo "ERROR: CUDA is not compatible with this compiler" echo " Please re-run configure without CUDA flags to use this compiler:" echo " `mod_command_args '-cuda -cuda_SPXP -cuda_DPFP' ''`" exit 1 fi if [ "$mpi" = 'yes' ]; then ld=' mpif90 ' else ld=' openf90 ' fi if [ "$intelmpi" = 'yes' ]; then echo "Intel MPI requires the intel compilers." exit 1 fi flibs_arch='-lfortran -lmv -lm -lacml_mv -lffio -lopen64rt' flibsf_arch= cc=opencc cflags= cplusplus=openCC cxxflags= fc=openf90 fflags='-fno-second-underscore -intrinsic=rand' # src/nmr_aux/fantasian/fantasian.f uses rand() intrinsic despite # the intention of using amrand. So add -intrinsic=rand for open64. staticflag='-static' # If -noopt has been requested, force lack of optimisation; # otherwise, use the default levels. Since cflags, cxxflags # and fflags are used everywhere, and *optflags and # *nooptflags are not (some parts of Amber and AmberTools use # neither *optflags nor *nooptflags), we'll put -O0 in cflags # and so forth instead. if [ "$optimise" = 'no' ]; then cflags="$cflags -O0" cnooptflags="" coptflags="" cxxflags="$cxxflags -O0" cxxnooptflags="" cxxoptflags="" fflags="$fflags -O0" fnooptflags="" foptflags="" else cnooptflags= coptflags="-O3 -ffast-math" cxxnooptflags= cxxoptflags="-O3 -ffast-math" fnooptflags="-O0" foptflags="-O3 -ffast-math" fi # Debugging options if [ "$debug" = 'yes' ]; then cflags="$cflags -g" cxxflags="$cxxflags -g" fflags="$fflags -g" fi # Only use -mtune=native if gcc suite >= 4.2 if [ $sse = 'yes' -a "$optimise" = "yes" ]; then if [ $x86_64 = 'yes' ]; then #-mfpmath=sse is default for x86_64, no need to specific it coptflags="$coptflags -mtune=auto" foptflags="$foptflags -mtune=auto" else # i386 needs to be told to use sse prior to using -mfpmath=sse coptflags="$coptflags -msse" foptflags="$foptflags -msse" fi fi freeformat_flag=-freeform #PMEMD Specifics pmemd_fpp_flags='-DPUBFFT' pmemd_foptflags="$fflags $foptflags" pmemd_coptflags="$cflags $coptflags" ;; #################### unknown choice ####### *) echo "Error: Architecture/compiler '$compiler' is not supported!" echo " Type './configure -help' for options." exit 1 ;; esac # If -crayxt5 was specified, switch to cc, CC, and ftn compiler wrappers if [ "$crayxt5" = 'yes' ]; then cc="cc" cplusplus="CC" fc="ftn" ld="ftn" fi # If -intelmpi is specified, make sure mpiicpc, mpiicc, and mpiifort exist if [ "$intelmpi" = 'yes' ]; then mpiifort=`which mpiifort 2>/dev/null` mpiicc=`which mpiicc 2>/dev/null` mpiicpc=`which mpiicpc 2>/dev/null` if [ -z "$mpiifort" -o -z "$mpiicc" -o -z "$mpiicpc" ]; then inerr='yes' echo "Cannot find Intel MPI compiler wrappers; Intel MPI must not be" echo "installed or correctly configured" exit 1 fi fi # Link the $AMBERHOME/lib and $AMBERHOME/lib64 directories together if they're # not already created. Some OSes (like SuSE) will build NetCDF to lib64. This # will make sure they're all found by the linker cd ../../ if [ ! -d lib ]; then mkdir lib fi if [ ! -x lib64 ]; then ln -s lib lib64 fi cd AmberTools/src #-------------------------------------------------------------------------- # Configure the MKL and GOTO libraries: #-------------------------------------------------------------------------- if [ "$mkl" = 'yes' ]; then lapack=skip blas=skip flibs="-larpack " flibsf="-larpack " mkll="$MKL_HOME/lib/32" mkl_processor="32" mkl_procstring="ia32" mklinterfacelayer='libmkl_intel.a' if [ "$x86_64" = 'yes' ]; then if [ -d "$MKL_HOME/lib/em64t" ]; then mkll="$MKL_HOME/lib/em64t" mkl_processor="em64t" mkl_procstring="em64t" else mkll="$MKL_HOME/lib/intel64" mkl_processor="intel64" mkl_procstring="intel64" fi # lp64 is 32 bit integers on 64 bit platforms mklinterfacelayer='libmkl_intel_lp64.a' fi echo "Using Intel MKL libraries in $mkll" if [ "$gnuld" = 'yes' ]; then echo "MKL Version 10 or greater assumed." # We always link to the sequential version of MKL since typically # one runs an MPI thread for each core. However, if openmp is # specified, for example to turn on SMP diagonalizers for QMMM # then we link to the threaded version of MKL and inside the code # the number of threads for vector functions etc will be set to # 1. Always link static version of MKL - just easier from an end # user perspective. # changed by MBJ if [ "$openmp" = 'yes' ]; then flibs_mkl="-Wl,--start-group $mkll/$mklinterfacelayer $mkll/libmkl_intel_thread.a $mkll/libmkl_core.a -Wl,--end-group -lpthread" else flibs_mkl="-Wl,--start-group $mkll/$mklinterfacelayer $mkll/libmkl_sequential.a $mkll/libmkl_core.a -Wl,--end-group -lpthread" fi else echo "Non-GNU linker assumed." if [ "$openmp" = 'yes' ]; then flibs_mkl="-L$mkll $mkll/$mklinterfacelayer $mkll/libmkl_intel_thread.a $mkll/libmkl_core.a -lpthread" else flibs_mkl="-L$mkll $mkll/$mklinterfacelayer $mkll/libmkl_sequential.a $mkll/libmkl_core.a -lpthread" fi fi # GNU compilers with MKL requires -ldl if [ "$compiler" = 'gnu' ]; then flibs_mkl="$flibs_mkl -ldl" fi fi if [ "$gotolib" = 'yes' ]; then lapack=skip blas=skip flibs="-larpack $GOTO -lpthread" flibsf="-larpack $GOTO -lpthread" elif [ "$macAccelerate" = 'yes' ] ; then lapack=skip blas=skip flibs="-larpack " flibsf="-larpack " flibs_arch="$flibs_arch -framework Accelerate" flibsf_arch="$flibsf_arch -framework Accelerate" fi #-------------------------------------------------------------------------- # Support platforms without a C by building c9x-complex. #-------------------------------------------------------------------------- if [ -r /usr/include/complex.h ]; then c9xcomplex='skip' elif [ "$cygwin" = 'yes' ]; then c9xcomplex='skip' else c9xcomplex='libmc.a' cflags="$cflags -DUSE_AMBER_C9XCOMPLEX" pmemd_coptflags="$pmemd_coptflags -DUSE_AMBER_C9XCOMPLEX" flibs_arch="$flibs_arch -lmc" fi #-------------------------------------------------------------------------- # Support platforms without but with # usually a non-Linux Unix with a non-native compiler. #-------------------------------------------------------------------------- if [ ! -r /usr/include/sys/dir.h -a -r /usr/include/dirent.h ]; then if [ "$cygwin" != 'yes' ]; then cflags="$cflags -DSYSV" pmemd_coptflags="$pmemd_coptflags -DSYSV" fi fi #-------------------------------------------------------------------------- # Check for large file support: #-------------------------------------------------------------------------- if [ "$lfs" = 'yes' ]; then cflags="$cflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE" pmemd_coptflags="$pmemd_coptflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE" fi #-------------------------------------------------------------------------- # Test various compilers, linking, MPI etc. #-------------------------------------------------------------------------- #-------------------------------------------------------------------------- # Test if the C compiler works: #-------------------------------------------------------------------------- cat <testp.c #include int main() { printf( "testing a C program\n" ); } EOF echo "" echo "Testing the $cc compiler:" echo " $cc $cflags $cnooptflags -o testp$suffix testp.c" $cc $cflags $cnooptflags -o testp$suffix testp.c ./testp | grep "testing a C program" > /dev/null status=$? if [ $status -gt 0 ]; then echo "Error: Unable to compile a C program using $cc $cflags $cnooptflags" echo " Please check your compiler settings or configure flags." exit 1 fi echo "OK" /bin/rm -f testp.c testp$objsuffix testp$suffix #-------------------------------------------------------------------------- # Test if the C++ compiler works: #-------------------------------------------------------------------------- echo "" echo "Testing the $cplusplus compiler:" echo " $cplusplus $cxxflags -o testp$suffix testp.cpp" cat > testp.cpp < int main() { printf("Testing\n"); return 0; } EOF $cplusplus $cxxflags -o testp$suffix testp.cpp ./testp | grep "Testing" > /dev/null status=$? if [ $status -gt 0 ] ; then echo "Error: Unable to compile a C program using $cplusplus $cxxflags" echo " Please check your compiler settings or configure flags." exit 1 fi echo "OK" /bin/rm -f testp.cpp testp$objsuffix testp$suffix #-------------------------------------------------------------------------- # Test if the Fortran compiler works: #-------------------------------------------------------------------------- cat <testp.f program testf write(6,*) 'testing a Fortran program' end program testf EOF echo "" echo "Testing the $fc compiler:" echo " $fc $fflags $fnooptflags -o testp$suffix testp.f" $fc $fflags $fnooptflags -o testp testp.f ./testp | grep "testing a Fortran program" > /dev/null status=$? if [ $status -gt 0 ]; then echo "Error: Unable to compile a Fortran program using $fc $fflags $fnooptflags" echo " Please check your compiler settings and configure flags." exit 1 else hasfc='yes' echo "OK" fi /bin/rm -f testp.f testp$objsuffix testp$suffix #-------------------------------------------------------------------------- # Test mixed C/Fortran compilation. #-------------------------------------------------------------------------- cat > testp.c < extern void hello_(); int main(int argc, char **argv) { printf("Hello from c.\n"); hello_(); return 0; } EOF cat > testp.f < /dev/null status=$? if [ $status -gt 0 ]; then echo "Error: Unable to compile mixed C/Fortran code." echo " Please check your compiler settings and configure flags." exit 1 else echo "OK" fi /bin/rm -f testp.c testp.f testp.c$objsuffix testp.f$objsuffix testp$suffix #-------------------------------------------------------------------------- # Determine if machine is 32 bit or 64 bit # # We have the x86_64 flag which tries to detect this based on uname but # this will not catch everything. Especially if someone is using a 32 bit # compatibility compiler on a x86_64 machine. #-------------------------------------------------------------------------- cat > test_pointer_size.c < int main() { printf ("%d\n", (int )sizeof(void*)); return 0; } EOF echo "" echo "Testing pointer size:" echo " $cc $cflags $cnooptflags -o test_pointer_size$suffix test_pointer_size.c" $cc $cflags $cnooptflags -o test_pointer_size$suffix test_pointer_size.c ./test_pointer_size$suffix | grep "4" > /dev/null status=$? if [ $status -eq 0 ]; then #Align doubles on 32 bit machines. Needed for cuda to work on 32 bit machine. echo "Detected 32 bit operating system." pmemd_coptflags="$pmemd_coptflags -malign-double" else echo "Detected 64 bit operating system." fi /bin/rm -f test_pointer_size.c test_pointer_size$suffix #-------------------------------------------------------------------------- # Test if lex/flex is available and works #-------------------------------------------------------------------------- echo "" printf "Testing $lex:" cat <testp.l %{ %} %% ddm[=\ ][^\ \n\t,]+ { ECHO; ddm = 1;} %% EOF $lex -t testp.l | grep ddm > /dev/null status=$? if [ $status -gt 0 ]; then echo "" echo "Error: Unable to run $lex; this is required for NAB and antechamber" echo "Please check your PATH, or install the program" echo "" exit 1 else echo " OK" fi /bin/rm -f testp.l #-------------------------------------------------------------------------- # Configure NetCDF #-------------------------------------------------------------------------- if [ "$bintraj" = 'yes' ]; then printf "\nChecking NetCDF...\n" netcdf_flag="-lnetcdf" # Right now, just used for FLIBS, i.e. for NAB cflags="$cflags -DBINTRAJ" pmemd_coptflags="$pmemd_coptflags -DBINTRAJ" fppflags="$fppflags -DBINTRAJ" if [ "$netcdf_dir" = '' ]; then # Use bundled NetCDF library. # Intially set full paths for use with test_netcdf_compile. printf "\tUsing bundled NetCDF library.\n" netcdfflagc="$AMBERHOME/lib/libnetcdf.a" # For C netcdfflagf="$AMBERHOME/lib/libnetcdff.a $netcdfflagc" # For Fortran netcdfinc="-I$AMBERHOME/include" netcdf="$AMBERHOME/include/netcdf.mod" build_netcdf='' # If any file not yet present, trigger the build. if [ ! -e "$netcdf" -o ! -e "$netcdfflagc" -o ! -e "$AMBERHOME/lib/libnetcdff.a" ] ; then build_netcdf="build_netcdf" printf "\tStarting NetCDF build.\n" else # Test compilation. If it fails, assume NetCDF needs to be rebuilt test_netcdf_compile if [ $? -gt 0 ] ; then build_netcdf="build_netcdf" printf "\tNetCDF must be rebuilt.\n" /bin/rm $AMBERHOME/lib/libnetcdf* $AMBERHOME/include/netcdf.* fi fi if [ ! -z "$build_netcdf" ] ; then # === DEVELOPMENT ONLY ================================================= # Check the timestamps of some automake-related files since switching # branches can make it seem that they have been modified, which # triggers unnecessary rebuilds. # if [ "$is_mac" = 'yes' ]; then # # Semantics of stat are different on Mac # timestamp1=`stat -f %a netcdf-4.3.0/aclocal.m4` # timestamp2=`stat -f %a netcdf-4.3.0/configure` # else # timestamp1=`stat -c %Y netcdf-4.3.0/aclocal.m4` # timestamp2=`stat -c %Y netcdf-4.3.0/configure` # fi # if [ $timestamp2 -le $timestamp1 ] ; then # # ./netcdf-fix-timestamp.sh # echo "Skipping touches..." # fi # ====================================================================== # NetCDF C configure/build cd netcdf-4.3.0 printf "\tConfiguring NetCDF C interface (may be time-consuming)...\n" make clean > /dev/null 2>&1 if [ "$mic" = 'yes' ]; then ./configure --host=x86_64-k1om-linux --build=x86_64-unknown-linux \ CC="$cc -mmic" CFLAGS="$cflags $cnooptflags" LDFLAGS="$ldflags -mmic" \ --prefix=$AMBERHOME --disable-netcdf-4 --disable-dap \ > ../netcdf_config.log 2>&1 else ./configure CC="$cc" CFLAGS="$cflags $cnooptflags" LDFLAGS="$ldflags" \ --prefix=$AMBERHOME --disable-netcdf-4 --disable-dap \ > ../netcdf_config.log 2>&1 fi ncerror=$? if [ $ncerror -gt 0 ]; then printf "Error: NetCDF C configure returned $ncerror\n" printf "\tNetCDF configure failed! Check the netcdf_config.log file\n" printf "\tin the $AMBERHOME/AmberTools/src directory.\n" exit 1 fi # The NetCDF C interface MUST be present prior to configuring the # Fortran interface, so build it now. printf "\tCompiling the NetCDF C interface (may be time-consuming)...\n" make install > netcdf.c.compile.log 2>&1 if [ $? -ne 0 ]; then printf "Error: NetCDF C compile failed.\n" printf "\tCheck $AMBERHOME/AmberTools/src/netcdf-4.3.0/netcdf.c.compile.log\n" printf "\tfor errors.\n" exit 1 fi # NetCDF Fortran configure/build cd ../netcdf-fortran-4.2 # The NetCDF Fortran config script will need access to the C library. export LD_LIBRARY_PATH="$AMBERHOME/lib:$LD_LIBRARY_PATH" printf "\tConfiguring NetCDF Fortran interface (may be time-consuming)...\n" make clean > /dev/null 2>&1 if [ "$mic" = 'yes' ]; then ./configure --host=x86_64-k1om-linux --build=x86_64-unknown-linux \ CC="$cc" CFLAGS="$cflags $cnooptflags -mmic" \ LDFLAGS="-L$AMBERHOME/lib $ldflags -mmic" \ CPPFLAGS="-I$AMBERHOME/include" \ FC="$fc" FCFLAGS="$fflags $foptflags -mmic" \ F77="$fc" FFLAGS="$fflags $foptflags -mmic" \ --prefix=$AMBERHOME >> ../netcdf_config.log 2>&1 cd fortran cp nfconfig.in nfconfig.inc-orig sed s/"#undef NF_INT1_IS_C_SIGNED_CHAR"/"#define NF_INT1_IS_C_SIGNED_CHAR 1"/ nfconfig.inc-orig >nfconfig.tmp1 sed s/"#undef NF_INT2_IS_C_SHORT"/"#define NF_INT2_IS_C_SHORT 1"/ nfconfig.tmp1 >nfconfig.tmp2 sed s/"#undef NF_INT_IS_C_INT"/"#define NF_INT_IS_C_INT 1"/ nfconfig.tmp2 >nfconfig.tmp3 sed s/"#undef NF_REAL_IS_C_FLOAT"/"#define NF_REAL_IS_C_FLOAT 1"/ nfconfig.tmp3 >nfconfig.tmp4 sed s/"#undef NF_DOUBLEPRECISION_IS_C_DOUBLE"/"#define NF_DOUBLEPRECISION_IS_C_DOUBLE 1"/ nfconfig.tmp4 >nfconfig.in cp nfconfig.in nfconfig.inc cd .. else ./configure CC="$cc" CFLAGS="$cflags $cnooptflags" \ LDFLAGS="-L$AMBERHOME/lib $ldflags" \ CPPFLAGS="-I$AMBERHOME/include" \ FC="$fc" FCFLAGS="$fflags $foptflags" \ F77="$fc" FFLAGS="$fflags $foptflags" \ --prefix=$AMBERHOME >> ../netcdf_config.log 2>&1 fi ncerror=$? if [ $ncerror -gt 0 ]; then printf "Error: NetCDF Fortran configure returned $ncerror\n" printf "\tNetCDF configure failed! Check the netcdf_config.log file\n" printf "\tin the $AMBERHOME/AmberTools/src directory.\n" exit 1 fi # Build the fortran interface printf "\tCompiling the NetCDF Fortran interface (may be time-consuming)...\n" make install > netcdf.fortran.compile.log 2>&1 if [ $? -ne 0 ]; then printf "Error: NetCDF Fortran compile failed.\n" printf "\tCheck $AMBERHOME/AmberTools/src/netcdf-fortran-4.2/netcdf.fortran.compile.log\n" printf "\tfor errors.\n" exit 1 fi cd ../ if [ "$mic" = 'no' ]; then # Test compilation. test_netcdf_compile verbose if [ $? -gt 0 ] ; then echo "Error: NetCDF build failed." exit 1 fi fi echo "NetCDF build succeeded." else printf "\tUsing existing NetCDF in '$AMBERHOME'\n" fi # Restore relative paths for config.h netcdfflagc="\$(LIBDIR)/libnetcdf.a" # for C netcdfflagf="\$(LIBDIR)/libnetcdff.a $netcdfflagc" # for Fortran netcdfinc="-I\$(INCDIR)" netcdf="\$(INCDIR)/netcdf.mod" else # A NetCDF directory was specified. Check that library exists and compiles printf "\tUsing NetCDF in '$netcdf_dir'\n" netcdf=$netcdf_dir"/include/netcdf.mod" if [ ! -e "$netcdf" ]; then echo "Error: '$netcdf' not found." exit 1 fi netcdfinc="-I"$netcdf_dir"/include" if [ "$netcdfstatic" = 'no' ] ; then netcdfflagc="-L${netcdf_dir}/lib -lnetcdf" # Newer versions of NetCDF have a separate fortran library. # If not found default to libnetcdf.a netcdfflagf=$netcdf_dir"/lib/libnetcdff" if [ ! -e "${netcdfflagf}.a" -a ! -e "${netcdfflagf}.so" ]; then echo "Does not exist!" netcdfflagf=$netcdfflagc else netcdfflagf="$netcdfflagc -lnetcdff" fi else # Force netcdf to link statically printf "\tForcing static link of external NetCDF\n" netcdfflagc=$netcdf_dir"/lib/libnetcdf.a" if [ ! -e "$netcdfflagc" ]; then echo "Error: '$netcdfflagc' not found." exit 1 fi netcdfflagf=$netcdf_dir"/lib/libnetcdff.a" if [ ! -e "$netcdfflagf" ]; then netcdfflagf=$netcdfflagc fi fi # Test netcdf compilation test_netcdf_compile verbose if [ $? -gt 0 ]; then echo "Error: Could not compile using NetCDF in '$netcdf_dir'" exit 1 fi fi else netcdf_flag='' netcdf='' netcdfflagf='' netcdfflagc='' netcdfinc='' fi #------------------------------------------------------------------------------ # Set up the static flags: #------------------------------------------------------------------------------ if [ "$static" = 'yes' ]; then flibs="$flibs $staticflag" ldflags="$staticflag" fi #-------------------------------------------------------------------------- # Check for Zlib and Bzlib (currently only cpptraj) #-------------------------------------------------------------------------- # Zlib cat >testp.c < #include "zlib.h" int main() { gzFile fp; printf( "testing a C program\n" ); } EOF echo "" printf "Checking for zlib: " $cc $cflags -o testp$suffix testp.c ./testp | grep "testing a C program" > /dev/null status=$? if [ $status -gt 0 ]; then echo "Not found." zlib='' else echo "OK" zlib='-lz' cflags="$cflags -DHASGZ" fi /bin/rm -f testp.c testp$objsuffix testp$suffix # Bzlib cat >testp.c < #include "bzlib.h" int main() { BZFILE *infile; printf( "testing a C program\n" ); } EOF printf "\nChecking for libbz2: " $cc $cflags -o testp$suffix testp.c ./testp | grep "testing a C program" > /dev/null status=$? if [ $status -gt 0 ]; then echo "Not found." bzlib='' else echo "OK" bzlib='-lbz2' cflags="$cflags -DHASBZ2" fi /bin/rm -f testp.c testp$objsuffix testp$suffix #------------------------------------------------------------------------------- # Set RISM & NAB flags that depend on MPI/serial build #------------------------------------------------------------------------------- if [ "$cygwin" = 'yes' ]; then rism='no' fi if [ "$mpi" = "yes" ]; then #NAB nablibsff="-lsff_mpi" #RISM #preprocessor flag for RISM in NAB rismsff="" #RISM library for NAB to link to nablibrism="" #name and path of the amber_rism_interface object to link to sff_rism_interface="" #run the NAB-RISM and 1D-RISM tests testrismsff="" #preprocessor flag for RISM in SANDER rismsander="" #RISM library for SANDER to link to flibs_rismsander="" #name and path of the amber_rism_interface object to link to sander_rism_interface="" #run the SANDER-RISM tests testrismsander="" if [ "$rism" = "default" ];then rism='no' elif [ "$rism" = "yes" ]; then #turn on sander/RISM w/ FFTW if [ -z "$XTRA_FLIBS" ]; then # try to determine the MPI vendor to automatically set # XTRA_FLIBS. We currently know what to do with OpenMPI and # MPICH. Others may be added later printf "\nDetermining MPI vendor... " mpi_vendor=`mpiexec -version 2>&1 | head -1 | cut -d' ' -f1,2` #echo "|||$mpi_vendor|||" if [ "$mpi_vendor" = "mpiexec (OpenRTE)" ]; then export XTRA_FLIBS=-lmpi_f77 echo "Found OpenMPI. Setting XTRA_FLIBS=$XTRA_FLIBS" elif [ "$mpi_vendor" = "HYDRA build" ]; then export XTRA_FLIBS=-lfmpich echo "Found MPICH. Setting XTRA_FLIBS=$XTRA_FLIBS" else echo echo "ERROR: MPI vendor auto detect failed. Could not set XTRA_FLIBS." echo " To compile 3D-RISM support in MPI NAB you must set" echo " XTRA_FLIBS to the name of the Fortran MPI libraries for" echo " your MPI distribution. For example:" echo " OpenMPI:" echo " export XTRA_FLIBS=-lmpi_f77" echo " MPICH:" echo " export XTRA_FLIBS=-lfmpich" echo echo " To omit 3D-RISM support, re-configure with the -norism flag:" echo " `mod_command_args '-rism' '-norism'`" exit 1 fi else echo echo "XTRA_FLIBS set: $XTRA_FLIBS" fi rismsff="-DRISMSFF" nablibrism="-lrism_mpi" sff_rism_interface="../rism/amber_rism_interface.NAB.o" testrismsff="testrism" rismsander="-DRISMSANDER" flibs_rismsander="-lrism_mpi" sander_rism_interface="../rism/amber_rism_interface.SANDER.o" testrismsander="testrism" fi else #NAB nablibsff="-lsff" #RISM rismsff="-DRISMSFF" nablibrism="-lrism" sff_rism_interface="../rism/amber_rism_interface.NAB.o" testrismsff="testrism" flibs_rismsander="-lrism" rismsander="-DRISMSANDER" sander_rism_interface="../rism/amber_rism_interface.SANDER.o" testrismsander="testrism" if [ "$rism" = "default" ]; then rism='yes' elif [ "$rism" = 'no' ]; then rismsff="" nablibrism="" sff_rism_interface="" testrismsff="" rismsander="" flibs_rismsander="" sander_rism_interface="" testrismsander="" fi if [ -n "$XTRA_FLIBS" ]; then echo echo "Error: please unset XTRA_FLIBS for serial compilation." echo "For example:" echo " export -n XTRA_FLIBS=" exit 1 fi fi #-------------------------------------------------------------------------- # Configure fftw-3.3: #-------------------------------------------------------------------------- if [ "$compiler" = "intel" ]; then if [ -n "$MKL_HOME" ]; then echo echo "Configuring MKL FFTW for PMEMD..." echo echo " MKL_HOME set to" "$MKL_HOME" pmemd_fpp_flags="$pmemd_fppflags -DFFTW_FFT -DMKL_FFTW_FFT " pmemd_coptflags="$pmemd_coptflags -DFFTW_FFT " # it would be best if we had a cflags var fi #GNU compilers currently not working for MKL # elif [ "$compiler" = "gnu" ]; then # if [ -n "$MKLROOT" ]; then # echo # echo "Configuring MKL FFTW..." # echo # echo " MKLROOT set to" "$MKLROOT" # pmemd_foptflags="$pmemd_foptflags -fopenmp -m64 -I$MKLROOT/include" # pmemd_coptflags="$pmemd_coptflags -fopenmp -m64 -I$MKLROOT/include" # pmemd_flibs_mkl="-L$MKLROOT/lib/intel64 -lmkl_gf_lp64 -lmkl_core -lmkl_gnu_thread -ldl -lpthread -lm" # fi fi if [ "$rism" = 'yes' -o "$pbsaflag" = '-DFFTW' ]; then echo echo "Configuring fftw-3.3 (may be time-consuming)..." echo enable_mpi="" enable_debug="" enable_sse="--enable-sse=no --enable-sse2=no --enable-avx=no" if [ "$mpi" = "yes" ]; then enable_mpi="--enable-mpi=yes" fi if [ "$debug" = "yes" ]; then enable_debug="--enable-debug=yes --enable-debug-malloc=yes --enable-debug-alignment=yes" fi if [ "$sse" = "yes" ]; then enable_sse="--enable-sse2=yes" # --enable-avx=yes" fi if [ "$mic" = 'yes' ]; then echo " --configuring for mic (native mode)..." echo cd fftw-3.3 && \ ./configure --prefix=$AMBERHOME --libdir=$AMBERHOME/lib \ --enable-static --enable-shared --host=x86_64-k1om-linux \ --build=x86_64-unknown-linux \ $enable_mpi $enable_debug \ CC="$cc -mmic" CFLAGS="$cflags $coptflags " \ F77="$fc -mmic" FFLAGS="$fflags $foptflags " \ FLIBS="$flibs_arch" \ > ../fftw3_config.log 2>&1 ncerror=$? else cd fftw-3.3 && \ ./configure --prefix=$AMBERHOME --libdir=$AMBERHOME/lib \ --enable-static --enable-shared \ $enable_mpi $enable_debug $enable_sse\ CC="$cc" CFLAGS="$cflags $coptflags" \ F77="$fc" FFLAGS="$fflags $foptflags" \ FLIBS="$flibs_arch" \ > ../fftw3_config.log 2>&1 ncerror=$? fi if [ $ncerror -gt 0 ]; then echo " Error: FFTW configure returned $ncerror" echo " FFTW configure failed! Check the fftw3_config.log file" echo " in the $AMBERHOME/AmberTools/src directory." exit 1 else echo " fftw-3.3 configure succeeded." fi cd .. fftw3="FFTW3" flibs_fftw3="-lfftw3" fftw3="\$(LIBDIR)/libfftw3.a" if [ "$mpi" = 'yes' ]; then flibs_fftw3="-lfftw3_mpi $flibs_fftw3" fftw3="\$(LIBDIR)/libfftw3_mpi.a" fi elif [ "$mdgx" = 'yes' ]; then echo echo "Configuring fftw-3.3 for mdgx (may be time-consuming)..." echo enable_mpi="" enable_debug="" enable_sse="--enable-sse=no --enable-sse2=no --enable-avx=no" if [ "$debug" = "yes" ]; then enable_debug="--enable-debug=yes --enable-debug-malloc=yes --enable-debug-alignment=yes" fi if [ "$sse" = "yes" ]; then enable_sse="--enable-sse2=yes" # --enable-avx=yes" fi cd fftw-3.3 && \ ./configure --prefix=$AMBERHOME --libdir=$AMBERHOME/lib \ --enable-static --enable-shared --disable-fortran \ $enable_debug $enable_sse\ CC="$cc" CFLAGS="$cflags $coptflags" \ > ../fftw3_config.log 2>&1 ncerror=$? if [ $ncerror -gt 0 ]; then echo " Error: FFTW configure returned $ncerror" echo " FFTW configure failed! Check the fftw3_config.log file" echo " in the $AMBERHOME/AmberTools/src directory." exit 1 else echo " fftw-3.3 configure succeeded." fi cd .. fftw3="FFTW3" flibs_fftw3="-lfftw3" fftw3="\$(LIBDIR)/libfftw3.a" else echo "" echo "Skipping configuration of FFTW3" fftw3="" fi #-------------------------------------------------------------------------- # Enable parallel mdgx. If mdgx is no from fftw3, leave it at no. #-------------------------------------------------------------------------- if [ "$mpi" = 'yes' -a "$mdgx" = 'yes' ]; then mdgx='parallel' fi #-------------------------------------------------------------------------- # Configure XBLAS #-------------------------------------------------------------------------- if [ "$rism" = "yes" ]; then echo echo "Configuring XBLAS (may be time-consuming)..." echo xblas="\$(LIBDIR)/libxblas-amb.a" cd xblas CC="$cc" FC="$fc" CFLAGS="$cflags $coptflags" ./configure --prefix="$AMBERHOME/lib" > ../xblas_config.log 2>&1 ncerror=$? if [ $ncerror -gt 0 ]; then echo " Error: XBLAS configure returned $ncerror" echo " XBLAS configure failed! Check the xblas_config.log file" echo " in the $AMBERHOME/AmberTools/src directory." exit 1 else echo " XBLAS configure succeeded." fi cd .. else xblas="" fi #-------------------------------------------------------------------------- # Configure mtkpp: #-------------------------------------------------------------------------- if [ "$mtkpp" = 'install_mtkpp' ]; then boostDir=$PWD/boost-1.38.0 cd mtkpp echo echo "Configuring MTK++ (may be time-consuming)..." echo if [ "$is_mac" = 'yes' ]; then ./configure CXX="$cplusplus" CC="$cc" QTDIR="" \ CFLAGS="$cflags" \ CXXFLAGS="$cxxflags" \ --prefix=$AMBERHOME \ --includedir=$AMBERHOME/include/mtkpp \ --disable-shared \ --with-boost="${boostDir}" > ../mtkpp_config.log 2>&1 else ./configure CXX="$cplusplus" CC="$cc" QTDIR="" \ CFLAGS="$cflags" \ CXXFLAGS="$cxxflags" \ --disable-shared --enable-static="yes" \ --prefix=$AMBERHOME \ --includedir=$AMBERHOME/include/mtkpp \ --with-boost="${boostDir}" > ../mtkpp_config.log 2>&1 fi mtkerror=$? if [ $mtkerror -gt 0 ]; then echo " Warning: MTK++ configure returned $mtkerror" echo " MTK++ configure failed! Check the mtkpp_config.log file" echo " in the $AMBERHOME/AmberTools/src directory." echo " MTK++ will not be built alongside AmberTools." mtkpp='' else echo " MTK++-0.2.0 configure succeeded." fi cd .. fi # Configure PUPIL support pupillibs="-lm -lc -L\${PUPIL_PATH}/lib -lPUPIL -lPUPILBlind" if [ "$is_mac" != 'yes' ]; then pupillibs="-lrt $pupillibs" fi #------------------------------------------------------------------------------ # Set up the mpi compilers: #------------------------------------------------------------------------------ pmemd_ld="$ld" if [ "$mpi" = 'yes' ]; then if [ "$crayxt5" = 'yes' -o "$compiler" = 'cray' ]; then cc="cc" fc="ftn" cplusplus="CC" mpi_flag="-DMPI " elif [ "$intelmpi" = 'yes' ]; then cc="mpiicc" fc="mpiifort" cplusplus="mpiicpc" mpi_flag="-DMPI " else cc="mpicc" cplusplus="mpicxx" fc="mpif90" mpi_flag="-DMPI " # Catch a corner-case of unusually setup intel compilers. # if [ $compiler = 'intel' ]; then # cc="$cc -cc=icc" # cplusplus="$cplusplus -cxx=icc" # fc="$fc -fc=ifort" # pmemd_ld="mpif90 -fc=ifort" # fi fi fi #----------------------------------------------------------------------------- # Configure EMIL #----------------------------------------------------------------------------- emil=""; emillib="" if [ "$build_emil" = 'yes' ]; then emil="EMIL" ###add emil linking for sander, pmemd and eventually everything else fppflags="$fppflags -DEMIL" ###gfortran (at least) needs stdc++ on the command line **AFTER** libemil.a emillib="\$(LIBDIR)/libemil.a $fc_cxx_link_flag" ###emil needs a different MPI flag... -DMPI will create problems with the C++ MPI headers if [ "$mpi" = 'yes' ]; then emil_mpiflags="-DUSE_MPI" else emil_mpiflags="" fi fi ##Test if mpi_cxx is needed. ##(Inconsistent organisation of libraries between different mpis means that mpi_cxx does not exist ##when linking with mpich mpif90; but is needed with openMPI mpif90) if [ "$mpi" = 'yes' ] && ( [ "$build_emil" = 'yes' ] || [ "$installtype" = 'cuda_parallel' ] ) then printf "testing [C++ / fortran] cross-compile with MPI libs" libmpi_cxx="" ##clean test files. rm -f testMPICXX.C testF90_main.F90 testF90_main.o testMPICXX.o testMPICXX ##make a dummy MPI/C++ source file cat > testMPICXX.C < void cpp_mpi_func(){MPI_Start((MPI_Request *)0);} extern "C" {void c_fortran_hook_(){cpp_mpi_func();}} EOF ##make a dummy F90 source file cat > testF90_main.F90 </dev/null >/dev/null if [ "$?" != "0" ]; then echo "Error! Unable to compile MPI/C++ code with command: " echo "$cplusplus -c testMPICXX.C" echo "[C++ / MPI] code is needed for CUDA and EMIL builds." exit 1 fi ##try compiling f90 main code $fc -c testF90_main.F90 2>/dev/null >/dev/null if [ "$?" != "0" ]; then echo "Error! Unable to compile F90 code with the command: " echo "$fc -c testF90_main.F90" exit 1 fi ##try linking without libmpi_cxx and silently add it if fail $fc testF90_main.o testMPICXX.o -o testMPICXX -lstdc++ 2>/dev/null >/dev/null if [ "$?" != "0" ]; then libmpi_cxx="-lmpi_cxx" fi ##try linking with libmpi_cxx and silently add it if fail $fc testMPICXX.o testF90_main.o -o testMPICXX $libmpi_cxx -lstdc++ 2>/dev/null >/dev/null if [ "$?" != "0" ]; then libmpi_cxx="-lmpi_cxx" fi ##try linking again, with the flag set to whatever it should be, and this time ##report any failures $fc testMPICXX.o testF90_main.o -o testMPICXX -lstdc++ $libmpi_cxx 2>/dev/null >/dev/null if [ "$?" != "0" ]; then echo "" echo "Error! Could not link C++ mpi code using mpi fortran linker:" echo " \"$fc -lstdc++ $libmpi_cxx\"" echo "[C++ / fortran / MPI] cross-linking is needed for cuda_parallel and EMIL builds." echo "Try: \"mpif90 -show\"" exit 1 fi ##clean test files. rm -f testMPICXX.C testF90_main.F90 testF90_main.o testMPICXX.o testMPICXX ##If emil or emil+cuda are defined, then any cuda targets are also emil ##targets, and we do not need to change the pmemd_cu_libs. if [ "$build_emil" = 'yes' ]; then emillib=$(echo "$emillib" "$libmpi_cxx") elif [ "$installtype" = 'cuda_parallel' ]; then pmemd_cu_libs=$(echo "$pmemd_cu_libs" "$libmpi_cxx") fi fi #------------------------------------------------------------------------------ # Python-dev include directory for Amber_Phenix #------------------------------------------------------------------------------ if [ $amberphenix = 'yes' ]; then include_py=$(python -c "from distutils import sysconfig as s; print s.get_config_vars()['INCLUDEPY']") echo $include_py if [ ! -f "${include_py}/Python.h" ]; then echo "ERROR: Attempting Amber_Phenix build but python-devel not installed" exit 1 fi python_ver=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))') fi #------------------------------------------------------------------------------ # LIO GPU Library setup #------------------------------------------------------------------------------ if [ "$lio" = 'yes' ]; then # Checking if LIOHOME exists if [ -z "$LIOHOME" ]; then echo "" echo "You selected to compile AMBER with LIO support, but LIOHOME environment variable is not set!" echo "Configure it and retry." exit 1 elif [ ! -d $LIOHOME ]; then echo "" echo "You selected to compile AMBER with LIO support, but LIOHOME environment variable is set to '$LIOHOME' -- this does" echo "not appear to be a directory. Configure it and retry." exit 1 fi echo "Configuring for LIO QM GPU Library" cflags="$cflags -DLIO" fflags="$fflags -DLIO" liolibs="-L/usr/lib -L/usr/lib64 -L$LIOHOME/g2g/ -lg2g -L$LIOHOME/lioamber -llio-g2g" fi #LIOHOME #------------------------------------------------------------------------------ # Make some needed directories: #------------------------------------------------------------------------------ # first, at the top $AMBERHOME level: cd ../.. if [ ! -d bin ]; then mkdir bin fi if [ ! -d include ]; then mkdir include fi if [ ! -d src ]; then mkdir src fi if [ ! -d share ]; then mkdir share fi if [ ! -d logs ]; then mkdir logs fi # next, links in AmberTools to some $AMBERHOME directories cd AmberTools if [ ! -x bin ]; then ln -s ../bin . fi if [ ! -x lib ]; then ln -s ../lib . fi if [ ! -x lib64 ]; then ln -s ../lib lib64 fi if [ ! -x include ]; then ln -s ../include . fi if [ ! -x share ]; then ln -s ../share . fi cd src #------------------------------------------------------------------------------ # Finally, write out the config.h file: #------------------------------------------------------------------------------ cat < config.h # Amber configuration file, created with: $command ############################################################################### # (1) Location of the installation BASEDIR=$AMBERHOME BINDIR=$AMBERHOME/bin LIBDIR=$AMBERHOME/lib INCDIR=$AMBERHOME/include DATDIR=$AMBERHOME/dat LOGDIR=$AMBERHOME/logs ############################################################################### # (2) If you want NAB to search additional libraries by default, add them # to the FLIBS variable here. (External libraries can also be linked into # NAB programs simply by including them on the command line; libraries # included in FLIBS are always searched.) FLIBS= $nablibsff -lpbsa $nablibrism $flibs_fftw3 $flibs $netcdf_flag $flibs_mkl $flibs_arch $XTRA_FLIBS FLIBS_PTRAJ= $flibs $flibs_mkl $flibs_arch FLIBSF= $flibsf $flibs_mkl $flibsf_arch FLIBS_FFTW3= $flibs_fftw3 ############################################################################### # (3) Modify any of the following if you need to change, e.g. to use gcc # rather than cc, etc. SHELL=/bin/sh INSTALLTYPE=$installtype BUILDAMBER=$amber # Set the C compiler, etc. # The configure script should be fine, but if you need to hand-edit, # here is some info: # Example: CC-->gcc; LEX-->flex; YACC-->yacc (built in byacc) # Note: If your lexer is "really" flex, you need to set # LEX=flex below. For example, on some distributions, # /usr/bin/lex is really just a pointer to /usr/bin/flex, # so LEX=flex is necessary. In general, gcc seems to need flex. # The compiler flags CFLAGS and CXXFLAGS should always be used. # By contrast, *OPTFLAGS and *NOOPTFLAGS will only be used with # certain files, and usually at compile-time but not link-time. # Where *OPTFLAGS and *NOOPTFLAGS are requested (in Makefiles, # makedepend and depend), they should come before CFLAGS or # CXXFLAGS; this allows the user to override *OPTFLAGS and # *NOOPTFLAGS using the BUILDFLAGS variable. # AMBERBUILDFLAGS provides a hook into all stages of the build process. # It can be used to build debug versions, invoke special features, etc. # Example: make AMBERBUILDFLAGS='-O0 -g' sander # CC=$cc CFLAGS=$cflags $mpi_flag \$(CUSTOMBUILDFLAGS) $mklinc \$(AMBERBUILDFLAGS) CNOOPTFLAGS=$cnooptflags COPTFLAGS=$coptflags $omp_flag AMBERCFLAGS=$ambercflags \$(AMBERBUILDFLAGS) CXX=$cplusplus CPLUSPLUS=$cplusplus CXXFLAGS=$cxxflags $mpi_flag \$(CUSTOMBUILDFLAGS) \$(AMBERBUILDFLAGS) CXXNOOPTFLAGS=$cxxnooptflags CXXOPTFLAGS=$cxxoptflags AMBERCXXFLAGS=$ambercxxflags \$(AMBERBUILDFLAGS) NABFLAGS=$nabflags \$(AMBERBUILDFLAGS) PBSAFLAG=$pbsaflag \$(AMBERBUILDFLAGS) LDFLAGS=$ldflags \$(CUSTOMBUILDFLAGS) \$(AMBERBUILDFLAGS) AMBERLDFLAGS=\$(AMBERBUILDFLAGS) LEX= $lex YACC= \$(BINDIR)/yacc AR= ar rv M4= $m4 RANLIB=$ranlib # Set the C-preprocessor. Code for a small preprocessor is in # ucpp-1.3; it gets installed as \$(BINDIR)/ucpp; CPP=$cpp # These variables control whether we will use compiled versions of BLAS # and LAPACK (which are generally slower), or whether those libraries are # already available (presumably in an optimized form). LAPACK=$lapack BLAS=$blas F2C=$f2c # These variables determine whether builtin versions of certain components # can be used, or whether we need to compile our own versions. UCPP=$ucpp C9XCOMPLEX=$c9xcomplex # For Windows/cygwin, set SFX to ".exe"; for Unix/Linux leave it empty: # Set OBJSFX to ".obj" instead of ".o" on Windows: SFX=$suffix OSFX=$objsuffix MV=$localmv RM=$localrm CP=$localcp # Information about Fortran compilation: FC=$fc FFLAGS= $fflags \$(LOCALFLAGS) \$(CUSTOMBUILDFLAGS) -I\$(INCDIR) \$(NETCDFINC) $mklinc \$(AMBERBUILDFLAGS) FNOOPTFLAGS= $fnooptflags FOPTFLAGS= $foptflags AMBERFFLAGS=\$(AMBERBUILDFLAGS) FREEFORMAT_FLAG= $freeformat_flag LM=$lm FPP=$fpp FPPFLAGS=$fppflags $mpi_flag \$(CUSTOMBUILDFLAGS) \$(AMBERBUILDFLAGS) AMBERFPPFLAGS=\$(AMBERBUILDFLAGS) FCREAL8=$fcreal8 NOFORTRANMAIN=$flibs_arch XHOME= $xhome XLIBS= $xlibs MAKE_XLEAP=$make_xleap NETCDF=$netcdf NETCDFLIB=$netcdfflagc NETCDFLIBF=$netcdfflagf NETCDFINC=$netcdfinc FFTWLIB=$flibs_fftw3 EMIL=$emil EMILLIB=$emillib ZLIB=$zlib BZLIB=$bzlib HASFC=$hasfc MTKPP=$mtkpp XBLAS=$xblas FFTW3=$fftw3 MDGX=$mdgx COMPILER=$compiler MKL=$MKL_HOME MKL_PROCESSOR=$mkl_processor #CUDA Specific build flags NVCC=$nvcc PMEMD_CU_INCLUDES=$pmemd_cu_includes PMEMD_CU_LIBS=$pmemd_cu_libs PMEMD_CU_DEFINES=$pmemd_cu_defines #PMEMD Specific build flags PMEMD_F90=$fc $mpi_flag $fppflags $pmemd_fpp_flags PMEMD_FOPTFLAGS=$pmemd_foptflags \$(AMBERBUILDFLAGS) PMEMD_CC=$cc PMEMD_COPTFLAGS=$pmemd_coptflags $mpi_flag \$(AMBERBUILDFLAGS) PMEMD_FLIBSF=$flibs_mkl $win_mpilibs $emillib PMEMD_LD=$ld \$(AMBERBUILDFLAGS) LDOUT=$ldout #for NAB: MPI=$mpinab #1D-RISM RISM=$rism #3D-RISM NAB RISMSFF=$rismsff SFF_RISM_INTERFACE=$sff_rism_interface TESTRISMSFF=$testrismsff #3D-RISM SANDER RISMSANDER=$rismsander SANDER_RISM_INTERFACE=$sander_rism_interface FLIBS_RISMSANDER=$flibs_rismsander TESTRISMSANDER=$testrismsander #for EMIL: EMIL_MPIFLAGS=$emil_mpiflags #PUPIL PUPILLIBS=$pupillibs #Python interpreter we are using PYTHON=$python #Type of Amber_Phenix build and python include file AMBERPHENIX=$amberphenix INCLUDE_PY=$include_py PYTHON_VER=$python_ver #For LIO QM GPU Library LIOLIBS=$liolibs EOD echo " " echo "The configuration file, config.h, was successfully created." echo " " # Write resource files cat > $ambhome/amber.sh << EOF export AMBERHOME="$ambhome" export PATH="\${PATH}:\${AMBERHOME}/bin" EOF cat > $ambhome/amber.csh << EOF setenv AMBERHOME "$ambhome" setenv PATH "\${PATH}:\${AMBERHOME}/bin" EOF if [ "$is_mac" = 'no' ]; then # For Linux machines, we need to augment LD_LIBRARY_PATH as well cat >> $ambhome/amber.sh << EOF if [ -z "\${LD_LIBRARY_PATH}" ]; then export LD_LIBRARY_PATH="\${AMBERHOME}/lib" else export LD_LIBRARY_PATH="\${LD_LIBRARY_PATH}:\${AMBERHOME}/lib" fi EOF cat >> $ambhome/amber.csh << EOF if( -z "\${LD_LIBRARY_PATH}" ) then setenv LD_LIBRARY_PATH "\${AMBERHOME}/lib" else setenv LD_LIBRARY_PATH "\${LD_LIBRARY_PATH}:\${AMBERHOME}/lib" endif EOF fi echo "--------------------------------------------------------------------------------" echo "Environment resource files are provided to set the proper environment" echo "variables to use AMBER and AmberTools." echo "" echo "If you use a Bourne shell (e.g., bash, sh, zsh, etc.), source the" echo "$ambhome/amber.sh file in your shell. Consider adding the line" echo " test -f $ambhome/amber.sh && source $ambhome/amber.sh" echo "to your startup file (e.g., ~/.bashrc)" echo "" echo "If you use a C shell (e.g., csh, tcsh), source the" echo "$ambhome/amber.csh file in your shell. Consider adding the line" echo " test -f $ambhome/amber.csh && source $ambhome/amber.csh" echo "to your startup file (e.g., ~/.cshrc)" if [ "$cuda_SPFP" = 'yes' -o "$cuda_SPXP" = 'yes' -o "$cuda_DPFP" = 'yes' ]; then echo "" echo "If you have not already done so, you may need to add $CUDA_HOME/lib" echo "and/or $CUDA_HOME/lib64 to LD_LIBRARY_PATH using the command" echo " export LD_LIBRARY_PATH=\"${CUDA_HOME}/lib:\${LD_LIBRARY_PATH}\" (bash, sh)" echo " setenv LD_LIBRARY_PATH \"${CUDA_HOME}/lib:\${LD_LIBRARY_PATH}\" (tcsh, csh)" fi echo "--------------------------------------------------------------------------------" echo "" echo "The next step is to type 'make install'" echo "" # make a copy of config.h in the AMBERHOME/src directory # make it a link so that changing one changes the other if we can if [ -d ../../src ]; then if [ -e ../../src/config.h ]; then /bin/rm -f ../../src/config.h fi if [ -x /bin/ln ]; then cd ../../src && /bin/ln -s ../AmberTools/src/config.h cd ../AmberTools/src else /bin/cp -f config.h ../../src fi fi exit