diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b69476668f..2fcdd99f45 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,4 +33,4 @@ jobs: conda: uses: ./.github/workflows/condaWF.yml - secrets: inherit \ No newline at end of file + secrets: inherit diff --git a/.github/workflows/dockerWF.yml b/.github/workflows/dockerWF.yml index ff535fa80d..e37f001c4f 100644 --- a/.github/workflows/dockerWF.yml +++ b/.github/workflows/dockerWF.yml @@ -19,11 +19,9 @@ jobs: strategy: fail-fast: false matrix: - # centos7 (gcc 4.8) # fedora38 (gcc 13) # rockylinux8 variant: - - centos7 - fedora38 - rocky8 steps: diff --git a/CHANGES/v2.10.md b/CHANGES/v2.10.md index 430998292d..4b6df535ed 100644 --- a/CHANGES/v2.10.md +++ b/CHANGES/v2.10.md @@ -4,5 +4,7 @@ This page contains changes that will end up in 2.10 +- **PLUMED 2.10 requires a C++17 compatible compiler**. + - Changes relevant for developers: - - Removed some shortcuts for `ActionRegister.h` (from the modules bias colvar function sasa and vatom) and `CLToolRegister.h` (from the module cltools), now the two headers can only be included with `#include "core/ActionRegister.h"` or `#include "core/CLToolRegister.h"`. \ No newline at end of file + - Removed some shortcuts for `ActionRegister.h` (from the modules bias colvar function sasa and vatom) and `CLToolRegister.h` (from the module cltools), now the two headers can only be included with `#include "core/ActionRegister.h"` or `#include "core/CLToolRegister.h"`. diff --git a/README.md b/README.md index 9433178a63..f094687118 100644 --- a/README.md +++ b/README.md @@ -92,9 +92,8 @@ Required software Required software: * GNU make. -* C/c++ compiler (c++11 support is required as of version 2.4). +* C/c++ compiler (c++17 support is required as of version 2.10). * A modern version of the `patch` command line tool. -* Support for POSIX library `dirent.h`. Suggested software (libraries are checked by `./configure` and enabled if available): diff --git a/conda/plumed/build.sh b/conda/plumed/build.sh index 2edb05b8b3..ef840ba13c 100644 --- a/conda/plumed/build.sh +++ b/conda/plumed/build.sh @@ -16,6 +16,11 @@ export CPPFLAGS="-D__PLUMED_DEFAULT_KERNEL=$PREFIX/lib/libplumedKernel$SHLIB_EXT # enable optimization export CXXFLAGS="${CXXFLAGS//-O2/-O3}" +if [[ $(uname) == "Darwin" ]]; then +# see https://conda-forge.org/docs/maintainer/knowledge_base.html#newer-c-features-with-old-sdk + CXXFLAGS="${CXXFLAGS} -D_LIBCPP_DISABLE_AVAILABILITY" +fi + # libraries are explicitly listed here due to --disable-libsearch export LIBS="-lfftw3 -lgsl -lgslcblas -llapack -lblas -lz $LIBS" diff --git a/configure b/configure index cbfff8ac9a..c1dfeb7cab 100755 --- a/configure +++ b/configure @@ -731,13 +731,9 @@ enable_external_blas enable_molfile_plugins enable_external_molfile_plugins enable_zlib -enable_readdir_r -enable_cregex enable_dlopen enable_rtld_default -enable_chdir enable_subprocess -enable_getcwd enable_popen enable_execinfo enable_gsl @@ -1393,8 +1389,8 @@ Optional Features: --enable-pdfdoc enable pdf version of the manual, default: no --enable-debug enable debugging, default: no --enable-gcov enable gcov to estimate code coverage, default: no - --enable-cxx 11 or 14. To link libraries with headers that need - this C++ level. Use --enable-cxx=none to remove + --enable-cxx 17, 20, or 23. To link libraries with headers that + need this C++ level. Use --enable-cxx=none to remove -std=c++ flag --enable-basic-warnings enable basic warnings, default: yes --enable-fussy enable fussy warnings, default: no @@ -1433,15 +1429,10 @@ Optional Features: enable search for external molfile_plugins, default: yes --enable-zlib enable search for zlib, default: yes - --enable-readdir-r enable search for readdir_r (threadsafe), default: - no - --enable-cregex enable search for C regular expression, default: yes --enable-dlopen enable search for dlopen, default: yes --enable-rtld_default enable search for RTLD_DEFAULT macro, default: yes - --enable-chdir enable search for chdir function, default: yes --enable-subprocess enable search for functions needed to manage a subprocess, default: yes - --enable-getcwd enable search for getcwd function, default: yes --enable-popen enable search for popen, default: yes --enable-execinfo enable search for execinfo, default: yes --enable-gsl enable search for gsl, default: yes @@ -1769,6 +1760,48 @@ fi } # ac_fn_c_try_link +# ac_fn_cxx_try_run LINENO +# ------------------------ +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_cxx_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_run + # ac_fn_cxx_try_cpp LINENO # ------------------------ # Try to preprocess conftest.$ac_ext, and return whether this succeeded. @@ -1893,48 +1926,6 @@ fi } # ac_fn_cxx_check_header_mongrel -# ac_fn_cxx_try_run LINENO -# ------------------------ -# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes -# that executables *can* be run. -ac_fn_cxx_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then : - ac_retval=0 -else - $as_echo "$as_me: program exited with status $ac_status" >&5 - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_cxx_try_run - # ac_fn_cxx_check_header_compile LINENO HEADER VAR INCLUDES # --------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in @@ -1965,73 +1956,6 @@ $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_header_compile - -# ac_fn_cxx_check_func LINENO FUNC VAR -# ------------------------------------ -# Tests whether FUNC exists, setting the cache variable VAR accordingly -ac_fn_cxx_check_func () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -/* Define $2 to an innocuous variant, in case declares $2. - For example, HP-UX 11i declares gettimeofday. */ -#define $2 innocuous_$2 - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $2 (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $2 - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $2 (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$2 || defined __stub___$2 -choke me -#endif - -int -main () -{ -return $2 (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_cxx_check_func cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. @@ -2622,8 +2546,11 @@ fi if test "${enable_cxx+set}" = set; then : enableval=$enable_cxx; case "${enableval}" in - (11) cxx_level=11 ;; - (14) cxx_level=14 ;; + (11) cxx_level=17 ;; + (14) cxx_level=17 ;; + (17) cxx_level=17 ;; + (20) cxx_level=20 ;; + (23) cxx_level=23 ;; (none) cxx_level="" ;; (*) as_fn_error $? "cxx level not supported" "$LINENO" 5 esac @@ -2632,7 +2559,7 @@ $as_echo "$as_me: Selected C++ level: $cxx_level" >&6;} else - cxx_level="11" + cxx_level="17" fi @@ -3016,42 +2943,6 @@ fi -readdir_r= -# Check whether --enable-readdir-r was given. -if test "${enable_readdir_r+set}" = set; then : - enableval=$enable_readdir_r; case "${enableval}" in - (yes) readdir_r=true ;; - (no) readdir_r=false ;; - (*) as_fn_error $? "wrong argument to --enable-readdir-r" "$LINENO" 5 ;; - esac -else - case "no" in - (yes) readdir_r=true ;; - (no) readdir_r=false ;; - esac - -fi - - - -cregex= -# Check whether --enable-cregex was given. -if test "${enable_cregex+set}" = set; then : - enableval=$enable_cregex; case "${enableval}" in - (yes) cregex=true ;; - (no) cregex=false ;; - (*) as_fn_error $? "wrong argument to --enable-cregex" "$LINENO" 5 ;; - esac -else - case "yes" in - (yes) cregex=true ;; - (no) cregex=false ;; - esac - -fi - - - dlopen= # Check whether --enable-dlopen was given. if test "${enable_dlopen+set}" = set; then : @@ -3088,24 +2979,6 @@ fi -chdir= -# Check whether --enable-chdir was given. -if test "${enable_chdir+set}" = set; then : - enableval=$enable_chdir; case "${enableval}" in - (yes) chdir=true ;; - (no) chdir=false ;; - (*) as_fn_error $? "wrong argument to --enable-chdir" "$LINENO" 5 ;; - esac -else - case "yes" in - (yes) chdir=true ;; - (no) chdir=false ;; - esac - -fi - - - subprocess= # Check whether --enable-subprocess was given. if test "${enable_subprocess+set}" = set; then : @@ -3124,24 +2997,6 @@ fi -getcwd= -# Check whether --enable-getcwd was given. -if test "${enable_getcwd+set}" = set; then : - enableval=$enable_getcwd; case "${enableval}" in - (yes) getcwd=true ;; - (no) getcwd=false ;; - (*) as_fn_error $? "wrong argument to --enable-getcwd" "$LINENO" 5 ;; - esac -else - case "yes" in - (yes) getcwd=true ;; - (no) getcwd=false ;; - esac - -fi - - - popen= # Check whether --enable-popen was given. if test "${enable_popen+set}" = set; then : @@ -5283,13 +5138,13 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX declares c++11 support" >&5 -$as_echo_n "checking whether $CXX declares c++11 support... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX declares c++17 support" >&5 +$as_echo_n "checking whether $CXX declares c++17 support... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#if __cplusplus <= 199711L -this_compiler_does_not_support_cxx11 +#if __cplusplus < 201703L +this_compiler_does_not_support_cxx17 #endif int @@ -5303,88 +5158,24 @@ _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; }; - support_cxx11=true + support_cxx17=true else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ; - support_cxx11=false + support_cxx17=false fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -if test "$support_cxx11" = false +if test "$support_cxx17" = false then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: C++11 support is required as of PLUMED 2.4" >&5 -$as_echo "$as_me: WARNING: C++11 support is required as of PLUMED 2.4" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Your compiler appears not to support C++11" >&5 -$as_echo "$as_me: WARNING: Your compiler appears not to support C++11" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: C++17 support is required as of PLUMED 2.10" >&5 +$as_echo "$as_me: WARNING: C++17 support is required as of PLUMED 2.10" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Your compiler appears not to support C++17" >&5 +$as_echo "$as_me: WARNING: Your compiler appears not to support C++17" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Please change compiler or make sure that everything works correctly" >&5 $as_echo "$as_me: WARNING: Please change compiler or make sure that everything works correctly" >&2;} fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C++ library supports C++11 exceptions" >&5 -$as_echo_n "checking whether C++ library supports C++11 exceptions... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -#include -#include -#include -// capable to catch: -void func(void) { - try{ - } catch(std::bad_array_new_length &) { - } catch(std::bad_function_call &) { - } catch(std::bad_weak_ptr &) { - } catch(std::ios_base::failure &e) { - if(e.code().category()==std::generic_category()) {} - else if(e.code().category()==std::system_category()) {} - else if(e.code().category()==std::iostream_category()) {} - else if(e.code().category()==std::future_category()) {} - } catch(std::system_error &e) { - if(e.code().category()==std::generic_category()) {} - else if(e.code().category()==std::system_category()) {} - else if(e.code().category()==std::iostream_category()) {} - else if(e.code().category()==std::future_category()) {} - } -// capable to throw: - auto a=std::bad_array_new_length(); - auto b=std::bad_function_call(); - auto c=std::bad_weak_ptr(); - auto d=std::system_error(10,std::generic_category(),"msg"); - auto e=std::system_error(10,std::system_category(),"msg"); - auto f=std::system_error(10,std::iostream_category(),"msg"); - auto g=std::system_error(10,std::future_category(),"msg"); - auto h=std::ios_base::failure("msg",std::error_code(10,std::generic_category())); - auto i=std::ios_base::failure("msg",std::error_code(10,std::system_category())); - auto j=std::ios_base::failure("msg",std::error_code(10,std::iostream_category())); - auto k=std::ios_base::failure("msg",std::error_code(10,std::future_category())); -} - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; }; - $as_echo "#define __PLUMED_LIBCXX11 1" >>confdefs.h - - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if test "$dependency_tracking" = true @@ -5473,412 +5264,147 @@ fi # some of them might be made optional if we find that are not available in some system { $as_echo "$as_me:${as_lineno-$LINENO}: Now we will check compulsory headers and libraries" >&5 $as_echo "$as_me: Now we will check compulsory headers and libraries" >&6;} -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 -$as_echo_n "checking how to run the C++ preprocessor... " >&6; } -if test -z "$CXXCPP"; then - if ${ac_cv_prog_CXXCPP+:} false; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CXXCPP needs to be expanded - for CXXCPP in "$CXX -E" "/lib/cpp" - do - ac_preproc_ok=false -for ac_cxx_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_cxx_try_cpp "$LINENO"; then : -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_cxx_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext + found=ko + __PLUMED_CXX17_FILESYSTEM=no + if test "${libsearch}" = true ; then + testlibs="stdc++fs" + else + testlibs="" + fi + save_LIBS="$LIBS" -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CXXCPP=$CXXCPP - -fi - CXXCPP=$ac_cv_prog_CXXCPP -else - ac_cv_prog_CXXCPP=$CXXCPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 -$as_echo "$CXXCPP" >&6; } -ac_preproc_ok=false -for ac_cxx_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_cxx_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_cxx_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } -fi - -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if ${ac_cv_path_GREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_GREP" || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_GREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_GREP=$GREP -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } -if ${ac_cv_path_EGREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_EGREP" || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count + # check if multiple libraries are required simultaneously + multiple="no" + if test "" = "true"; then + multiple="yes" + all_LIBS="" + for testlib in $testlibs; + do + all_LIBS="$all_LIBS -l$testlib" + done + testlibs=" " # to check only without libraries, and later with all together fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_EGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_EGREP=$EGREP -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if ${ac_cv_header_stdc+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + # check without libraries + { $as_echo "$as_me:${as_lineno-$LINENO}: checking filesystem library without extra libs" >&5 +$as_echo_n "checking filesystem library without extra libs... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include -#include -#include -#include -int -main () -{ +#include +#include +#include - ; +int main(){ + std::filesystem::path path; + for (auto const& dir_entry : std::filesystem::directory_iterator{"a"}) { + std::cout<conftest.$ac_ext -/* end confdefs.h. */ -#include _ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - +if ac_fn_cxx_try_link "$LINENO"; then : + found=ok + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } else - ac_cv_header_stdc=no -fi -rm -f conftest* + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test "$found" = "ko" ; then + if test "$multiple" = "yes" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking filesystem library with $all_LIBS" >&5 +$as_echo_n "checking filesystem library with $all_LIBS... " >&6; } + LIBS="$all_LIBS $LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif +#include +#include +#include -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; +int main(){ + std::filesystem::path path; + for (auto const& dir_entry : std::filesystem::directory_iterator{"a"}) { + std::cout<&5 +$as_echo "yes" >&6; } else - ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + else + for testlib in $testlibs + do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking filesystem library with -l$testlib" >&5 +$as_echo_n "checking filesystem library with -l$testlib... " >&6; } + LIBS="-l$testlib $LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ -$as_echo "#define STDC_HEADERS 1" >>confdefs.h +#include +#include +#include -fi +int main(){ + std::filesystem::path path; + for (auto const& dir_entry : std::filesystem::directory_iterator{"a"}) { + std::cout<>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + found=ok + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test $found = ok ; then + break + fi + LIBS="$save_LIBS" + done + fi + fi -done - - -ac_fn_cxx_check_header_mongrel "$LINENO" "dirent.h" "ac_cv_header_dirent_h" "$ac_includes_default" -if test "x$ac_cv_header_dirent_h" = xyes; then : - -else - as_fn_error $? "compulsory header not found" "$LINENO" 5 -fi + if test $found = ok ; then + $as_echo "#define __PLUMED_CXX17_FILESYSTEM 1" >>confdefs.h + __PLUMED_CXX17_FILESYSTEM=yes + else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot enable __PLUMED_CXX17_FILESYSTEM" >&5 +$as_echo "$as_me: WARNING: cannot enable __PLUMED_CXX17_FILESYSTEM" >&2;} + LIBS="$save_LIBS" + fi -ac_fn_cxx_check_func "$LINENO" "readdir" "ac_cv_func_readdir" -if test "x$ac_cv_func_readdir" = xyes; then : -else - as_fn_error $? "compulsory function not found" "$LINENO" 5 +if test "$__PLUMED_CXX17_FILESYSTEM" != yes +then + as_fn_error $? "C++17 filesystem library not supported, please check your compiler" "$LINENO" 5 fi @@ -6572,520 +6098,470 @@ int main(){ else return 1; } -_ACEOF -if ac_fn_cxx_try_run "$LINENO"; then : - sdot_returns_double=yes ; { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - sdot_returns_double=no ; { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - - -fi - -if test "$sdot_returns_double" = yes ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: Setting workaround for blas float functions returning double" >&5 -$as_echo "$as_me: Setting workaround for blas float functions returning double" >&6;} - $as_echo "#define __PLUMED_BLAS_RETURNS_FLOAT double" >>confdefs.h - - if test -n "$lapack_found" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: Setting workaround for lapack float functions returning double" >&5 -$as_echo "$as_me: Setting workaround for lapack float functions returning double" >&6;} - $as_echo "#define __PLUMED_LAPACK_RETURNS_FLOAT double" >>confdefs.h - - fi -else if test "$sdot_returns_float" = no && test "$sdot_returns_double" = no ; -then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: There is a problem with your blas implementation" >&5 -$as_echo "$as_me: WARNING: There is a problem with your blas implementation" >&2;} -fi - -fi - -fi - -#### End of compulsory libraries #### - -#### Optional libraries #### -{ $as_echo "$as_me:${as_lineno-$LINENO}: Now we will check for optional headers and libraries" >&5 -$as_echo "$as_me: Now we will check for optional headers and libraries" >&6;} - -############################################################# -# I add the possibility to completely remove molfile_plugins -# I would like to be 100% that the molfile module compiles -# correctly on all machines -# In case of problem, it is sufficient to configure with -# ./configure --disable-molfile-plugins -# GB -############################################################# - -if test $molfile_plugins = true ; then - -# Check for molfile_plugins and use internal fallback if not found. TG - -# We always have molfile, now -$as_echo "#define __PLUMED_HAS_MOLFILE_PLUGINS 1" >>confdefs.h - - - if test "$external_molfile_plugins" = true ; then - - found=ko - __PLUMED_HAS_EXTERNAL_MOLFILE_PLUGINS=no - ac_fn_cxx_check_header_mongrel "$LINENO" "libmolfile_plugin.h" "ac_cv_header_libmolfile_plugin_h" "$ac_includes_default" -if test "x$ac_cv_header_libmolfile_plugin_h" = xyes; then : - - - if test "${libsearch}" = true ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing molfile_dcdplugin_init" >&5 -$as_echo_n "checking for library containing molfile_dcdplugin_init... " >&6; } -if ${ac_cv_search_molfile_dcdplugin_init+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char molfile_dcdplugin_init (); -int -main () -{ -return molfile_dcdplugin_init (); - ; - return 0; -} -_ACEOF -for ac_lib in '' molfile_plugin; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_search_molfile_dcdplugin_init=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_molfile_dcdplugin_init+:} false; then : - break -fi -done -if ${ac_cv_search_molfile_dcdplugin_init+:} false; then : - -else - ac_cv_search_molfile_dcdplugin_init=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_molfile_dcdplugin_init" >&5 -$as_echo "$ac_cv_search_molfile_dcdplugin_init" >&6; } -ac_res=$ac_cv_search_molfile_dcdplugin_init -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - found=ok -fi - - else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing molfile_dcdplugin_init" >&5 -$as_echo_n "checking for library containing molfile_dcdplugin_init... " >&6; } -if ${ac_cv_search_molfile_dcdplugin_init+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char molfile_dcdplugin_init (); -int -main () -{ -return molfile_dcdplugin_init (); - ; - return 0; -} -_ACEOF -for ac_lib in '' ; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_search_molfile_dcdplugin_init=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_molfile_dcdplugin_init+:} false; then : - break -fi -done -if ${ac_cv_search_molfile_dcdplugin_init+:} false; then : - -else - ac_cv_search_molfile_dcdplugin_init=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_molfile_dcdplugin_init" >&5 -$as_echo "$ac_cv_search_molfile_dcdplugin_init" >&6; } -ac_res=$ac_cv_search_molfile_dcdplugin_init -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - found=ok -fi - - fi - - +_ACEOF +if ac_fn_cxx_try_run "$LINENO"; then : + sdot_returns_double=yes ; { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + sdot_returns_double=no ; { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi - if test $found = ok ; then - $as_echo "#define __PLUMED_HAS_EXTERNAL_MOLFILE_PLUGINS 1" >>confdefs.h +fi - __PLUMED_HAS_EXTERNAL_MOLFILE_PLUGINS=yes - else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot enable __PLUMED_HAS_EXTERNAL_MOLFILE_PLUGINS" >&5 -$as_echo "$as_me: WARNING: cannot enable __PLUMED_HAS_EXTERNAL_MOLFILE_PLUGINS" >&2;} - fi +if test "$sdot_returns_double" = yes ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Setting workaround for blas float functions returning double" >&5 +$as_echo "$as_me: Setting workaround for blas float functions returning double" >&6;} + $as_echo "#define __PLUMED_BLAS_RETURNS_FLOAT double" >>confdefs.h - if test "$__PLUMED_HAS_EXTERNAL_MOLFILE_PLUGINS" != yes ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using internal molfile_plugins, which only support dcd/xtc/trr/trj/crd files" >&5 -$as_echo "$as_me: WARNING: using internal molfile_plugins, which only support dcd/xtc/trr/trj/crd files" >&2;} - else - $as_echo "#define __PLUMED_HAS_EXTERNAL_MOLFILE_PLUGINS 1" >>confdefs.h + if test -n "$lapack_found" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Setting workaround for lapack float functions returning double" >&5 +$as_echo "$as_me: Setting workaround for lapack float functions returning double" >&6;} + $as_echo "#define __PLUMED_LAPACK_RETURNS_FLOAT double" >>confdefs.h - fi fi +else if test "$sdot_returns_float" = no && test "$sdot_returns_double" = no ; +then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: There is a problem with your blas implementation" >&5 +$as_echo "$as_me: WARNING: There is a problem with your blas implementation" >&2;} fi -# this is special and is also attached to STATIC_LIBS -# this flag should be used also when linking MD engines to allow plumed -# to be loaded later -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 -$as_echo_n "checking for dlopen in -ldl... " >&6; } -if ${ac_cv_lib_dl_dlopen+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dlopen (); -int -main () -{ -return dlopen (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_dl_dlopen=yes -else - ac_cv_lib_dl_dlopen=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 -$as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = xyes; then : - STATIC_LIBS="-ldl $STATIC_LIBS" LIBS="-ldl $LIBS" + fi +#### End of compulsory libraries #### -mpi_found=ko -# optional libraries follow -if test $mpi = true ; then +#### Optional libraries #### +{ $as_echo "$as_me:${as_lineno-$LINENO}: Now we will check for optional headers and libraries" >&5 +$as_echo "$as_me: Now we will check for optional headers and libraries" >&6;} - found=ko - __PLUMED_HAS_MPI=no - ac_fn_cxx_check_header_mongrel "$LINENO" "mpi.h" "ac_cv_header_mpi_h" "$ac_includes_default" -if test "x$ac_cv_header_mpi_h" = xyes; then : +############################################################# +# I add the possibility to completely remove molfile_plugins +# I would like to be 100% that the molfile module compiles +# correctly on all machines +# In case of problem, it is sufficient to configure with +# ./configure --disable-molfile-plugins +# GB +############################################################# +if test $molfile_plugins = true ; then - if test "${libsearch}" = true ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing MPI_Init" >&5 -$as_echo_n "checking for library containing MPI_Init... " >&6; } -if ${ac_cv_search_MPI_Init+:} false; then : +# Check for molfile_plugins and use internal fallback if not found. TG + +# We always have molfile, now +$as_echo "#define __PLUMED_HAS_MOLFILE_PLUGINS 1" >>confdefs.h + + + if test "$external_molfile_plugins" = true ; then + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 +$as_echo_n "checking how to run the C++ preprocessor... " >&6; } +if test -z "$CXXCPP"; then + if ${ac_cv_prog_CXXCPP+:} false; then : $as_echo_n "(cached) " >&6 else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext + # Double quotes because CXXCPP needs to be expanded + for CXXCPP in "$CXX -E" "/lib/cpp" + do + ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" +#ifdef __STDC__ +# include +#else +# include #endif -char MPI_Init (); -int -main () -{ -return MPI_Init (); - ; - return 0; -} + Syntax error _ACEOF -for ac_lib in '' ; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_search_MPI_Init=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_MPI_Init+:} false; then : - break -fi -done -if ${ac_cv_search_MPI_Init+:} false; then : +if ac_fn_cxx_try_cpp "$LINENO"; then : else - ac_cv_search_MPI_Init=no + # Broken: fails on valid input. +continue fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_MPI_Init" >&5 -$as_echo "$ac_cv_search_MPI_Init" >&6; } -ac_res=$ac_cv_search_MPI_Init -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - found=ok +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing MPI_Init" >&5 -$as_echo_n "checking for library containing MPI_Init... " >&6; } -if ${ac_cv_search_MPI_Init+:} false; then : - $as_echo_n "(cached) " >&6 + done + ac_cv_prog_CXXCPP=$CXXCPP + +fi + CXXCPP=$ac_cv_prog_CXXCPP else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext + ac_cv_prog_CXXCPP=$CXXCPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 +$as_echo "$CXXCPP" >&6; } +ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" +#ifdef __STDC__ +# include +#else +# include #endif -char MPI_Init (); -int -main () -{ -return MPI_Init (); - ; - return 0; -} -_ACEOF -for ac_lib in '' ; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_search_MPI_Init=$ac_res + Syntax error +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_MPI_Init+:} false; then : - break +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break fi +rm -f conftest.err conftest.i conftest.$ac_ext + done -if ${ac_cv_search_MPI_Init+:} false; then : +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : else - ac_cv_search_MPI_Init=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_MPI_Init" >&5 -$as_echo "$ac_cv_search_MPI_Init" >&6; } -ac_res=$ac_cv_search_MPI_Init -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - found=ok + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } fi - fi +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_GREP" || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" - if test $found = ok ; then - $as_echo "#define __PLUMED_HAS_MPI 1" >>confdefs.h - __PLUMED_HAS_MPI=yes - else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot enable __PLUMED_HAS_MPI" >&5 -$as_echo "$as_me: WARNING: cannot enable __PLUMED_HAS_MPI" >&2;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_EGREP" || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac - if test "$__PLUMED_HAS_MPI" = yes; then - mpi_found=ok + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else - mpi_found=ko + ac_cv_path_EGREP=$EGREP fi -# search for openmp is automatically disabled by autoconf -# when configuring with --disable-openmp - - OPENMP_CXXFLAGS= - # Check whether --enable-openmp was given. -if test "${enable_openmp+set}" = set; then : - enableval=$enable_openmp; + fi fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" - if test "$enable_openmp" != no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CXX option to support OpenMP" >&5 -$as_echo_n "checking for $CXX option to support OpenMP... " >&6; } -if ${ac_cv_prog_cxx_openmp+:} false; then : + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#include +#include +#include +#include -#ifndef _OPENMP - choke me -#endif -#include -int main () { return omp_get_num_threads (); } +int +main () +{ + ; + return 0; +} _ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_prog_cxx_openmp='none needed' +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes else - ac_cv_prog_cxx_openmp='unsupported' - for ac_option in -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp -homp \ - -Popenmp --openmp; do - ac_save_CXXFLAGS=$CXXFLAGS - CXXFLAGS="$CXXFLAGS $ac_option" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -#ifndef _OPENMP - choke me -#endif -#include -int main () { return omp_get_num_threads (); } +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include _ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_prog_cxx_openmp=$ac_option -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - CXXFLAGS=$ac_save_CXXFLAGS - if test "$ac_cv_prog_cxx_openmp" != unsupported; then - break - fi - done -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_openmp" >&5 -$as_echo "$ac_cv_prog_cxx_openmp" >&6; } - case $ac_cv_prog_cxx_openmp in #( - "none needed" | unsupported) - ;; #( - *) - OPENMP_CXXFLAGS=$ac_cv_prog_cxx_openmp ;; - esac - fi +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : +else + ac_cv_header_stdc=no +fi +rm -f conftest* +fi -if test $asmjit = true ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether architecture is X86/X64" >&5 -$as_echo_n "checking whether architecture is X86/X64... " >&6; } +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#include -#if !(defined(_M_IX86 ) || defined(__X86__ ) || defined(__i386 ) || \ - defined(__IA32__) || defined(__I86__ ) || defined(__i386__) || \ - defined(__i486__) || defined(__i586__) || defined(__i686__) || \ - defined(_M_X64 ) || defined(__x86_64) || defined(__x86_64__) || \ - defined(_M_AMD64) || defined(__amd64 ) || defined(__amd64__ )) -this_is_not_x86_x64 +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { - - ; + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; }; - x86_x64=true +if ac_fn_cxx_try_run "$LINENO"; then : + else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } ; - x86_x64=false + ac_cv_header_stdc=no fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi -if test $asmjit = true && test $x86_x64 = false ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: asmjit does not support this architecture, it will be disabled" >&5 -$as_echo "$as_me: WARNING: asmjit does not support this architecture, it will be disabled" >&2;} - asmjit=false fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_cxx_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + found=ko + __PLUMED_HAS_EXTERNAL_MOLFILE_PLUGINS=no + ac_fn_cxx_check_header_mongrel "$LINENO" "libmolfile_plugin.h" "ac_cv_header_libmolfile_plugin_h" "$ac_includes_default" +if test "x$ac_cv_header_libmolfile_plugin_h" = xyes; then : -if test $asmjit = true ; then - found=ko -# asmjit calls clock_gettime and thus should be linked to rt on Linux - if test `(uname)` = Linux ; then if test "${libsearch}" = true ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5 -$as_echo_n "checking for library containing clock_gettime... " >&6; } -if ${ac_cv_search_clock_gettime+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing molfile_dcdplugin_init" >&5 +$as_echo_n "checking for library containing molfile_dcdplugin_init... " >&6; } +if ${ac_cv_search_molfile_dcdplugin_init+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS @@ -7098,16 +6574,16 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char clock_gettime (); +char molfile_dcdplugin_init (); int main () { -return clock_gettime (); +return molfile_dcdplugin_init (); ; return 0; } _ACEOF -for ac_lib in '' rt; do +for ac_lib in '' molfile_plugin; do if test -z "$ac_lib"; then ac_res="none required" else @@ -7115,34 +6591,34 @@ for ac_lib in '' rt; do LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_search_clock_gettime=$ac_res + ac_cv_search_molfile_dcdplugin_init=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext - if ${ac_cv_search_clock_gettime+:} false; then : + if ${ac_cv_search_molfile_dcdplugin_init+:} false; then : break fi done -if ${ac_cv_search_clock_gettime+:} false; then : +if ${ac_cv_search_molfile_dcdplugin_init+:} false; then : else - ac_cv_search_clock_gettime=no + ac_cv_search_molfile_dcdplugin_init=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_clock_gettime" >&5 -$as_echo "$ac_cv_search_clock_gettime" >&6; } -ac_res=$ac_cv_search_clock_gettime +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_molfile_dcdplugin_init" >&5 +$as_echo "$ac_cv_search_molfile_dcdplugin_init" >&6; } +ac_res=$ac_cv_search_molfile_dcdplugin_init if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" found=ok fi else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5 -$as_echo_n "checking for library containing clock_gettime... " >&6; } -if ${ac_cv_search_clock_gettime+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing molfile_dcdplugin_init" >&5 +$as_echo_n "checking for library containing molfile_dcdplugin_init... " >&6; } +if ${ac_cv_search_molfile_dcdplugin_init+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS @@ -7155,11 +6631,11 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char clock_gettime (); +char molfile_dcdplugin_init (); int main () { -return clock_gettime (); +return molfile_dcdplugin_init (); ; return 0; } @@ -7172,25 +6648,25 @@ for ac_lib in '' ; do LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_search_clock_gettime=$ac_res + ac_cv_search_molfile_dcdplugin_init=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext - if ${ac_cv_search_clock_gettime+:} false; then : + if ${ac_cv_search_molfile_dcdplugin_init+:} false; then : break fi done -if ${ac_cv_search_clock_gettime+:} false; then : +if ${ac_cv_search_molfile_dcdplugin_init+:} false; then : else - ac_cv_search_clock_gettime=no + ac_cv_search_molfile_dcdplugin_init=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_clock_gettime" >&5 -$as_echo "$ac_cv_search_clock_gettime" >&6; } -ac_res=$ac_cv_search_clock_gettime +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_molfile_dcdplugin_init" >&5 +$as_echo "$ac_cv_search_molfile_dcdplugin_init" >&6; } +ac_res=$ac_cv_search_molfile_dcdplugin_init if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" found=ok @@ -7198,33 +6674,87 @@ fi fi - else - found=ok - fi - if test "$found" = ok ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: Enabling embedded asmjit" >&5 -$as_echo "$as_me: Enabling embedded asmjit" >&6;} - $as_echo "#define __PLUMED_HAS_ASMJIT 1" >>confdefs.h - else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot link clock_gettime on this Linux, asmjit will not be enabled" >&5 -$as_echo "$as_me: WARNING: cannot link clock_gettime on this Linux, asmjit will not be enabled" >&2;} +fi + + + if test $found = ok ; then + $as_echo "#define __PLUMED_HAS_EXTERNAL_MOLFILE_PLUGINS 1" >>confdefs.h + + __PLUMED_HAS_EXTERNAL_MOLFILE_PLUGINS=yes + else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot enable __PLUMED_HAS_EXTERNAL_MOLFILE_PLUGINS" >&5 +$as_echo "$as_me: WARNING: cannot enable __PLUMED_HAS_EXTERNAL_MOLFILE_PLUGINS" >&2;} + fi + + if test "$__PLUMED_HAS_EXTERNAL_MOLFILE_PLUGINS" != yes ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using internal molfile_plugins, which only support dcd/xtc/trr/trj/crd files" >&5 +$as_echo "$as_me: WARNING: using internal molfile_plugins, which only support dcd/xtc/trr/trj/crd files" >&2;} + else + $as_echo "#define __PLUMED_HAS_EXTERNAL_MOLFILE_PLUGINS 1" >>confdefs.h + + fi fi fi +# this is special and is also attached to STATIC_LIBS +# this flag should be used also when linking MD engines to allow plumed +# to be loaded later +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 +$as_echo_n "checking for dlopen in -ldl... " >&6; } +if ${ac_cv_lib_dl_dlopen+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_dl_dlopen=yes +else + ac_cv_lib_dl_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +$as_echo "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = xyes; then : + STATIC_LIBS="-ldl $STATIC_LIBS" LIBS="-ldl $LIBS" +fi + -if test $readdir_r = true ; then +mpi_found=ko +# optional libraries follow +if test $mpi = true ; then found=ko - __PLUMED_HAS_READDIR_R=no - ac_fn_cxx_check_header_mongrel "$LINENO" "dirent.h" "ac_cv_header_dirent_h" "$ac_includes_default" -if test "x$ac_cv_header_dirent_h" = xyes; then : + __PLUMED_HAS_MPI=no + ac_fn_cxx_check_header_mongrel "$LINENO" "mpi.h" "ac_cv_header_mpi_h" "$ac_includes_default" +if test "x$ac_cv_header_mpi_h" = xyes; then : if test "${libsearch}" = true ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing readdir_r" >&5 -$as_echo_n "checking for library containing readdir_r... " >&6; } -if ${ac_cv_search_readdir_r+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing MPI_Init" >&5 +$as_echo_n "checking for library containing MPI_Init... " >&6; } +if ${ac_cv_search_MPI_Init+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS @@ -7237,11 +6767,11 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char readdir_r (); +char MPI_Init (); int main () { -return readdir_r (); +return MPI_Init (); ; return 0; } @@ -7254,34 +6784,34 @@ for ac_lib in '' ; do LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_search_readdir_r=$ac_res + ac_cv_search_MPI_Init=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext - if ${ac_cv_search_readdir_r+:} false; then : + if ${ac_cv_search_MPI_Init+:} false; then : break fi done -if ${ac_cv_search_readdir_r+:} false; then : +if ${ac_cv_search_MPI_Init+:} false; then : else - ac_cv_search_readdir_r=no + ac_cv_search_MPI_Init=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_readdir_r" >&5 -$as_echo "$ac_cv_search_readdir_r" >&6; } -ac_res=$ac_cv_search_readdir_r +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_MPI_Init" >&5 +$as_echo "$ac_cv_search_MPI_Init" >&6; } +ac_res=$ac_cv_search_MPI_Init if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" found=ok fi else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing readdir_r" >&5 -$as_echo_n "checking for library containing readdir_r... " >&6; } -if ${ac_cv_search_readdir_r+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing MPI_Init" >&5 +$as_echo_n "checking for library containing MPI_Init... " >&6; } +if ${ac_cv_search_MPI_Init+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS @@ -7294,11 +6824,11 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char readdir_r (); +char MPI_Init (); int main () { -return readdir_r (); +return MPI_Init (); ; return 0; } @@ -7311,25 +6841,25 @@ for ac_lib in '' ; do LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_search_readdir_r=$ac_res + ac_cv_search_MPI_Init=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext - if ${ac_cv_search_readdir_r+:} false; then : + if ${ac_cv_search_MPI_Init+:} false; then : break fi done -if ${ac_cv_search_readdir_r+:} false; then : +if ${ac_cv_search_MPI_Init+:} false; then : else - ac_cv_search_readdir_r=no + ac_cv_search_MPI_Init=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_readdir_r" >&5 -$as_echo "$ac_cv_search_readdir_r" >&6; } -ac_res=$ac_cv_search_readdir_r +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_MPI_Init" >&5 +$as_echo "$ac_cv_search_MPI_Init" >&6; } +ac_res=$ac_cv_search_MPI_Init if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" found=ok @@ -7342,27 +6872,139 @@ fi if test $found = ok ; then - $as_echo "#define __PLUMED_HAS_READDIR_R 1" >>confdefs.h + $as_echo "#define __PLUMED_HAS_MPI 1" >>confdefs.h - __PLUMED_HAS_READDIR_R=yes + __PLUMED_HAS_MPI=yes else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot enable __PLUMED_HAS_READDIR_R" >&5 -$as_echo "$as_me: WARNING: cannot enable __PLUMED_HAS_READDIR_R" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot enable __PLUMED_HAS_MPI" >&5 +$as_echo "$as_me: WARNING: cannot enable __PLUMED_HAS_MPI" >&2;} fi + if test "$__PLUMED_HAS_MPI" = yes; then + mpi_found=ok + fi +else + mpi_found=ko fi -if test $cregex = true ; then - found=ko - __PLUMED_HAS_CREGEX=no - ac_fn_cxx_check_header_mongrel "$LINENO" "regex.h" "ac_cv_header_regex_h" "$ac_includes_default" -if test "x$ac_cv_header_regex_h" = xyes; then : +# search for openmp is automatically disabled by autoconf +# when configuring with --disable-openmp + + OPENMP_CXXFLAGS= + # Check whether --enable-openmp was given. +if test "${enable_openmp+set}" = set; then : + enableval=$enable_openmp; +fi + + if test "$enable_openmp" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CXX option to support OpenMP" >&5 +$as_echo_n "checking for $CXX option to support OpenMP... " >&6; } +if ${ac_cv_prog_cxx_openmp+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifndef _OPENMP + choke me +#endif +#include +int main () { return omp_get_num_threads (); } + +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_prog_cxx_openmp='none needed' +else + ac_cv_prog_cxx_openmp='unsupported' + for ac_option in -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp -homp \ + -Popenmp --openmp; do + ac_save_CXXFLAGS=$CXXFLAGS + CXXFLAGS="$CXXFLAGS $ac_option" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifndef _OPENMP + choke me +#endif +#include +int main () { return omp_get_num_threads (); } + +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_prog_cxx_openmp=$ac_option +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CXXFLAGS=$ac_save_CXXFLAGS + if test "$ac_cv_prog_cxx_openmp" != unsupported; then + break + fi + done +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_openmp" >&5 +$as_echo "$ac_cv_prog_cxx_openmp" >&6; } + case $ac_cv_prog_cxx_openmp in #( + "none needed" | unsupported) + ;; #( + *) + OPENMP_CXXFLAGS=$ac_cv_prog_cxx_openmp ;; + esac + fi + + + +if test $asmjit = true ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether architecture is X86/X64" >&5 +$as_echo_n "checking whether architecture is X86/X64... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#if !(defined(_M_IX86 ) || defined(__X86__ ) || defined(__i386 ) || \ + defined(__IA32__) || defined(__I86__ ) || defined(__i386__) || \ + defined(__i486__) || defined(__i586__) || defined(__i686__) || \ + defined(_M_X64 ) || defined(__x86_64) || defined(__x86_64__) || \ + defined(_M_AMD64) || defined(__amd64 ) || defined(__amd64__ )) +this_is_not_x86_x64 +#endif + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; + x86_x64=true +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } ; + x86_x64=false +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +if test $asmjit = true && test $x86_x64 = false ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: asmjit does not support this architecture, it will be disabled" >&5 +$as_echo "$as_me: WARNING: asmjit does not support this architecture, it will be disabled" >&2;} + asmjit=false +fi +if test $asmjit = true ; then + found=ko +# asmjit calls clock_gettime and thus should be linked to rt on Linux + if test `(uname)` = Linux ; then if test "${libsearch}" = true ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing regcomp" >&5 -$as_echo_n "checking for library containing regcomp... " >&6; } -if ${ac_cv_search_regcomp+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5 +$as_echo_n "checking for library containing clock_gettime... " >&6; } +if ${ac_cv_search_clock_gettime+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS @@ -7375,16 +7017,16 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char regcomp (); +char clock_gettime (); int main () { -return regcomp (); +return clock_gettime (); ; return 0; } _ACEOF -for ac_lib in '' ; do +for ac_lib in '' rt; do if test -z "$ac_lib"; then ac_res="none required" else @@ -7392,34 +7034,34 @@ for ac_lib in '' ; do LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_search_regcomp=$ac_res + ac_cv_search_clock_gettime=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext - if ${ac_cv_search_regcomp+:} false; then : + if ${ac_cv_search_clock_gettime+:} false; then : break fi done -if ${ac_cv_search_regcomp+:} false; then : +if ${ac_cv_search_clock_gettime+:} false; then : else - ac_cv_search_regcomp=no + ac_cv_search_clock_gettime=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_regcomp" >&5 -$as_echo "$ac_cv_search_regcomp" >&6; } -ac_res=$ac_cv_search_regcomp +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_clock_gettime" >&5 +$as_echo "$ac_cv_search_clock_gettime" >&6; } +ac_res=$ac_cv_search_clock_gettime if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" found=ok fi else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing regcomp" >&5 -$as_echo_n "checking for library containing regcomp... " >&6; } -if ${ac_cv_search_regcomp+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5 +$as_echo_n "checking for library containing clock_gettime... " >&6; } +if ${ac_cv_search_clock_gettime+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS @@ -7432,11 +7074,11 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char regcomp (); +char clock_gettime (); int main () { -return regcomp (); +return clock_gettime (); ; return 0; } @@ -7449,25 +7091,25 @@ for ac_lib in '' ; do LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_search_regcomp=$ac_res + ac_cv_search_clock_gettime=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext - if ${ac_cv_search_regcomp+:} false; then : + if ${ac_cv_search_clock_gettime+:} false; then : break fi done -if ${ac_cv_search_regcomp+:} false; then : +if ${ac_cv_search_clock_gettime+:} false; then : else - ac_cv_search_regcomp=no + ac_cv_search_clock_gettime=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_regcomp" >&5 -$as_echo "$ac_cv_search_regcomp" >&6; } -ac_res=$ac_cv_search_regcomp +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_clock_gettime" >&5 +$as_echo "$ac_cv_search_clock_gettime" >&6; } +ac_res=$ac_cv_search_clock_gettime if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" found=ok @@ -7475,20 +7117,20 @@ fi fi + else + found=ok + fi + if test "$found" = ok ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Enabling embedded asmjit" >&5 +$as_echo "$as_me: Enabling embedded asmjit" >&6;} + $as_echo "#define __PLUMED_HAS_ASMJIT 1" >>confdefs.h + else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot link clock_gettime on this Linux, asmjit will not be enabled" >&5 +$as_echo "$as_me: WARNING: cannot link clock_gettime on this Linux, asmjit will not be enabled" >&2;} + fi fi - - if test $found = ok ; then - $as_echo "#define __PLUMED_HAS_CREGEX 1" >>confdefs.h - - __PLUMED_HAS_CREGEX=yes - else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot enable __PLUMED_HAS_CREGEX" >&5 -$as_echo "$as_me: WARNING: cannot enable __PLUMED_HAS_CREGEX" >&2;} - fi - -fi if test $dlopen = true ; then found=ko @@ -7685,211 +7327,72 @@ $as_echo_n "checking RTLD_DEFAULT with $all_LIBS... " >&6; } LIBS="$all_LIBS $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -#include -int -main () -{ - void* f=dlsym(RTLD_DEFAULT,"path"); - return 0; -} - -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - found=ok - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - else - for testlib in $testlibs - do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking RTLD_DEFAULT with -l$testlib" >&5 -$as_echo_n "checking RTLD_DEFAULT with -l$testlib... " >&6; } - LIBS="-l$testlib $LIBS" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -int -main () -{ - void* f=dlsym(RTLD_DEFAULT,"path"); - return 0; -} - -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - found=ok - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - if test $found = ok ; then - break - fi - LIBS="$save_LIBS" - done - fi - fi - - if test $found = ok ; then - $as_echo "#define __PLUMED_HAS_RTLD_DEFAULT 1" >>confdefs.h - - __PLUMED_HAS_RTLD_DEFAULT=yes - else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot enable __PLUMED_HAS_RTLD_DEFAULT" >&5 -$as_echo "$as_me: WARNING: cannot enable __PLUMED_HAS_RTLD_DEFAULT" >&2;} - LIBS="$save_LIBS" - fi - -fi - -if test $chdir = true ; then - - found=ko - __PLUMED_HAS_CHDIR=no - ac_fn_cxx_check_header_mongrel "$LINENO" "unistd.h" "ac_cv_header_unistd_h" "$ac_includes_default" -if test "x$ac_cv_header_unistd_h" = xyes; then : - - - if test "${libsearch}" = true ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing chdir" >&5 -$as_echo_n "checking for library containing chdir... " >&6; } -if ${ac_cv_search_chdir+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char chdir (); + +#include int main () { -return chdir (); - ; + void* f=dlsym(RTLD_DEFAULT,"path"); return 0; } -_ACEOF -for ac_lib in '' ; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_search_chdir=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_chdir+:} false; then : - break -fi -done -if ${ac_cv_search_chdir+:} false; then : -else - ac_cv_search_chdir=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_chdir" >&5 -$as_echo "$ac_cv_search_chdir" >&6; } -ac_res=$ac_cv_search_chdir -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : found=ok -fi - - else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing chdir" >&5 -$as_echo_n "checking for library containing chdir... " >&6; } -if ${ac_cv_search_chdir+:} false; then : - $as_echo_n "(cached) " >&6 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + else + for testlib in $testlibs + do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking RTLD_DEFAULT with -l$testlib" >&5 +$as_echo_n "checking RTLD_DEFAULT with -l$testlib... " >&6; } + LIBS="-l$testlib $LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char chdir (); +#include int main () { -return chdir (); - ; + void* f=dlsym(RTLD_DEFAULT,"path"); return 0; } -_ACEOF -for ac_lib in '' ; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_search_chdir=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_chdir+:} false; then : - break -fi -done -if ${ac_cv_search_chdir+:} false; then : -else - ac_cv_search_chdir=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_chdir" >&5 -$as_echo "$ac_cv_search_chdir" >&6; } -ac_res=$ac_cv_search_chdir -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : found=ok -fi - - fi - + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi - +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test $found = ok ; then + break + fi + LIBS="$save_LIBS" + done + fi + fi if test $found = ok ; then - $as_echo "#define __PLUMED_HAS_CHDIR 1" >>confdefs.h + $as_echo "#define __PLUMED_HAS_RTLD_DEFAULT 1" >>confdefs.h - __PLUMED_HAS_CHDIR=yes + __PLUMED_HAS_RTLD_DEFAULT=yes else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot enable __PLUMED_HAS_CHDIR" >&5 -$as_echo "$as_me: WARNING: cannot enable __PLUMED_HAS_CHDIR" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot enable __PLUMED_HAS_RTLD_DEFAULT" >&5 +$as_echo "$as_me: WARNING: cannot enable __PLUMED_HAS_RTLD_DEFAULT" >&2;} + LIBS="$save_LIBS" fi fi @@ -8090,145 +7593,6 @@ $as_echo "$as_me: WARNING: cannot enable __PLUMED_HAS_SUBPROCESS" >&2;} fi -if test $getcwd = true ; then - - found=ko - __PLUMED_HAS_GETCWD=no - ac_fn_cxx_check_header_mongrel "$LINENO" "unistd.h" "ac_cv_header_unistd_h" "$ac_includes_default" -if test "x$ac_cv_header_unistd_h" = xyes; then : - - - if test "${libsearch}" = true ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing getcwd" >&5 -$as_echo_n "checking for library containing getcwd... " >&6; } -if ${ac_cv_search_getcwd+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char getcwd (); -int -main () -{ -return getcwd (); - ; - return 0; -} -_ACEOF -for ac_lib in '' ; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_search_getcwd=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_getcwd+:} false; then : - break -fi -done -if ${ac_cv_search_getcwd+:} false; then : - -else - ac_cv_search_getcwd=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_getcwd" >&5 -$as_echo "$ac_cv_search_getcwd" >&6; } -ac_res=$ac_cv_search_getcwd -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - found=ok -fi - - else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing getcwd" >&5 -$as_echo_n "checking for library containing getcwd... " >&6; } -if ${ac_cv_search_getcwd+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char getcwd (); -int -main () -{ -return getcwd (); - ; - return 0; -} -_ACEOF -for ac_lib in '' ; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_search_getcwd=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_getcwd+:} false; then : - break -fi -done -if ${ac_cv_search_getcwd+:} false; then : - -else - ac_cv_search_getcwd=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_getcwd" >&5 -$as_echo "$ac_cv_search_getcwd" >&6; } -ac_res=$ac_cv_search_getcwd -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - found=ok -fi - - fi - - -fi - - - if test $found = ok ; then - $as_echo "#define __PLUMED_HAS_GETCWD 1" >>confdefs.h - - __PLUMED_HAS_GETCWD=yes - else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot enable __PLUMED_HAS_GETCWD" >&5 -$as_echo "$as_me: WARNING: cannot enable __PLUMED_HAS_GETCWD" >&2;} - fi - -fi - if test $popen = true ; then found=ko @@ -10191,53 +9555,6 @@ fi #added by luigibonati if test $libtorch = true ; then - # enable c++14 support - - save_CXXFLAGS="$CXXFLAGS" - CXXFLAGS="$CXXFLAGS -std=c++14" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -std=c++14" >&5 -$as_echo_n "checking whether $CXX accepts -std=c++14... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not linking" >&5 -$as_echo "not linking" >&6; }; CXXFLAGS="$save_CXXFLAGS" -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; CXXFLAGS="$save_CXXFLAGS" - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - # test program found=ko diff --git a/configure.ac b/configure.ac index c614ef38fe..44640b150a 100644 --- a/configure.ac +++ b/configure.ac @@ -270,18 +270,21 @@ PLUMED_CONFIG_ENABLE([pdfdoc],[pdf version of the manual],[no]) PLUMED_CONFIG_ENABLE([debug],[debugging],[no]) PLUMED_CONFIG_ENABLE([gcov],[gcov to estimate code coverage],[no]) AC_ARG_ENABLE([cxx], - AS_HELP_STRING([--enable-cxx], [11 or 14. To link libraries with headers that need this C++ level. Use --enable-cxx=none to remove -std=c++ flag]), + AS_HELP_STRING([--enable-cxx], [17, 20, or 23. To link libraries with headers that need this C++ level. Use --enable-cxx=none to remove -std=c++ flag]), [ case "${enableval}" in - (11) cxx_level=11 ;; - (14) cxx_level=14 ;; + (11) cxx_level=17 ;; + (14) cxx_level=17 ;; + (17) cxx_level=17 ;; + (20) cxx_level=20 ;; + (23) cxx_level=23 ;; (none) cxx_level="" ;; (*) AC_MSG_ERROR([cxx level not supported]) esac AC_MSG_NOTICE([Selected C++ level: $cxx_level]) ], [ - cxx_level="11" + cxx_level="17" ] ) PLUMED_CONFIG_ENABLE([basic-warnings],[basic warnings],[yes]) @@ -305,13 +308,9 @@ PLUMED_CONFIG_ENABLE([external-blas],[search for external blas],[yes]) PLUMED_CONFIG_ENABLE([molfile-plugins],[use molfile_plugins],[yes]) PLUMED_CONFIG_ENABLE([external-molfile-plugins],[search for external molfile_plugins],[yes]) PLUMED_CONFIG_ENABLE([zlib],[search for zlib],[yes]) -PLUMED_CONFIG_ENABLE([readdir-r],[search for readdir_r (threadsafe)],[no]) -PLUMED_CONFIG_ENABLE([cregex],[search for C regular expression],[yes]) PLUMED_CONFIG_ENABLE([dlopen],[search for dlopen],[yes]) PLUMED_CONFIG_ENABLE([rtld_default],[search for RTLD_DEFAULT macro],[yes]) -PLUMED_CONFIG_ENABLE([chdir],[search for chdir function],[yes]) PLUMED_CONFIG_ENABLE([subprocess],[search for functions needed to manage a subprocess],[yes]) -PLUMED_CONFIG_ENABLE([getcwd],[search for getcwd function],[yes]) PLUMED_CONFIG_ENABLE([popen],[search for popen],[yes]) PLUMED_CONFIG_ENABLE([execinfo],[search for execinfo],[yes]) PLUMED_CONFIG_ENABLE([gsl],[search for gsl],[yes]) @@ -431,70 +430,24 @@ then PLUMED_CHECK_CXXFLAG([-Wold-style-cast]) fi -AC_MSG_CHECKING([whether $CXX declares c++11 support]) +AC_MSG_CHECKING([whether $CXX declares c++17 support]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ -#if __cplusplus <= 199711L -this_compiler_does_not_support_cxx11 +#if __cplusplus < 201703L +this_compiler_does_not_support_cxx17 #endif ])], [AC_MSG_RESULT([yes])]; - support_cxx11=true, + support_cxx17=true, [AC_MSG_RESULT([no]) ; - support_cxx11=false]) + support_cxx17=false]) -if test "$support_cxx11" = false +if test "$support_cxx17" = false then - AC_MSG_WARN([C++11 support is required as of PLUMED 2.4]) - AC_MSG_WARN([Your compiler appears not to support C++11]) + AC_MSG_WARN([C++17 support is required as of PLUMED 2.10]) + AC_MSG_WARN([Your compiler appears not to support C++17]) AC_MSG_WARN([Please change compiler or make sure that everything works correctly]) fi -AC_MSG_CHECKING([whether C++ library supports C++11 exceptions]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ -#include -#include -#include -#include -#include -#include -// capable to catch: -void func(void) { - try{ - } catch(std::bad_array_new_length &) { - } catch(std::bad_function_call &) { - } catch(std::bad_weak_ptr &) { - } catch(std::ios_base::failure &e) { - if(e.code().category()==std::generic_category()) {} - else if(e.code().category()==std::system_category()) {} - else if(e.code().category()==std::iostream_category()) {} - else if(e.code().category()==std::future_category()) {} - } catch(std::system_error &e) { - if(e.code().category()==std::generic_category()) {} - else if(e.code().category()==std::system_category()) {} - else if(e.code().category()==std::iostream_category()) {} - else if(e.code().category()==std::future_category()) {} - } -// capable to throw: - auto a=std::bad_array_new_length(); - auto b=std::bad_function_call(); - auto c=std::bad_weak_ptr(); - auto d=std::system_error(10,std::generic_category(),"msg"); - auto e=std::system_error(10,std::system_category(),"msg"); - auto f=std::system_error(10,std::iostream_category(),"msg"); - auto g=std::system_error(10,std::future_category(),"msg"); - auto h=std::ios_base::failure("msg",std::error_code(10,std::generic_category())); - auto i=std::ios_base::failure("msg",std::error_code(10,std::system_category())); - auto j=std::ios_base::failure("msg",std::error_code(10,std::iostream_category())); - auto k=std::ios_base::failure("msg",std::error_code(10,std::future_category())); -} -])], -[ - AC_MSG_RESULT([yes]); - AC_DEFINE([__PLUMED_LIBCXX11]) -], -[AC_MSG_RESULT([no]) -]) - AC_SUBST(disable_dependency_tracking) if test "$dependency_tracking" = true @@ -532,8 +485,26 @@ fi #### Compulsory libraries #### # some of them might be made optional if we find that are not available in some system AC_MSG_NOTICE([Now we will check compulsory headers and libraries]) -AC_CHECK_HEADER([dirent.h], [ ], [AC_MSG_ERROR([compulsory header not found])] ) -AC_CHECK_FUNC( [readdir], [ ], [AC_MSG_ERROR([compulsory function not found])] ) + +PLUMED_CHECK_CXX_PACKAGE([filesystem library],[ +#include +#include +#include + +int main(){ + std::filesystem::path path; + for (auto const& dir_entry : std::filesystem::directory_iterator{"a"}) { + std::cout< diff --git a/docker/Makefile b/docker/Makefile index 96af12d47e..e3675eff78 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -1,12 +1,9 @@ -.PHONY: ubuntu plumed2.tgz clean centos7 fedora38 rocky8 +.PHONY: ubuntu plumed2.tgz clean fedora38 rocky8 ubuntu: plumed2.tgz docker build -t plumed . -centos7: plumed2.tgz - docker build -t plumed -f centos7 . - fedora38: plumed2.tgz docker build -t plumed -f fedora38 . diff --git a/docker/centos7 b/docker/centos7 deleted file mode 100644 index 0f63443eb6..0000000000 --- a/docker/centos7 +++ /dev/null @@ -1,46 +0,0 @@ -FROM centos:7 - -# NOTE: numpy==1.19 is the last version compatible with python 3.6 -# NOTE: pillow==8.4.0 leads to an error while installing on centos7 -# NOTE: gsd 3 does not compile on centos7 -RUN yum -y update \ - && yum -y group install "Development Tools" \ - && yum -y install environment-modules gawk vim wget \ - lapack-devel blas-devel zlib-devel gsl-devel fftw-devel openmpi-devel \ - python3 python3-devel python3-pip \ - && pip3 install pillow==8.3.2 \ - && pip3 install numpy==1.19 \ - && pip3 install "cython<3" numpy pandas mdtraj \ - && pip3 install "gsd<3" \ - && pip3 install MDAnalysis==1.0.0 - -RUN useradd -ms /bin/bash plumed -USER plumed -WORKDIR /home/plumed - -# import plumed code. -# assumes a file plumed2.tgz is present in the Dockerfile directory -COPY plumed2.tgz /home/plumed - -# build and test plumed (no install) -RUN . /etc/bashrc \ - && module load mpi \ - && export OMPI_MCA_btl_base_warn_component_unused=0 \ - && export OMPI_MCA_btl_base_verbose=0 \ - && export OMPI_MCA_plm=isolated \ - && export OMPI_MCA_btl_vader_single_copy_mechanism=none \ - && export OMPI_MCA_rmaps_base_oversubscribe=yes \ - && export PATH=$HOME/opt/bin:$PATH \ - && export CPATH=$HOME/opt/include:$CPATH \ - && export INCLUDE=$HOME/opt/include:$INCLUDE \ - && export LIBRARY_PATH=$HOME/opt/lib:$LIBRARY_PATH \ - && export LD_LIBRARY_PATH=$HOME/opt/lib:$LD_LIBRARY_PATH \ - && tar xzf plumed2.tgz \ - && cd plumed2 \ - && export PYTHONPATH=$PWD/python:$PYTHONPATH \ - && export PYTHON_BIN=python3 \ - && .ci/install.boost release \ - && ./configure --enable-modules=all --enable-boost_serialization \ - && make -j 4 \ - && make check - diff --git a/macports/Portfile.in b/macports/Portfile.in index 4f73fe8863..486bd1cbb0 100644 --- a/macports/Portfile.in +++ b/macports/Portfile.in @@ -63,7 +63,7 @@ configure.args-append BASH_COMPLETION_DIR=${prefix}/share/bash-completion/comple configure.cppflags-append "-D__PLUMED_DEFAULT_KERNEL=${prefix}/lib/libplumedKernel.dylib" compilers.choose cc cxx -compiler.cxx_standard 2011 +compiler.cxx_standard 2017 mpi.setup diff --git a/regtest/basic/rt-make-exceptions/config b/regtest/basic/rt-make-exceptions/config index 694e13b4a7..239639fe9c 100644 --- a/regtest/basic/rt-make-exceptions/config +++ b/regtest/basic/rt-make-exceptions/config @@ -1,4 +1,4 @@ type=make -plumed_needs="dlopen cregex" +plumed_needs=dlopen # this is needed because we are explicitly checking some exception message export PLUMED_STACK_TRACE=no diff --git a/regtest/basic/rt-make-exceptions/main.cpp b/regtest/basic/rt-make-exceptions/main.cpp index ece31d6386..bb9c484ae7 100644 --- a/regtest/basic/rt-make-exceptions/main.cpp +++ b/regtest/basic/rt-make-exceptions/main.cpp @@ -1,8 +1,6 @@ -#ifdef __PLUMED_LIBCXX11 // In order to correctly catch the thrown C++11 exceptions, // we notify the Plumed wrapper that those exceptions are recognized by the compiler. #define __PLUMED_WRAPPER_LIBCXX11 1 -#endif #include "plumed/tools/Stopwatch.h" #include "plumed/wrapper/Plumed.h" #include @@ -166,17 +164,27 @@ int main(){ #define TEST_STD_NOMSG(type) try { p.cmd("throw", #type);} catch (type & e ) { } TEST_STD_NOMSG(std::bad_cast); -#ifdef __PLUMED_LIBCXX11 TEST_STD_NOMSG(std::bad_weak_ptr); TEST_STD_NOMSG(std::bad_function_call); -#endif TEST_STD_NOMSG(std::bad_typeid); TEST_STD_NOMSG(std::bad_alloc); -#ifdef __PLUMED_LIBCXX11 TEST_STD_NOMSG(std::bad_array_new_length); -#endif TEST_STD_NOMSG(std::bad_exception); +#define TEST_REGEX(type) try { p.cmd("throw", "std::regex_error std::regex_constants::error_" #type);} catch (std::regex_error & e) { plumed_assert(e.code()==std::regex_constants::error_ ##type); } + TEST_REGEX(collate); + TEST_REGEX(ctype); + TEST_REGEX(escape); + TEST_REGEX(backref); + TEST_REGEX(brack); + TEST_REGEX(paren); + TEST_REGEX(brace); + TEST_REGEX(badbrace); + TEST_REGEX(range); + TEST_REGEX(space); + TEST_REGEX(badrepeat); + TEST_REGEX(complexity); + TEST_REGEX(stack); try { p.cmd("throw","PLMD::Exception msg"); } catch (PLMD::Plumed::Exception &e) { } @@ -187,7 +195,6 @@ int main(){ try { p.cmd("throw","PLMD::lepton::Exception msg"); } catch (PLMD::Plumed::LeptonException &e) { plumed_assert(std::string(e.what())=="PLMD::lepton::Exception msg"); } -#ifdef __PLUMED_LIBCXX11 try { p.cmd("throw","std::system_error std::generic_category 100"); } catch (std::system_error & e) { plumed_assert(e.code().value()==100)<<" value="< #include -#if defined(__PLUMED_HAS_GETCWD) -#include -#endif namespace PLMD { namespace bias { @@ -1194,18 +1191,14 @@ MetaD::MetaD(const ActionOptions& ao): } } else { // read the grid in input, find the keys -#ifdef __PLUMED_HAS_GETCWD if(walkers_mpi_&&gridreadfilename_.at(0)!='/') { //if possible the root replica will share its current folder so that all walkers will read the same file - char cwd[4096]= {0}; - const char* ret=getcwd(cwd,4096); - plumed_assert(ret)<<"Name of current directory too long, increase buffer size"; + const std::string ret = std::filesystem::current_path(); gridreadfilename_ = "/" + gridreadfilename_; gridreadfilename_ = ret + gridreadfilename_; if(comm.Get_rank()==0) multi_sim_comm.Bcast(gridreadfilename_,0); comm.Bcast(gridreadfilename_,0); } -#endif IFile gridfile; gridfile.link(*this); if(gridfile.FileExist(gridreadfilename_)) { @@ -1238,18 +1231,14 @@ MetaD::MetaD(const ActionOptions& ao): if(result!=0&&result!=mpi_nw_) error("in this WALKERS_MPI run some replica have restarted from GRID while other do not!"); } -#ifdef __PLUMED_HAS_GETCWD if(walkers_mpi_&&mw_dir_==""&&hillsfname.at(0)!='/') { //if possible the root replica will share its current folder so that all walkers will read the same file - char cwd[4096]= {0}; - const char* ret=getcwd(cwd,4096); - plumed_assert(ret)<<"Name of current directory too long, increase buffer size"; + const std::string ret = std::filesystem::current_path(); mw_dir_ = ret; mw_dir_ = mw_dir_ + "/"; if(comm.Get_rank()==0) multi_sim_comm.Bcast(mw_dir_,0); comm.Bcast(mw_dir_,0); } -#endif // creating std::vector of ifile* for hills reading // open all files at the beginning and read Gaussians if restarting diff --git a/src/bias/PBMetaD.cpp b/src/bias/PBMetaD.cpp index d9860d7290..f75ad056e0 100644 --- a/src/bias/PBMetaD.cpp +++ b/src/bias/PBMetaD.cpp @@ -33,9 +33,6 @@ #include "tools/File.h" #include #include -#if defined(__PLUMED_HAS_GETCWD) -#include -#endif namespace PLMD { namespace bias { diff --git a/src/cltools/Driver.cpp b/src/cltools/Driver.cpp index b0ff6e5e0e..d4bda9aa10 100644 --- a/src/cltools/Driver.cpp +++ b/src/cltools/Driver.cpp @@ -345,7 +345,7 @@ int Driver::main(FILE* in,FILE*out,Communicator& pc) { int grex_stride=0; FILE*grex_log=NULL; // call fclose when fp goes out of scope - auto deleter=[](FILE* f) { if(f) std::fclose(f); }; + auto deleter=[](auto f) { if(f) std::fclose(f); }; std::unique_ptr grex_log_deleter(grex_log,deleter); if(debug_grex) { @@ -552,7 +552,7 @@ int Driver::main(FILE* in,FILE*out,Communicator& pc) { std::unique_ptr fp_deleter(fp,deleter); std::unique_ptr fp_forces_deleter(fp_forces,deleter); - auto xdr_deleter=[](xdrfile::XDRFILE* xd) { if(xd) xdrfile::xdrfile_close(xd); }; + auto xdr_deleter=[](auto xd) { if(xd) xdrfile::xdrfile_close(xd); }; xdrfile::XDRFILE* xd=NULL; diff --git a/src/cltools/SimpleMD.cpp b/src/cltools/SimpleMD.cpp index 87f63953ed..c069a29d8a 100644 --- a/src/cltools/SimpleMD.cpp +++ b/src/cltools/SimpleMD.cpp @@ -76,7 +76,7 @@ plumed simplemd --help // simple static function to close a file // defined once here since it's used in many places in this file // in addition, this seems the only way to use it in the write_statistics_fp_deleter member -static void (*deleter)(FILE* f) = [](FILE* f) { if(f) std::fclose(f); }; +static void (*deleter)(FILE* f) = [](auto f) { if(f) std::fclose(f); }; class SimpleMD: public PLMD::CLTool diff --git a/src/core/ActionRegister.h b/src/core/ActionRegister.h index f9d9ede40e..cba3125bf4 100644 --- a/src/core/ActionRegister.h +++ b/src/core/ActionRegister.h @@ -88,11 +88,36 @@ ActionRegister& actionRegister(); std::ostream & operator<<(std::ostream &log,const ActionRegister&ar); -} +template +inline constexpr bool isActionType = std::is_base_of::value; +//in C++20 you we'll make this a concept +//template +//concept ActionType = std::is_base_of<::PLMD::Action, T>::value; +//so the template will be templateclass ActionRegistration{...} +//without the explicit need of the static assert + +///Each instance of this specialized class represents an action that can be called +///with the specified directive. +///As soon it goes out of scope it will deregister the directive from the singleton ActionRegister +template +class ActionRegistration { + static std::unique_ptr create(const ActionOptions&ao) { + return std::make_unique(ao); + } +public: + ///On construction register the ActionClass with the wanted directive + ActionRegistration(std::string_view directive) { + static_assert(isActionType, + "ActionRegistration accepts only class that inherit from Action"); + actionRegister().add(directive.data(),create,ActionClass::registerKeywords); + } + ///On destruction deregister the ActionClass (useful when you unload a shared object) + ~ActionRegistration() {actionRegister().remove(create);} +}; +} //PLMD #define PLUMED_CONCATENATE_DIRECT(s1, s2) s1##s2 #define PLUMED_CONCATENATE(s1, s2) PLUMED_CONCATENATE_DIRECT(s1, s2) -#define PLUMED_UNIQUENAME(str) PLUMED_CONCATENATE(str, __LINE__) /// Shortcut for Action registration /// \relates PLMD::ActionRegister @@ -101,13 +126,7 @@ std::ostream & operator<<(std::ostream &log,const ActionRegister&ar); /// \param directive a string containing the corresponding directive /// This macro should be used in the .cpp file of the corresponding class #define PLUMED_REGISTER_ACTION(classname,directive) \ - namespace { class PLUMED_UNIQUENAME(classname##RegisterMe){ \ - static std::unique_ptr create(const PLMD::ActionOptions&ao){return PLMD::Tools::make_unique(ao);} \ - public: \ - PLUMED_UNIQUENAME(classname##RegisterMe)(){PLMD::actionRegister().add(directive,create,classname::registerKeywords);} \ - ~PLUMED_UNIQUENAME(classname##RegisterMe)(){PLMD::actionRegister().remove(create);} \ - } PLUMED_UNIQUENAME(classname##RegisterMe); } - - + namespace {::PLMD::ActionRegistration \ + PLUMED_CONCATENATE(classname##Registerer,__LINE__)(directive);} #endif diff --git a/src/core/ActionWithArguments.cpp b/src/core/ActionWithArguments.cpp index 56e1acc345..275488bf1f 100644 --- a/src/core/ActionWithArguments.cpp +++ b/src/core/ActionWithArguments.cpp @@ -25,10 +25,7 @@ #include "PlumedMain.h" #include "ActionSet.h" #include -#ifdef __PLUMED_HAS_CREGEX -#include -#include -#endif +#include namespace PLMD { @@ -70,65 +67,28 @@ void ActionWithArguments::interpretArgumentList(const std::vector& unsigned l=c[i].length(); if(!c[i].compare(l-1,1,")")) { // start regex parsing -#ifdef __PLUMED_HAS_CREGEX + bool found_something=false; // take the string enclosed in quotes and put in round brackets std::string myregex=c[i]; - //log<<" Evaluating regexp for this action: "< errbuf(errbuf_size); - regerror(errcode, ®, errbuf.data(), errbuf_size); - plumed_error()<<"Error parsing regular expression: "< reg_deleter(®,deleter); - - plumed_massert(reg.re_nsub==1,"I can parse with only one subexpression"); - regmatch_t match; - // select all the actions that have a value std::vector all=plumed.getActionSet().select(); if( all.empty() ) error("your input file is not telling plumed to calculate anything"); - bool found_something=false; - for(unsigned j=0; j ss=all[j]->getComponentsVector(); - for(unsigned k=0; k str(ll); - std::strcpy(&str[0],ss[k].c_str()); - const char *ppstr=&str[0]; - if(!regexec(®, ppstr, reg.re_nsub, &match, 0)) { - //log.printf(" Something matched with \"%s\" : ",ss[k].c_str()); - do { - if (match.rm_so != -1) { /* The regex is matching part of a string */ - size_t matchlen = match.rm_eo - match.rm_so; - std::vector submatch(matchlen+1); - std::strncpy(submatch.data(), ppstr+match.rm_so, matchlen+1); - submatch[matchlen]='\0'; - //log.printf(" subpattern %s\n", submatch.data()); - // this is the match: try to see if it is a valid action - std::string putativeVal(submatch.data()); - if( all[j]->exists(putativeVal) ) { - arg.push_back(all[j]->copyOutput(putativeVal)); - found_something=true; - //log.printf(" Action %s added! \n",putativeVal.c_str()); - } - } - ppstr += match.rm_eo; /* Restart from last match */ - } while(!regexec(®,ppstr,reg.re_nsub,&match,0)); + + try { + std::regex txt_regex(myregex,std::regex::extended); + plumed_massert(txt_regex.mark_count()==1,"I can parse with only one subexpression"); + for(unsigned j=0; j ss=all[j]->getComponentsVector(); + for(unsigned k=0; kcopyOutput(ss[k])); + found_something=true; + } } } + } catch(std::regex_error & e) { + plumed_error()<<"Error parsing regular expression: "< fp_deleter(nullptr,deleter); if(argc==2) { diff --git a/src/core/PlumedMain.cpp b/src/core/PlumedMain.cpp index eb57947b32..40c9f4376c 100644 --- a/src/core/PlumedMain.cpp +++ b/src/core/PlumedMain.cpp @@ -55,12 +55,11 @@ #include #include #include -#ifdef __PLUMED_LIBCXX11 #include #include #include #include -#endif +#include namespace PLMD { @@ -76,14 +75,10 @@ namespace PLMD { __PLUMED_THROW_MSG(PLMD::Exception); __PLUMED_THROW_MSG(PLMD::lepton::Exception); __PLUMED_THROW_NOMSG(std::bad_exception); -#ifdef __PLUMED_LIBCXX11 __PLUMED_THROW_NOMSG(std::bad_array_new_length); -#endif __PLUMED_THROW_NOMSG(std::bad_alloc); -#ifdef __PLUMED_LIBCXX11 __PLUMED_THROW_NOMSG(std::bad_function_call); __PLUMED_THROW_NOMSG(std::bad_weak_ptr); -#endif __PLUMED_THROW_NOMSG(std::bad_cast); __PLUMED_THROW_NOMSG(std::bad_typeid); __PLUMED_THROW_MSG(std::underflow_error); @@ -96,7 +91,6 @@ namespace PLMD { __PLUMED_THROW_MSG(std::invalid_argument); __PLUMED_THROW_MSG(std::logic_error); -#ifdef __PLUMED_LIBCXX11 if(words[0]=="std::system_error") { plumed_assert(words.size()>2); int error_code; @@ -106,17 +100,32 @@ namespace PLMD { if(words[1]=="std::iostream_category") throw std::system_error(error_code,std::iostream_category(),what); if(words[1]=="std::future_category") throw std::system_error(error_code,std::future_category(),what); } -#endif + +#define __PLUMED_THROW_REGEX(name) if(words[1]=="std::regex_constants::error_" #name) throw std::regex_error(std::regex_constants::error_ ##name) + if(words[0]=="std::regex_error") { + plumed_assert(words.size()>1); + __PLUMED_THROW_REGEX(collate); + __PLUMED_THROW_REGEX(ctype); + __PLUMED_THROW_REGEX(escape); + __PLUMED_THROW_REGEX(backref); + __PLUMED_THROW_REGEX(brack); + __PLUMED_THROW_REGEX(paren); + __PLUMED_THROW_REGEX(brace); + __PLUMED_THROW_REGEX(badbrace); + __PLUMED_THROW_REGEX(range); + __PLUMED_THROW_REGEX(space); + __PLUMED_THROW_REGEX(badrepeat); + __PLUMED_THROW_REGEX(complexity); + __PLUMED_THROW_REGEX(stack); + } if(words[0]=="std::ios_base::failure") { -#ifdef __PLUMED_LIBCXX11 int error_code=0; if(words.size()>2) Tools::convert(words[2],error_code); if(words.size()>1 && words[1]=="std::generic_category") throw std::ios_base::failure(what,std::error_code(error_code,std::generic_category())); if(words.size()>1 && words[1]=="std::system_category") throw std::ios_base::failure(what,std::error_code(error_code,std::system_category())); if(words.size()>1 && words[1]=="std::iostream_category") throw std::ios_base::failure(what,std::error_code(error_code,std::iostream_category())); if(words.size()>1 && words[1]=="std::future_category") throw std::ios_base::failure(what,std::error_code(error_code,std::future_category())); -#endif throw std::ios_base::failure(what); } @@ -786,7 +795,7 @@ void PlumedMain::readInputLines(const std::string & str) { plumed_assert(fp); // make sure file is closed (and thus deleted) also if an exception occurs - auto deleter=[](FILE* fp) { std::fclose(fp); }; + auto deleter=[](auto fp) { std::fclose(fp); }; std::unique_ptr fp_deleter(fp,deleter); auto ret=std::fputs(str.c_str(),fp); diff --git a/src/core/PlumedMainInitializer.cpp b/src/core/PlumedMainInitializer.cpp index a65225de08..17461d22ea 100644 --- a/src/core/PlumedMainInitializer.cpp +++ b/src/core/PlumedMainInitializer.cpp @@ -34,12 +34,11 @@ #include #include #include -#ifdef __PLUMED_LIBCXX11 #include #include #include #include -#endif +#include #include "tools/TypesafePtr.h" #include "tools/Log.h" #include "tools/Tools.h" @@ -144,34 +143,43 @@ static void translate_current(plumed_nothrow_handler_x nothrow,void**nested=null } catch(const std::bad_exception & e) { if(!msg) msg=e.what(); nothrow.handler(nothrow.ptr,11500,msg,opt); -#ifdef __PLUMED_LIBCXX11 } catch(const std::bad_array_new_length & e) { if(!msg) msg=e.what(); nothrow.handler(nothrow.ptr,11410,msg,opt); -#endif } catch(const std::bad_alloc & e) { if(!msg) msg=e.what(); nothrow.handler(nothrow.ptr,11400,msg,opt); -#ifdef __PLUMED_LIBCXX11 } catch(const std::bad_function_call & e) { if(!msg) msg=e.what(); nothrow.handler(nothrow.ptr,11300,msg,opt); } catch(const std::bad_weak_ptr & e) { if(!msg) msg=e.what(); nothrow.handler(nothrow.ptr,11200,msg,opt); -#endif } catch(const std::bad_cast & e) { if(!msg) msg=e.what(); nothrow.handler(nothrow.ptr,11100,msg,opt); } catch(const std::bad_typeid & e) { if(!msg) msg=e.what(); nothrow.handler(nothrow.ptr,11000,msg,opt); - // not implemented yet: std::regex_error - // we do not allow regex yet due to portability problems with gcc 4.8 - // as soon as we transition to using it should be straightforward to add + } catch(const std::regex_error & e) { + if(!msg) msg=e.what(); + if(e.code()==std::regex_constants::error_collate) nothrow.handler(nothrow.ptr,10240,msg,opt); + else if(e.code()==std::regex_constants::error_ctype) nothrow.handler(nothrow.ptr,10241,msg,opt); + else if(e.code()==std::regex_constants::error_escape) nothrow.handler(nothrow.ptr,10242,msg,opt); + else if(e.code()==std::regex_constants::error_backref) nothrow.handler(nothrow.ptr,10243,msg,opt); + else if(e.code()==std::regex_constants::error_brack) nothrow.handler(nothrow.ptr,10244,msg,opt); + else if(e.code()==std::regex_constants::error_paren) nothrow.handler(nothrow.ptr,10245,msg,opt); + else if(e.code()==std::regex_constants::error_brace) nothrow.handler(nothrow.ptr,10246,msg,opt); + else if(e.code()==std::regex_constants::error_badbrace) nothrow.handler(nothrow.ptr,10247,msg,opt); + else if(e.code()==std::regex_constants::error_range) nothrow.handler(nothrow.ptr,10248,msg,opt); + else if(e.code()==std::regex_constants::error_space) nothrow.handler(nothrow.ptr,10249,msg,opt); + else if(e.code()==std::regex_constants::error_badrepeat) nothrow.handler(nothrow.ptr,10250,msg,opt); + else if(e.code()==std::regex_constants::error_complexity) nothrow.handler(nothrow.ptr,10251,msg,opt); + else if(e.code()==std::regex_constants::error_stack) nothrow.handler(nothrow.ptr,10252,msg,opt); + // fallback to generic runtime_error + else nothrow.handler(nothrow.ptr,10200,msg,opt); } catch(const std::ios_base::failure & e) { if(!msg) msg=e.what(); -#ifdef __PLUMED_LIBCXX11 int value=e.code().value(); opt[2]="c"; // "c" passes the error code. opt[3]=&value; @@ -180,10 +188,8 @@ static void translate_current(plumed_nothrow_handler_x nothrow,void**nested=null else if(e.code().category()==std::iostream_category()) nothrow.handler(nothrow.ptr,10232,msg,opt); else if(e.code().category()==std::future_category()) nothrow.handler(nothrow.ptr,10233,msg,opt); else -#endif // 10239 represents std::ios_base::failure with default constructur nothrow.handler(nothrow.ptr,10239,msg,opt); -#ifdef __PLUMED_LIBCXX11 } catch(const std::system_error & e) { if(!msg) msg=e.what(); int value=e.code().value(); @@ -195,7 +201,6 @@ static void translate_current(plumed_nothrow_handler_x nothrow,void**nested=null else if(e.code().category()==std::future_category()) nothrow.handler(nothrow.ptr,10223,msg,opt); // fallback to generic runtime_error else nothrow.handler(nothrow.ptr,10200,msg,opt); -#endif } catch(const std::underflow_error &e) { if(!msg) msg=e.what(); nothrow.handler(nothrow.ptr,10215,msg,opt); diff --git a/src/maketools/codecheck b/src/maketools/codecheck index 1485f9c3e2..e8a62aa4b1 100755 --- a/src/maketools/codecheck +++ b/src/maketools/codecheck @@ -34,7 +34,7 @@ if [ $do_cppcheck == true ] ; then else files="$(echo */*.{h,cpp})" fi - cppcheck --std=c++11 -j 4 --platform=unix64 --language=c++ \ + cppcheck --std=c++17 -j 4 --platform=unix64 --language=c++ \ -U__GNUG__ -U__PLUMED_HAS_EXTERNAL_LAPACK -U__PLUMED_HAS_EXTERNAL_BLAS \ -UGMX_CYGWIN -UF77_NO_UNDERSCORE -U_GLIBCXX_DEBUG -DNDEBUG -U__PLUMED_PBC_WHILE \ -U__PLUMED_HAS_ASMJIT \ diff --git a/src/maketools/nmcheck b/src/maketools/nmcheck index e408537db0..2a38f26732 100755 --- a/src/maketools/nmcheck +++ b/src/maketools/nmcheck @@ -4,6 +4,7 @@ # NOTE: also shared_ptr in some GNU library version has the same problem :-( This seems not solvable. # NOTE: ubuntu 22 have something in the std library, I remove std:: from the checks (GB) # NOTE: also libtorch (in particular the c10 library) has unique global symbols [added by luigibonati] +# NOTE: when compiling with debug options, also regex_trait has issues LIST=$(nm -C "$@" 2>/dev/null | grep " u " | grep -v "boost::" | grep -v "c10::" | grep -v "std::_Sp_make_shared_tag" | grep -v " std::") diff --git a/src/maketools/plumedcheck b/src/maketools/plumedcheck index 04dae8fe5a..1d4c354d0c 100755 --- a/src/maketools/plumedcheck +++ b/src/maketools/plumedcheck @@ -341,10 +341,6 @@ BEGINFILE{ # DOC: using the modern header all the functions are declared inside the `std` namespace. # DOC: Also notice that we have a special exception to allow them in Plumed.h. if(h in deprecated_headers && !(module in outer_modules)) error("deprecated_header","including deprecated header " h); -# DOC: :unsupported_header_regex: -# DOC: Header ``, although part of the C++11 standard, is not supported by gcc 4.8. -# DOC: In order to allow compatibility with old compilers, this header should not be used. - if(h == "regex") error("unsupported_header_regex","including unsupported header " h); # DOC: :external_header: (style) # DOC: Header files should possibly not include other header files from external libraries. # DOC: Indeed, once PLUMED is installed, if paths are not set correctly the include files of the other libraries diff --git a/src/mapping/PathTools.cpp b/src/mapping/PathTools.cpp index 0cf4a0922b..0d35ad602d 100644 --- a/src/mapping/PathTools.cpp +++ b/src/mapping/PathTools.cpp @@ -145,7 +145,7 @@ int PathTools::main(FILE* in, FILE*out,Communicator& pc) { std::fprintf(out,"Reparameterising path in file named %s so that all frames are equally spaced \n",ifilename.c_str() ); FILE* fp=std::fopen(ifilename.c_str(),"r"); // call fclose when fp goes out of scope - auto deleter=[](FILE* f) { if(f) std::fclose(f); }; + auto deleter=[](auto f) { if(f) std::fclose(f); }; std::unique_ptr fp_deleter(fp,deleter); bool do_read=true; std::vector> frames; while (do_read) { @@ -221,7 +221,7 @@ int PathTools::main(FILE* in, FILE*out,Communicator& pc) { { FILE* fp2=std::fopen(istart.c_str(),"r"); // call fclose when fp goes out of scope - auto deleter=[](FILE* f) { std::fclose(f); }; + auto deleter=[](auto f) { std::fclose(f); }; std::unique_ptr fp_deleter(fp2,deleter); if( istart.length()==0 ) error("input is missing use --istart + --iend or --path"); if( !mystartpdb.readFromFilepointer(fp2,false,0.1) ) error("could not read fila " + istart); @@ -234,7 +234,7 @@ int PathTools::main(FILE* in, FILE*out,Communicator& pc) { { FILE* fp1=std::fopen(iend.c_str(),"r"); // call fclose when fp goes out of scope - auto deleter=[](FILE* f) { std::fclose(f); }; + auto deleter=[](auto f) { std::fclose(f); }; std::unique_ptr fp_deleter(fp1,deleter); if( iend.length()==0 ) error("input is missing using --istart + --iend or --path"); if( !myendpdb.readFromFilepointer(fp1,false,0.1) ) error("could not read fila " + iend); diff --git a/src/tools/FileBase.cpp b/src/tools/FileBase.cpp index 9e656eb022..3cc79af87e 100644 --- a/src/tools/FileBase.cpp +++ b/src/tools/FileBase.cpp @@ -78,7 +78,7 @@ bool FileBase::FileExist(const std::string& path) { // first try with suffix FILE *ff=std::fopen(const_cast(this->path.c_str()),"r"); // call fclose when ff goes out of scope - auto deleter=[](FILE* f) { if(f) std::fclose(f); }; + auto deleter=[](auto f) { if(f) std::fclose(f); }; std::unique_ptr fp_deleter(ff,deleter); if(!ff) { diff --git a/src/tools/PDB.cpp b/src/tools/PDB.cpp index 0383fc0c3d..52071817bf 100644 --- a/src/tools/PDB.cpp +++ b/src/tools/PDB.cpp @@ -396,7 +396,7 @@ bool PDB::read(const std::string&file,bool naturalUnits,double scale) { FILE* fp=std::fopen(file.c_str(),"r"); if(!fp) return false; // call fclose when exiting this function - auto deleter=[](FILE* f) { std::fclose(f); }; + auto deleter=[](auto f) { std::fclose(f); }; std::unique_ptr fp_deleter(fp,deleter); readFromFilepointer(fp,naturalUnits,scale); return true; diff --git a/src/tools/Tools.cpp b/src/tools/Tools.cpp index 76bfee3698..095b208805 100644 --- a/src/tools/Tools.cpp +++ b/src/tools/Tools.cpp @@ -25,14 +25,10 @@ #include "IFile.h" #include "lepton/Lepton.h" #include -#include #include #include -#if defined(__PLUMED_HAS_CHDIR) || defined(__PLUMED_HAS_GETCWD) -#include -#endif - #include +#include namespace PLMD { @@ -358,23 +354,9 @@ void Tools::interpretLabel(std::vector&s) { } std::vector Tools::ls(const std::string&d) { - DIR*dir; std::vector result; - if ((dir=opendir(d.c_str()))) { -#if defined(__PLUMED_HAS_READDIR_R) - struct dirent ent; -#endif - while(true) { - struct dirent *res; -#if defined(__PLUMED_HAS_READDIR_R) - readdir_r(dir,&ent,&res); -#else - res=readdir(dir); -#endif - if(!res) break; - if(std::string(res->d_name)!="." && std::string(res->d_name)!="..") result.push_back(res->d_name); - } - closedir (dir); + for (auto const& dir_entry : std::filesystem::directory_iterator{d}) { + result.push_back(dir_entry.path().filename()); } return result; } @@ -420,31 +402,20 @@ bool Tools::findKeyword(const std::vector&line,const std::string&ke return false; } -Tools::DirectoryChanger::DirectoryChanger(const char*path) { +Tools::DirectoryChanger::DirectoryChanger(const char*path): + path(std::filesystem::current_path()) +{ if(!path) return; if(std::strlen(path)==0) return; -#ifdef __PLUMED_HAS_GETCWD - char* ret=getcwd(cwd,buffersize); - plumed_assert(ret)<<"Name of current directory too long, increase buffer size"; -#else - plumed_error()<<"You are trying to use DirectoryChanger but your system does not support getcwd"; -#endif -#ifdef __PLUMED_HAS_CHDIR - int r=chdir(path); - plumed_assert(r==0) <<"Cannot chdir to directory "<> Tools::molfile_lock() { diff --git a/src/tools/Tools.h b/src/tools/Tools.h index 802a2f4a72..f92137db9d 100644 --- a/src/tools/Tools.h +++ b/src/tools/Tools.h @@ -37,6 +37,8 @@ #include #include #include +#include +#include namespace PLMD { @@ -208,36 +210,16 @@ class Tools { /// In case system calls to change dir are not available it throws an exception. /// \warning By construction, changing directory breaks thread safety! Use with care. class DirectoryChanger { - static const std::size_t buffersize=4096; - char cwd[buffersize]= {0}; + const std::filesystem::path path; public: explicit DirectoryChanger(const char*path); ~DirectoryChanger(); }; -/// Mimic C++14 std::make_unique - template struct _Unique_if { - typedef std::unique_ptr _Single_object; - }; - template struct _Unique_if { - typedef std::unique_ptr _Unknown_bound; - }; - template struct _Unique_if { - typedef void _Known_bound; - }; + template - static typename _Unique_if::_Single_object - make_unique(Args&&... args) { - return std::unique_ptr(new T(std::forward(args)...)); + static auto make_unique(Args&&... args) { + return std::make_unique(std::forward(args)...); } - template - static typename _Unique_if::_Unknown_bound - make_unique(std::size_t n) { - typedef typename std::remove_extent::type U; - return std::unique_ptr(new U[n]()); - } - template - static typename _Unique_if::_Known_bound - make_unique(Args&&...) = delete; static void set_to_zero(double*ptr,unsigned n) { for(unsigned i=0; i /* future_category */ #include /* bad_weak_ptr */ #include /* bad_function_call */ +#include /* regex_error */ #endif #if __cplusplus > 199711L @@ -1777,6 +1778,21 @@ class Plumed { #endif f(::std::ios_base::failure(msg)); } +#if __cplusplus > 199711L && __PLUMED_WRAPPER_LIBCXX11 + if(h.code==10240) f(add_buffer_to< ::std::regex_error>(::std::regex_error(::std::regex_constants::error_collate),msg)); + if(h.code==10241) f(add_buffer_to< ::std::regex_error>(::std::regex_error(::std::regex_constants::error_ctype),msg)); + if(h.code==10242) f(add_buffer_to< ::std::regex_error>(::std::regex_error(::std::regex_constants::error_escape),msg)); + if(h.code==10243) f(add_buffer_to< ::std::regex_error>(::std::regex_error(::std::regex_constants::error_backref),msg)); + if(h.code==10244) f(add_buffer_to< ::std::regex_error>(::std::regex_error(::std::regex_constants::error_brack),msg)); + if(h.code==10245) f(add_buffer_to< ::std::regex_error>(::std::regex_error(::std::regex_constants::error_paren),msg)); + if(h.code==10246) f(add_buffer_to< ::std::regex_error>(::std::regex_error(::std::regex_constants::error_brace),msg)); + if(h.code==10247) f(add_buffer_to< ::std::regex_error>(::std::regex_error(::std::regex_constants::error_badbrace),msg)); + if(h.code==10248) f(add_buffer_to< ::std::regex_error>(::std::regex_error(::std::regex_constants::error_range),msg)); + if(h.code==10249) f(add_buffer_to< ::std::regex_error>(::std::regex_error(::std::regex_constants::error_space),msg)); + if(h.code==10250) f(add_buffer_to< ::std::regex_error>(::std::regex_error(::std::regex_constants::error_badrepeat),msg)); + if(h.code==10251) f(add_buffer_to< ::std::regex_error>(::std::regex_error(::std::regex_constants::error_complexity),msg)); + if(h.code==10252) f(add_buffer_to< ::std::regex_error>(::std::regex_error(::std::regex_constants::error_stack),msg)); +#endif f(::std::runtime_error(msg)); } /* "bad" errors */ @@ -2090,25 +2106,35 @@ class Plumed { class add_buffer_to: public T { - char msg[__PLUMED_WRAPPER_CXX_EXCEPTION_BUFFER]; \ - public: - __PLUMED_WRAPPER_CXX_EXPLICIT add_buffer_to(const char * msg) __PLUMED_WRAPPER_CXX_NOEXCEPT { + char msg[__PLUMED_WRAPPER_CXX_EXCEPTION_BUFFER]; + void init(const char* msg) __PLUMED_WRAPPER_CXX_NOEXCEPT { this->msg[0]='\0'; __PLUMED_WRAPPER_STD strncat(this->msg,msg,__PLUMED_WRAPPER_CXX_EXCEPTION_BUFFER-1); this->msg[__PLUMED_WRAPPER_CXX_EXCEPTION_BUFFER-1]='\0'; if(PlumedGetenvExceptionsDebug() && __PLUMED_WRAPPER_STD strlen(msg) > __PLUMED_WRAPPER_CXX_EXCEPTION_BUFFER-1) __PLUMED_WRAPPER_STD fprintf(stderr,"+++ WARNING: message will be truncated\n"); } - add_buffer_to(const add_buffer_to & other) __PLUMED_WRAPPER_CXX_NOEXCEPT { - msg[0]='\0'; - __PLUMED_WRAPPER_STD memcpy(msg,other.msg,__PLUMED_WRAPPER_CXX_EXCEPTION_BUFFER); + public: + __PLUMED_WRAPPER_CXX_EXPLICIT add_buffer_to(const char * msg) __PLUMED_WRAPPER_CXX_NOEXCEPT { + init(msg); + } + add_buffer_to(const T& base,const char * msg) __PLUMED_WRAPPER_CXX_NOEXCEPT: + T(base) + { + init(msg); + } + add_buffer_to(const add_buffer_to & other) __PLUMED_WRAPPER_CXX_NOEXCEPT: + T(other) + { + init(other.msg); } add_buffer_to & operator=(const add_buffer_to & other) __PLUMED_WRAPPER_CXX_NOEXCEPT { if(this==&other) return *this; - msg[0]='\0'; - __PLUMED_WRAPPER_STD memcpy(msg,other.msg,__PLUMED_WRAPPER_CXX_EXCEPTION_BUFFER); + init(other.msg); return *this; } - const char* what() const __PLUMED_WRAPPER_CXX_NOEXCEPT __PLUMED_WRAPPER_CXX_OVERRIDE {return msg;} + const char* what() const __PLUMED_WRAPPER_CXX_NOEXCEPT __PLUMED_WRAPPER_CXX_OVERRIDE { + return msg; + } #if ! (__cplusplus > 199711L) /* Destructor should be declared in order to have the correct throw() before C++11 */ /* see https://stackoverflow.com/questions/50025862/why-is-the-stdexception-destructor-not-noexcept */ diff --git a/user-doc/GettingStarted.md b/user-doc/GettingStarted.md index adcd5cb18d..bf48689d08 100644 --- a/user-doc/GettingStarted.md +++ b/user-doc/GettingStarted.md @@ -55,8 +55,7 @@ PRINT ARG=d1 FILE=colvar STRIDE=10 Also notice that all the actions can be labeled, and that many actions besides normal collective variables can define one or more value, which can be then referred using the corresponding label. -Actions can be referred also with POSIX regular expressions (see \ref Regex) if regex library is available on your system -and detected at configure time. +Actions can be referred also with POSIX regular expressions (see \ref Regex). You can also add \ref comments to the input or set up your input over multiple files and then create a composite input by \ref includes. diff --git a/user-doc/Installation.md b/user-doc/Installation.md index 1a275a6c34..a8b84c4b9c 100644 --- a/user-doc/Installation.md +++ b/user-doc/Installation.md @@ -40,17 +40,12 @@ discover how to link it. \section SupportedCompilers Supported compilers -As of PLUMED 2.4, we require a compiler that supports C++11. The following compilers -(or later versions) should be sufficient: +As of PLUMED 2.10, we require a compiler that supports C++17. -- gcc 4.8.1 -- clang 3.3 -- intel 15 - -Notice that the `./configure` script verifies that your compiler supports C++11. -Some compilers do not declare full support, but implement anyway a number of C++11 features -sufficient to compile PLUMED (this is the case for instance of intel 15 compiler). -In case you see a warning about C++11 support during `./configure` +Notice that the `./configure` script verifies that your compiler supports C++17. +Some compilers do not declare full support, but implement anyway a number of C++17 features +sufficient to compile PLUMED. +In case you see a warning about C++17 support during `./configure` please make sure that PLUMED compiles correctly and, if possible, execute the regtests (using `make regtest`). Notice that we regularly test a number of compilers on travis-ci, and at least those compilers are guaranteed to be able to compile PLUMED correctly. @@ -594,7 +589,7 @@ take advantage of openMP > sudo port install plumed +mpich +clang50 -Notice that support for c++11 with gcc compilers is someway problematic within MacPorts +Notice that support for c++17 with gcc compilers is someway problematic within MacPorts due to impossibility to use the system c++ library. For this reason, only clang compilers are supported (see also [this discussion](https://github.com/macports/macports-ports/pull/1252)). diff --git a/user-doc/Regex.md b/user-doc/Regex.md index 34b596b154..4bb26845fb 100644 --- a/user-doc/Regex.md +++ b/user-doc/Regex.md @@ -4,11 +4,6 @@ When you use need to pass many arguments to a PLUMED action, being them components of a few collective variables or also multiple collective variables, you might find it convenient to use [regular expressions](https://en.wikipedia.org/wiki/Regular_expression). -Since version 2.1, plumed takes advantage of a configuration scripts that -detects libraries installed on your system. If regex library is found, -then you will be able to use regular expressions to refer to collective variables -or function names. - Regular expressions are enclosed in round braces and must not contain spaces (the components names have no spaces indeed, so why use them?).