add code and scripts to support all three plumed linkage modes with fix plumed for conventional build

This commit is contained in:
Axel Kohlmeyer
2018-11-14 21:26:36 -05:00
parent 4805e1df22
commit 04520e627d
5 changed files with 41 additions and 25 deletions

View File

@ -11,27 +11,29 @@ import sys,os,re,subprocess,hashlib
help = """ help = """
Syntax from src dir: make lib-plumed args="-b" Syntax from src dir: make lib-plumed args="-b"
or: make lib-plumed args="-b -v 2.4.3" or: make lib-plumed args="-b -v 2.4.3"
or: make lib-plumed args="-p /usr/local/plumed2-2.4.3" or: make lib-plumed args="-p /usr/local/plumed2 -m shared"
Syntax from lib dir: python Install.py -b -v 2.4.3 Syntax from lib dir: python Install.py -b -v 2.4.3
or: python Install.py -b or: python Install.py -b
or: python Install.py -p /usr/local/plumed2-2.4.3 or: python Install.py -p /usr/local/plumed2 -m shared
specify one or more options, order does not matter specify one or more options, order does not matter
-b = download and build the plumed2 library -b = download and build the plumed2 library
-p = specify folder of existing plumed2 installation
-v = set version of plumed2 to download and build (default: 2.4.3) -v = set version of plumed2 to download and build (default: 2.4.3)
-p = specify folder of existing plumed2 installation
-m = set plumed linkage mode: static (default), shared, or runtime
Example: Example:
make lib-plumed args="-b" # download/build in lib/plumed/plumed2 make lib-plumed args="-b" # download/build in lib/plumed/plumed2
make lib-plumed args="-p $HOME/plumed-2.4.3" # use existing Plumed2 installation in $HOME/plumed-2.4.3 make lib-plumed args="-p $HOME/plumed2 -m shared" # use existing Plumed2 installation in $HOME/plumed2
""" """
# settings # settings
version = "2.4.3" version = "2.4.3"
mode = "static"
# known checksums for different PLUMED versions. used to validate the download. # known checksums for different PLUMED versions. used to validate the download.
checksums = { \ checksums = { \
@ -40,11 +42,6 @@ checksums = { \
'2.5b' : 'e341bdef469be1da058b8a0b97a3db22', \ '2.5b' : 'e341bdef469be1da058b8a0b97a3db22', \
} }
#checksums = { \
# '2.4.2' : '0f66f24b4c763ae8b2f39574113e9935', \
# '2.4.3' : 'dc38de0ffd59d13950d8f1ef1ce05574', \
# }
# print error message or help # print error message or help
def error(str=None): def error(str=None):
if not str: print(help) if not str: print(help)
@ -132,6 +129,10 @@ while iarg < nargs:
plumedpath = fullpath(args[iarg+1]) plumedpath = fullpath(args[iarg+1])
pathflag = True pathflag = True
iarg += 2 iarg += 2
elif args[iarg] == "-m":
if iarg+2 > nargs: error()
mode = args[iarg+1]
iarg += 2
elif args[iarg] == "-b": elif args[iarg] == "-b":
buildflag = True buildflag = True
iarg += 1 iarg += 1
@ -149,13 +150,14 @@ if (buildflag and pathflag):
if (not buildflag and not pathflag): if (not buildflag and not pathflag):
error("Have to use either -b or -p flag") error("Have to use either -b or -p flag")
if ((mode != "static") and (mode != "shared") and (mode != "runtime")):
error("Unknown linkage mode '%s' for Plumed" % mode)
# download and unpack plumed2 tarball # download and unpack plumed2 tarball
if buildflag: if buildflag:
url = "https://github.com/plumed/plumed2/releases/download/v%s/plumed-src-%s.tgz" % (version,version) url = "https://github.com/plumed/plumed2/releases/download/v%s/plumed-src-%s.tgz" % (version,version)
filename = "plumed-src-%s.tar.gz" %version filename = "plumed-src-%s.tar.gz" %version
#url = "https://github.com/plumed/plumed2/archive/v%s.tar.gz" % version
#filename = "v%s.tar.gz" %version
print("Downloading plumed ...") print("Downloading plumed ...")
geturl(url,filename) geturl(url,filename)
@ -168,9 +170,6 @@ if buildflag:
if os.path.exists("%s/plumed-%s" % (homepath,version)): if os.path.exists("%s/plumed-%s" % (homepath,version)):
cmd = 'rm -rf "%s/plumed-%s"' % (homepath,version) cmd = 'rm -rf "%s/plumed-%s"' % (homepath,version)
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
#if os.path.exists("%s/plumed2-%s" % (homepath,version)):
# cmd = 'rm -rf "%s/plumed2-%s"' % (homepath,version)
# subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
if os.path.exists("%s/plumed2" % (homepath)): if os.path.exists("%s/plumed2" % (homepath)):
cmd = 'rm -rf "%s/plumed2"' % (homepath) cmd = 'rm -rf "%s/plumed2"' % (homepath)
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
@ -183,7 +182,6 @@ if buildflag:
if buildflag: if buildflag:
print("Building plumed ...") print("Building plumed ...")
cmd = 'cd %s/plumed-%s; ./configure --prefix=%s/plumed2 --enable-static-patch ; make ; make install' % (homepath,version,homepath) cmd = 'cd %s/plumed-%s; ./configure --prefix=%s/plumed2 --enable-static-patch ; make ; make install' % (homepath,version,homepath)
#cmd = 'cd %s/plumed2-%s; ./configure --prefix=%s/plumed2 --enable-static-patch ; make ; make install' % (homepath,version,homepath)
txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
print(txt.decode('UTF-8')) print(txt.decode('UTF-8'))
# #
@ -195,12 +193,12 @@ if linkflag:
os.remove("includelink") os.remove("includelink")
if os.path.isfile("liblink") or os.path.islink("liblink"): if os.path.isfile("liblink") or os.path.islink("liblink"):
os.remove("liblink") os.remove("liblink")
cmd = 'ln -s "%s/plumed2/include" includelink' % homepath cmd = 'ln -s "%s/include" includelink' % homedir
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
cmd = 'ln -s "%s/plumed2/lib" liblink' % homepath cmd = 'ln -s "%s/lib" liblink' % homedir
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
if os.path.isfile("Makefile.lammps.static"): if os.path.isfile("Makefile.lammps.%s" % mode):
print("Creating Makefile.lammps") print("Creating Makefile.lammps")
cmd = 'cat liblink/plumed/src/lib/Plumed.inc.static Makefile.lammps.static > Makefile.lammps' cmd = 'echo PLUMED_LIBDIR="%s/lib" > Makefile.lammps; cat liblink/plumed/src/lib/Plumed.inc.%s Makefile.lammps.%s >> Makefile.lammps' % (homedir,mode,mode)
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)

View File

@ -0,0 +1,5 @@
# Settings that the LAMMPS build will import when this package library is used
plumed_SYSINC = -D__PLUMED_HAS_DLOPEN=1 -D__PLUMED_DEFAULT_KERNEL=$(PLUMED_LIBDIR)/libplumedKernel.so
plumed_SYSLIB = $(PLUMED_LOAD) -rdynamic
plumed_SYSPATH =

View File

@ -0,0 +1,5 @@
# Settings that the LAMMPS build will import when this package library is used
plumed_SYSINC =
plumed_SYSLIB = $(PLUMED_LOAD)
plumed_SYSPATH =

View File

@ -1,5 +1,7 @@
# Settings that the LAMMPS build will import when this package library is used # Settings that the LAMMPS build will import when this package library is used
plumed_SYSINC = # Use statically linked C++ interface to plumed
plumed_SYSINC = -D__PLUMED_WRAPPER_CXX=1
plumed_SYSLIB = $(PLUMED_LOAD) plumed_SYSLIB = $(PLUMED_LOAD)
plumed_SYSPATH = plumed_SYSPATH =

View File

@ -34,13 +34,14 @@
#include "modify.h" #include "modify.h"
#include "pair.h" #include "pair.h"
/*
Use statically linked C++ interface to plumed
*/
#define __PLUMED_WRAPPER_CXX 1
#include "plumed/wrapper/Plumed.h" #include "plumed/wrapper/Plumed.h"
#if defined(__PLUMED_DEFAULT_KERNEL)
#define PLUMED_QUOTE_DIRECT(name) #name
#define PLUMED_QUOTE(macro) PLUMED_QUOTE_DIRECT(macro)
static char plumed_default_kernel[] = "PLUMED_KERNEL=" PLUMED_QUOTE(__PLUMED_DEFAULT_KERNEL);
#endif
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -64,6 +65,11 @@ FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) :
error->warning(FLERR,"Fix group for fix plumed is not 'all'. " error->warning(FLERR,"Fix group for fix plumed is not 'all'. "
"Group will be ignored."); "Group will be ignored.");
#if defined(__PLUMED_DEFAULT_KERNEL)
if (getenv("PLUMED_KERNEL") == NULL)
putenv(plumed_default_kernel);
#endif
p=new PLMD::Plumed; p=new PLMD::Plumed;
// Check API version // Check API version