From cb6c6fb3747aafbfb0fe81803eacf2807dde301f Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Mon, 11 Apr 2016 16:28:30 -0500 Subject: Add elk package --- var/spack/repos/builtin/packages/elk/package.py | 116 +++++++++++++++++++++ var/spack/repos/builtin/packages/libxc/package.py | 18 ++++ .../repos/builtin/packages/openblas/package.py | 6 ++ 3 files changed, 140 insertions(+) create mode 100644 var/spack/repos/builtin/packages/elk/package.py create mode 100644 var/spack/repos/builtin/packages/libxc/package.py (limited to 'var') diff --git a/var/spack/repos/builtin/packages/elk/package.py b/var/spack/repos/builtin/packages/elk/package.py new file mode 100644 index 0000000000..28ebb89db3 --- /dev/null +++ b/var/spack/repos/builtin/packages/elk/package.py @@ -0,0 +1,116 @@ +from spack import * +import spack + +class Elk(Package): + '''An all-electron full-potential linearised augmented-plane wave + (FP-LAPW) code with many advanced features.''' + + homepage = 'http://elk.sourceforge.net/' + url = 'https://sourceforge.net/projects/elk/files/elk-3.3.17.tgz' + + version('3.3.17', 'f57f6230d14f3b3b558e5c71f62f0592') + + # Elk provides these libraries, but allows you to specify your own + variant('blas', default=True, description='Build with custom BLAS library') + variant('lapack', default=True, description='Build with custom LAPACK library') + variant('fft', default=True, description='Build with custom FFT library') + + # Elk does not provide these libraries, but allows you to use them + variant('mpi', default=True, description='Enable MPI parallelism') + variant('openmp', default=True, description='Enable OpenMP support') + variant('libxc', default=True, description='Link to Libxc functional library') + + depends_on('blas', when='+blas') + depends_on('lapack', when='+lapack') + depends_on('fftw', when='+fft') + depends_on('mpi', when='+mpi') + depends_on('libxc', when='+libxc') + + # Cannot be built in parallel + parallel = False + + + def configure(self, spec): + # Dictionary of configuration options + config = { + 'MAKE': 'make', + 'F90': join_path(spack.build_env_path, 'f90'), + 'F77': join_path(spack.build_env_path, 'f77'), + 'AR': 'ar', + 'LIB_FFT': 'fftlib.a', + 'SRC_MPI': 'mpi_stub.f90', + 'SRC_OMP': 'omp_stub.f90', + 'SRC_libxc': 'libxcifc_stub.f90', + 'SRC_FFT': 'zfftifc.f90' + } + + # Compiler-specific flags + flags = '' + if self.compiler.name == 'intel': + flags = '-O3 -ip -unroll -no-prec-div -openmp' + elif self.compiler.name == 'gcc': + flags = '-O3 -ffast-math -funroll-loops -fopenmp' + elif self.compiler.name == 'pgi': + flags = '-O3 -mp -lpthread' + elif self.compiler.name == 'g95': + flags = '-O3 -fno-second-underscore' + elif self.compiler.name == 'nag': + flags = '-O4 -kind=byte -dusty -dcfuns' + elif self.compiler.name == 'xl': + flags = '-O3 -qsmp=omp' + config['F90_OPTS'] = flags + config['F77_OPTS'] = flags + + # BLAS/LAPACK support + blas = 'blas.a' + lapack = 'lapack.a' + if '+blas' in spec: + blas = join_path(spec['blas'].prefix.lib, 'libblas.so') + if '+lapack' in spec: + lapack = join_path(spec['lapack'].prefix.lib, 'liblapack.so') + config['LIB_LPK'] = ' '.join([lapack, blas]) # lapack must come before blas + + # FFT support + if '+fft' in spec: + config['LIB_FFT'] = join_path(spec['fftw'].prefix.lib, 'libfftw3.so') + config['SRC_FFT'] = 'zfftifc_fftw.f90' + + # MPI support + if '+mpi' in spec: + config.pop('SRC_MPI') + config['F90'] = join_path(spec['mpi'].prefix.bin, 'mpif90') + config['F77'] = join_path(spec['mpi'].prefix.bin, 'mpif77') + + # OpenMP support + if '+openmp' in spec: + config.pop('SRC_OMP') + + # Libxc support + if '+libxc' in spec: + config['LIB_libxc'] = ' '.join([ + join_path(spec['libxc'].prefix.lib, 'libxcf90.so'), + join_path(spec['libxc'].prefix.lib, 'libxc.so') + ]) + config['SRC_libxc'] = ' '.join([ + 'libxc_funcs.f90', + 'libxc.f90', + 'libxcifc.f90' + ]) + + # Write configuration options to include file + with open('make.inc', 'w') as inc: + for key in config: + inc.write('{0} = {1}\n'.format(key, config[key])) + + + def install(self, spec, prefix): + self.configure(spec) + + make() + make('test') + + mkdirp(prefix.bin) + + install('src/elk', prefix.bin) + install('src/eos/eos', prefix.bin) + install('src/spacegroup/spacegroup', prefix.bin) diff --git a/var/spack/repos/builtin/packages/libxc/package.py b/var/spack/repos/builtin/packages/libxc/package.py new file mode 100644 index 0000000000..010a5918c5 --- /dev/null +++ b/var/spack/repos/builtin/packages/libxc/package.py @@ -0,0 +1,18 @@ +from spack import * + +class Libxc(Package): + """Libxc is a library of exchange-correlation functionals for + density-functional theory.""" + + homepage = "http://www.tddft.org/programs/octopus/wiki/index.php/Libxc" + url = "http://www.tddft.org/programs/octopus/down.php?file=libxc/libxc-2.2.2.tar.gz" + + version('2.2.2', 'd9f90a0d6e36df6c1312b6422280f2ec') + + + def install(self, spec, prefix): + configure('--prefix=%s' % prefix, + '--enable-shared') + + make() + make("install") diff --git a/var/spack/repos/builtin/packages/openblas/package.py b/var/spack/repos/builtin/packages/openblas/package.py index 9f13d0690b..4522130ccc 100644 --- a/var/spack/repos/builtin/packages/openblas/package.py +++ b/var/spack/repos/builtin/packages/openblas/package.py @@ -12,6 +12,7 @@ class Openblas(Package): version('0.2.15', 'b1190f3d3471685f17cfd1ec1d252ac9') variant('shared', default=True, description="Build shared libraries as well as static libs.") + variant('openmp', default=True, description="Enable OpenMP support.") # virtual dependency provides('blas') @@ -37,6 +38,11 @@ class Openblas(Package): if spec.satisfies('@0.2.16'): make_defs += ['BUILD_LAPACK_DEPRECATED=1'] + # Add support for OpenMP + # Note: Make sure your compiler supports OpenMP + if '+openmp' in spec: + make_defs += ['USE_OPENMP=1'] + make_args = make_defs + make_targets make(*make_args) -- cgit v1.2.3-60-g2f50