#!/bin/sh #set -xv command="$0 $*" # configure script for amber: creates config_amber.h #------------------------------------------------------------------------------ # set up usage statement: #------------------------------------------------------------------------------ usage(){ cat< is one of: compaqf90, hpf90, ifort, pgf90, sgi_altix, sgi_mips, sparc, xlf90_aix, xlf90_suse, xlf90_macosx, xlf90_bluegene, ifort_macosx, g95, gfortran, pathscale Parallel option flags: -mpi Use native MPI (assumes that the proper path will be searched) -mpi2 Like -mpi, but assumes mpi2 compatibility -nopar Explicit request of no MPI, the default -lamsource Use LAM/MPI (compile from source code) -lam Use (existing) LAM/MPI (MPI_HOME must be set) -mpich Use MPICH (MPI_HOME must be set) -mpich2 Use MPICH2 (MPI_HOME must be set) -openmpi Use OpenMPI (MPI_HOME must be set) -intelmpi Use Intel MPI (MPI_HOME must be set, e.g. to /opt/intel/mpi/2.0) -scali Use scali MPI (MPI_HOME must be set, e.g. to /opt/scali) Platform option flags: -gnucompat Add a second underscore to some symbols to maintain GNU link compatibility (g95, gfortran, pgf90). -p4 Optimize for Pentium 4 processor (pgf90,g95, gfortran, pathscale). Adds SSE1, SSE2 vectorisation where available. -cygwin Add CygWin flags for Windows (g95, gfortran). General flags: -mmtsb Request building sander for MMTSB. -static Static linking, i.e., prevent linking with shared libraries. -verbose Add verbose compiler comment and warning flags. -nobintraj Do not include support for binary (netCDF) trajectory files -nolfs Remove compile flags for Large File Support -nosanderidc Do not include support for IDC>0 in Sander. Environment variables: MKL_HOME Root directory of the Intel Math Kernel Library for example, /opt/intel/mkl/8.0. The MKL helps some with performance, but it is generally not a big deal if you leave this variable empty. GOTO Location for the "Goto" optimized blas library; this is used if MKL_HOME is *not* defined. =============================================================================== EOD exit 1; } #------------------------------------------------------------------------------ # Process commandline configuration options: #------------------------------------------------------------------------------ arch='unknown' cygwin='no' # This controls GNU's second underscore fortran external symbol convention. # Our default is no second underscore. # This is a good default because by default ifort and pgf90 (which can # link to gnu object files) do not add a second underscore. gnucompat='no' mmtsb='no' parallel='none' p4='no' bintraj='yes' sfx='' sgimips='unknown' static='no' verbose='no' verbosity='' lm='-lm' lfs='yes' libdivcon='../dcqtp/src/qmmm/libdivcon.a' incdivcon='divcon' testsanderDIVCON='test.sander.DIVCON' nosanderidc='false' openmp='no' openmp_flag='' while [ $# -gt 0 ]; do case "$1" in -lam) parallel="lam" ;; -lamsource) parallel="lamsource" ;; -mpi) parallel="mpi" ;; -mpi2) parallel="mpi2" ;; -mpich) parallel="mpich" ;; -mpich2) parallel="mpich2" ;; -intelmpi) parallel="intelmpi" ;; -openmpi) parallel="openmpi" ;; -scali) parallel="scali" ;; -nopar) parallel="none" ;; -gnucompat) gnucompat="yes" ;; -p4) p4="yes" ;; -cygwin) cygwin="yes" ; lfs="no"; sfx=".exe" ;; -mmtsb) mmtsb="yes" ;; -static) static="yes" ;; -verbose) verbose="yes" ;; -nobintraj) bintraj="no" ;; -nolfs) lfs="no";; -nosanderidc) nosanderidc="true";; #OpenMP is currently experimental - it is not currently documented as an #available option. It has only been tested with ifort and gfortran. This is currently #only used for parts of the QMMM code and is expected to also be used #with an MPI run. - This will turn on -DQMMM_OMP -openmp) openmp="yes";; -help) usage ;; --help) usage ;; -h) usage ;; -*) echo ""; echo "unknown flag $1"; usage ;; *) if [ $# -gt 1 ]; then usage fi arch=$1 ;; esac shift done #------------------------------------------------------------------------------ # Set up defaults that work for most machines: #------------------------------------------------------------------------------ workdir=`pwd` AMBERHOME=`dirname $workdir` echo "Setting AMBERHOME to $AMBERHOME" echo " " #------------------- # Platform specific: #------------------- x86_64='no' machine=`uname -m` if [ "$machine" = "em64t" ] || [ "$machine" = "x86_64" ]; then x86_64='yes'; if [ $arch = "ifort" ]; then arch="ifort_x86_64" fi elif [ "$machine" = "i686" ] && [ $arch = "ifort" ]; then arch="ifort_ia32" elif [ "$machine" = "ia64" ] && [ $arch = "ifort" ]; then arch="ifort_ia64" fi if [ "$arch" = "xlf90_aix" ]; then #dcqtp (idc) compilation is broken on xlf90_aix. nosanderidc="true" fi #------------------- # Program specific: #------------------- localflags= #------------------- # preprocessor: #------------------- fpp="cpp -traditional" fppflags="-P" if [ $mmtsb = "yes" ]; then fppflags="$fppflags -DMMTSB" fi #----------------------------------- # Remove Divcon support from sander? #----------------------------------- if [ $nosanderidc = "true" ]; then fppflags="$fppflags -DNO_SANDER_DIVCON" libdivcon=" " incdivcon=" " testsanderDIVCON="skipsanderDIVCON" fi moduledir="-I" #------------------- # C compilation: #------------------- cpp=cpp cc=cc cplusplus=CC cppflags= if [ $mmtsb = "yes" ]; then cppflags="$cppflags -DMMTSB" fi cflags= if [ $lfs = "yes" ]; then cflags="$cflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE" fi #------------------- # Fortran compilation: #------------------- fc=f90 fflags="-O0 -132" foptflags=-O2 freeformat_flag= #------------------- # Loading: #------------------- loadcc="$cc" loadlib= if [ $static = "yes" ]; then static_flag='-static' else static_flag= fi #------------------- # Libraries: #------------------- m4='m4' use_blas=SOURCE_COMPILED use_lapack=SOURCE_COMPILED xhome='/usr/X11R6' xlibs="-L$xhome/lib" if [ "$x86_64" = "yes" ]; then xlibs="-L$xhome/lib64 $xlibs" fi #------------------- # Auxiliary programs: #------------------- ar='ar rv' ranlib=ranlib # NetCDF variables: netcdf=netcdf.mod netcdflib="../netcdf/lib/libnetcdf.a" par_error () { cat <&1 exit 1 fi use_lapack=VENDER_SUPPLIED use_blas=VENDER_SUPPLIED loadlib="$loadlib -L$ACML_DIR -lacml" echo "Using optimized AMD Core Math Library (ACML)" fi fc="pathf90" fpp="$fc -cpp -E" if [ "$set_foptflags" != "" ]; then foptflags="$set_foptflags" fflags="$set_foptflags" elif [ "$p4" = "yes" ]; then foptflags="-O3 -m32 -msse2" fflags="-O0 -m32 -msse2" else foptflags="-O3" fflags="-O0" fi intr_flags="-intrinsic=PGI -intrinsic=fdate" fflags="$fflags $intr_flags $verbosity -fno-unsafe-math-optimizations" foptflags="$foptflags $intr_flags $verbosity -fno-unsafe-math-optimizations" freeformat_flag='-freeform' cc="pathcc" cplusplus="pathCC" cpp="$pathcc -E" if [ "$set_cflags" != "" ]; then cflags="$cflags $set_cflags" elif [ "$p4" = "yes" ]; then cflags="$cflags -O3 -m32 -msse2" else cflags="$cflags -O1" fi cflags="$cflags $verbosity" loadcc="$cc $static_flag" ;; #################### g95 or gfortran compiler (Linux/cygwin/Macintosh only) ####### g95|gfortran) cc=gcc cplusplus=g++ cflags="$cflags -O2" if [ $arch = "g95" ]; then fc=g95 fppflags="$fppflags -xassembler-with-cpp" fflags="-O0 " foptflags="-O3 " else fc=gfortran fppflags="$fppflags -xassembler-with-cpp -Dsecond=ambsecond" fflags="-O0 -fno-range-check" foptflags="-O3 -fno-range-check" fi if [ $gnucompat = "yes" ]; then gnucompatibility="-fsecond-underscore" else gnucompatibility="-fno-second-underscore" fi fflags="$fflags $gnucompatibility" foptflags="$foptflags $gnucompatibility" if [ $p4 = "yes" ]; then fflags="$fflags -march=pentium4 -mfpmath=sse -msse -msse2 -malign-double" foptflags="$foptflags -march=pentium4 -mfpmath=sse -msse -msse2 -malign-double" fi if [ $x86_64 = "yes" ]; then cflags="$cflags -m64" elif [ "$machine" = "ia64" ]; then cflags="$cflags" elif [ "$machine" = "Power Macintosh" ]; then cflags="$cflags" else cflags="$cflags -m32" fi freeformat_flag=-ffree-form loadcc="$cc $static_flag" # check for installation of the Intel Math Kernel library: mkll='no' if [ -z "$MKL_HOME" -a "$OSTYPE" = "darwin" -a "$VENDOR" = "apple" ]; then echo "Using Apple Accelerate Framework for g95." use_lapack=VENDOR_SUPPLIED use_blas=VENDOR_SUPPLIED loadlib="$loadlib -framework Accelerate" elif [ -z "$MKL_HOME" ]; then echo "The MKL_HOME environment variable is not defined." elif [ $x86_64 = "yes" ]; then echo "MKL_HOME is set to $MKL_HOME" if [ -d $MKL_HOME/lib/em64t ]; then mkll=$MKL_HOME/lib/em64t echo "Using MKL libraries from $mkll" else echo "MKL libraries were not found !" fi else echo "MKL_HOME is set to $MKL_HOME" if [ -d $MKL_HOME/lib/32 ]; then mkll=$MKL_HOME/lib/32 echo "Using MKL libraries from $mkll" else echo "MKL libraries were not found !" fi fi if [ $mkll != 'no' ]; then use_lapack=VENDOR_SUPPLIED use_blas=VENDOR_SUPPLIED if [ $static = "yes" ]; then if [ $x86_64 = "yes" ]; then loadlib="$loadlib $mkll/libmkl_lapack.a $mkll/libmkl_em64t.a -L$mkll -lguide -lpthread" else loadlib="$loadlib $mkll/libmkl_lapack.a $mkll/libmkl_ia32.a -L$mkll -lguide -lpthread" fi else loadlib="$loadlib -L$mkll -lvml -lmkl_lapack -lmkl -lguide -lpthread" fi fppflags="$fppflags -DMKL" fi #openMP support for QMMM Density build. - only gfortran supports it at present - no g95. if [ $openmp = "yes" ]; then if [ $arch = "gfortran" ]; then foptflags="$foptflags -openmp" fflags="$fflags -openmp" fppflags="$fppflags -DQMMM_OMP" openmp_flag="-fopenmp" else echo "WARNING: Openmp is not supported with g95 - the -openmp option will be ignored." fi fi ;; #################### Portland Compiler ##################### pgf90) cc=gcc cplusplus=g++ cflags="$cflags -O2" loadcc="$cc $static_flag" fc=pgf90 fflags="-O1" foptflags="-fast -O3" if [ $p4 = "yes" ]; then fflags="-tp p7 $fflags" foptflags="-tp p7 -fastsse $foptflags" fi moduledir='-module $(EMPTY)' if [ $static = "yes" ]; then static_flag='-Bstatic' fi if [ -e /usr/pgi/linux86/lib/liblapack.a ]; then use_lapack=VENDOR_SUPPLIED use_blas=VENDOR_SUPPLIED loadlib="$loadlib -llapack -lblas" echo "Using Portland Group LAPACK and BLAS." fi if [ $gnucompat = "yes" ]; then gnucompatibility='-Msecond_underscore' # cflags="$cflags $gnucompatibility" fflags="$fflags $gnucompatibility" foptflags="$foptflags $gnucompatibility" fi if [ $verbose = "yes" ]; then verbosity='-v -V -Minfo=all -Minform=inform -Mneginfo' fi fflags="$fflags $verbosity" foptflags="$foptflags $verbosity" freeformat_flag='-Mfree' ;; #################### Absoft Windows ##################### absoft) # (absoft-Linux, tested on with Absoft V10.0) cc=gcc cplusplus='g++' cflags="$cflags -DCLINK_CAPS" fc=f95 loadcc=$cc loadlib="$loadlib -lU77 " fflags=" -O1 -safefp" foptflags=" -O1 -safefp" if [ $verbose = "yes" ]; then echo "verbose option is not implemented yet." fi fflags="$fflags $verbosity" foptflags="$foptflags $verbosity" freeformat_flag='-f free' if [ $x86_64 = "yes" ]; then cflags="$cflags -m64" else cflags="$cflags -m32" fi # use_lapack=VENDOR_SUPPLIED # use_blas=VENDOR_SUPPLIED moduledir="-p " ;; ##################### SGI IRIX 32-bit ############### sgi_mips|IRIX64) sgi_abi='-n32' fpp='/lib/cpp' fppflags="$fppflags -DSGI -DnoVDINVSQRT" if [ -e /usr/lib32/mips4/libscs.so ]; then use_lapack=VENDOR_SUPPLIED use_blas=VENDOR_SUPPLIED loadlib="$loadlib -lscs" fi sgi_cpuarch=` hinv -t cpu | awk ' { print $3 } ' | head -1 ` sgi_Rdigit=` echo $sgi_cpuarch | sed s/R// ` if [ $sgi_Rdigit -lt 4000 ]; then # R3k machines, those less than R4000 are not supported. echo "The $sgi_cpuarch Processor is no longer supported." exit 1 elif [ $sgi_Rdigit -lt 5000 ]; then # R4k machines: only ones with -mips3 sgi_mips='-mips3' else # All others are now -mips4 sgi_mips="-mips4 -r$sgi_Rdigit" fi if [ $sgi_cpuarch = R5000 ]; then # R5k machines sgi_options='-OPT:roundoff=3:IEEE_arithmetic=3 -TENV:X=1 -SWP:strict_ivdep=OFF:if_conversion=OFF -WK,-dr=ACK,-o=1,-so=1,-r=3' # -WK options should be removed in a year; SRB Apr 2003. loadlib="$loadlib -lm" elif [ $sgi_cpuarch = R8000 ]; then # R8k machines sgi_options='-OPT:cis=off:roundoff=3:IEEE_arithmetic=3 -TENV:X=3 -SWP:strict_ivdep=OFF -WK,-dr=AKC' # -WK options should be removed in a year; SRB Apr 2003. loadlib="$loadlib -lfastm" else # The following line causes problems with at least the 7.3 MIPSpro # compiler suite. If you turn it back on, please test carefully, # especially for QM/MM: # sgi_options='-OPT:roundoff=3:IEEE_arithmetic=3 -TENV:X=1' sgi_options="" loadlib="$loadlib -lfastm" fi cflags="$cflags $sgi_abi $sgi_mips $sgi_options -O2 -DSYSV" cppflags="-LANG:std $cflags" fflags="$sgi_abi $sgi_mips $sgi_options -O0" foptflags="$sgi_abi $sgi_mips $sgi_options -O3" if [ $verbose = "yes" ]; then # include -S to get a software pipelining report, # delete the .s files later else the build will not be up to date. verbosity="-LIST:notes=ON:software_names=ON -LIST:all_options=ON:cite=ON:symbols=ON" fi cflags="$cflags " fflags="$fflags $verbosity" foptflags="$foptflags $verbosity" load="$fc $sgi_abi $sgi_mips" #Note: not used! loadcc="$cc $sgi_abi $sgi_mips" if [ $static = "yes" ]; then echo "Warning: static linking is not supported; option ignored." fi freeformat_flag='-freeform' ar='ar rvs $(EMPTY)' ranlib=/bin/true m4='m4 -B50000' xhome='/usr/lib32' xlibs="-L$xhome" ;; ####################### HP ############################ hpf90|HP-UX) fpp='/lib/cpp' if [ $parallel = "mpi" ]; then fppflags="$fppflags -I/opt/mpi/include" fc='mpif90' else fc=f90 fi cplusplus=aCC use_lapack=VENDOR_SUPPLIED use_blas=VENDOR_SUPPLIED loadlib="$loadlib -lveclib -llapack -lm " if [ $static = "yes" ]; then # +noshared is preferred over -N which is ignored by ld. # But it is not clear that +noshared is working; so use archive_shared. static_flag='+noshared -Wl,-aarchive_shared' fi loadcc="$cc $static_flag" fppflags="$fppflags -DHP " cppflags="-DCLINK_PLAIN" cflags="$cflags -Ae -DSYSV" # no postpending underscores (ppu) to link Fortran and C. # U77 library contains: etime, getarg, iargc. fflags='+noppu +U77 +Ofast' # +Ofaster is ~10% faster (JAC) but build is very slow # and in Sep 2003 for unknown reasons suddenly produces link errors foptflags='+noppu +U77 +Ofast' if [ $verbose = "yes" ]; then verbosity='-v +Oinfo -Wl,-v,-m' fi cflags="$cflags " fflags="$fflags $verbosity" foptflags="$foptflags $verbosity" freeformat_flag='+source=free' ar='ar rvs $(EMPTY)' ranlib=/bin/true m4='m4 -B50000' ;; ####################### IBM AIX ############################ xlf90_aix|AIX) libpath=/usr/lib if [ -e $libpath/libmassv.a ]; then loadlib="$loadlib -L$libpath -lmassv -lmass" fppflags="$fppflags -DMASSLIB" fi if [ -e $libpath/libblas.a ]; then loadlib="$loadlib -L$libpath -lblas" use_blas=VENDOR_SUPPLIED fi fppflags="$fppflags -DNMLEQ -DCLINK_PLAIN -DXLF90" fpp='/lib/cpp' # if you are in AIX 5.2 add -I/usr/lpp/ppe.poe/include/thread64: # fpp="$fpp -I/usr/lpp/ppe.poe/include/thread64" if [ $parallel = "mpi" ]; then if [ -e /usr/lpp/ppe.poe/include/mpif.h ]; then AIXMPIFDIR=/usr/lpp/ppe.poe/include/mpif.h else echo " ***** CANNOT FIND mpif.h ******** " echo using: \"mpxlf90 -v -c bogus.f\" to find mpif.h directory cat > tmp.awk << EEEOF {CT=1; while( CT <= NF){ if(substr( \$CT,1,2)=="-I"){print \$CT; exit;} CT++; }} EEEOF AIXMPIFINC=`mpxlf90 -v -c bogus.f 2>1 | head -1 | awk -f tmp.awk` AIXMPIFDIR=`echo $AIXMPIFINC | sed s/-I//` /bin/rm tmp.awk if [ -e $AIXMPIFDIR/mpif.h ]; then echo "Found in $AIXMPIFDIR" else echo "**** FAILED to find mpif.h, ask sys admin person" exit 1 fi fi fppflags="$fppflags -DPOE" fpp="$fpp $AIXMPIFINC" echo $fpp fc='mpxlf90_r -bmaxdata:0x80000000' # (for 64-bit environments, rmove the -bmaxdata flag above) else fc=xlf90 fi cc="xlc -qlanglvl=stdc99" cppflags="-DCLINK_PLAIN" cflags="$cflags -O2" cplusplus=xlC if [ $static = "yes" ]; then static_flag='-bstatic' fi loadcc="$cc $static_flag" fflags="-qfixed" foptflags="-qfixed -O3 -qmaxmem=-1 -qarch=auto -qtune=auto" if [ $verbose = "yes" ]; then verbosity='-qsource -qreport=hotlist' fi fflags="$fflags $verbosity" foptflags="$foptflags $verbosity" freeformat_flag='-qfree=f90' ar='ar rvs $(EMPTY)' ranlib=/bin/true m4='m4 -B50000' ;; ####################### IBM XLF90 AIX ############################ xlf90_bluegene) #libpath=/bgl/BlueLight/ppcfloor/bglsys/lib libpath=/usr/local/apps/lib #if [ -e $libpath/libmassv.a ]; then # loadlib="$loadlib -L$libpath -lmassv -lmass" # fppflags="$fppflags -DMASSLIB" #fi #if [ -e $libpath/libblas.a ]; then # loadlib="$loadlib -L$libpath -lblas" # use_blas=VENDOR_SUPPLIED #fi fppflags="$fppflags -DNMLEQ -DCLINK_PLAIN -DXLF90 -I/bgl/BlueLight/ppcfloor/bglsys/include/" fpp='/opt/ibmcmp/xlf/9.1/exe/cpp' if [ $parallel = "mpi" ]; then fppflags="$fppflags -DPOE" fpp="$fpp $AIXMPIFINC" fc='mpxlf90 -qarch=440 -qtune=440' echo " ***** Blue Gene support is currently experimental. It may be necessary *****" echo " ***** to manually edit the config_amber.h file to insert the correct paths. *****" else echo " ***** ERROR - ONLY PARALLEL MPI COMPILATION SUPPORTED ON BLUE GENE ***** " exit 1 fi cc="mpcc -qlanglvl=stdc99 -qarch=440 -qtune=440" cppflags="-DCLINK_PLAIN" cflags="$cflags -O2" cplusplus="mpCC -qarch=440 -qtune=440" loadcc="$cc" fflags="-qfixed" foptflags="-qfixed -O3 -qmaxmem=-1 -qarch=auto -qtune=auto" freeformat_flag='-qfree=f90' ar='ar rvs $(EMPTY)' ranlib=/bin/true m4='m4 -B50000' ;; ####################### PowerPC SUSE Linux ############################ xlf90_suse) libpath=/usr/lib if [ -e $libpath/libmass.a ]; then loadlib="$loadlib -L$libpath " fi if [ -e $libpath/libblas.a ]; then loadlib="$loadlib -L$libpath -lblas" use_blas=VENDOR_SUPPLIED fi if [ -e $libpath/libessl.a ]; then loadlib="$loadlib -L$libpath -lessl" use_lapack=VENDOR_SUPPLIED fi fc=xlf90 fppflags="$fppflags -DCLINK_PLAIN -DXLF90" fpp='/opt/ibmcmp/xlf/8.1/exe/cpp ' cc=cc cppflags="-DCLINK_PLAIN" cflags="$cflags -O2" cplusplus=xlC if [ $static = "yes" ]; then static_flag='-bstatic' fi loadcc="$cc $static_flag" fflags="-qfixed" foptflags="-qfixed -O3 -qmaxmem=-1 -qarch=auto -qtune=auto" if [ $verbose = "yes" ]; then verbosity='-qsource -qreport=hotlist' fi fflags="$fflags $verbosity" foptflags="$foptflags $verbosity" freeformat_flag='-qfree=f90' ar='ar rvs $(EMPTY)' ranlib=/bin/true ;; ####################### Compaq DEC Alpha OSF1 ########################## compaqf90|OSF1) use_lapack=VENDOR_SUPPLIED use_blas=VENDOR_SUPPLIED # -C prevents striping of C-style AND C++-style comments; # some format statements contain // fppflags="-C $fppflags" fpp='/lib/cpp -traditional' fflags="-tune host -arch host" foptflags="-fast -O3 -tune host -arch host" cplusplus=cxx cflags="$cflags -O -std1" if [ $verbose = "yes" ]; then verbosity='-source_listing -annotations all -Wl,-v,-m,-M' fi fflags="$fflags $verbosity" foptflags="$foptflags $verbosity" if [ $static = "yes" ]; then static_flag='-non_shared' fi loadcc="$cc $static_flag" loadlib="$loadlib -ldxml -lm" freeformat_flag='-free' ranlib=/bin/true m4='m4 -B50000' ;; ####################### Sun ############################ sparc|SunOS) xhome='/usr/openwin' fpp='/lib/cpp' fppflags="$fppflags" if [ -f /opt/SUNWspro/lib/libsunperf.so ]; then use_lapack=VENDOR_SUPPLIED use_blas=VENDOR_SUPPLIED loadlib="$loadlib -xlic_lib=sunperf" # Note that the Sun Performance Library has FFT routines. # Sun Performance Library User's Guide, # http://docs.sun.com/source/806-3566/index.html fi loadlib="$loadlib -lm" fflags='-O1' foptflags='-O2' if [ $verbose = "yes" ]; then echo "verbose option is not implemented yet." fi fflags="$fflags $verbosity" foptflags="$foptflags $verbosity" if [ $static = "yes" ]; then static_flag='-Bstatic' fi loadcc="$cc $static_flag" cflags="$cflags -DSYSV " freeformat_flag='-free' m4='m4 -B50000' moduledir="-M" ;; ####################### Mac OS X ############################ xlf90_macosx) xhome='/usr/X11R6' libpath=/System/Library/Frameworks/Accelerate.framework if [ -e $libpath/Accelerate ]; then loadlib="$loadlib -Wl,-framework -Wl,Accelerate" use_blas=VENDOR_SUPPLIED use_lapack=VENDOR_SUPPLIED fflags="-qextname=ddot:fdate:flush:lsame:dscal:dnrm2:idamax:drot:dswap:dspmv:daxpy:dspr2:dgemm:dcopy:dgemv:dtrmv:dtrmm:dger:lsame:dspev:dgeev:dspevd:dsyev:dppsv:dspsv:dlamch:dsteqr:dgeqr2:dorm2r:dlacpy:dlarnv:dlascl:dlaset:dlartg:dlanst:dlaev2:dlapy2:dlasr" foptflags="-qextname=ddot:fdate:flush:lsame:dscal:dnrm2:idamax:drot:dswap:dspmv:daxpy:dspr2:dgemm:dcopy:dgemv:dtrmv:dtrmm:dger:lsame:dspev:dgeev:dspevd:dsyev:dppsv:dspsv:dlamch:dsteqr:dgeqr2:dorm2r:dlacpy:dlarnv:dlascl:dlaset:dlartg:dlanst:dlaev2:dlapy2:dlasr" fi fppflags="$fppflags -DNMLEQ -DCLINK_PLAIN -DXLF90 -DHASSECOND" fpp='/opt/ibmcmp/xlf/8.1/exe/cpp' if [ $parallel = "mpi" ]; then fppflags="$fppflags -DPOE" fpp="$fpp -I/usr/lpp/ppe.poe/include" fc='mpxlf90_r -bmaxdata:0x80000000' else fc=xlf90 fi cc="xlc -qlanglvl=stdc99" cppflags="-DCLINK_PLAIN -I/usr/include/malloc" cflags="$cflags -O0 -Ddspev=dspev_" cplusplus=g++ if [ $static = "yes" ]; then static_flag='-bstatic' fi loadcc="$cc $static_flag" fflags="$fflags -qfloat=nomaf -qfixed" foptflags="$foptflags -qfloat=nomaf -qfixed -O3 -qmaxmem=-1 -qarch=auto -qtune=auto" if [ $verbose = "yes" ]; then verbosity='-qsource -qreport=hotlist' fi fflags="$fflags $verbosity" foptflags="$foptflags $verbosity" freeformat_flag='-qfree=f90' ar='ar rvs $(EMPTY)' ranlib=ranlib m4='m4 -B50000' ;; ifort_macosx) cc="gcc -m32" cplusplus=g++ cflags="$cflags -O2" loadcc="$cc $static_flag" fppflags="$fppflags" freeformat_flag='-FR' fflags=" -w95 " verbosity='-vec_report0' if [ $verbose = "yes" ]; then verbosity='-sox -vec_report3 -opt_report -opt_report_level max -opt_report_phase all -V -v -Wl,-verbose,-M' fi fflags="$fflags $verbosity" foptflags="$fflags -mp1 -ip -O3" fflags="$fflags -mp1 -O0" if [ $static = "yes" ]; then static_flag='-i-static' else static_flag= fi fc=ifort # check for installation of the Intel Math Kernel library: mkll='no' if [ -z "$MKL_HOME" ]; then echo "The MKL_HOME environment variable is not defined." echo " The MKL is recommended for optimal performance." else echo "MKL_HOME is set to $MKL_HOME" if [ -d $MKL_HOME/lib/32 ]; then mkll=$MKL_HOME/lib/32 echo "Using MKL libraries from $mkll" else echo "MKL libraries were not found !" fi fi if [ $mkll != 'no' ]; then use_lapack=VENDOR_SUPPLIED use_blas=VENDOR_SUPPLIED if [ $static = "yes" ]; then # IA-32 static linking of LAPACK and kernels loadlib="$loadlib $mkll/libmkl_lapack.a $mkll/libmkl_ia32.a -L$mkll -lguide -lpthread" else # IA-32 dynamic linking of double-precision-LAPACK and kernels loadlib="$loadlib -L$mkll -lmkl_lapack -lmkl_ia32 -lguide -lpthread" fi fppflags="$fppflags -DMKL" fi ;; *) echo "Architecture/compiler $arch is not supported (?)" 1>&2 usage ;; esac #-------------------------------------------------------------------------- # Test if the compilers work: #-------------------------------------------------------------------------- cat <testp.c #include int main() { printf( "testing a C program\n" ); } EOF echo "" echo "Testing the C compiler:" echo " $cc $cflags -o testp testp.c" $cc $cflags -o testp testp.c ./testp | grep "testing a C program" > /dev/null status=$? if [ "$status" -gt 0 ]; then echo "Unable to compile a C program using $cc $cflags" echo "Please check your compiler settings or configure flags." exit 1 fi /bin/rm -f testp.c testp.o testp echo "OK" cat <testp.f program testf write(6,*) 'testing a Fortran program' end program testf EOF echo "" echo "Testing the Fortran compiler:" echo " $fc $fflags -o testp testp.f" $fc $fflags -o testp testp.f ./testp | grep "testing a Fortran program" > /dev/null status=$? if [ "$status" -gt 0 ]; then echo "Unable to compile a Fortran program using $fc $fflags" echo "Please check your compiler settings or configure flags." exit 1 fi /bin/rm -f testp.f testp.o testp echo "OK" #-------------------------------------------------------------------------- # Set configuration for netcdf: # This comes before the "parallel" section as we don't want to use the mpi wrapped $fc #-------------------------------------------------------------------------- if [ $bintraj = "yes" ]; then fncflags= f90ncflags= case "$fc" in *xlf90*) fncflags='-O3 -qmaxmem=-1 -qarch=auto -qtune=auto' f90ncflags=' -qsuffix=f=f90' ;; *) fncflags="$foptflags" f90ncflags="$foptflags" ;; esac echo "" echo " ------ Configuring the netCDF libraries: --------" echo "" netcdfflag="--prefix=$AMBERHOME/src/netcdf --disable-cxx" if [ $arch = 'sgi_altix' ] ; then netcdfflag="$netcdfflag --enable-64bit" fi echo "Configuring netcdf; (may be time-consuming)" cd netcdf/src && \ env FC="$fc" F90="$fc" FFLAGS="$static_flag $fncflags" \ F90FLAGS="$static_flag $f90ncflags" CC="$cc" \ CFLAGS="$cflags" CPPFLAGS="-DNDEBUG" ./configure $netcdfflag \ > ../../netcdf_config.log ncerror=$? if [ "$ncerror" -gt 0 ]; then echo "netcdf configure returned $ncerror" echo "NETCDF configure failed! Check the netcdf_config.log file" exit 1 else echo "NETCDF configure succeeded." fi cd ../.. fppflags="$fppflags -DBINTRAJ" cppflags="$cppflags -DBINTRAJ -I../netcdf/include" else netcdf= netcdflib= fi #------------------------------------------------------------------------------ # Case statement identifying the parallel options: #------------------------------------------------------------------------------ case "$parallel" in mpi) loadlib="-lmpi $loadlib" fppflags="$fppflags -DMPI " ;; mpi2) loadlib="-lmpi $loadlib" fppflags="$fppflags -DMPI -DUSE_MPI_INPLACE" ;; lamsource) export MPI_HOME=$AMBERHOME echo "MPI_HOME is set to $MPI_HOME" fppflags="-I$MPI_HOME/include $fppflags -DMPI" echo "" echo " ------ Configuring the lam libraries: --------" echo "" cat < configure_lam #!/bin/sh cd lam-7.1.3 && \\ ./configure --prefix=$AMBERHOME --disable-tv-queue --without-mpi2cpp \\ --without-profiling --without-romio FC="$fc" FFLAGS="$fflags" \\ CXX="$cplusplus" lamcerror=\$? if [ "\$lamcerror" -gt 0 ]; then echo "lam configure returned \$lamcerror" echo "LAM configure failed! Check the above messages." exit 1 else echo "LAM configure succeeded." fi make clean make install cd .. EOF chmod +x ./configure_lam echo "" echo " Creating a 'configure_lam' script " echo "" echo " Please execute './configure_lam' before 'make parallel'" echo " (You only need to execute configure_lam once, unless you)" echo " change compilers.)" echo "" fc=$MPI_HOME/bin/mpif77 ;; lam) if [ -z "$MPI_HOME" ]; then PAR="LAM" FILES="mpif.h and libmpi.a, liblam.a or liblamf77mpi.a" EXAMPLE="/opt/lam" par_error fi echo "MPI_HOME is set to $MPI_HOME" fppflags="-I$MPI_HOME/include $fppflags -DMPI" fc=$MPI_HOME/bin/mpif77 ;; openmpi) if [ -z "$MPI_HOME" ]; then PAR="OPENMPI" FILES="mpif.h and libmpi.a" EXAMPLE="/usr/local/openmpi-1.0" par_error fi echo "MPI_HOME is set to $MPI_HOME" fppflags="-I$MPI_HOME/include $fppflags -DMPI" fc=$MPI_HOME/bin/mpif90 ;; scali) if [ -z "$MPI_HOME" ]; then PAR="SCALI" FILES="mpif.h and libmpi.a or libfmpi.a" EXAMPLE="/opt/scali" par_error fi echo "MPI_HOME is set to $MPI_HOME" loadlib="$loadlib -L$MPI_HOME/lib -lfmpi -lmpi" fppflags="-I$MPI_HOME/include $fppflags -DMPI" ;; mpich) if [ -z "$MPI_HOME" ]; then PAR="MPICH" FILES="mpif.h and libmpi.a or libmpich.a" EXAMPLE="/usr/local/src/mpich/build/LINUX/ch_pentium4" par_error fi echo "MPI_HOME is set to $MPI_HOME" fppflags="-I$MPI_HOME/include $fppflags -DMPI" fc=$MPI_HOME/bin/mpif90 ;; mpich2) if [ -z "$MPI_HOME" ]; then PAR="MPICH2" FILES="mpif.h and libmpi.a or libmpich.a" EXAMPLE="/usr/local/src/mpich/build/LINUX/ch_pentium4" par_error fi echo "MPI_HOME is set to $MPI_HOME" #MPICH 2 is supposed to be MPI v2 complient so must support MPI_IN_PLACE. fppflags="-I$MPI_HOME/include $fppflags -DMPI -DUSE_MPI_IN_PLACE" fc=$MPI_HOME/bin/mpif90 ;; intelmpi) if [ -z "$MPI_HOME" ]; then PAR="INTELMPI" FILES="mpif.h and libmpi.a" EXAMPLE="/opt/intel/mpi/2.0" par_error fi echo "MPI_HOME is set to $MPI_HOME" loadlib2="-L$MPI_HOME/lib -lmpi -lmpiif -lmpigi" fppflags="-I$MPI_HOME/include $fppflags -DMPI" if [ "$machine" = "x86_64" ] || [ "$x86_64" = "yes" ]; then loadlib2="-L$MPI_HOME/lib64 -lmpi -lmpiif -lmpigi -lrt" fppflags="-I$MPI_HOME/include64 $fppflags -DMPI" else loadlib2="-L$MPI_HOME/lib -lmpi -lmpiif -lmpigi -lrt" fppflags="-I$MPI_HOME/include $fppflags -DMPI" fi loadlib="$loadlib $loadlib2" ;; none) # Nothing to do ;; *) echo "FIXME: add support for parallel flag $parallel" exit 1 ;; esac #------------------------------------------------------------------------------ # Make some needed directories #------------------------------------------------------------------------------ cd .. if [ ! -x bin ]; then mkdir bin fi if [ ! -x lib ]; then mkdir lib fi if [ ! -x include ]; then mkdir include fi if [ ! -x exe ]; then ln -s bin exe fi cd src #------------------------------------------------------------------------------ # Finally, write out the config_amber.h file: #------------------------------------------------------------------------------ cat < config_amber.h #============================================================================== # AMBER Makefile configuration for compiler/architecture: $arch # Generated via command: $command # # Configuration script written mainly by Joe Krahn, Scott Brozell, and # Dave Case, with contributions from lots of people. #============================================================================== #------------------------------------------------------------------------------ # AMBERBUILDFLAGS provides a hook into the build process for installers; # for example, to build debug versions of the amber programs # make -e AMBERBUILDFLAGS="-DDEBUG -g" #------------------------------------------------------------------------------ AMBERBUILDFLAGS= #------------------------------------------------------------------------------ # LOCALFLAGS is intended for program specific modifications to the # Fortran build process and may be modified by the program's local makefile #------------------------------------------------------------------------------ LOCALFLAGS=$localflags #------------------------------------------------------------------------------ # Availability and method of delivery of math and optional libraries #------------------------------------------------------------------------------ USE_BLASLIB=\$($use_blas) USE_LAPACKLIB=\$($use_lapack) #------------------------------------------------------------------------------ # C compiler #------------------------------------------------------------------------------ CC= $cc CPLUSPLUS=$cplusplus CFLAGS=$cflags \$(AMBERBUILDFLAGS) CPPFLAGS=$cppflags \$(AMBERBUILDFLAGS) #------------------------------------------------------------------------------ # Fortran preprocessing and compiler. # FPPFLAGS holds the main Fortran options, such as whether MPI is used. #------------------------------------------------------------------------------ FPPFLAGS= $fppflags \$(AMBERBUILDFLAGS) FPP= $fpp \$(FPPFLAGS) FC= $fc FFLAGS= $fflags \$(LOCALFLAGS) \$(AMBERBUILDFLAGS) FOPTFLAGS= $foptflags \$(LOCALFLAGS) \$(AMBERBUILDFLAGS) FREEFORMAT_FLAG= $freeformat_flag #------------------------------------------------------------------------------ # Loader: #------------------------------------------------------------------------------ LOAD= $fc $static_flag $openmp_flag \$(LOCALFLAGS) \$(AMBERBUILDFLAGS) LOADCC= $loadcc \$(LOCALFLAGS) \$(AMBERBUILDFLAGS) LOADLIB= $loadlib LM= $lm XHOME= $xhome XLIBS= $xlibs #------------------------------------------------------------------------------ # Other stuff: #------------------------------------------------------------------------------ .SUFFIXES: .f90 EMPTY= AR=$ar M4=$m4 RANLIB=$ranlib SFX=$sfx NETCDF=$netcdf NETCDFLIB=$netcdflib MODULEDIR=$moduledir testsanderDIVCON=$testsanderDIVCON INCDIVCON=$incdivcon LIBDIVCON=$libdivcon # Location for executables, etc: BINDIR=$AMBERHOME/bin LIBDIR=$AMBERHOME/lib INCDIR=$AMBERHOME/include DATDIR=$AMBERHOME/dat # default rules for Fortran and C compilation: .f.o: \$< \$(FPP) \$< > _\$< \$(FC) -c \$(FFLAGS) -o \$@ _\$< .c.o: \$(CC) -c \$(CFLAGS) \$(CPPFLAGS) -o \$@ \$< EOD echo " " echo "The configuration file, config_amber.h, was successfully created." echo " " exit