diff --git a/Makefile.conf.in b/Makefile.conf.in index 38e8ca23b1243dfb7740fe03fa57d49dd3c59225..344524bddd6a87fffa2cd5849262ebf79cf2a49a 100644 --- a/Makefile.conf.in +++ b/Makefile.conf.in @@ -15,3 +15,5 @@ LDSO=@LDSO@ GCCDEP=@CXX@ prefix=@prefix@ program_transform_name=@program_transform_name@ +program_can_run_mpi=@program_can_run_mpi@ +program_can_run=@program_can_run@ diff --git a/configure b/configure index 65fbb71070cadfcb2949974d74515bf8158834a8..c2e5b3a8a0fa49550123c489dce41dd354b1ad27 100755 --- a/configure +++ b/configure @@ -621,6 +621,8 @@ ac_includes_default="\ ac_subst_vars='LTLIBOBJS LIBOBJS build_dir +program_can_run_mpi +program_can_run xxd dot doxygen @@ -5433,9 +5435,9 @@ if test -z "$blas_found" ; then $as_echo "$as_me: WARNING: using internal lapack and blas, could be inefficient" >&2;} LIBS="$save_LIBS" -$as_echo "#define __PLUMED_INTERNAL_BLAS 1" >>confdefs.h +$as_echo "#define __PLUMED_HAS_INTERNAL_BLAS 1" >>confdefs.h -$as_echo "#define __PLUMED_INTERNAL_LAPACK 1" >>confdefs.h +$as_echo "#define __PLUMED_HAS_INTERNAL_LAPACK 1" >>confdefs.h fi @@ -5510,7 +5512,7 @@ if test -z "$lapack_found" ; then $as_echo "$as_me: WARNING: using internal lapack, could be inefficient" >&2;} LIBS="$save_LIBS" -$as_echo "#define __PLUMED_INTERNAL_LAPACK 1" >>confdefs.h +$as_echo "#define __PLUMED_HAS_INTERNAL_LAPACK 1" >>confdefs.h fi @@ -5599,7 +5601,7 @@ fi if test $found == ko ; 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;} - $as_echo "#define __PLUMED_INTERNAL_MOLFILE_PLUGINS 1" >>confdefs.h + $as_echo "#define __PLUMED_HAS_INTERNAL_MOLFILE_PLUGINS 1" >>confdefs.h fi @@ -6639,6 +6641,86 @@ then as_fn_error $? "xxd should be installed for PLUMED to compile properly" "$LINENO" 5 fi + +program_can_run="" +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can be run on this machine" >&5 +$as_echo_n "checking whether a program can be run on this machine... " >&6; } +if test "$cross_compiling" = yes; then : + program_can_run=no ; { $as_echo "$as_me:${as_lineno-$LINENO}: result: no (cross compiling)" >&5 +$as_echo "no (cross compiling)" >&6; } + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef __PLUMED_MPI +#include <mpi.h> +#endif +// notice that [] is required to cheat autoconf +int main(int argc,char*argv[]){ +#ifdef __PLUMED_MPI +// this emulates what happens when plumed +// is compiled with mpi and invoked with --no-mpi + if(argc==10){ + MPI_Init(&argc,&argv); + return MPI_Finalize(); + } +#endif + return 0; +} + +_ACEOF +if ac_fn_cxx_try_run "$LINENO"; then : + program_can_run=yes ; { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + program_can_run=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 $mpi_found == ok ; then + +program_can_run_mpi="" +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program compiled with mpi can be run on this machine" >&5 +$as_echo_n "checking whether a program compiled with mpi can be run on this machine... " >&6; } +if test "$cross_compiling" = yes; then : + program_can_run_mpi=no ; { $as_echo "$as_me:${as_lineno-$LINENO}: result: no (cross compiling)" >&5 +$as_echo "no (cross compiling)" >&6; } + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef __PLUMED_MPI +#include <mpi.h> +#endif +// notice that [] is required to cheat autoconf +int main(int argc,char*argv[]){ +#ifdef __PLUMED_MPI + MPI_Init(&argc,&argv); + return MPI_Finalize(); +#endif + return 0; +} + +_ACEOF +if ac_fn_cxx_try_run "$LINENO"; then : + program_can_run_mpi=yes ; { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + program_can_run_mpi=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 + #### This further tests are required to allow linking with non c++ compiler { $as_echo "$as_me:${as_lineno-$LINENO}: PLUMED seems to be configured properly!" >&5 $as_echo "$as_me: PLUMED seems to be configured properly!" >&6;} @@ -6738,6 +6820,9 @@ program_name=$(echo plumed | sed "$program_transform_name_sh") if test "$(echo "$program_name" | tr 'A-Z' 'a-z')" != "$(echo "$program_name" | tr 'A-Z' 'a-z' | sed 's/kernel$//')" ; then as_fn_error $? "$program_name is not a valid program name (should not terminate with Kernel)" "$LINENO" 5 fi +if test "$(echo "$program_name" | tr 'A-Z' 'a-z')" != "$(echo "$program_name" | tr 'A-Z' 'a-z' | sed 's/-patch$//')" ; then + as_fn_error $? "$program_name is not a valid program name (should not terminate with -patch)" "$LINENO" 5 +fi { $as_echo "$as_me:${as_lineno-$LINENO}: **** PLUMED will be installed using prefix $prefix" >&5 $as_echo "$as_me: **** PLUMED will be installed using prefix $prefix" >&6;} @@ -6759,6 +6844,30 @@ else $as_echo "$as_me: **** PLUMED will be compiled without MPI" >&6;} fi +if test $program_can_run == no ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: plumed executable will not run on this machine" >&5 +$as_echo "$as_me: WARNING: plumed executable will not run on this machine" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: to patch an MD code now use 'plumed-patch'" >&5 +$as_echo "$as_me: WARNING: to patch an MD code now use 'plumed-patch'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: after installing plumed you should use '$prefix/lib/$program_name/plumed-patch'" >&5 +$as_echo "$as_me: WARNING: after installing plumed you should use '$prefix/lib/$program_name/plumed-patch'" >&2;} +elif test $mpi_found == ok ; then + if test $program_can_run_mpi == no ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: plumed executable will not run on this machine" >&5 +$as_echo "$as_me: WARNING: plumed executable will not run on this machine" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unless you invoke it as 'plumed --no-mpi'" >&5 +$as_echo "$as_me: WARNING: unless you invoke it as 'plumed --no-mpi'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: to patch an MD code now use 'plumed --no-mpi patch'" >&5 +$as_echo "$as_me: WARNING: to patch an MD code now use 'plumed --no-mpi patch'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: (notice that MPI will be available anyway in the patched code)" >&5 +$as_echo "$as_me: WARNING: (notice that MPI will be available anyway in the patched code)" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: all command line tools are available as 'plumed --no-mpi name-of-the-tool'" >&5 +$as_echo "$as_me: WARNING: all command line tools are available as 'plumed --no-mpi name-of-the-tool'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: e.g. 'plumed --no-mpi driver'" >&5 +$as_echo "$as_me: WARNING: e.g. 'plumed --no-mpi driver'" >&2;} + fi +fi + build_dir=`pwd` diff --git a/configure.ac b/configure.ac index 4e9b2ad5a1740bea61a6d3ad7c6dc4b871648acc..fdf57fa6875f122b09a1dc3bc3845b4a14304d2f 100644 --- a/configure.ac +++ b/configure.ac @@ -552,6 +552,54 @@ then AC_MSG_ERROR([xxd should be installed for PLUMED to compile properly]) fi +AC_SUBST(program_can_run) +program_can_run="" +AC_MSG_CHECKING([whether a program can be run on this machine]) +AC_RUN_IFELSE([AC_LANG_SOURCE([ +#ifdef __PLUMED_MPI +#include <mpi.h> +#endif +// notice that [[]] is required to cheat autoconf +int main(int argc,char*argv[[]]){ +#ifdef __PLUMED_MPI +// this emulates what happens when plumed +// is compiled with mpi and invoked with --no-mpi + if(argc==10){ + MPI_Init(&argc,&argv); + return MPI_Finalize(); + } +#endif + return 0; +} +])], + [ program_can_run=yes ; AC_MSG_RESULT([yes]) ], + [ program_can_run=no ; AC_MSG_RESULT([no]) ], + [ program_can_run=no ; AC_MSG_RESULT([no (cross compiling)]) ] +) + +if test $mpi_found == ok ; then +AC_SUBST(program_can_run_mpi) +program_can_run_mpi="" +AC_MSG_CHECKING([whether a program compiled with mpi can be run on this machine]) +AC_RUN_IFELSE([AC_LANG_SOURCE([ +#ifdef __PLUMED_MPI +#include <mpi.h> +#endif +// notice that [[]] is required to cheat autoconf +int main(int argc,char*argv[[]]){ +#ifdef __PLUMED_MPI + MPI_Init(&argc,&argv); + return MPI_Finalize(); +#endif + return 0; +} +])], + [ program_can_run_mpi=yes ; AC_MSG_RESULT([yes]) ], + [ program_can_run_mpi=no ; AC_MSG_RESULT([no]) ], + [ program_can_run_mpi=no ; AC_MSG_RESULT([no (cross compiling)]) ] +) +fi + #### This further tests are required to allow linking with non c++ compiler AC_MSG_NOTICE([PLUMED seems to be configured properly!]) AC_MSG_NOTICE([**************************]) @@ -632,6 +680,9 @@ program_name=$(echo plumed | sed "$program_transform_name_sh") if test "$(echo "$program_name" | tr '[A-Z]' '[a-z]')" != "$(echo "$program_name" | tr '[A-Z]' '[a-z]' | sed 's/kernel$//')" ; then AC_MSG_ERROR([$program_name is not a valid program name (should not terminate with Kernel)]) fi +if test "$(echo "$program_name" | tr '[A-Z]' '[a-z]')" != "$(echo "$program_name" | tr '[A-Z]' '[a-z]' | sed 's/-patch$//')" ; then + AC_MSG_ERROR([$program_name is not a valid program name (should not terminate with -patch)]) +fi AC_MSG_NOTICE([**** PLUMED will be installed using prefix $prefix]) AC_MSG_NOTICE([**** You can change this later using "make install prefix=/path"]) @@ -647,6 +698,21 @@ else AC_MSG_NOTICE([**** PLUMED will be compiled without MPI]) fi +if test $program_can_run == no ; then + AC_MSG_WARN([plumed executable will not run on this machine]) + AC_MSG_WARN([to patch an MD code now use 'plumed-patch']) + AC_MSG_WARN([after installing plumed you should use '$prefix/lib/$program_name/plumed-patch']) +elif test $mpi_found == ok ; then + if test $program_can_run_mpi == no ; then + AC_MSG_WARN([plumed executable will not run on this machine]) + AC_MSG_WARN([unless you invoke it as 'plumed --no-mpi']) + AC_MSG_WARN([to patch an MD code now use 'plumed --no-mpi patch']) + AC_MSG_WARN([(notice that MPI will be available anyway in the patched code)]) + AC_MSG_WARN([all command line tools are available as 'plumed --no-mpi name-of-the-tool']) + AC_MSG_WARN([e.g. 'plumed --no-mpi driver']) + fi +fi + AC_SUBST(build_dir) build_dir=`pwd` diff --git a/src/lib/Makefile b/src/lib/Makefile index 9e99a1425b5e80ac195c1ac8d9c22e7ada6e1674..b3faf2556ba8ce4c0ec3246035e1568fcf04cfa8 100644 --- a/src/lib/Makefile +++ b/src/lib/Makefile @@ -104,15 +104,16 @@ install-do: @sed "s|@_PREFIX_@|$(PLUMED_INSTALL_PREFIX)|" modulefile.in | sed "s|@_SOEXT_@|$(SOEXT)|" | sed "s|@_PROGNAME_@|$(PLUMED_PROGRAM_NAME)|" > $(DESTDIR)$(PLUMED_INSTALL_ROOT)/src/lib/modulefile # install links cd $(DESTDIR)$(PLUMED_INSTALL_PREFIX)/bin/ && ln -s ../lib/$(PLUMED_PROGRAM_NAME)/src/lib/plumed $(PLUMED_PROGRAM_NAME) - cd $(DESTDIR)$(PLUMED_INSTALL_PREFIX)/bin/ && for file in $(PLUMED_SCRIPTS) ; do ln -s ../lib/$(PLUMED_PROGRAM_NAME)/src/lib/plumed-$$file $(PLUMED_PROGRAM_NAME)-$$file ; done + cd $(DESTDIR)$(PLUMED_INSTALL_ROOT) && for file in $(PLUMED_SCRIPTS) ; do ln -s src/lib/plumed-$$file plumed-$$file ; done + cd $(DESTDIR)$(PLUMED_INSTALL_PREFIX)/bin/ && ln -s ../lib/$(PLUMED_PROGRAM_NAME)/src/lib/plumed-patch $(PLUMED_PROGRAM_NAME)-patch ifdef SOEXT cd $(DESTDIR)$(PLUMED_INSTALL_PREFIX)/lib/ && ln -s $(PLUMED_PROGRAM_NAME)/src/lib/libplumed.$(SOEXT) lib$(PLUMED_PROGRAM_NAME).$(SOEXT) cd $(DESTDIR)$(PLUMED_INSTALL_PREFIX)/lib/ && ln -s $(PLUMED_PROGRAM_NAME)/src/lib/libplumedKernel.$(SOEXT) lib$(PLUMED_PROGRAM_NAME)Kernel.$(SOEXT) endif chmod -R go+rX,go-w $(DESTDIR)$(PLUMED_INSTALL_ROOT) + chmod -R go+rX,go-w $(DESTDIR)$(PLUMED_INSTALL_ROOT)/plumed-* chmod -R go+rX,go-w $(DESTDIR)$(PLUMED_INSTALL_PREFIX)/include/$(PLUMED_PROGRAM_NAME) chmod -R go+rX,go-w $(DESTDIR)$(PLUMED_INSTALL_PREFIX)/bin/$(PLUMED_PROGRAM_NAME) - chmod -R go+rX,go-w $(DESTDIR)$(PLUMED_INSTALL_PREFIX)/bin/$(PLUMED_PROGRAM_NAME)-* @echo @echo "*** PLUMED has been installed ***" @echo @@ -138,17 +139,30 @@ endif @echo $(PLUMED_INSTALL_ROOT) @echo $(PLUMED_INSTALL_PREFIX)/include/$(PLUMED_PROGRAM_NAME) @echo $(PLUMED_INSTALL_PREFIX)/bin/$(PLUMED_PROGRAM_NAME) - @for file in $(PLUMED_INSTALL_PREFIX)/bin/$(PLUMED_PROGRAM_NAME)-* ; do echo $$file ; done + @echo $(PLUMED_INSTALL_PREFIX)/bin/$(PLUMED_PROGRAM_NAME)-patch ifdef SOEXT @echo $(PLUMED_INSTALL_PREFIX)/lib/lib$(PLUMED_PROGRAM_NAME).$(SOEXT) @echo $(PLUMED_INSTALL_PREFIX)/lib/lib$(PLUMED_PROGRAM_NAME)Kernel.$(SOEXT) endif +ifeq ($(program_can_run),no) + @echo "WARNING: $(PLUMED_PROGRAM_NAME) executable will not run on this machine" + @echo "WARNING: to patch an MD code use 'plumed-patch'" + @echo "WARNING: a few other command line tools are avalable as $(PLUMED_INSTALL_ROOT)/plumed-*" +else ifeq ($(program_can_run_mpi),no) + @echo "WARNING: $(PLUMED_PROGRAM_NAME) executable will not run on this machine" + @echo "WARNING: unless you invoke it as '$(PLUMED_PROGRAM_NAME) --no-mpi'" + @echo "WARNING: to patch an MD code now use '$(PLUMED_PROGRAM_NAME) --no-mpi patch'" + @echo "WARNING: (notice that MPI will be available anyway in the patched code)" + @echo "WARNING: all command line tools are available as '$(PLUMED_PROGRAM_NAME) --no-mpi name-of-the-tool'" + @echo "WARNING: e.g. '$(PLUMED_PROGRAM_NAME) --no-mpi driver'" +endif + uninstall: rm -fr $(DESTDIR)$(PLUMED_INSTALL_ROOT) rm -fr $(DESTDIR)$(PLUMED_INSTALL_PREFIX)/include/$(PLUMED_PROGRAM_NAME) rm -f $(DESTDIR)$(PLUMED_INSTALL_PREFIX)/bin/$(PLUMED_PROGRAM_NAME) - rm -f $(DESTDIR)$(PLUMED_INSTALL_PREFIX)/bin/$(PLUMED_PROGRAM_NAME)-* + rm -f $(DESTDIR)$(PLUMED_INSTALL_PREFIX)/bin/$(PLUMED_PROGRAM_NAME)-patch rm -f $(DESTDIR)$(PLUMED_INSTALL_PREFIX)/lib/lib$(PLUMED_PROGRAM_NAME).$(SOEXT) rm -f $(DESTDIR)$(PLUMED_INSTALL_PREFIX)/lib/lib$(PLUMED_PROGRAM_NAME)Kernel.$(SOEXT) diff --git a/user-doc/Installation.txt b/user-doc/Installation.txt index b856e7eacff76d557769495b7b016a33d2a6e22a..aa934e83bf108dc3e39bf5d7666f02ff7879a9d8 100644 --- a/user-doc/Installation.txt +++ b/user-doc/Installation.txt @@ -361,16 +361,6 @@ with the option --program-transform-name=PROGRAM These options are useful if you do not want to set up modules, but we believe that using modules as described above is more flexible. -\warning Avoid suffixes starting with a dash since they could clash with the fact that plumed reserved names with a `-something` appended -for scripts used in cross compiling (see below). -As a consequence, by doing -\verbatim -> make install --program-suffix=-2 -> make install -\endverbatim -The second install would remove all the executables installed by the first install. -Better using `make install --program-suffix=_2`. - \section Patching Patching your MD code In case your MD code is not supporting PLUMED already, you should modify it. @@ -443,12 +433,18 @@ in combination with an MD software should work if both PLUMED and the MD softwar Also notice that it will not be possible to use the command `plumed patch` on the machine where you are compiling. You should thus use `plumed-patch` instead of `plumed patch` (notice that it should be written as a single word). + Try e.g.: \verbatim > plumed-patch --help \endverbatim This script provides a "shell only" implementation of `plumed patch` that will skip the launch of the `plumed` executable. +Notice that other command line tools will be available in the directory `prefix/lib/progname/`. If configuring with +default values this would be `/usr/local/lib/plumed/plumed-*`. These files are not included in the execution path (prefix/bin) +to avoid clashes, but can be executed also when plumed is cross compiled and the main plumed executable cannot be +launched. + \section installingalmost Installing PLUMED with ALMOST In order to used some of the NMR based collective variables (\ref CS2BACKBONE and \ref CH3SHIFTS) PLUMED needs to be linked with ALMOST.