diff --git a/Jenkinsfile b/Jenkinsfile index 079b0a25e6..ddd1c4757b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -129,7 +129,7 @@ pipeline { steps { unstash "source" - sh "./configure --with-netcdf --with-fftw3 -mpi gnu" + sh "./configure --with-netcdf --with-fftw3 -mpi --buildlibs gnu" sh "make -j4 install" sh "make -e DO_PARALLEL='mpiexec -n 2' check" sh "make -e DO_PARALLEL='mpiexec -n 4' check" diff --git a/README.md b/README.md index b8894d233b..db7b21971f 100644 --- a/README.md +++ b/README.md @@ -92,11 +92,16 @@ CPPTRAJ also makes use of the following libraries that are bundled with CPPTRAJ. CPPTRAJ also uses the PCG32 and Xoshiro 128++ pseudo-random number generators. `./configure gnu` should be adequate to set up compilation for most systems. -For systems without BLAS/LAPACK/ARPACK and/or NetCDF libraries installed, +For systems without BLAS/LAPACK, FFTW, and/or NetCDF libraries installed, the `-amberlib` flag can be specified to use the ones already compiled in an AmberTools installation (`$AMBERHOME` must be set), e.g. -`./configure -amberlib gnu`. C++11 support is required to enable particle mesh -Ewald (PME) calculation support. +`./configure -amberlib gnu`. If enabled libraries are not present, CPPTRAJ's +configure can attempt to download and install them into $CPPTRAJHOME. By default +CPPTRAJ will ask if these should be installed; the '--buildlibs' option can +be used to try to automatically install any missing enabled library. To prevent +CPPTRAJ from asking about building external libraries, use the '--nobuildlibs' +option. +C++11 support is required to enable particle mesh Ewald (PME) calculation support. For multicore systems, the `-openmp` flag can be specified to enable OpenMP parallelization, e.g. `./configure -openmp gnu`. diff --git a/configure b/configure index cd393c0e7e..49026419f6 100755 --- a/configure +++ b/configure @@ -3,6 +3,7 @@ # Daniel R. Roe # 2010-11-18 # Rewritten 2018-01-25 (getting old...) +# Support for getting and building external libraries (get_library.sh) added 2021-03-03 # This script will determine compiler and linker flags based on # desired user-specified options. Generates config.h, which is # used by src/Makefile. @@ -45,6 +46,8 @@ UsageFull() { echo " --with-= : Use library in specified directory." echo " -l= : Use specified library file." echo " -no : Disable library." + echo " --buildlibs : Attempt to build enabled libraries if they are not present." + echo " --nobuildlibs : Do not asking about building enabled libraries." echo " Libraries: netcdf pnetcdf zlib bzlib blas lapack arpack fftw3 readline sanderlib xdrfile tng openmm" echo " Note: pnetcdf is needed for writing NetCDF trajectories with MPI." echo " LINKING OPTIONS" @@ -94,22 +97,61 @@ UsageFull() { } # ----- Script variables ------------------------------------------------------- -WORKDIR=`dirname $0` # Working directory of the configure script -COMPILERS='' # User-specified compiler suite to use. -FLINK='' # Flag for linking in Fortran code -REQUIRES_FLINK=0 # If 1 FLINK flag required during link phase -REQUIRES_PTHREAD=0 # If 1 -lpthread required during link phase -C11FLAG='' # Flag for compiling C++11 code -C11_SUPPORT='yes' # Support C++11 code -SHARED_SUFFIX='' # Suffix for shared libraries -DBFLAG='' # Flag for turning on compiler debug symbols -DIRECTIVES='' # Common compiler directives -INCLUDE='' # Library header include line -SFX='' # Binary suffix -EXE='' # Binary executable suffix +WORKDIR=`dirname $0` # Working directory of the configure script +COMPILERS='' # User-specified compiler suite to use. +FLINK='' # Flag for linking in Fortran code +REQUIRES_FLINK=0 # If 1 FLINK flag required during link phase +REQUIRES_PTHREAD=0 # If 1 -lpthread required during link phase +C11FLAG='' # Flag for compiling C++11 code +C11_SUPPORT='yes' # Support C++11 code +SHARED_SUFFIX='' # Suffix for shared libraries +DBFLAG='' # Flag for turning on compiler debug symbols +DIRECTIVES='' # Common compiler directives +INCLUDE='' # Library header include line +SFX='' # Binary suffix +EXE='' # Binary executable suffix +REBUILDOPT='' # Can be set to --rebuild and passed to get_library.sh +BUILDTESTOPT='silent' # Set to blank to avoid asking about building libraries +INSTALL_DAT='install_dat' # Target for installing data directory COMPERR='cpptrajcfg.compile.err' COMPOUT='cpptrajcfg.compile.out' +# ----- Variables for downloading libraries ------ +NETCDF_SRCTAR='netcdf-4.6.1.tar.gz' +NETCDF_SRCDIR='netcdf-4.6.1' +NETCDF_URL="ftp://ftp.unidata.ucar.edu/pub/netcdf/$NETCDF_SRCTAR" +NETCDF_OPTS=" --disable-netcdf-4 --disable-dap $windows_hostflag --disable-shared --disable-doxygen" + +BZIP2_SRCTAR='bzip2-latest.tar.gz' +BZIP2_SRCDIR='' +BZIP2_URL="https://www.sourceware.org/pub/bzip2/$BZIP2_SRCTAR" +BZIP2_OPTS='' + +ZLIB_SRCTAR='zlib-1.2.11.tar.gz' +ZLIB_SRCDIR='zlib-1.2.11' +ZLIB_URL="https://zlib.net/$ZLIB_SRCTAR" +ZLIB_OPTS='' + +OPENBLAS_SRCTAR='OpenBLAS-0.3.13.tar.gz' +OPENBLAS_SRCDIR='OpenBLAS-0.3.13' +OPENBLAS_URL="https://github.com/xianyi/OpenBLAS/releases/download/v0.3.13/$OPENBLAS_SRCTAR" +OPENBLAS_OPTS='' + +LAPACK_SRCTAR='v3.9.0.tar.gz' +LAPACK_SRCDIR='lapack-3.9.0' +LAPACK_URL="https://github.com/Reference-LAPACK/lapack/archive/$LAPACK_SRCTAR" +LAPACK_OPTS='' + +PNETCDF_SRCTAR='pnetcdf-1.12.2.tar.gz' +PNETCDF_SRCDIR='' +PNETCDF_URL="https://parallel-netcdf.github.io/Release/$PNETCDF_SRCTAR" +PNETCDF_OPTS='--disable-fortran --disable-cxx' + +FFTW_SRCTAR='fftw-3.3.9.tar.gz' +FFTW_SRCDIR='fftw-3.3.9' +FFTW_URL="ftp://ftp.fftw.org/pub/fftw/$FFTW_SRCTAR" +FFTW_OPTS='--enable-threads --with-combined-threads --with-pic --disable-fortran' + # ----- Configure options ------------------------ USE_CMAKE=0 # 1 = use cmake for build COMPILE_VERBOSE=0 # 1 = show details during compile @@ -117,7 +159,7 @@ USE_MPI=0 # 0 = no MPI, 1 = mpicc etc, 2 = mpiicc etc USE_OPENMP=0 # 0 = no OpenMP, 1 = OpenMP USE_CUDA=0 # 0 = no CUDA, 1 = CUDA USE_OPT=1 # 0 = no optimization, 1 = use compiler optimizations, 2 = optimize/tune. -BLAS_TYPE='other' # other=normal BLAS, mkl, libsci (cray) etc +BLAS_TYPE='other' # none|mkl|libsci(cray)|openblas|macAccelerate|other=normal BLAS MKL_TYPE='mkl' # mkl = -mkl for Intel compilers, line = link-line advisor style MKL_FFTW='' # If yes, use FFTW from MKL if not otherwise specified. If 'no' prevent this. USE_DEBUG=0 # 0 = no debug info, 1 = enable compiler debug info @@ -125,6 +167,7 @@ USE_STATIC=0 # 0 = dynamic linking, 1 = static linking, 2 = static link for USE_SHARED=0 # 1 = Use flag for position-independent code (required for libcpptraj) USE_PROFILE=0 # 0 = no profiling, 1 = C++ profiling, 2 = GLIBC profiling, 3 = Intel Vtune USE_AMBERLIB=0 # 1 = Use AMBERHOME to fill in NetCDF/BLAS/LAPACK/ARPACK as needed +BUILD_LIBS=0 # 1 = Means automatically say yes to building enabled libs when not present. USE_SINGLEENSEMBLE=0 # Enable support for single ensemble trajectories USE_CPPTRAJDEBUG=0 # Enable internal cpptraj debug flags @@ -139,6 +182,8 @@ LFS='-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64' CPPTRAJHOME='' CPPTRAJBIN='' CPPTRAJLIB='' +CPPTRAJINC='' +CPPTRAJDAT='' # ----- External Libraries ----------------------- # Library indices @@ -368,16 +413,25 @@ CheckLibraryKeys() { # Test compile and run a program. # ARGS: [noexe|silent|quiet] [] TestProgram() { + if [ $BUILD_LIBS -eq 0 ] ; then + REBUILDOPT='' + else + REBUILDOPT='--rebuild' + fi if [ "$1" = 'noexe' ] ; then + # Output messages, do not execute compiled binary silent=3 shift elif [ "$1" = 'quiet' ] ; then + # Output nothing. silent=2 shift elif [ "$1" = 'silent' ] ; then + # Output messages but return 1 instead of exit 1 silent=1 shift else + # Output message; exit on error silent=0 fi desc="$1" @@ -397,6 +451,8 @@ TestProgram() { cat $COMPERR >&2 exit 1 else + COMPILE_ERROR_LINE=$COMPILELINE + COMPILE_ERROR_MESSAGE=`cat $COMPERR` rm $COMPERR $COMPOUT return 1 fi @@ -414,6 +470,26 @@ TestProgram() { return 0 } +# Error message for TestProgram silent +TestProgErr() { + desc=$1 + echo "Failed." + ErrMsg "$1 build/link failed: $COMPILE_ERROR_LINE" + ErrMsg "Error message follows:" + ErrMsg "$COMPILE_ERROR_MESSAGE" + exit 1 +} + +# This is invoked if linking a bundled library fails. +CheckRebuild() { + desc=$1 + libfile=$2 + if [ -z "$REBUILDOPT" -a -f "$libfile" ] ; then + echo "Bundled $desc present but needs to be rebuilt." + REBUILDOPT='--rebuild' + fi +} + # ===== LIBRARY TESTS ========================================================== TestBzlib() { cat > testp.cpp <' or '-lblas='" fi @@ -1104,6 +1375,16 @@ SetupCompilers() { FLINK='-lifport -lifcore' picflag="-fpic" C11FLAG='-std=c++11' + # Check for 'error: identifier "_LIB_VERSION_TYPE" is undefined' + cat > testp.cpp < +int main() { double x; x = sqrt(2); return 0; } +EOF + TestProgram quiet " Testing Intel compatibility with C headers" "$CXX" "$CXXFLAGS" testp.cpp + if [ $? -ne 0 ] ; then + CFLAGS="-D__PURE_INTEL_C99_HEADERS__ $CFLAGS" + CXXFLAGS="-D__PURE_INTEL_C99_HEADERS__ $CXXFLAGS" + fi ;; "pgi" ) if [ -z "$CC" ]; then CC=pgcc; fi @@ -1467,6 +1748,10 @@ BasicChecks() { CPPTRAJHOME=`pwd` CPPTRAJBIN=$CPPTRAJHOME/bin CPPTRAJLIB=$CPPTRAJHOME/lib + CPPTRAJINC=$CPPTRAJHOME/include + CPPTRAJDAT=$CPPTRAJHOME/dat + # No need to install data directory + INSTALL_DAT='' elif [ ! -d "$CPPTRAJHOME" ] ; then Err "Install directory '$CPPTRAJHOME' does not exist." fi @@ -1484,6 +1769,8 @@ BasicChecks() { if [ "${LIB_STAT[$LPARANC]}" != 'off' -a $USE_MPI -eq 0 ] ; then WrnMsg "Parallel NetCDF enabled but MPI not specified. Assuming '-mpi'." USE_MPI=1 + elif [ $USE_MPI -ne 0 -a "${LIB_STAT[$LPARANC]}" = 'off' ] ; then + LIB_STAT[$LPARANC]='enabled' fi # If we are using the bundled ARPACK then we will need C++/Fortran linking. if [ "${LIB_STAT[$LARPACK]}" = 'bundled' ] ; then @@ -1915,6 +2202,8 @@ while [ ! -z "$1" ] ; do '-nomathlib' ) BLAS_TYPE='none' ;; '--requires-flink' ) REQUIRES_FLINK=1 ;; '--requires-pthread') REQUIRES_PTHREAD=1 ;; + '--buildlibs' ) BUILD_LIBS=1 ;; + '--nobuildlibs' ) BUILD_LIBS=0 ; BUILDTESTOPT='' ;; # Install options '--compile-verbose' ) COMPILE_VERBOSE=1 ;; '-noclean' ) CLEAN='no' ;; @@ -1923,6 +2212,8 @@ while [ ! -z "$1" ] ; do CPPTRAJHOME=$VALUE CPPTRAJBIN=$VALUE/bin CPPTRAJLIB=$VALUE/lib + CPPTRAJINC=$VALUE/include + CPPTRAJDAT=$VALUE/dat ;; # Hidden debug options '--debug-parallel' ) DIRECTIVES="$DIRECTIVES -DPARALLEL_DEBUG_VERBOSE" ;; @@ -2094,7 +2385,7 @@ fi CPPTRAJ_TARGET="" LIBCPPTRAJ_TARGET="" NPROC_TARGET="" -INSTALL_TARGETS="" +INSTALL_TARGETS="$INSTALL_DAT" # Always build cpptraj CPPTRAJ_TARGET=cpptraj$SFX$EXE INSTALL_TARGETS=$INSTALL_TARGETS" install_cpptraj" @@ -2157,6 +2448,8 @@ cat >> config.h <> $external_config + echo "ZLIB_INCL=${LIB_INCL[$LZIP]}" >> $external_config fi # ----- Create directories if necessary ---------- @@ -2214,6 +2508,9 @@ fi if [ ! -e "$CPPTRAJLIB" ] ; then mkdir "$CPPTRAJLIB" fi +if [ ! -e "$CPPTRAJDAT" ] ; then + mkdir "$CPPTRAJDAT" +fi # ----- Create a resource file. ------------------ # If PERFORM_CHECKS is 'no' assume we are in AmberTools, no resource file needed. diff --git a/get_library.sh b/get_library.sh new file mode 100755 index 0000000000..d7c71b01d4 --- /dev/null +++ b/get_library.sh @@ -0,0 +1,229 @@ +#!/bin/bash +# Companion script to CPPTRAJ 'configure' script. +# Responsible for downloading, unpacking, configuring, and compiling external libraries. +# Daniel R. Roe +# 2021-03-03 + +WORKDIR=`pwd` + +# Attempt to download and install a copy of library +if [ -z "$SRCTAR" -o -z "$URL" -o -z "$LIBNAME" ] ; then + echo "Error: Script variables are empty." + exit 1 +fi + +# Check if --rebuild specified +REBUILD=0 +if [ "$1" == '--rebuild' ] ; then + REBUILD=1 + shift +fi + +# First ask if we want to get the library +if [ $REBUILD -eq 0 ] ; then + echo -n "Should CPPTRAJ attempt to build its own $LIBNAME? {y|n}: " + read yesno + while [ "$yesno" != 'y' -a "$yesno" != 'n' ] ; do + echo -n " Please enter 'y' or 'n': " + read yesno + done + if [ "$yesno" = 'n' ] ; then + exit 1 + fi +fi + +# Get configure options +CONFIGOPTS='' +while [ ! -z "$1" ] ; do + CONFIGOPTS="$CONFIGOPTS $1" + shift +done + +#echo " CONFIGOPTS: $CONFIGOPTS" + +CONFIGURE_LOG=$WORKDIR/$LIBNAME"_config.log" +COMPILE_LOG=$WORKDIR/$LIBNAME"_compile.log" + +# Get library if necessary +if [ ! -f "$SRCTAR" ] ; then + echo " Downloading $LIBNAME..." + WGET=`which wget` + + if [ -z "$WGET" ] ; then + echo "Error: 'wget' not found. Cannot download $LIBNAME" + exit 1 + fi + + $WGET $URL + if [ $? -ne 0 -o ! -f "$SRCTAR" ] ; then + echo "Error: Could not download $URL" + exit 1 + fi +fi + +# Get SRCDIR if necessary +if [ -z "$SRCDIR" ] ; then + FIRSTFILE=`tar -tzf $SRCTAR | head -1` + if [ ! -z "$FIRSTFILE" ] ; then + SRCDIR=`dirname $FIRSTFILE` + if [ "$SRCDIR" = '.' ] ; then + SRCDIR=$FIRSTFILE + fi + fi +fi + +# Unpack +if [ -z "$SRCDIR" ] ; then + echo "Error: SRCDIR is empty." + exit 1 +fi +if [ ! -d "$SRCDIR" ] ; then + echo " Unpacking $LIBNAME..." + tar -zxf $SRCTAR + if [ $? -ne 0 -o ! -d "$SRCDIR" ] ; then + echo "Error: Could not unpack $SRCTAR" + exit 1 + fi +fi +if [ "$SRCDIR" = '.' -o ! -d "$SRCDIR" ] ; then + echo "Error: $SRCDIR is not a directory." + exit 1 +fi +cd $SRCDIR + +# Compiler/library-specific modifications +MAKE_TARGET='' +if [ -f 'make.inc' ] ; then + rm 'make.inc' +fi +if [ "$LIBNAME" = 'lapack' ] ; then + MAKE_TARGET='blaslib lapacklib' + lapackflags='' + if [ "$FC" = 'gfortran' ] ; then + lapackflags='-frecursive' + fi + # LAPACK has no configure; requires make.inc + cat > make.inc < $CONFIGURE_LOG 2>&1 + if [ $? -ne 0 ] ; then + echo "Failed." + echo "Check $CONFIGURE_LOG for errors." + exit 1 + fi +elif [ -f 'Makefile' ] ; then + # No configure - try to modify Makefile on the fly. + if [ ! -f 'Makefile.original' ] ; then + cp Makefile Makefile.original + fi + awk -v cc="$CC" -v cflags="$CFLAGS" -v fc="$FC" -v fflags="$FFLAGS" -v prefix="$PREFIX" '{ + if (index($1,"CC=")!=0) + printf("CC=%s\n", cc); + else if (index($1,"FC=")!=0) + printf("FC=%s\n", fc); + else if (index($1,"CFLAGS=")!=0) + printf("CFLAGS=%s\n", cflags); + else if (index($1,"FFLAGS=")!=0) + printf("FFLAGS=%s\n", fflags); + else if (index($1,"PREFIX=")!=0) + printf("PREFIX=%s\n", prefix); + else + print $0; + }' Makefile.original > Makefile + if [ $? -ne 0 ] ; then + exit 1 + fi +else + echo "Error: $LIBNAME has no 'configure' or 'Makefile'." + exit 1 +fi +echo "Success." + +# Determine make command +if [ -z "$MAKE_COMMAND" ] ; then + NPROC=`nproc` + if [ -z "$NPROC" ] ; then + MAKE_COMMAND='make' + elif [ $NPROC -le 2 ] ; then + MAKE_COMMAND='make' + else + HALF=`echo "$NPROC / 2" | bc` + MAKE_COMMAND="make -j$HALF" + fi + echo " MAKE_COMMAND is not set; set to '$MAKE_COMMAND'" +fi + +# Build +echo -n " Compiling $LIBNAME (may be time-consuming)... " +make clean > $COMPILE_LOG 2>&1 +$MAKE_COMMAND $MAKE_TARGET > $COMPILE_LOG 2>&1 +if [ $? -ne 0 ] ; then + echo "Build failed." + echo "Check $COMPILE_LOG for errors." + exit 1 +fi + +# Install +if [ "$LIBNAME" = 'lapack' ] ; then + # Only made blas and lapack libraries; need to move them manually + if [ -f 'BLAS/SRC/libblas.a' ] ; then + blaslib=BLAS/SRC/libblas.a + else + echo "Error: BLAS not made." + exit 1 + fi + if [ -f 'liblapack.a' ] ; then + lapacklib=liblapack.a + elif [ -f 'SRC/liblapack.a' ] ; then + lapacklib=SRC/liblapack.a + else + echo "Error: LAPACK not made." + exit 1 + fi + mv $blaslib $lapacklib $PREFIX/lib/ +else + make install >> $COMPILE_LOG 2>&1 +fi +if [ $? -ne 0 ] ; then + echo "Install failed." + echo "Check $COMPILE_LOG for errors." + exit 1 +fi + +echo "Success." + +exit 0 diff --git a/src/Makefile b/src/Makefile index d33588d468..5299508d59 100644 --- a/src/Makefile +++ b/src/Makefile @@ -11,7 +11,7 @@ OBJECTS=$(SOURCES:.cpp=.o) $(CSOURCES:.c=.o) all: cpptraj$(SFX)$(EXE) # Install all targets -install: $(INSTALL_TARGETS) +install: $(INSTALL_TARGETS) # Cpptraj ------------------------------ install_cpptraj: cpptraj$(SFX)$(EXE) @@ -30,6 +30,13 @@ libcpptraj: $(LIBCPPTRAJ_TARGET) $(CPPTRAJLIB)/libcpptraj$(SHARED_SUFFIX): $(LIBCPPTRAJ_OBJECTS) $(FFT_TARGET) $(CUDA_TARGET) $(XDRFILE_TARGET) $(ARPACK_TARGET) $(TNGFILE_TARGET) $(CXX) -shared -o $(CPPTRAJLIB)/libcpptraj$(SHARED_SUFFIX) $(LIBCPPTRAJ_OBJECTS) $(FFT_TARGET) $(CUDA_TARGET) $(CPPTRAJ_LIB) $(LDFLAGS) +# Data directory ----------------------- +install_dat: + cp ../dat/ATOMTYPE_CHECK.TAB $(CPPTRAJDAT)/ + cp ../dat/BONDTYPE_CHECK.TAB $(CPPTRAJDAT)/ + cp ../dat/Karplus.txt $(CPPTRAJDAT)/ + cp ../dat/README $(CPPTRAJDAT)/ + # Static libraries --------------------- #$(CPPTRAJLIB)/libcpptraj.a: $(LIBCPPTRAJ_OBJECTS) $(FFT_TARGET) $(CUDA_TARGET) # ar rv $(CPPTRAJLIB)/libcpptraj.a $(LIBCPPTRAJ_OBJECTS) $(FFT_TARGET) $(CUDA_TARGET) @@ -117,7 +124,20 @@ clean: cd cuda_kernels && $(MAKE) clean cd tng && $(MAKE) clean -uninstall: +uninstall_lib: + $(DEL_FILE) $(CPPTRAJLIB)/*.a + $(DEL_FILE) $(CPPTRAJLIB)/*.la + $(DEL_FILE) $(CPPTRAJLIB)/*.so* + $(DEL_FILE) $(CPPTRAJLIB)/*.settings + $(DEL_FILE) -r $(CPPTRAJLIB)/cmake + $(DEL_FILE) -r $(CPPTRAJLIB)/pkgconfig + +uninstall_inc: + $(DEL_FILE) $(CPPTRAJINC)/*.h + $(DEL_FILE) $(CPPTRAJINC)/*.f + $(DEL_FILE) $(CPPTRAJINC)/*.f03 + +uninstall: uninstall_lib uninstall_inc $(DEL_FILE) $(CPPTRAJBIN)/cpptraj$(SFX)$(EXE) $(DEL_FILE) $(CPPTRAJLIB)/libcpptraj$(SHARED_SUFFIX) cd readline && make uninstall diff --git a/src/tng/Makefile b/src/tng/Makefile index d24a73f647..98c5234a7c 100644 --- a/src/tng/Makefile +++ b/src/tng/Makefile @@ -1,7 +1,7 @@ # Makefile for TNG bundled with cpptraj include ../../external.config.h -CFLAGS += -I . +CFLAGS += -I . $(ZLIB_INCL) # Variables DEL_FILE = /bin/rm -f diff --git a/src/vmdplugin/dtrplugin.cpp b/src/vmdplugin/dtrplugin.cpp index 9fba377ac2..cdaa7ff3ea 100644 --- a/src/vmdplugin/dtrplugin.cpp +++ b/src/vmdplugin/dtrplugin.cpp @@ -75,6 +75,14 @@ static bool badversion(const std::string& version) { return version != SERIALIZED_VERSION; } +#ifndef M_PI +#define M_PI (3.1415926535897932385) +#endif + +#ifndef M_PI_2 +#define M_PI_2 (1.5707963267948966192) +#endif + #ifndef _WIN32 static const char s_sep = '/'; #include @@ -95,8 +103,6 @@ static const char s_sep = '/'; #else /// windows version -#define M_PI (3.1415926535897932385) -#define M_PI_2 (1.5707963267948966192) #ifndef S_ISREG #define S_ISREG(x) (((x) & S_IFMT) == S_IFREG) diff --git a/test/MasterTest.sh b/test/MasterTest.sh index 669c8579ce..8fe08ae930 100644 --- a/test/MasterTest.sh +++ b/test/MasterTest.sh @@ -838,7 +838,7 @@ SetBinaries() { if [ $STANDALONE -eq 0 ] ; then CPPTRAJ_NDIFF=$DIRPREFIX/test/ndiff.awk else - CPPTRAJ_NDIFF=$DIRPREFIX/util/ndiff/ndiff.awk + CPPTRAJ_NDIFF=$CPPTRAJ_TEST_ROOT/../util/ndiff/ndiff.awk fi if [ ! -f "$CPPTRAJ_NDIFF" ] ; then ErrMsg "'ndiff.awk' not present: $CPPTRAJ_NDIFF" @@ -852,7 +852,7 @@ SetBinaries() { if [ $STANDALONE -eq 0 ] ; then CPPTRAJ_NPROC=$DIRPREFIX/AmberTools/test/numprocs else - CPPTRAJ_NPROC=$DIRPREFIX/test/nproc + CPPTRAJ_NPROC=$CPPTRAJ_TEST_ROOT/nproc fi if [ -z "$CPPTRAJ_NPROC" ] ; then ErrMsg "Error: nproc $CPPTRAJ_NPROC not found." @@ -889,8 +889,8 @@ SetBinaries() { # directories the path needs to be incremented one dir up. if [ "$PATH_TYPE" = 'relative' -a "$CPPTRAJ_TEST_MODE" = 'master' ] ; then CPPTRAJ="../$CPPTRAJ" - CPPTRAJ_NDIFF="../$CPPTRAJ_NDIFF" - CPPTRAJ_NPROC="../$CPPTRAJ_NPROC" + # CPPTRAJ_NDIFF="../$CPPTRAJ_NDIFF" + # CPPTRAJ_NPROC="../$CPPTRAJ_NPROC" fi } @@ -1205,6 +1205,14 @@ if [ -z "$CPPTRAJ_TEST_SETUP" ] ; then #echo "DEBUG: Initial test setup." # MasterTest.sh has not been called yet; set up test environment. export CPPTRAJ_TEST_ROOT=`pwd` + # If invocation is "./RunTest.sh", individual test dir. If "./CpptrajTest.sh", all tests. + if [ "$0" = './RunTest.sh' ] ; then + CPPTRAJ_TEST_ROOT=`dirname $CPPTRAJ_TEST_ROOT` + elif [ "$0" != './CpptrajTest.sh' ] ; then + ErrMsg "Unknown test invocation. Expected RunTest.sh or CpptrajTest.sh, got $0" + exit 1 + fi + #echo "DEBUG: CPPTRAJ_TEST_ROOT= $CPPTRAJ_TEST_ROOT $0" # If CPPTRAJ_TEST_OS is not set, try to determine. if [ -z "$CPPTRAJ_TEST_OS" ] ; then export CPPTRAJ_TEST_OS=`uname -s | awk '{print $1}'`