summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@googlemail.com>2016-08-04 09:42:02 +0200
committeralalazo <massimiliano.culpo@googlemail.com>2016-08-09 09:23:53 +0200
commit15d9fb187916d94d4a11ed4654cbbb3c978001c4 (patch)
tree2cca2f5187ace8e44dd5413af2b079cdc125957b
parent2b94d7cf8eb97e7dd08ea26da0d3481dd36927d5 (diff)
downloadspack-15d9fb187916d94d4a11ed4654cbbb3c978001c4.tar.gz
spack-15d9fb187916d94d4a11ed4654cbbb3c978001c4.tar.bz2
spack-15d9fb187916d94d4a11ed4654cbbb3c978001c4.tar.xz
spack-15d9fb187916d94d4a11ed4654cbbb3c978001c4.zip
plumed : adding dependents
* cp2k : added plumed * gromacs : patched pme load balancing * gromacs : added plumed
-rw-r--r--var/spack/repos/builtin/packages/cp2k/package.py51
-rw-r--r--var/spack/repos/builtin/packages/gromacs/package.py10
-rw-r--r--var/spack/repos/builtin/packages/plumed/package.py28
3 files changed, 71 insertions, 18 deletions
diff --git a/var/spack/repos/builtin/packages/cp2k/package.py b/var/spack/repos/builtin/packages/cp2k/package.py
index 8fdd1e0ca3..5f59286323 100644
--- a/var/spack/repos/builtin/packages/cp2k/package.py
+++ b/var/spack/repos/builtin/packages/cp2k/package.py
@@ -40,6 +40,7 @@ class Cp2k(Package):
version('3.0', 'c05bc47335f68597a310b1ed75601d35')
variant('mpi', default=True, description='Enable MPI support')
+ variant('plumed', default=False, description='Enable PLUMED support')
depends_on('python') # Build dependency
@@ -49,6 +50,8 @@ class Cp2k(Package):
depends_on('mpi', when='+mpi')
depends_on('scalapack', when='+mpi')
+ depends_on('plumed+shared+mpi', when='+plumed+mpi')
+ depends_on('plumed+shared~mpi', when='+plumed~mpi')
# TODO : add dependency on libint
# TODO : add dependency on libsmm, libxsmm
@@ -56,7 +59,6 @@ class Cp2k(Package):
# TODO : add dependency on CUDA
# TODO : add dependency on PEXSI
# TODO : add dependency on QUIP
- # TODO : add dependency on plumed
# TODO : add dependency on libwannier90
parallel = False
@@ -70,22 +72,6 @@ class Cp2k(Package):
# Write the custom makefile
with open(makefile, 'w') as mkf:
- mkf.write('CC = {0.compiler.cc}\n'.format(self))
- if '%intel' in self.spec:
- # CPP is a commented command in Intel arch of CP2K
- # This is the hack through which cp2k developers avoid doing :
- #
- # ${CPP} <file>.F > <file>.f90
- #
- # and use `-fpp` instead
- mkf.write('CPP = # {0.compiler.cc} -P\n'.format(self))
- mkf.write('AR = xiar -r\n')
- else:
- mkf.write('CPP = {0.compiler.cc} -E\n'.format(self))
- mkf.write('AR = ar -r\n')
- fc = self.compiler.fc if '~mpi' in spec else self.spec['mpi'].mpifc
- mkf.write('FC = {0}\n'.format(fc))
- mkf.write('LD = {0}\n'.format(fc))
# Optimization flags
optflags = {
'gcc': ['-O2',
@@ -110,6 +96,37 @@ class Cp2k(Package):
])
ldflags = ['-L' + spec['fftw'].prefix.lib]
libs = []
+ if '+plumed' in self.spec:
+ # Include Plumed.inc in the Makefile
+ mkf.write('include {0}\n'.format(
+ join_path(self.spec['plumed'].prefix.lib,
+ 'plumed',
+ 'src',
+ 'lib',
+ 'Plumed.inc')
+ ))
+ # Add required macro
+ cppflags.extend(['-D__PLUMED2'])
+ libs.extend([
+ join_path(self.spec['plumed'].prefix.lib, 'libplumed.so')
+ ])
+
+ mkf.write('CC = {0.compiler.cc}\n'.format(self))
+ if '%intel' in self.spec:
+ # CPP is a commented command in Intel arch of CP2K
+ # This is the hack through which cp2k developers avoid doing :
+ #
+ # ${CPP} <file>.F > <file>.f90
+ #
+ # and use `-fpp` instead
+ mkf.write('CPP = # {0.compiler.cc} -P\n'.format(self))
+ mkf.write('AR = xiar -r\n')
+ else:
+ mkf.write('CPP = {0.compiler.cc} -E\n'.format(self))
+ mkf.write('AR = ar -r\n')
+ fc = self.compiler.fc if '~mpi' in spec else self.spec['mpi'].mpifc
+ mkf.write('FC = {0}\n'.format(fc))
+ mkf.write('LD = {0}\n'.format(fc))
# Intel
if '%intel' in self.spec:
cppflags.extend([
diff --git a/var/spack/repos/builtin/packages/gromacs/package.py b/var/spack/repos/builtin/packages/gromacs/package.py
index 55eacc8d38..99c6701bc3 100644
--- a/var/spack/repos/builtin/packages/gromacs/package.py
+++ b/var/spack/repos/builtin/packages/gromacs/package.py
@@ -22,6 +22,8 @@
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
+import subprocess
+
from spack import *
@@ -46,14 +48,20 @@ class Gromacs(Package):
variant('shared', default=True, description='Enables the build of shared libraries')
variant('debug', default=False, description='Enables debug mode')
variant('double', default=False, description='Produces a double precision version of the executables')
+ variant('plumed', default=False, description='Enable PLUMED support')
depends_on('mpi', when='+mpi')
-
+ depends_on('plumed+mpi', when='+plumed+mpi')
+ depends_on('plumed~mpi', when='+plumed~mpi')
depends_on('fftw')
depends_on('cmake', type='build')
# TODO : add GPU support
+ def patch(self):
+ if '+plumed' in self.spec:
+ self.spec['plumed'].package.apply_patch(self)
+
def install(self, spec, prefix):
options = []
diff --git a/var/spack/repos/builtin/packages/plumed/package.py b/var/spack/repos/builtin/packages/plumed/package.py
index 32571455eb..4a1dd1baa5 100644
--- a/var/spack/repos/builtin/packages/plumed/package.py
+++ b/var/spack/repos/builtin/packages/plumed/package.py
@@ -22,6 +22,7 @@
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
+import subprocess
from spack import *
@@ -55,6 +56,33 @@ class Plumed(Package):
depends_on('mpi', when='+mpi')
depends_on('gsl', when='+gsl')
+ # Dictionary mapping PLUMED versions to the patches it provides
+ # interactively
+ patches = {
+ '2.2.3': {
+ 'amber-14': '1',
+ 'gromacs-4.5.7': '2',
+ 'gromacs-4.6.7': '3',
+ 'gromacs-5.0.7': '4',
+ 'gromacs-5.1.2': '5',
+ 'lammps-6Apr13': '6',
+ 'namd-2.8': '7',
+ 'namd-2.9': '8',
+ 'espresso-5.0.2': '9'
+ }
+ }
+
+ def apply_patch(self, other):
+ plumed = subprocess.Popen(
+ [join_path(self.spec.prefix.bin, 'plumed'), 'patch', '-p'],
+ stdin=subprocess.PIPE
+ )
+ opts = Plumed.patches[str(self.version)]
+ search = '{0.name}-{0.version}'.format(other)
+ choice = opts[search] + '\n'
+ plumed.stdin.write(choice)
+ plumed.wait()
+
def setup_dependent_package(self, module, ext_spec):
# Make plumed visible from dependent packages
module.plumed = Executable(join_path(self.spec.prefix.bin, 'plumed'))