From eee44923106e521367cdb242ce3c74e2a7a36ba1 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sun, 28 Feb 2021 12:53:38 -0500 Subject: [PATCH 01/52] Start adding support for automatically getting and building netcdf --- configure | 26 +++++++++++++++++++++++++- get_netcdf.sh | 14 ++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 get_netcdf.sh diff --git a/configure b/configure index cd393c0e7e..319c2f4070 100755 --- a/configure +++ b/configure @@ -440,7 +440,31 @@ TestNetcdf() { void unused() {int ncid; nc_open("foo.nc", 0, &ncid);} int main() { printf("Testing\n"); printf("%s\n",nc_strerror(0)); return 0; } EOF - TestProgram " Checking NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LNETCDF]}" testp.cpp "${LIB_FLAG[$LNETCDF]}" + TestProgram silent " Checking NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LNETCDF]}" testp.cpp "${LIB_FLAG[$LNETCDF]}" + if [ $? -ne 0 ] ; then + # Should we try to get netcdf? + if [ "${LIB_STAT[$LNETCDF]}" = 'enabled' ] ; then + echo "No NetCDF found; should CPPTRAJ try to download and compile it? {y|n}: " + read yesno + while [ "$yesno" != 'y' -a "$yesno" ! = 'n' ] ; do + echo " Please enter 'y' or 'n': " + read yesno + done + if [ "$yesno" = 'y' ] ; then + CC=$CC CFLAGS=$CFLAGS ./get_netcdf.sh + if [ $? -ne 0 ] ; then + echo "Getting NetCDF failed." + exit 1 + fi + else + echo "No NetCDF. Configure failed." + exit 1 + fi + else + echo "Could not build/link with NetCDF." + exit 1 + fi + fi } TestPnetcdf() { diff --git a/get_netcdf.sh b/get_netcdf.sh new file mode 100644 index 0000000000..2826e0c032 --- /dev/null +++ b/get_netcdf.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# Attempt to download and install a copy of NetCDF +URL='ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.6.1.tar.gz' + +# Necessary programs +WGET=`which wget` + +if [ -z "$WGET" ] ; then + echo "Error: 'wget' not found. Cannot download NetCDF" + exit 1 +fi + + From 4f3dcce818c26c087f6921ec1acc5ea7dc546bca Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sun, 28 Feb 2021 13:25:33 -0500 Subject: [PATCH 02/52] Fix extra space, make executable --- configure | 2 +- get_netcdf.sh | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) mode change 100644 => 100755 get_netcdf.sh diff --git a/configure b/configure index 319c2f4070..37f2c202fa 100755 --- a/configure +++ b/configure @@ -446,7 +446,7 @@ EOF if [ "${LIB_STAT[$LNETCDF]}" = 'enabled' ] ; then echo "No NetCDF found; should CPPTRAJ try to download and compile it? {y|n}: " read yesno - while [ "$yesno" != 'y' -a "$yesno" ! = 'n' ] ; do + while [ "$yesno" != 'y' -a "$yesno" != 'n' ] ; do echo " Please enter 'y' or 'n': " read yesno done diff --git a/get_netcdf.sh b/get_netcdf.sh old mode 100644 new mode 100755 index 2826e0c032..03a4ba18c8 --- a/get_netcdf.sh +++ b/get_netcdf.sh @@ -11,4 +11,7 @@ if [ -z "$WGET" ] ; then exit 1 fi +echo "CC=$CC" +echo "CFLAGS=$CFLAGS" +exit 1 From 2d118e01dba33679df1bd117c9496c3a13582b11 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sun, 28 Feb 2021 13:50:58 -0500 Subject: [PATCH 03/52] Download and build netcdf automatically --- configure | 7 +++++- get_netcdf.sh | 67 +++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 66 insertions(+), 8 deletions(-) diff --git a/configure b/configure index 37f2c202fa..01499df823 100755 --- a/configure +++ b/configure @@ -451,11 +451,16 @@ EOF read yesno done if [ "$yesno" = 'y' ] ; then - CC=$CC CFLAGS=$CFLAGS ./get_netcdf.sh + PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS ./get_netcdf.sh if [ $? -ne 0 ] ; then echo "Getting NetCDF failed." exit 1 fi + LIB_STAT[$LNETCDF]='specified' + LIB_HOME[$LNETCDF]=$CPPTRAJHOME + LIB_FLAG[$LNETCDF]=$CPPTRAJHOME/lib/${LIB_STTC[$LNETCDF]} + LIB_INCL[$LNETCDF]="-I$CPPTRAJHOME/include" + TestProgram " Checking NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LNETCDF]}" testp.cpp "${LIB_FLAG[$LNETCDF]}" else echo "No NetCDF. Configure failed." exit 1 diff --git a/get_netcdf.sh b/get_netcdf.sh index 03a4ba18c8..486f367b16 100755 --- a/get_netcdf.sh +++ b/get_netcdf.sh @@ -1,17 +1,70 @@ #!/bin/bash +WORKDIR=`pwd` # Attempt to download and install a copy of NetCDF -URL='ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.6.1.tar.gz' +SRCTAR='netcdf-4.6.1.tar.gz' +SRCDIR='netcdf-4.6.1' +URL="ftp://ftp.unidata.ucar.edu/pub/netcdf/$SRCTAR" -# Necessary programs -WGET=`which wget` +# Get netcdf if necessary +if [ ! -f "$SRCTAR" ] ; then + WGET=`which wget` -if [ -z "$WGET" ] ; then - echo "Error: 'wget' not found. Cannot download NetCDF" - exit 1 + if [ -z "$WGET" ] ; then + echo "Error: 'wget' not found. Cannot download NetCDF" + exit 1 + fi + + $WGET $URL + if [ $? -ne 0 -o ! -f "$SRCTAR" ] ; then + echo "Error: Could not download $URL" + exit 1 + fi +fi + +# Unpack +if [ ! -d "$SRCDIR" ] ; then + tar -zxf $SRCTAR + if [ $? -ne 0 -o ! -d "$SRCDIR" ] ; then + echo "Error: Could not unpack $SRCTAR" + exit 1 + fi fi +cd $SRCDIR +# Configure +echo "" echo "CC=$CC" echo "CFLAGS=$CFLAGS" +echo "PREFIX=$PREFIX" +echo -n "Configuring NetCDF... " +./configure CC="$CC" CFLAGS="$CFLAGS" \ + --prefix=$PREFIX --disable-netcdf-4 --disable-dap $windows_hostflag \ + --disable-shared --disable-doxygen > ../netcdf_config.log 2>&1 +if [ $? -ne 0 ] ; then + echo "Failed." + echo "Check $WORKDIR/netcdf_config.log for errors." + exit 1 +else + echo "Success." +fi + +# Build +echo -n "Compiling NetCDF... " +make > ../netcdf_compile.log 2>&1 +if [ $? -ne 0 ] ; then + echo "Build failed." + echo "Check $WORKDIR/netcdf_compile.log for errors." + exit 1 +fi + +# Install +make install >> ../netcdf_compile.log 2>&1 +if [ $? -ne 0 ] ; then + echo "Install failed." + echo "Check $WORKDIR/netcdf_compile.log for errors." + exit 1 +fi +echo "Success." -exit 1 +exit 0 From 2f493ab8f5e744daa7efb0f91dfff112c10c7767 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sun, 28 Feb 2021 16:08:23 -0500 Subject: [PATCH 04/52] Fix netcdf specified build failure message --- configure | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 01499df823..e94e72a0bb 100755 --- a/configure +++ b/configure @@ -397,6 +397,8 @@ TestProgram() { cat $COMPERR >&2 exit 1 else + COMPILE_ERROR_LINE=$COMPILELINE + COMPILE_ERROR_MESSAGE=`cat $COMPERR` rm $COMPERR $COMPOUT return 1 fi @@ -466,7 +468,10 @@ EOF exit 1 fi else - echo "Could not build/link with NetCDF." + echo "Failed." + ErrMsg "NetCDF build/link failed: $COMPILE_ERROR_LINE" + echo "Error message follows:" + echo "$COMPILE_ERROR_MESSAGE" exit 1 fi fi From ca5610e5b660de2a85b35cf864ae5d731872b241 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sun, 28 Feb 2021 22:52:37 -0500 Subject: [PATCH 05/52] Move all logic for determining if and how netcdf will be built to configure. --- configure | 64 ++++++++++++++++++++++++++++++++++++--------------- get_netcdf.sh | 7 +++--- 2 files changed, 49 insertions(+), 22 deletions(-) diff --git a/configure b/configure index e94e72a0bb..00e6510e0e 100755 --- a/configure +++ b/configure @@ -110,6 +110,12 @@ EXE='' # Binary executable suffix 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" + + # ----- Configure options ------------------------ USE_CMAKE=0 # 1 = use cmake for build COMPILE_VERBOSE=0 # 1 = show details during compile @@ -444,30 +450,50 @@ int main() { printf("Testing\n"); printf("%s\n",nc_strerror(0)); return 0; } EOF TestProgram silent " Checking NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LNETCDF]}" testp.cpp "${LIB_FLAG[$LNETCDF]}" if [ $? -ne 0 ] ; then - # Should we try to get netcdf? if [ "${LIB_STAT[$LNETCDF]}" = 'enabled' ] ; then - echo "No NetCDF found; should CPPTRAJ try to download and compile it? {y|n}: " - read yesno - while [ "$yesno" != 'y' -a "$yesno" != 'n' ] ; do - echo " Please enter 'y' or 'n': " - read yesno - done - if [ "$yesno" = 'y' ] ; then - PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS ./get_netcdf.sh - if [ $? -ne 0 ] ; then - echo "Getting NetCDF failed." + LIB_STAT[$LNETCDF]='specified' + LIB_HOME[$LNETCDF]=$CPPTRAJHOME + LIB_FLAG[$LNETCDF]=$CPPTRAJHOME/lib/${LIB_STTC[$LNETCDF]} + LIB_INCL[$LNETCDF]="-I$CPPTRAJHOME/include" + # See if cpptraj previously downloaded netcdf + build_netcdf='yes' + if [ -d "$NETCDF_SRCDIR" ] ; then + # See if we can link to it + TestProgram silent " Checking bundled NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LNETCDF]}" testp.cpp "${LIB_FLAG[$LNETCDF]}" + if [ $? -eq 0 ] ; then + build_netcdf='built' + else + echo "Must be rebuilt." + fi + fi + if [ "$build_netcdf" = 'yes' ] ; then + # Should we try to get netcdf? + if [ ! -f "$NETCDF_SRCTAR" ] ; then + echo "No working NetCDF found; should CPPTRAJ try to download and compile it? {y|n}: " + read yesno + while [ "$yesno" != 'y' -a "$yesno" != 'n' ] ; do + echo " Please enter 'y' or 'n': " + read yesno + done + if [ "$yesno" = 'n' ] ; then + build_netcdf='no' + fi + fi + if [ "$build_netcdf" = 'yes' ] ; then + PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS \ + SRCDIR=$NETCDF_SRCDIR SRCTAR=$NETCDF_SRCTAR URL=$NETCDF_URL ./get_netcdf.sh + if [ $? -ne 0 ] ; then + ErrMsg "Building NetCDF failed." + exit 1 + fi + TestProgram " Checking built NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LNETCDF]}" testp.cpp "${LIB_FLAG[$LNETCDF]}" + else + ErrMsg "No NetCDF. Configure failed." exit 1 fi - LIB_STAT[$LNETCDF]='specified' - LIB_HOME[$LNETCDF]=$CPPTRAJHOME - LIB_FLAG[$LNETCDF]=$CPPTRAJHOME/lib/${LIB_STTC[$LNETCDF]} - LIB_INCL[$LNETCDF]="-I$CPPTRAJHOME/include" - TestProgram " Checking NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LNETCDF]}" testp.cpp "${LIB_FLAG[$LNETCDF]}" - else - echo "No NetCDF. Configure failed." - exit 1 fi else + # NetCDF specified but failed. echo "Failed." ErrMsg "NetCDF build/link failed: $COMPILE_ERROR_LINE" echo "Error message follows:" diff --git a/get_netcdf.sh b/get_netcdf.sh index 486f367b16..b6d266b4bd 100755 --- a/get_netcdf.sh +++ b/get_netcdf.sh @@ -2,9 +2,10 @@ WORKDIR=`pwd` # Attempt to download and install a copy of NetCDF -SRCTAR='netcdf-4.6.1.tar.gz' -SRCDIR='netcdf-4.6.1' -URL="ftp://ftp.unidata.ucar.edu/pub/netcdf/$SRCTAR" +if [ -z "$SRCTAR" -o -z "$SRCDIR" -o -z "$URL" ] ; then + echo "Error: Script variables are empty." + exit 1 +fi # Get netcdf if necessary if [ ! -f "$SRCTAR" ] ; then From e20002061b158b12f5b567d7e8ac77c3fc75f329 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Sun, 28 Feb 2021 23:00:58 -0500 Subject: [PATCH 06/52] Hide some debug info. Ensure clean is run before make --- get_netcdf.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/get_netcdf.sh b/get_netcdf.sh index b6d266b4bd..81f1540eba 100755 --- a/get_netcdf.sh +++ b/get_netcdf.sh @@ -34,10 +34,10 @@ fi cd $SRCDIR # Configure -echo "" -echo "CC=$CC" -echo "CFLAGS=$CFLAGS" -echo "PREFIX=$PREFIX" +#echo "" +#echo "CC=$CC" +#echo "CFLAGS=$CFLAGS" +#echo "PREFIX=$PREFIX" echo -n "Configuring NetCDF... " ./configure CC="$CC" CFLAGS="$CFLAGS" \ --prefix=$PREFIX --disable-netcdf-4 --disable-dap $windows_hostflag \ @@ -52,6 +52,7 @@ fi # Build echo -n "Compiling NetCDF... " +make clean > ../netcdf_compile.log 2>&1 make > ../netcdf_compile.log 2>&1 if [ $? -ne 0 ] ; then echo "Build failed." From becbe5659a8e7f81cfa16187b3b29fea5e667d03 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 1 Mar 2021 21:20:34 -0500 Subject: [PATCH 07/52] Make script more general so it can be potentially used for other libraries --- configure | 6 +++--- get_netcdf.sh | 40 +++++++++++++++++++++++++--------------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/configure b/configure index 00e6510e0e..ec8de31185 100755 --- a/configure +++ b/configure @@ -114,7 +114,7 @@ COMPOUT='cpptrajcfg.compile.out' 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" # ----- Configure options ------------------------ USE_CMAKE=0 # 1 = use cmake for build @@ -480,8 +480,8 @@ EOF fi fi if [ "$build_netcdf" = 'yes' ] ; then - PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS \ - SRCDIR=$NETCDF_SRCDIR SRCTAR=$NETCDF_SRCTAR URL=$NETCDF_URL ./get_netcdf.sh + PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS LIBNAME='netcdf' \ + SRCDIR=$NETCDF_SRCDIR SRCTAR=$NETCDF_SRCTAR URL=$NETCDF_URL ./get_netcdf.sh $NETCDF_OPTS if [ $? -ne 0 ] ; then ErrMsg "Building NetCDF failed." exit 1 diff --git a/get_netcdf.sh b/get_netcdf.sh index 81f1540eba..80b268d23d 100755 --- a/get_netcdf.sh +++ b/get_netcdf.sh @@ -1,18 +1,30 @@ #!/bin/bash WORKDIR=`pwd` -# Attempt to download and install a copy of NetCDF -if [ -z "$SRCTAR" -o -z "$SRCDIR" -o -z "$URL" ] ; then +# Attempt to download and install a copy of library +if [ -z "$SRCTAR" -o -z "$SRCDIR" -o -z "$URL" -o -z "$LIBNAME" ] ; then echo "Error: Script variables are empty." exit 1 fi -# Get netcdf if necessary +# 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 WGET=`which wget` if [ -z "$WGET" ] ; then - echo "Error: 'wget' not found. Cannot download NetCDF" + echo "Error: 'wget' not found. Cannot download $LIBNAME" exit 1 fi @@ -38,33 +50,31 @@ cd $SRCDIR #echo "CC=$CC" #echo "CFLAGS=$CFLAGS" #echo "PREFIX=$PREFIX" -echo -n "Configuring NetCDF... " -./configure CC="$CC" CFLAGS="$CFLAGS" \ - --prefix=$PREFIX --disable-netcdf-4 --disable-dap $windows_hostflag \ - --disable-shared --disable-doxygen > ../netcdf_config.log 2>&1 +echo -n "Configuring $LIBNAME... " +./configure CC="$CC" CFLAGS="$CFLAGS" --prefix=$PREFIX $CONFIGOPTS > $CONFIGURE_LOG 2>&1 if [ $? -ne 0 ] ; then echo "Failed." - echo "Check $WORKDIR/netcdf_config.log for errors." + echo "Check $CONFIGURE_LOG for errors." exit 1 else echo "Success." fi # Build -echo -n "Compiling NetCDF... " -make clean > ../netcdf_compile.log 2>&1 -make > ../netcdf_compile.log 2>&1 +echo -n "Compiling $LIBNAME... " +make clean > $COMPILE_LOG 2>&1 +make > $COMPILE_LOG 2>&1 if [ $? -ne 0 ] ; then echo "Build failed." - echo "Check $WORKDIR/netcdf_compile.log for errors." + echo "Check $COMPILE_LOG for errors." exit 1 fi # Install -make install >> ../netcdf_compile.log 2>&1 +make install >> $COMPILE_LOG 2>&1 if [ $? -ne 0 ] ; then echo "Install failed." - echo "Check $WORKDIR/netcdf_compile.log for errors." + echo "Check $COMPILE_LOG for errors." exit 1 fi echo "Success." From a0a0fea13ea114c44301bc4a6dc1ed6c9449e2f0 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 1 Mar 2021 21:21:19 -0500 Subject: [PATCH 08/52] Rename to make more general --- configure | 2 +- get_netcdf.sh => get_library.sh | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename get_netcdf.sh => get_library.sh (100%) diff --git a/configure b/configure index ec8de31185..e302ec1933 100755 --- a/configure +++ b/configure @@ -481,7 +481,7 @@ EOF fi if [ "$build_netcdf" = 'yes' ] ; then PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS LIBNAME='netcdf' \ - SRCDIR=$NETCDF_SRCDIR SRCTAR=$NETCDF_SRCTAR URL=$NETCDF_URL ./get_netcdf.sh $NETCDF_OPTS + SRCDIR=$NETCDF_SRCDIR SRCTAR=$NETCDF_SRCTAR URL=$NETCDF_URL ./get_library.sh $NETCDF_OPTS if [ $? -ne 0 ] ; then ErrMsg "Building NetCDF failed." exit 1 diff --git a/get_netcdf.sh b/get_library.sh similarity index 100% rename from get_netcdf.sh rename to get_library.sh From 809b4376a84465dc8adc9038dcf6b0dbe63652c2 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Mon, 1 Mar 2021 21:22:41 -0500 Subject: [PATCH 09/52] Add messages about downloading and unpacking --- get_library.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/get_library.sh b/get_library.sh index 80b268d23d..9ebd8808f3 100755 --- a/get_library.sh +++ b/get_library.sh @@ -21,6 +21,7 @@ COMPILE_LOG=$WORKDIR/$LIBNAME"_compile.log" # Get library if necessary if [ ! -f "$SRCTAR" ] ; then + echo "Downloading $LIBNAME..." WGET=`which wget` if [ -z "$WGET" ] ; then @@ -37,6 +38,7 @@ fi # Unpack if [ ! -d "$SRCDIR" ] ; then + echo "Unpacking $LIBNAME..." tar -zxf $SRCTAR if [ $? -ne 0 -o ! -d "$SRCDIR" ] ; then echo "Error: Could not unpack $SRCTAR" From e04a3472dc870cac9157496d583b8d02460ed0d4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 2 Mar 2021 10:50:11 -0500 Subject: [PATCH 10/52] Move question to get_library.sh --- configure | 25 ++++--------------------- get_library.sh | 12 ++++++++++++ 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/configure b/configure index e302ec1933..77872bd1d2 100755 --- a/configure +++ b/configure @@ -467,30 +467,13 @@ EOF fi fi if [ "$build_netcdf" = 'yes' ] ; then - # Should we try to get netcdf? - if [ ! -f "$NETCDF_SRCTAR" ] ; then - echo "No working NetCDF found; should CPPTRAJ try to download and compile it? {y|n}: " - read yesno - while [ "$yesno" != 'y' -a "$yesno" != 'n' ] ; do - echo " Please enter 'y' or 'n': " - read yesno - done - if [ "$yesno" = 'n' ] ; then - build_netcdf='no' - fi - fi - if [ "$build_netcdf" = 'yes' ] ; then - PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS LIBNAME='netcdf' \ + PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS LIBNAME='netcdf' \ SRCDIR=$NETCDF_SRCDIR SRCTAR=$NETCDF_SRCTAR URL=$NETCDF_URL ./get_library.sh $NETCDF_OPTS - if [ $? -ne 0 ] ; then - ErrMsg "Building NetCDF failed." - exit 1 - fi - TestProgram " Checking built NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LNETCDF]}" testp.cpp "${LIB_FLAG[$LNETCDF]}" - else - ErrMsg "No NetCDF. Configure failed." + if [ $? -ne 0 ] ; then + ErrMsg "Building NetCDF failed." exit 1 fi + TestProgram " Checking built NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LNETCDF]}" testp.cpp "${LIB_FLAG[$LNETCDF]}" fi else # NetCDF specified but failed. diff --git a/get_library.sh b/get_library.sh index 9ebd8808f3..8b6548cbe3 100755 --- a/get_library.sh +++ b/get_library.sh @@ -1,12 +1,24 @@ #!/bin/bash WORKDIR=`pwd` + # Attempt to download and install a copy of library if [ -z "$SRCTAR" -o -z "$SRCDIR" -o -z "$URL" -o -z "$LIBNAME" ] ; then echo "Error: Script variables are empty." exit 1 fi +# First ask if we want to get the library +echo "Should CPPTRAJ attempt to build its own $LIBNAME? {y|n}: " +read yesno +while [ "$yesno" != 'y' -a "$yesno" != 'n' ] ; do + echo " Please enter 'y' or 'n': " + read yesno +done +if [ "$yesno" = 'n' ] ; then + exit 1 +fi + # Get configure options CONFIGOPTS='' while [ ! -z "$1" ] ; do From 78ed802ce5316db7f3666cb0566ed7ef9c8e365e Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 2 Mar 2021 13:21:46 -0500 Subject: [PATCH 11/52] Change indents in get_library. Simplify logic for checking for bundled netcdf. --- configure | 17 +++++------------ get_library.sh | 12 ++++++------ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/configure b/configure index 77872bd1d2..9ead11b103 100755 --- a/configure +++ b/configure @@ -451,28 +451,21 @@ EOF TestProgram silent " Checking NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LNETCDF]}" testp.cpp "${LIB_FLAG[$LNETCDF]}" if [ $? -ne 0 ] ; then if [ "${LIB_STAT[$LNETCDF]}" = 'enabled' ] ; then + # See if there is already a version of NetCDF in CPPTRAJHOME LIB_STAT[$LNETCDF]='specified' LIB_HOME[$LNETCDF]=$CPPTRAJHOME LIB_FLAG[$LNETCDF]=$CPPTRAJHOME/lib/${LIB_STTC[$LNETCDF]} LIB_INCL[$LNETCDF]="-I$CPPTRAJHOME/include" - # See if cpptraj previously downloaded netcdf - build_netcdf='yes' - if [ -d "$NETCDF_SRCDIR" ] ; then - # See if we can link to it - TestProgram silent " Checking bundled NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LNETCDF]}" testp.cpp "${LIB_FLAG[$LNETCDF]}" - if [ $? -eq 0 ] ; then - build_netcdf='built' - else - echo "Must be rebuilt." - fi - fi - if [ "$build_netcdf" = 'yes' ] ; then + TestProgram silent " Checking for bundled NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LNETCDF]}" testp.cpp "${LIB_FLAG[$LNETCDF]}" + if [ $? -ne 0 ] ; then + # See if user would like to get netcdf PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS LIBNAME='netcdf' \ SRCDIR=$NETCDF_SRCDIR SRCTAR=$NETCDF_SRCTAR URL=$NETCDF_URL ./get_library.sh $NETCDF_OPTS if [ $? -ne 0 ] ; then ErrMsg "Building NetCDF failed." exit 1 fi + # Test the built netcdf TestProgram " Checking built NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LNETCDF]}" testp.cpp "${LIB_FLAG[$LNETCDF]}" fi else diff --git a/get_library.sh b/get_library.sh index 8b6548cbe3..505dadd542 100755 --- a/get_library.sh +++ b/get_library.sh @@ -12,7 +12,7 @@ fi echo "Should CPPTRAJ attempt to build its own $LIBNAME? {y|n}: " read yesno while [ "$yesno" != 'y' -a "$yesno" != 'n' ] ; do - echo " Please enter 'y' or 'n': " + echo " Please enter 'y' or 'n': " read yesno done if [ "$yesno" = 'n' ] ; then @@ -26,14 +26,14 @@ while [ ! -z "$1" ] ; do shift done -echo "CONFIGOPTS: $CONFIGOPTS" +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..." + echo " Downloading $LIBNAME..." WGET=`which wget` if [ -z "$WGET" ] ; then @@ -50,7 +50,7 @@ fi # Unpack if [ ! -d "$SRCDIR" ] ; then - echo "Unpacking $LIBNAME..." + echo " Unpacking $LIBNAME..." tar -zxf $SRCTAR if [ $? -ne 0 -o ! -d "$SRCDIR" ] ; then echo "Error: Could not unpack $SRCTAR" @@ -64,7 +64,7 @@ cd $SRCDIR #echo "CC=$CC" #echo "CFLAGS=$CFLAGS" #echo "PREFIX=$PREFIX" -echo -n "Configuring $LIBNAME... " +echo -n " Configuring $LIBNAME... " ./configure CC="$CC" CFLAGS="$CFLAGS" --prefix=$PREFIX $CONFIGOPTS > $CONFIGURE_LOG 2>&1 if [ $? -ne 0 ] ; then echo "Failed." @@ -75,7 +75,7 @@ else fi # Build -echo -n "Compiling $LIBNAME... " +echo -n " Compiling $LIBNAME... " make clean > $COMPILE_LOG 2>&1 make > $COMPILE_LOG 2>&1 if [ $? -ne 0 ] ; then From 8661e6598e123c69a4ed4ae6e18da6afd316861d Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 2 Mar 2021 13:39:17 -0500 Subject: [PATCH 12/52] Try to determine SRCDIR automatically if not specified. --- get_library.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/get_library.sh b/get_library.sh index 505dadd542..7f24706170 100755 --- a/get_library.sh +++ b/get_library.sh @@ -3,7 +3,7 @@ WORKDIR=`pwd` # Attempt to download and install a copy of library -if [ -z "$SRCTAR" -o -z "$SRCDIR" -o -z "$URL" -o -z "$LIBNAME" ] ; then +if [ -z "$SRCTAR" -o -z "$URL" -o -z "$LIBNAME" ] ; then echo "Error: Script variables are empty." exit 1 fi @@ -48,7 +48,19 @@ if [ ! -f "$SRCTAR" ] ; then fi fi +# Get SRCDIR if necessary +if [ -z "$SRCDIR" ] ; then + FIRSTFILE=`tar -tzf $SRCTAR | head -1` + if [ ! -z "$FIRSTFILE" ] ; then + SRCDIR=`dirname $FIRSTFILE` + 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 From e55541132bfb6c7432160b449b3729e44fef1b1f Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 2 Mar 2021 13:44:57 -0500 Subject: [PATCH 13/52] Start trying to automatically build bzip2 --- configure | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 9ead11b103..ac97579528 100755 --- a/configure +++ b/configure @@ -116,6 +116,11 @@ 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='' + # ----- Configure options ------------------------ USE_CMAKE=0 # 1 = use cmake for build COMPILE_VERBOSE=0 # 1 = show details during compile @@ -429,7 +434,35 @@ TestBzlib() { #include "bzlib.h" int main() { BZFILE *bfile; bfile=NULL; printf("Testing\n"); return 0; } EOF - TestProgram " Checking BZLIB" "$CXX" "$CXXFLAGS ${LIB_INCL[$LBZIP]}" testp.cpp "${LIB_FLAG[$LBZIP]}" + TestProgram silent " Checking BZLIB" "$CXX" "$CXXFLAGS ${LIB_INCL[$LBZIP]}" testp.cpp "${LIB_FLAG[$LBZIP]}" + if [ $? -ne 0 ] ; then + if [ "${LIB_STAT[$LBZIP]}" = 'enabled' ] ; then + # See if there is already a version of BZIP2 in CPPTRAJHOME + LIB_STAT[$LBZIP]='specified' + LIB_HOME[$LBZIP]=$CPPTRAJHOME + LIB_FLAG[$LBZIP]=$CPPTRAJHOME/lib/${LIB_STTC[$LBZIP]} + LIB_INCL[$LBZIP]="-I$CPPTRAJHOME/include" + TestProgram silent " Checking for bundled BZIP2" "$CXX" "$CXXFLAGS ${LIB_INCL[$LBZIP]}" testp.cpp "${LIB_FLAG[$LBZIP]}" + if [ $? -ne 0 ] ; then + # See if user would like to get Bzip2 + PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS LIBNAME='bzip2' \ + SRCDIR=$BZIP2_SRCDIR SRCTAR=$BZIP2_SRCTAR URL=$BZIP2_URL ./get_library.sh $BZIP2_OPTS + if [ $? -ne 0 ] ; then + ErrMsg "Building Bzip2 failed." + exit 1 + fi + # Test the built Bzip2 + TestProgram " Checking built Bzip2" "$CXX" "$CXXFLAGS ${LIB_INCL[$LBZIP]}" testp.cpp "${LIB_FLAG[$LBZIP]}" + fi + else + # Bzip2 specified but failed. + echo "Failed." + ErrMsg "Bzip2 build/link failed: $COMPILE_ERROR_LINE" + echo "Error message follows:" + echo "$COMPILE_ERROR_MESSAGE" + exit 1 + fi + fi } TestZlib() { From d91531d3434d951991098f9cf1c7e21c4c818103 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 2 Mar 2021 13:57:23 -0500 Subject: [PATCH 14/52] Try to handle case where library has a Makefile but not configure --- get_library.sh | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/get_library.sh b/get_library.sh index 7f24706170..c3b4bb6243 100755 --- a/get_library.sh +++ b/get_library.sh @@ -77,14 +77,37 @@ cd $SRCDIR #echo "CFLAGS=$CFLAGS" #echo "PREFIX=$PREFIX" echo -n " Configuring $LIBNAME... " -./configure CC="$CC" CFLAGS="$CFLAGS" --prefix=$PREFIX $CONFIGOPTS > $CONFIGURE_LOG 2>&1 -if [ $? -ne 0 ] ; then - echo "Failed." - echo "Check $CONFIGURE_LOG for errors." - exit 1 +if [ -f 'configure' ] ; then + # Run configure + ./configure CC="$CC" CFLAGS="$CFLAGS" --prefix=$PREFIX $CONFIGOPTS > $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 prefix="$PREFIX" '{ + if (index($1,"CC=")!=0) + printf("CC=%s\n", cc); + else if (index($1,"CFLAGS=")!=0) + printf("CFLAGS=%s\n", cflags); + 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 "Success." + echo "Error: No configure or Makefile." + exit 1 fi +echo "Success." # Build echo -n " Compiling $LIBNAME... " From 2e5530d59dc67f28eda9346fb54faefb572b6560 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 2 Mar 2021 13:58:18 -0500 Subject: [PATCH 15/52] Improve error message --- get_library.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get_library.sh b/get_library.sh index c3b4bb6243..808f3dfe2d 100755 --- a/get_library.sh +++ b/get_library.sh @@ -104,7 +104,7 @@ elif [ -f 'Makefile' ] ; then exit 1 fi else - echo "Error: No configure or Makefile." + echo "Error: $LIBNAME has no 'configure' or 'Makefile'." exit 1 fi echo "Success." From 5440dc0edd877e4b4b5e9fc03a7f797a609eeda4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 2 Mar 2021 14:07:21 -0500 Subject: [PATCH 16/52] Add support for getting zlib. Reorder CC and CFLAGS position when invoking configure. --- configure | 35 ++++++++++++++++++++++++++++++++++- get_library.sh | 2 +- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/configure b/configure index ac97579528..a792a306f3 100755 --- a/configure +++ b/configure @@ -121,6 +121,11 @@ 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='' + # ----- Configure options ------------------------ USE_CMAKE=0 # 1 = use cmake for build COMPILE_VERBOSE=0 # 1 = show details during compile @@ -471,7 +476,35 @@ TestZlib() { #include "zlib.h" int main() { gzFile gfile; gfile=NULL; printf("Testing\n"); return 0; } EOF - TestProgram " Checking ZLIB" "$CXX" "$CXXFLAGS ${LIB_INCL[$LZIP]}" testp.cpp "${LIB_FLAG[$LZIP]}" + TestProgram silent " Checking ZLIB" "$CXX" "$CXXFLAGS ${LIB_INCL[$LZIP]}" testp.cpp "${LIB_FLAG[$LZIP]}" + if [ $? -ne 0 ] ; then + if [ "${LIB_STAT[$LZIP]}" = 'enabled' ] ; then + # See if there is already a version of ZLIB in CPPTRAJHOME + LIB_STAT[$LZIP]='specified' + LIB_HOME[$LZIP]=$CPPTRAJHOME + LIB_FLAG[$LZIP]=$CPPTRAJHOME/lib/${LIB_STTC[$LZIP]} + LIB_INCL[$LZIP]="-I$CPPTRAJHOME/include" + TestProgram silent " Checking for bundled ZLIB" "$CXX" "$CXXFLAGS ${LIB_INCL[$LZIP]}" testp.cpp "${LIB_FLAG[$LZIP]}" + if [ $? -ne 0 ] ; then + # See if user would like to get ZLIB + PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS LIBNAME='zlib' \ + SRCDIR=$ZLIB_SRCDIR SRCTAR=$ZLIB_SRCTAR URL=$ZLIB_URL ./get_library.sh $ZLIB_OPTS + if [ $? -ne 0 ] ; then + ErrMsg "Building ZLIB failed." + exit 1 + fi + # Test the built ZLIB + TestProgram " Checking built ZLIB" "$CXX" "$CXXFLAGS ${LIB_INCL[$LZIP]}" testp.cpp "${LIB_FLAG[$LZIP]}" + fi + else + # ZLIB specified but failed. + echo "Failed." + ErrMsg "ZLIB build/link failed: $COMPILE_ERROR_LINE" + echo "Error message follows:" + echo "$COMPILE_ERROR_MESSAGE" + exit 1 + fi + fi } TestNetcdf() { diff --git a/get_library.sh b/get_library.sh index 808f3dfe2d..adbd26cc53 100755 --- a/get_library.sh +++ b/get_library.sh @@ -79,7 +79,7 @@ cd $SRCDIR echo -n " Configuring $LIBNAME... " if [ -f 'configure' ] ; then # Run configure - ./configure CC="$CC" CFLAGS="$CFLAGS" --prefix=$PREFIX $CONFIGOPTS > $CONFIGURE_LOG 2>&1 + CC="$CC" CFLAGS="$CFLAGS" ./configure --prefix=$PREFIX $CONFIGOPTS > $CONFIGURE_LOG 2>&1 if [ $? -ne 0 ] ; then echo "Failed." echo "Check $CONFIGURE_LOG for errors." From 902b814a1b063e5f0799aa1310e3ff2ecd22817e Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 2 Mar 2021 14:17:17 -0500 Subject: [PATCH 17/52] Fix 'error: identifier "_LIB_VERSION_TYPE" is undefined' with intel compilers --- get_library.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/get_library.sh b/get_library.sh index adbd26cc53..f8f80c8778 100755 --- a/get_library.sh +++ b/get_library.sh @@ -71,6 +71,12 @@ if [ ! -d "$SRCDIR" ] ; then fi cd $SRCDIR +# Compiler/library-specific modifications +if [ "$CC" = 'icc' ] ; then + # Avoids 'error: identifier "_LIB_VERSION_TYPE" is undefined' + CFLAGS="-D__PURE_INTEL_C99_HEADERS__ $CFLAGS" +fi + # Configure #echo "" #echo "CC=$CC" From 01c372e15aa5707eb14bf0714f1f855d7a2f34a1 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 2 Mar 2021 14:22:48 -0500 Subject: [PATCH 18/52] Start adding code for math library. --- configure | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure b/configure index a792a306f3..f1bdf6876b 100755 --- a/configure +++ b/configure @@ -126,6 +126,11 @@ ZLIB_SRCDIR='zlib-1.2.11' ZLIB_URL="https://zlib.net/$ZLIB_SRCTAR" ZLIB_OPTS='' +MATH_SRCTAR='OpenBLAS-0.3.13.tar.gz' +MATH_SRCDIR='OpenBLAS-0.3.13' +MATH_URL="https://github.com/xianyi/OpenBLAS/releases/download/v0.3.13/$MATH_SRCTAR" +MATH_OPTS='' + # ----- Configure options ------------------------ USE_CMAKE=0 # 1 = use cmake for build COMPILE_VERBOSE=0 # 1 = show details during compile From 5d630d36e70936ec6be61c98200df9b6e9968f9d Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 2 Mar 2021 15:33:03 -0500 Subject: [PATCH 19/52] Add some internal documentation --- configure | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure b/configure index f1bdf6876b..0f5171e667 100755 --- a/configure +++ b/configure @@ -390,15 +390,19 @@ CheckLibraryKeys() { # ARGS: [noexe|silent|quiet] [] TestProgram() { 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" From 75e59258b58655e04e5f32a6401b5c65ee7393de Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 2 Mar 2021 15:44:06 -0500 Subject: [PATCH 20/52] Consolidate error message code for TestProgram silent. Have DetermineFlink return with a status instead of exit on error. --- configure | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/configure b/configure index 0f5171e667..52b1e9e9c9 100755 --- a/configure +++ b/configure @@ -441,6 +441,15 @@ 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 +} # ===== LIBRARY TESTS ========================================================== TestBzlib() { cat > testp.cpp < Date: Tue, 2 Mar 2021 15:57:29 -0500 Subject: [PATCH 21/52] Skip asking user about building if already built once before --- configure | 17 ++++++++++++++++- get_library.sh | 23 ++++++++++++++++------- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/configure b/configure index 52b1e9e9c9..86241af6a6 100755 --- a/configure +++ b/configure @@ -107,6 +107,7 @@ 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 COMPERR='cpptrajcfg.compile.err' COMPOUT='cpptrajcfg.compile.out' @@ -389,6 +390,7 @@ CheckLibraryKeys() { # Test compile and run a program. # ARGS: [noexe|silent|quiet] [] TestProgram() { + REBUILDOPT='' if [ "$1" = 'noexe' ] ; then # Output messages, do not execute compiled binary silent=3 @@ -450,6 +452,17 @@ TestProgErr() { ErrMsg "$COMPILE_ERROR_MESSAGE" exit 1 } + +# This is invoked if linking a bundled library fails. +CheckRebuild() { + desc=$1 + libfile=$2 + if [ -f "$libfile" ] ; then + echo "Bundled $desc present but needs to be rebuilt." + REBUILDOPT='--rebuild' + fi +} + # ===== LIBRARY TESTS ========================================================== TestBzlib() { cat > testp.cpp < Date: Tue, 2 Mar 2021 16:01:13 -0500 Subject: [PATCH 22/52] Rebuild checks for zlib and bzlib --- configure | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 86241af6a6..98f517032d 100755 --- a/configure +++ b/configure @@ -478,11 +478,12 @@ EOF LIB_HOME[$LBZIP]=$CPPTRAJHOME LIB_FLAG[$LBZIP]=$CPPTRAJHOME/lib/${LIB_STTC[$LBZIP]} LIB_INCL[$LBZIP]="-I$CPPTRAJHOME/include" - TestProgram silent " Checking for bundled BZIP2" "$CXX" "$CXXFLAGS ${LIB_INCL[$LBZIP]}" testp.cpp "${LIB_FLAG[$LBZIP]}" + TestProgram silent " Checking for bundled Bzip2" "$CXX" "$CXXFLAGS ${LIB_INCL[$LBZIP]}" testp.cpp "${LIB_FLAG[$LBZIP]}" if [ $? -ne 0 ] ; then + CheckRebuild "Bzip2" "${LIB_FLAG[$LBZIP]}" # See if user would like to get Bzip2 PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS LIBNAME='bzip2' \ - SRCDIR=$BZIP2_SRCDIR SRCTAR=$BZIP2_SRCTAR URL=$BZIP2_URL ./get_library.sh $BZIP2_OPTS + SRCDIR=$BZIP2_SRCDIR SRCTAR=$BZIP2_SRCTAR URL=$BZIP2_URL ./get_library.sh $REBUILDOPT $BZIP2_OPTS if [ $? -ne 0 ] ; then ErrMsg "Building Bzip2 failed." exit 1 @@ -513,9 +514,10 @@ EOF LIB_INCL[$LZIP]="-I$CPPTRAJHOME/include" TestProgram silent " Checking for bundled ZLIB" "$CXX" "$CXXFLAGS ${LIB_INCL[$LZIP]}" testp.cpp "${LIB_FLAG[$LZIP]}" if [ $? -ne 0 ] ; then + CheckRebuild "ZLIB" "${LIB_FLAG[$LZIP]}" # See if user would like to get ZLIB PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS LIBNAME='zlib' \ - SRCDIR=$ZLIB_SRCDIR SRCTAR=$ZLIB_SRCTAR URL=$ZLIB_URL ./get_library.sh $ZLIB_OPTS + SRCDIR=$ZLIB_SRCDIR SRCTAR=$ZLIB_SRCTAR URL=$ZLIB_URL ./get_library.sh $REBUILDOPT $ZLIB_OPTS if [ $? -ne 0 ] ; then ErrMsg "Building ZLIB failed." exit 1 From bdab836dc7ab4d7a36dbdc4f5ec4d8618a56a2c9 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 2 Mar 2021 21:11:11 -0500 Subject: [PATCH 23/52] Add install of openblas --- configure | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 98f517032d..9eaeb03c12 100755 --- a/configure +++ b/configure @@ -655,7 +655,34 @@ int main() { EOF DetermineFlink " Checking LAPACK/BLAS" "${LIB_FLAG[$LLAPACK]} ${LIB_FLAG[$LBLAS]}" if [ $? -ne 0 ] ; then - TestProgErr "LAPACK/BLAS" + if [ "${LIB_STAT[$LBLAS]}" = 'enabled' ] ; then + # See if there is already a version of OpenBLAS in CPPTRAJHOME + LIB_STAT[$LBLAS]='specified' + LIB_HOME[$LBLAS]=$CPPTRAJHOME + LIB_FLAG[$LBLAS]=$CPPTRAJHOME/lib/libopenblas.a + LIB_INCL[$LBLAS]="-I$CPPTRAJHOME/include" + LIB_STAT[$LLAPACK]='off' + LIB_FLAG[$LLAPACK]='' + DetermineFlink " Checking for bundled OpenBLAS" "${LIB_FLAG[$LLAPACK]} ${LIB_FLAG[$LBLAS]}" + #TestProgram silent " Checking for bundled OpenBLAS" "$CXX" "$CXXFLAGS ${LIB_INCL[$LBLAS]}" testp.cpp "${LIB_FLAG[$LBLAS]}" + if [ $? -ne 0 ] ; then + # Check if lib present but needs to be rebuilt + CheckRebuild "OpenBLAS" "${LIB_FLAG[$LBLAS]}" + # See if user would like to get openblas + PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS LIBNAME='openblas' \ + SRCDIR=$MATH_SRCDIR SRCTAR=$MATH_SRCTAR URL=$MATH_URL ./get_library.sh $REBUILDOPT $MATH_OPTS + if [ $? -ne 0 ] ; then + ErrMsg "Building OpenBLAS failed." + exit 1 + fi + # Test the built openblas + DetermineFlink " Checking built OpenBLAS" "${LIB_FLAG[$LLAPACK]} ${LIB_FLAG[$LBLAS]}" + #TestProgram " Checking built OpenBLAS" "$CXX" "$CXXFLAGS ${LIB_INCL[$LBLAS]}" testp.cpp "${LIB_FLAG[$LBLAS]}" + fi + else + # BLAS specified but failed. + TestProgErr "LAPACK/BLAS" + fi fi } From 1ebf6bc55e000eb8573d6cf517a0e501cf566676 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 2 Mar 2021 21:15:51 -0500 Subject: [PATCH 24/52] Set up make command if not already set --- get_library.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/get_library.sh b/get_library.sh index 5a84d4a658..e030e24239 100755 --- a/get_library.sh +++ b/get_library.sh @@ -124,10 +124,24 @@ else 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: $MAKE_COMMAND" +fi + # Build echo -n " Compiling $LIBNAME... " make clean > $COMPILE_LOG 2>&1 -make > $COMPILE_LOG 2>&1 +$MAKE_COMMAND > $COMPILE_LOG 2>&1 if [ $? -ne 0 ] ; then echo "Build failed." echo "Check $COMPILE_LOG for errors." From decc78a83c785b08b68fc358a26452d080521651 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Tue, 2 Mar 2021 21:24:04 -0500 Subject: [PATCH 25/52] Fix up formatting --- get_library.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/get_library.sh b/get_library.sh index e030e24239..d1933ed918 100755 --- a/get_library.sh +++ b/get_library.sh @@ -17,10 +17,10 @@ fi # First ask if we want to get the library if [ $REBUILD -eq 0 ] ; then - echo "Should CPPTRAJ attempt to build its own $LIBNAME? {y|n}: " + echo -n "Should CPPTRAJ attempt to build its own $LIBNAME? {y|n}: " read yesno while [ "$yesno" != 'y' -a "$yesno" != 'n' ] ; do - echo " Please enter 'y' or 'n': " + echo -n " Please enter 'y' or 'n': " read yesno done if [ "$yesno" = 'n' ] ; then @@ -35,7 +35,7 @@ while [ ! -z "$1" ] ; do shift done -echo " CONFIGOPTS: $CONFIGOPTS" +#echo " CONFIGOPTS: $CONFIGOPTS" CONFIGURE_LOG=$WORKDIR/$LIBNAME"_config.log" COMPILE_LOG=$WORKDIR/$LIBNAME"_compile.log" From e09d0ab9937b4ab6365f426fdfbd0b2ad67baaee Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 3 Mar 2021 10:31:55 -0500 Subject: [PATCH 26/52] Pass in FC and FFLAGS --- configure | 2 +- get_library.sh | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 9eaeb03c12..843a12e4c8 100755 --- a/configure +++ b/configure @@ -669,7 +669,7 @@ EOF # Check if lib present but needs to be rebuilt CheckRebuild "OpenBLAS" "${LIB_FLAG[$LBLAS]}" # See if user would like to get openblas - PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS LIBNAME='openblas' \ + PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS FC=$FC FFLAGS=$FFLAGS LIBNAME='openblas' \ SRCDIR=$MATH_SRCDIR SRCTAR=$MATH_SRCTAR URL=$MATH_URL ./get_library.sh $REBUILDOPT $MATH_OPTS if [ $? -ne 0 ] ; then ErrMsg "Building OpenBLAS failed." diff --git a/get_library.sh b/get_library.sh index d1933ed918..5991528230 100755 --- a/get_library.sh +++ b/get_library.sh @@ -94,7 +94,7 @@ fi echo -n " Configuring $LIBNAME... " if [ -f 'configure' ] ; then # Run configure - CC="$CC" CFLAGS="$CFLAGS" ./configure --prefix=$PREFIX $CONFIGOPTS > $CONFIGURE_LOG 2>&1 + CC="$CC" CFLAGS="$CFLAGS" FC="$FC" FFLAGS="$FFLAGS" ./configure --prefix=$PREFIX $CONFIGOPTS > $CONFIGURE_LOG 2>&1 if [ $? -ne 0 ] ; then echo "Failed." echo "Check $CONFIGURE_LOG for errors." @@ -105,11 +105,15 @@ elif [ -f 'Makefile' ] ; then if [ ! -f 'Makefile.original' ] ; then cp Makefile Makefile.original fi - awk -v cc="$CC" -v cflags="$CFLAGS" -v prefix="$PREFIX" '{ + 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); + eles if (index($1,"FFLAGS=")!=0) + printf("FFLAGS=%s\n", fflags); else if (index($1,"PREFIX=")!=0) printf("PREFIX=%s\n", prefix); else From f8d2f23c8d8b2c8073fee633943c065b346e7647 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 3 Mar 2021 10:33:35 -0500 Subject: [PATCH 27/52] Fix syntax error --- get_library.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get_library.sh b/get_library.sh index 5991528230..4ce55da0ca 100755 --- a/get_library.sh +++ b/get_library.sh @@ -112,7 +112,7 @@ elif [ -f 'Makefile' ] ; then printf("FC=%s\n", fc); else if (index($1,"CFLAGS=")!=0) printf("CFLAGS=%s\n", cflags); - eles if (index($1,"FFLAGS=")!=0) + else if (index($1,"FFLAGS=")!=0) printf("FFLAGS=%s\n", fflags); else if (index($1,"PREFIX=")!=0) printf("PREFIX=%s\n", prefix); From 80767c0f38221faf6ae00bc0f06c20f8da85a504 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 3 Mar 2021 11:59:30 -0500 Subject: [PATCH 28/52] Start generalizing for different BLAS external builds. Pass FC but not FFLAGS since they might not be appropriate for F77 style code --- configure | 25 ++++++++++++++++++------- get_library.sh | 10 ++++++---- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/configure b/configure index 843a12e4c8..f28b568345 100755 --- a/configure +++ b/configure @@ -127,10 +127,10 @@ ZLIB_SRCDIR='zlib-1.2.11' ZLIB_URL="https://zlib.net/$ZLIB_SRCTAR" ZLIB_OPTS='' -MATH_SRCTAR='OpenBLAS-0.3.13.tar.gz' -MATH_SRCDIR='OpenBLAS-0.3.13' -MATH_URL="https://github.com/xianyi/OpenBLAS/releases/download/v0.3.13/$MATH_SRCTAR" -MATH_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='' # ----- Configure options ------------------------ USE_CMAKE=0 # 1 = use cmake for build @@ -139,7 +139,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 @@ -656,10 +656,20 @@ EOF DetermineFlink " Checking LAPACK/BLAS" "${LIB_FLAG[$LLAPACK]} ${LIB_FLAG[$LBLAS]}" if [ $? -ne 0 ] ; then if [ "${LIB_STAT[$LBLAS]}" = 'enabled' ] ; then + if [ "$BLAS_TYPE" = 'openblas' ] ; then + MATH_SRCDIR=$OPENBLAS_SRCDIR + MATH_SRCTAR=$OPENBLAS_SRCTAR + MATH_URL=$OPENBLAS_URL + MATH_OPTS=$OPENBLAS_OPTS + MATH_LIBNAME='openblas' + else + # Bundle not supported for this BLAS type + TestProgErr "LAPACK/BLAS" + fi # See if there is already a version of OpenBLAS in CPPTRAJHOME LIB_STAT[$LBLAS]='specified' LIB_HOME[$LBLAS]=$CPPTRAJHOME - LIB_FLAG[$LBLAS]=$CPPTRAJHOME/lib/libopenblas.a + LIB_FLAG[$LBLAS]=$CPPTRAJHOME/lib/${LIB_STTC[$LBLAS]} LIB_INCL[$LBLAS]="-I$CPPTRAJHOME/include" LIB_STAT[$LLAPACK]='off' LIB_FLAG[$LLAPACK]='' @@ -669,7 +679,7 @@ EOF # Check if lib present but needs to be rebuilt CheckRebuild "OpenBLAS" "${LIB_FLAG[$LBLAS]}" # See if user would like to get openblas - PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS FC=$FC FFLAGS=$FFLAGS LIBNAME='openblas' \ + PREFIX=$CPPTRAJHOME CC="$CC" CFLAGS="$CFLAGS" FC="$FC" LIBNAME="$MATH_LIBNAME" \ SRCDIR=$MATH_SRCDIR SRCTAR=$MATH_SRCTAR URL=$MATH_URL ./get_library.sh $REBUILDOPT $MATH_OPTS if [ $? -ne 0 ] ; then ErrMsg "Building OpenBLAS failed." @@ -1002,6 +1012,7 @@ SetupLibraries() { if [ "${LIB_STAT[$LBLAS]}" != 'direct' ] ; then LIB_FLAG[$LBLAS]='-lopenblas' fi + LIB_STTC[$LBLAS]='libopenblas.a' if [ -z "${LIB_HOME[$LBLAS]}" -a "${LIB_STAT[$LBLAS]}" != 'direct' ] ; then WrnMsg "'-openblas' may require specifying location with '--with-blas=' or '-lblas='" fi diff --git a/get_library.sh b/get_library.sh index 4ce55da0ca..852dc668df 100755 --- a/get_library.sh +++ b/get_library.sh @@ -87,10 +87,12 @@ if [ "$CC" = 'icc' ] ; then fi # Configure -#echo "" -#echo "CC=$CC" -#echo "CFLAGS=$CFLAGS" -#echo "PREFIX=$PREFIX" +echo "" +echo " CC=$CC" +echo " CFLAGS=$CFLAGS" +echo " PREFIX=$PREFIX" +echo " FC=$FC" +echo " FFLAGS=$FFLAGS" echo -n " Configuring $LIBNAME... " if [ -f 'configure' ] ; then # Run configure From 43e3326f6e878f45296866e0d4b8a30a22bf9bd2 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 3 Mar 2021 12:51:00 -0500 Subject: [PATCH 29/52] Add code for building vanilla lapack/blas --- configure | 29 ++++++++++++++++------- get_library.sh | 62 +++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 80 insertions(+), 11 deletions(-) diff --git a/configure b/configure index f28b568345..84d2ea6288 100755 --- a/configure +++ b/configure @@ -132,6 +132,11 @@ 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='' + # ----- Configure options ------------------------ USE_CMAKE=0 # 1 = use cmake for build COMPILE_VERBOSE=0 # 1 = show details during compile @@ -662,31 +667,39 @@ EOF MATH_URL=$OPENBLAS_URL MATH_OPTS=$OPENBLAS_OPTS MATH_LIBNAME='openblas' + elif [ "$BLAS_TYPE" = 'other' ] ; then + MATH_SRCDIR=$LAPACK_SRCDIR + MATH_SRCTAR=$LAPACK_SRCTAR + MATH_URL=$LAPACK_URL + MATH_OPTS=$LAPACK_OPTS + MATH_LIBNAME='lapack' + LIB_STAT[$LLAPACK]='specified' + LIB_HOME[$LLAPACK]=$CPPTRAJHOME + LIB_FLAG[$LLAPACK]=$CPPTRAJHOME/lib/${LIB_STTC[$LLAPACK]} + LIB_INCL[$LLAPACK]="-I$CPPTRAJHOME/include" else # Bundle not supported for this BLAS type TestProgErr "LAPACK/BLAS" fi - # See if there is already a version of OpenBLAS in CPPTRAJHOME + # See if there is already a version of BLAS in CPPTRAJHOME LIB_STAT[$LBLAS]='specified' LIB_HOME[$LBLAS]=$CPPTRAJHOME LIB_FLAG[$LBLAS]=$CPPTRAJHOME/lib/${LIB_STTC[$LBLAS]} LIB_INCL[$LBLAS]="-I$CPPTRAJHOME/include" - LIB_STAT[$LLAPACK]='off' - LIB_FLAG[$LLAPACK]='' - DetermineFlink " Checking for bundled OpenBLAS" "${LIB_FLAG[$LLAPACK]} ${LIB_FLAG[$LBLAS]}" + DetermineFlink " Checking for bundled BLAS" "${LIB_FLAG[$LLAPACK]} ${LIB_FLAG[$LBLAS]}" #TestProgram silent " Checking for bundled OpenBLAS" "$CXX" "$CXXFLAGS ${LIB_INCL[$LBLAS]}" testp.cpp "${LIB_FLAG[$LBLAS]}" if [ $? -ne 0 ] ; then # Check if lib present but needs to be rebuilt - CheckRebuild "OpenBLAS" "${LIB_FLAG[$LBLAS]}" - # See if user would like to get openblas + CheckRebuild "BLAS" "${LIB_FLAG[$LBLAS]}" + # See if user would like to get blas PREFIX=$CPPTRAJHOME CC="$CC" CFLAGS="$CFLAGS" FC="$FC" LIBNAME="$MATH_LIBNAME" \ SRCDIR=$MATH_SRCDIR SRCTAR=$MATH_SRCTAR URL=$MATH_URL ./get_library.sh $REBUILDOPT $MATH_OPTS if [ $? -ne 0 ] ; then - ErrMsg "Building OpenBLAS failed." + ErrMsg "Building BLAS failed." exit 1 fi # Test the built openblas - DetermineFlink " Checking built OpenBLAS" "${LIB_FLAG[$LLAPACK]} ${LIB_FLAG[$LBLAS]}" + DetermineFlink " Checking built BLAS" "${LIB_FLAG[$LLAPACK]} ${LIB_FLAG[$LBLAS]}" #TestProgram " Checking built OpenBLAS" "$CXX" "$CXXFLAGS ${LIB_INCL[$LBLAS]}" testp.cpp "${LIB_FLAG[$LBLAS]}" fi else diff --git a/get_library.sh b/get_library.sh index 852dc668df..aff36d919d 100755 --- a/get_library.sh +++ b/get_library.sh @@ -81,10 +81,44 @@ fi cd $SRCDIR # Compiler/library-specific modifications +MAKE_TARGET='' if [ "$CC" = 'icc' ] ; then # Avoids 'error: identifier "_LIB_VERSION_TYPE" is undefined' CFLAGS="-D__PURE_INTEL_C99_HEADERS__ $CFLAGS" fi +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 @@ -147,7 +183,7 @@ fi # Build echo -n " Compiling $LIBNAME... " make clean > $COMPILE_LOG 2>&1 -$MAKE_COMMAND > $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." @@ -155,12 +191,32 @@ if [ $? -ne 0 ] ; then fi # Install -make install >> $COMPILE_LOG 2>&1 +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 From d8e701e3c25b41bebee8cc1388e065336c15707c Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 3 Mar 2021 12:58:23 -0500 Subject: [PATCH 30/52] Add uninstall_lib target --- src/Makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index d33588d468..8d9a98f37a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -117,7 +117,15 @@ 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: uninstall_lib $(DEL_FILE) $(CPPTRAJBIN)/cpptraj$(SFX)$(EXE) $(DEL_FILE) $(CPPTRAJLIB)/libcpptraj$(SHARED_SUFFIX) cd readline && make uninstall From 2608097e7a379f4534a9092b6f01b55e31e303c1 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 3 Mar 2021 13:00:17 -0500 Subject: [PATCH 31/52] Add concept of a cpptraj include directory --- configure | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure b/configure index 84d2ea6288..878279cbe1 100755 --- a/configure +++ b/configure @@ -166,6 +166,7 @@ LFS='-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64' CPPTRAJHOME='' CPPTRAJBIN='' CPPTRAJLIB='' +CPPTRAJINC='' # ----- External Libraries ----------------------- # Library indices @@ -1653,6 +1654,7 @@ BasicChecks() { CPPTRAJHOME=`pwd` CPPTRAJBIN=$CPPTRAJHOME/bin CPPTRAJLIB=$CPPTRAJHOME/lib + CPPTRAJINC=$CPPTRAJHOM/include elif [ ! -d "$CPPTRAJHOME" ] ; then Err "Install directory '$CPPTRAJHOME' does not exist." fi @@ -2109,6 +2111,7 @@ while [ ! -z "$1" ] ; do CPPTRAJHOME=$VALUE CPPTRAJBIN=$VALUE/bin CPPTRAJLIB=$VALUE/lib + CPPTRAJINC=$VALUE/include ;; # Hidden debug options '--debug-parallel' ) DIRECTIVES="$DIRECTIVES -DPARALLEL_DEBUG_VERBOSE" ;; @@ -2343,6 +2346,7 @@ cat >> config.h < Date: Wed, 3 Mar 2021 13:01:32 -0500 Subject: [PATCH 32/52] Add uninstall_inc target --- src/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 8d9a98f37a..b03396a137 100644 --- a/src/Makefile +++ b/src/Makefile @@ -125,7 +125,10 @@ uninstall_lib: $(DEL_FILE) -r $(CPPTRAJLIB)/cmake $(DEL_FILE) -r $(CPPTRAJLIB)/pkgconfig -uninstall: uninstall_lib +uninstall_inc: + $(DEL_FILE) $(CPPTRAJINC)/*.h + +uninstall: uninstall_lib uninstall_inc $(DEL_FILE) $(CPPTRAJBIN)/cpptraj$(SFX)$(EXE) $(DEL_FILE) $(CPPTRAJLIB)/libcpptraj$(SHARED_SUFFIX) cd readline && make uninstall From 537f8e25cf082e62a150365111fa2f1761296b04 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 3 Mar 2021 14:09:34 -0500 Subject: [PATCH 33/52] Add --buildlibs option --- configure | 14 ++++++++++++-- get_library.sh | 12 ++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/configure b/configure index 878279cbe1..cdcc05ca76 100755 --- a/configure +++ b/configure @@ -45,6 +45,7 @@ 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 " 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" @@ -152,6 +153,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 @@ -396,7 +398,11 @@ CheckLibraryKeys() { # Test compile and run a program. # ARGS: [noexe|silent|quiet] [] TestProgram() { - REBUILDOPT='' + if [ $BUILD_LIBS -eq 0 ] ; then + REBUILDOPT='' + else + REBUILDOPT='--rebuild' + fi if [ "$1" = 'noexe' ] ; then # Output messages, do not execute compiled binary silent=3 @@ -463,7 +469,7 @@ TestProgErr() { CheckRebuild() { desc=$1 libfile=$2 - if [ -f "$libfile" ] ; then + if [ -z "$REBUILDOPT" -a -f "$libfile" ] ; then echo "Bundled $desc present but needs to be rebuilt." REBUILDOPT='--rebuild' fi @@ -872,6 +878,9 @@ EOF #------------------------------------------------------------------------------- # Test external libraries TestLibraries() { + if [ $BUILD_LIBS -eq 1 ] ; then + echo "Enabled libraries will be built if not present." + fi if [ "${LIB_TEST[$LBZIP]}" = 'yes' ] ; then TestBzlib ; fi if [ "${LIB_TEST[$LZIP]}" = 'yes' ] ; then TestZlib ; fi if [ "${LIB_TEST[$LNETCDF]}" = 'yes' ] ; then TestNetcdf ; fi @@ -2103,6 +2112,7 @@ while [ ! -z "$1" ] ; do '-nomathlib' ) BLAS_TYPE='none' ;; '--requires-flink' ) REQUIRES_FLINK=1 ;; '--requires-pthread') REQUIRES_PTHREAD=1 ;; + '--buildlibs' ) BUILD_LIBS=1 ;; # Install options '--compile-verbose' ) COMPILE_VERBOSE=1 ;; '-noclean' ) CLEAN='no' ;; diff --git a/get_library.sh b/get_library.sh index aff36d919d..75e54993f4 100755 --- a/get_library.sh +++ b/get_library.sh @@ -121,12 +121,12 @@ EOF fi # Configure -echo "" -echo " CC=$CC" -echo " CFLAGS=$CFLAGS" -echo " PREFIX=$PREFIX" -echo " FC=$FC" -echo " FFLAGS=$FFLAGS" +#echo "" +#echo " CC=$CC" +#echo " CFLAGS=$CFLAGS" +#echo " PREFIX=$PREFIX" +#echo " FC=$FC" +#echo " FFLAGS=$FFLAGS" echo -n " Configuring $LIBNAME... " if [ "$LIBNAME" = 'lapack' ] ; then echo -n "(using generated make.inc) " From dd4bbf4f57a014dae22da974ded88f1c1c783fb5 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 3 Mar 2021 14:14:47 -0500 Subject: [PATCH 34/52] Fix typo in variable --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index cdcc05ca76..ecb7e4bf18 100755 --- a/configure +++ b/configure @@ -1663,7 +1663,7 @@ BasicChecks() { CPPTRAJHOME=`pwd` CPPTRAJBIN=$CPPTRAJHOME/bin CPPTRAJLIB=$CPPTRAJHOME/lib - CPPTRAJINC=$CPPTRAJHOM/include + CPPTRAJINC=$CPPTRAJHOME/include elif [ ! -d "$CPPTRAJHOME" ] ; then Err "Install directory '$CPPTRAJHOME' does not exist." fi From 26203170311772bf830c7f0d160126c27c8c5c03 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 3 Mar 2021 14:21:38 -0500 Subject: [PATCH 35/52] Add note --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index ecb7e4bf18..32d3f9b94d 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 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. From 592d98a968bbaa537090d91e8f4dde4b50bfe9ef Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 3 Mar 2021 15:00:58 -0500 Subject: [PATCH 36/52] Fix issues with SRCDIR --- get_library.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/get_library.sh b/get_library.sh index 75e54993f4..5de3f4ab4a 100755 --- a/get_library.sh +++ b/get_library.sh @@ -1,4 +1,8 @@ #!/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` @@ -62,6 +66,9 @@ 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 @@ -78,6 +85,10 @@ if [ ! -d "$SRCDIR" ] ; then 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 From dab406d05ea5470b4fb61ef32784a2b47f05dfde Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 3 Mar 2021 15:01:10 -0500 Subject: [PATCH 37/52] Add pnetcdf --- configure | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 32d3f9b94d..747c06c23a 100755 --- a/configure +++ b/configure @@ -3,7 +3,7 @@ # Daniel R. Roe # 2010-11-18 # Rewritten 2018-01-25 (getting old...) -# Support for getting and building external libraries added 2021-03-03 +# 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. @@ -139,6 +139,11 @@ 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='' + # ----- Configure options ------------------------ USE_CMAKE=0 # 1 = use cmake for build COMPILE_VERBOSE=0 # 1 = show details during compile @@ -211,7 +216,7 @@ LIB_DOFF[$LNETCDF]='' # Directive if library off LIB_LINK[$LNETCDF]='dynamic' # How to link the library LIB_TYPE[$LNETCDF]='ld' # ld = LDFLAGS, cpp = cpptraj, blank = special -LIB_STAT[$LPARANC]='off' +LIB_STAT[$LPARANC]='enabled' LIB_CKEY[$LPARANC]='pnetcdf' LIB_HOME[$LPARANC]='' LIB_FLAG[$LPARANC]='-lpnetcdf' @@ -588,7 +593,33 @@ TestPnetcdf() { void unused() {int ncid; ncmpi_open(MPI_COMM_WORLD, "foo.nc", NC_NOWRITE, MPI_INFO_NULL, &ncid);} int main() { printf("Testing\n"); printf("%s\n",ncmpi_strerror(0)); return 0; } EOF - TestProgram " Checking Parallel NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LPARANC]}" testp.cpp "${LIB_FLAG[$LPARANC]}" + TestProgram silent " Checking Parallel NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LPARANC]}" testp.cpp "${LIB_FLAG[$LPARANC]}" + if [ $? -ne 0 ] ; then + if [ "${LIB_STAT[$LPARANC]}" = 'enabled' ] ; then + # See if there is already a version of parallel netcdf in CPPTRAJHOME + LIB_STAT[$LPARANC]='specified' + LIB_HOME[$LPARANC]=$CPPTRAJHOME + LIB_FLAG[$LPARANC]=$CPPTRAJHOME/lib/${LIB_STTC[$LPARANC]} + LIB_INCL[$LPARANC]="-I$CPPTRAJHOME/include" + TestProgram silent " Checking for bundled parallel NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LPARANC]}" testp.cpp "${LIB_FLAG[$LPARANC]}" + if [ $? -ne 0 ] ; then + CheckRebuild "Pnetcdf" "${LIB_FLAG[$LPARANC]}" + # See if user would like to get parallel netcdf + PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS LIBNAME='pnetcdf' \ + SRCDIR=$PNETCDF_SRCDIR SRCTAR=$PNETCDF_SRCTAR URL=$PNETCDF_URL ./get_library.sh $REBUILDOPT $PNETCDF_OPTS + if [ $? -ne 0 ] ; then + echo "Disabling parallel NetCDF support." + LIB_STAT[$LPARANC]='off' + else + # Test the built parallel netcdf + TestProgram " Checking built parallel NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LPARANC]}" testp.cpp "${LIB_FLAG[$LPARANC]}" + fi + fi + else + # Parallel NetCDF specified but failed. + TestProgErr "Pnetcdf" + fi + fi } DetermineFlink() { From 66dffa969c15806353aac6aa7bf570ce10990ad4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 3 Mar 2021 15:32:55 -0500 Subject: [PATCH 38/52] Disable pnetcdf interfaces that cpptraj does not use --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 747c06c23a..c6571133fa 100755 --- a/configure +++ b/configure @@ -142,7 +142,7 @@ LAPACK_OPTS='' PNETCDF_SRCTAR='pnetcdf-1.12.2.tar.gz' PNETCDF_SRCDIR='' PNETCDF_URL="https://parallel-netcdf.github.io/Release/$PNETCDF_SRCTAR" -PNETCDF_OPTS='' +PNETCDF_OPTS='--disable-fortran --disable-cxx' # ----- Configure options ------------------------ USE_CMAKE=0 # 1 = use cmake for build From 13cbfcd46e41c5552a95a30934a966e2acec6e86 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 3 Mar 2021 15:43:27 -0500 Subject: [PATCH 39/52] Add build of fftw --- configure | 33 ++++++++++++++++++++++++++++++++- get_library.sh | 2 +- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/configure b/configure index c6571133fa..2f0723e5a2 100755 --- a/configure +++ b/configure @@ -144,6 +144,11 @@ 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' + # ----- Configure options ------------------------ USE_CMAKE=0 # 1 = use cmake for build COMPILE_VERBOSE=0 # 1 = show details during compile @@ -784,6 +789,7 @@ int main() { } EOF if [ "${LIB_STAT[$LFFTW3]}" = 'amberopt' ] ; then + # Using FFTW from AMBER TestProgram silent " Checking for FFTW3 from AMBERHOME" "$CXX" "$CXXFLAGS ${LIB_INCL[$LFFTW3]}" testp.cpp "${LIB_FLAG[$LFFTW3]}" if [ $? -eq 1 ] ; then WrnMsg "FFTW3 test failed. CPPTRAJ will be built without FFTW3." @@ -793,7 +799,32 @@ EOF # Using FFTW from MKL TestProgram " Checking FFTW3" "$CXX" "$CXXFLAGS ${LIB_INCL[$LBLAS]}" testp.cpp "${LIB_FLAG[$LBLAS]}" else - TestProgram " Checking FFTW3" "$CXX" "$CXXFLAGS ${LIB_INCL[$LFFTW3]}" testp.cpp "${LIB_FLAG[$LFFTW3]}" + TestProgram silent " Checking FFTW3" "$CXX" "$CXXFLAGS ${LIB_INCL[$LFFTW3]}" testp.cpp "${LIB_FLAG[$LFFTW3]}" + if [ $? -ne 0 ] ; then + if [ "${LIB_STAT[$LFFTW3]}" = 'enabled' ] ; then + # See if there is already a version of FFTW in CPPTRAJHOME + LIB_STAT[$LFFTW3]='specified' + LIB_HOME[$LFFTW3]=$CPPTRAJHOME + LIB_FLAG[$LFFTW3]=$CPPTRAJHOME/lib/${LIB_STTC[$LFFTW3]} + LIB_INCL[$LFFTW3]="-I$CPPTRAJHOME/include" + TestProgram silent " Checking for bundled FFTW" "$CXX" "$CXXFLAGS ${LIB_INCL[$LFFTW3]}" testp.cpp "${LIB_FLAG[$LFFTW3]}" + if [ $? -ne 0 ] ; then + CheckRebuild "FFTW" "${LIB_FLAG[$LFFTW3]}" + # See if user would like to get FFTW + PREFIX=$CPPTRAJHOME CC=$CC CFLAGS=$CFLAGS LIBNAME='fftw' \ + SRCDIR=$FFTW_SRCDIR SRCTAR=$FFTW_SRCTAR URL=$FFTW_URL ./get_library.sh $REBUILDOPT $FFTW_OPTS + if [ $? -ne 0 ] ; then + ErrMsg "Building FFTW failed." + exit 1 + fi + # Test the built FFTW + TestProgram " Checking built FFTW" "$CXX" "$CXXFLAGS ${LIB_INCL[$LFFTW3]}" testp.cpp "${LIB_FLAG[$LFFTW3]}" + fi + else + # FFTW specified but failed. + TestProgErr "FFTW" + fi + fi fi } diff --git a/get_library.sh b/get_library.sh index 5de3f4ab4a..453409d084 100755 --- a/get_library.sh +++ b/get_library.sh @@ -188,7 +188,7 @@ if [ -z "$MAKE_COMMAND" ] ; then HALF=`echo "$NPROC / 2" | bc` MAKE_COMMAND="make -j$HALF" fi - echo " Make: $MAKE_COMMAND" + echo " MAKE_COMMAND is not set; set to '$MAKE_COMMAND'" fi # Build From 960caf721c816882bac89b145c5d78b50130ba9c Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 3 Mar 2021 15:56:03 -0500 Subject: [PATCH 40/52] Disable fortran interface for fftw. Only enable pnetcdf when mpi is specified --- configure | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 2f0723e5a2..41610db573 100755 --- a/configure +++ b/configure @@ -147,7 +147,7 @@ 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' +FFTW_OPTS='--enable-threads --with-combined-threads --with-pic --disable-fortran' # ----- Configure options ------------------------ USE_CMAKE=0 # 1 = use cmake for build @@ -221,7 +221,7 @@ LIB_DOFF[$LNETCDF]='' # Directive if library off LIB_LINK[$LNETCDF]='dynamic' # How to link the library LIB_TYPE[$LNETCDF]='ld' # ld = LDFLAGS, cpp = cpptraj, blank = special -LIB_STAT[$LPARANC]='enabled' +LIB_STAT[$LPARANC]='off' LIB_CKEY[$LPARANC]='pnetcdf' LIB_HOME[$LPARANC]='' LIB_FLAG[$LPARANC]='-lpnetcdf' @@ -1744,6 +1744,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 From aac774f6b0e98ae1e973575796cec82da0f4f89b Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 3 Mar 2021 16:01:33 -0500 Subject: [PATCH 41/52] Add message that compiling may be time-consuming --- get_library.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get_library.sh b/get_library.sh index 453409d084..59e13e9131 100755 --- a/get_library.sh +++ b/get_library.sh @@ -192,7 +192,7 @@ if [ -z "$MAKE_COMMAND" ] ; then fi # Build -echo -n " Compiling $LIBNAME... " +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 From 9c9dab50c76b5d889f3bd67407343ce1811dcdc9 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 3 Mar 2021 16:05:23 -0500 Subject: [PATCH 42/52] Add small blurb about --buildlibs --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b8894d233b..5d180ee38c 100644 --- a/README.md +++ b/README.md @@ -92,11 +92,14 @@ 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. +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`. From 7d2ff3ea8457c8a274b4c0407e44616ebf7db0f4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 3 Mar 2021 21:17:24 -0500 Subject: [PATCH 43/52] Put intel header fix into configure. Add zlib include path to external config.h for tng --- configure | 11 +++++++++++ get_library.sh | 4 ---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 41610db573..f0001d4990 100755 --- a/configure +++ b/configure @@ -1363,6 +1363,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 @@ -2470,6 +2480,7 @@ EOF BuildRules $external_config nvcc cc f77 if [ "${LIB_STAT[$LZIP]}" != 'off' ] ; then echo "ZLIB_FLAG=${LIB_FLAG[$LZIP]}" >> $external_config + echo "ZLIB_INCL=${LIB_INCL[$LZIP]}" >> $external_config fi # ----- Create directories if necessary ---------- diff --git a/get_library.sh b/get_library.sh index 59e13e9131..d7c71b01d4 100755 --- a/get_library.sh +++ b/get_library.sh @@ -93,10 +93,6 @@ cd $SRCDIR # Compiler/library-specific modifications MAKE_TARGET='' -if [ "$CC" = 'icc' ] ; then - # Avoids 'error: identifier "_LIB_VERSION_TYPE" is undefined' - CFLAGS="-D__PURE_INTEL_C99_HEADERS__ $CFLAGS" -fi if [ -f 'make.inc' ] ; then rm 'make.inc' fi From 2097aa9cd525ccc404e3f7b6399055bab8938802 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 3 Mar 2021 21:17:58 -0500 Subject: [PATCH 44/52] Use zlib include path from external config --- src/tng/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 9466ac880229d80ced67da9ccc52bd486e419482 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Wed, 3 Mar 2021 21:18:15 -0500 Subject: [PATCH 45/52] Define M_PI and M_PI_2 if not defined; some intel compilers do not have them defined. --- src/vmdplugin/dtrplugin.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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) From 4aeb497d6f01e72c753903bda448a88d10d0b5ce Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 4 Mar 2021 09:13:19 -0500 Subject: [PATCH 46/52] Add --nobuildlibs option to avoid asking about building libraries. Will still use bundled libraries if already present. --- configure | 61 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/configure b/configure index f0001d4990..03c116aa21 100755 --- a/configure +++ b/configure @@ -47,6 +47,7 @@ UsageFull() { 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" @@ -96,20 +97,21 @@ 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 -REBUILDOPT='' # Can be set to --rebuild and passed to get_library.sh +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 COMPERR='cpptrajcfg.compile.err' COMPOUT='cpptrajcfg.compile.out' @@ -501,7 +503,7 @@ EOF LIB_HOME[$LBZIP]=$CPPTRAJHOME LIB_FLAG[$LBZIP]=$CPPTRAJHOME/lib/${LIB_STTC[$LBZIP]} LIB_INCL[$LBZIP]="-I$CPPTRAJHOME/include" - TestProgram silent " Checking for bundled Bzip2" "$CXX" "$CXXFLAGS ${LIB_INCL[$LBZIP]}" testp.cpp "${LIB_FLAG[$LBZIP]}" + TestProgram $BUILDTESTOPT " Checking for bundled Bzip2" "$CXX" "$CXXFLAGS ${LIB_INCL[$LBZIP]}" testp.cpp "${LIB_FLAG[$LBZIP]}" if [ $? -ne 0 ] ; then CheckRebuild "Bzip2" "${LIB_FLAG[$LBZIP]}" # See if user would like to get Bzip2 @@ -535,7 +537,7 @@ EOF LIB_HOME[$LZIP]=$CPPTRAJHOME LIB_FLAG[$LZIP]=$CPPTRAJHOME/lib/${LIB_STTC[$LZIP]} LIB_INCL[$LZIP]="-I$CPPTRAJHOME/include" - TestProgram silent " Checking for bundled ZLIB" "$CXX" "$CXXFLAGS ${LIB_INCL[$LZIP]}" testp.cpp "${LIB_FLAG[$LZIP]}" + TestProgram $BUILDTESTOPT " Checking for bundled ZLIB" "$CXX" "$CXXFLAGS ${LIB_INCL[$LZIP]}" testp.cpp "${LIB_FLAG[$LZIP]}" if [ $? -ne 0 ] ; then CheckRebuild "ZLIB" "${LIB_FLAG[$LZIP]}" # See if user would like to get ZLIB @@ -570,7 +572,7 @@ EOF LIB_HOME[$LNETCDF]=$CPPTRAJHOME LIB_FLAG[$LNETCDF]=$CPPTRAJHOME/lib/${LIB_STTC[$LNETCDF]} LIB_INCL[$LNETCDF]="-I$CPPTRAJHOME/include" - TestProgram silent " Checking for bundled NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LNETCDF]}" testp.cpp "${LIB_FLAG[$LNETCDF]}" + TestProgram $BUILDTESTOPT " Checking for bundled NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LNETCDF]}" testp.cpp "${LIB_FLAG[$LNETCDF]}" if [ $? -ne 0 ] ; then # Check if lib present but needs to be rebuilt CheckRebuild "NetCDF" "${LIB_FLAG[$LNETCDF]}" @@ -606,7 +608,7 @@ EOF LIB_HOME[$LPARANC]=$CPPTRAJHOME LIB_FLAG[$LPARANC]=$CPPTRAJHOME/lib/${LIB_STTC[$LPARANC]} LIB_INCL[$LPARANC]="-I$CPPTRAJHOME/include" - TestProgram silent " Checking for bundled parallel NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LPARANC]}" testp.cpp "${LIB_FLAG[$LPARANC]}" + TestProgram $BUILDTESTOPT " Checking for bundled parallel NetCDF" "$CXX" "$CXXFLAGS ${LIB_INCL[$LPARANC]}" testp.cpp "${LIB_FLAG[$LPARANC]}" if [ $? -ne 0 ] ; then CheckRebuild "Pnetcdf" "${LIB_FLAG[$LPARANC]}" # See if user would like to get parallel netcdf @@ -628,6 +630,12 @@ EOF } DetermineFlink() { + if [ "$1" = 'silent' ] ; then + final_opt='silent' + shift + else + final_opt='' + fi desc="$1" flibs="$2" # Do we already need FLINK? @@ -649,7 +657,7 @@ DetermineFlink() { fi if [ "$use_flink" = 'yes' -a "$use_pthread" = 'yes' ] ; then # Final try. Report errors here - report='silent' + report=$final_opt else report='quiet' fi @@ -702,7 +710,7 @@ int main() { printf("Testing\n"); return 0; } EOF - DetermineFlink " Checking LAPACK/BLAS" "${LIB_FLAG[$LLAPACK]} ${LIB_FLAG[$LBLAS]}" + DetermineFlink silent " Checking LAPACK/BLAS" "${LIB_FLAG[$LLAPACK]} ${LIB_FLAG[$LBLAS]}" if [ $? -ne 0 ] ; then if [ "${LIB_STAT[$LBLAS]}" = 'enabled' ] ; then if [ "$BLAS_TYPE" = 'openblas' ] ; then @@ -730,20 +738,20 @@ EOF LIB_HOME[$LBLAS]=$CPPTRAJHOME LIB_FLAG[$LBLAS]=$CPPTRAJHOME/lib/${LIB_STTC[$LBLAS]} LIB_INCL[$LBLAS]="-I$CPPTRAJHOME/include" - DetermineFlink " Checking for bundled BLAS" "${LIB_FLAG[$LLAPACK]} ${LIB_FLAG[$LBLAS]}" + DetermineFlink $BUILDTESTOPT " Checking for bundled LAPACK/BLAS" "${LIB_FLAG[$LLAPACK]} ${LIB_FLAG[$LBLAS]}" #TestProgram silent " Checking for bundled OpenBLAS" "$CXX" "$CXXFLAGS ${LIB_INCL[$LBLAS]}" testp.cpp "${LIB_FLAG[$LBLAS]}" if [ $? -ne 0 ] ; then # Check if lib present but needs to be rebuilt - CheckRebuild "BLAS" "${LIB_FLAG[$LBLAS]}" + CheckRebuild "LAPACK/BLAS" "${LIB_FLAG[$LBLAS]}" # See if user would like to get blas PREFIX=$CPPTRAJHOME CC="$CC" CFLAGS="$CFLAGS" FC="$FC" LIBNAME="$MATH_LIBNAME" \ SRCDIR=$MATH_SRCDIR SRCTAR=$MATH_SRCTAR URL=$MATH_URL ./get_library.sh $REBUILDOPT $MATH_OPTS if [ $? -ne 0 ] ; then - ErrMsg "Building BLAS failed." + ErrMsg "Building LAPACK/BLAS failed." exit 1 fi # Test the built openblas - DetermineFlink " Checking built BLAS" "${LIB_FLAG[$LLAPACK]} ${LIB_FLAG[$LBLAS]}" + DetermineFlink " Checking built LAPACK/BLAS" "${LIB_FLAG[$LLAPACK]} ${LIB_FLAG[$LBLAS]}" #TestProgram " Checking built OpenBLAS" "$CXX" "$CXXFLAGS ${LIB_INCL[$LBLAS]}" testp.cpp "${LIB_FLAG[$LBLAS]}" fi else @@ -807,7 +815,7 @@ EOF LIB_HOME[$LFFTW3]=$CPPTRAJHOME LIB_FLAG[$LFFTW3]=$CPPTRAJHOME/lib/${LIB_STTC[$LFFTW3]} LIB_INCL[$LFFTW3]="-I$CPPTRAJHOME/include" - TestProgram silent " Checking for bundled FFTW" "$CXX" "$CXXFLAGS ${LIB_INCL[$LFFTW3]}" testp.cpp "${LIB_FLAG[$LFFTW3]}" + TestProgram $BUILDTESTOPT " Checking for bundled FFTW" "$CXX" "$CXXFLAGS ${LIB_INCL[$LFFTW3]}" testp.cpp "${LIB_FLAG[$LFFTW3]}" if [ $? -ne 0 ] ; then CheckRebuild "FFTW" "${LIB_FLAG[$LFFTW3]}" # See if user would like to get FFTW @@ -943,6 +951,8 @@ EOF TestLibraries() { if [ $BUILD_LIBS -eq 1 ] ; then echo "Enabled libraries will be built if not present." + elif [ -z "$BUILDTESTOPT" ] ; then + echo "CPPTRAJ will not ask to build libraries if not present." fi if [ "${LIB_TEST[$LBZIP]}" = 'yes' ] ; then TestBzlib ; fi if [ "${LIB_TEST[$LZIP]}" = 'yes' ] ; then TestZlib ; fi @@ -2188,6 +2198,7 @@ while [ ! -z "$1" ] ; do '--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' ;; From 36bec8d820f669b6fc3dfa6dbc7a8e5a689effd4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 4 Mar 2021 09:44:41 -0500 Subject: [PATCH 47/52] Add note about --nobuildlibs --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5d180ee38c..db7b21971f 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,9 @@ an AmberTools installation (`$AMBERHOME` must be set), e.g. `./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. +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 From a2cf7f879e27b74e1a2317cf0a57963c9fb6396e Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 4 Mar 2021 10:08:19 -0500 Subject: [PATCH 48/52] Fix uninstall rule to remove more fftw stuff --- src/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Makefile b/src/Makefile index b03396a137..8c15433dfd 100644 --- a/src/Makefile +++ b/src/Makefile @@ -127,6 +127,8 @@ uninstall_lib: 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) From 3e792ad141188660a8e9379897542b0d470bd3df Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 4 Mar 2021 10:40:20 -0500 Subject: [PATCH 49/52] Fix detection of cpptraj test root directory, and use it to find necessary test utilities. Should make it possible to source cpptraj.sh in any directory and have tests here use it. --- test/MasterTest.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/MasterTest.sh b/test/MasterTest.sh index 669c8579ce..b367fb9db3 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." @@ -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}'` From be2cfde5859da72f06fdac9eb83f2f046b640f73 Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 4 Mar 2021 11:25:11 -0500 Subject: [PATCH 50/52] Ensure the files in the dat directory get installed to PREFIX when prefix is specified. --- configure | 42 ++++++++++++++++++++++++++---------------- src/Makefile | 9 ++++++++- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/configure b/configure index 03c116aa21..49026419f6 100755 --- a/configure +++ b/configure @@ -97,21 +97,22 @@ 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 -REBUILDOPT='' # Can be set to --rebuild and passed to get_library.sh -BUILDTESTOPT='silent' # Set to blank to avoid asking about building libraries +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' @@ -182,6 +183,7 @@ CPPTRAJHOME='' CPPTRAJBIN='' CPPTRAJLIB='' CPPTRAJINC='' +CPPTRAJDAT='' # ----- External Libraries ----------------------- # Library indices @@ -1747,6 +1749,9 @@ BasicChecks() { 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 @@ -2208,6 +2213,7 @@ while [ ! -z "$1" ] ; do CPPTRAJBIN=$VALUE/bin CPPTRAJLIB=$VALUE/lib CPPTRAJINC=$VALUE/include + CPPTRAJDAT=$VALUE/dat ;; # Hidden debug options '--debug-parallel' ) DIRECTIVES="$DIRECTIVES -DPARALLEL_DEBUG_VERBOSE" ;; @@ -2379,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" @@ -2443,6 +2449,7 @@ CPPTRAJHOME="$CPPTRAJHOME" CPPTRAJBIN="$CPPTRAJBIN" CPPTRAJLIB="$CPPTRAJLIB" CPPTRAJINC="$CPPTRAJINC" +CPPTRAJDAT="$CPPTRAJDAT" INSTALL_TARGETS=$INSTALL_TARGETS @@ -2501,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/src/Makefile b/src/Makefile index 8c15433dfd..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) From 40cbacb68ff675e0ebbd54773ca58da3f04eec4e Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 4 Mar 2021 12:49:17 -0500 Subject: [PATCH 51/52] CPPTRAJ_NDIFF and CPPTRAJ_NPROC are now set by CPPTRAJ_TEST_ROOT which is an absolute path. --- test/MasterTest.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/MasterTest.sh b/test/MasterTest.sh index b367fb9db3..8fe08ae930 100644 --- a/test/MasterTest.sh +++ b/test/MasterTest.sh @@ -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 } From de0d357a5a6b2c6f8752a6d665edf857937d963d Mon Sep 17 00:00:00 2001 From: "Daniel R. Roe" Date: Thu, 4 Mar 2021 13:40:08 -0500 Subject: [PATCH 52/52] Add --buildlibs to Linux GNU parallel Jenkins build so pnetcdf check is not interactive. Will also serve as a partial test of --buildlibs. --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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"