|
| 1 | +import os |
1 | 2 | from spack import * |
2 | 3 |
|
| 4 | + |
3 | 5 | class Petsc(Package): |
4 | | - """PETSc is a suite of data structures and routines for the |
5 | | - scalable (parallel) solution of scientific applications modeled by |
6 | | - partial differential equations.""" |
| 6 | + """ |
| 7 | + PETSc is a suite of data structures and routines for the scalable (parallel) solution of scientific applications |
| 8 | + modeled by partial differential equations. |
| 9 | + """ |
7 | 10 |
|
8 | 11 | homepage = "http://www.mcs.anl.gov/petsc/index.html" |
9 | | - url = "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-3.5.3.tar.gz" |
| 12 | + url = "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-3.5.3.tar.gz" |
10 | 13 |
|
| 14 | + version('3.6.3', '91dd3522de5a5ef039ff8f50800db606') |
11 | 15 | version('3.5.3', 'd4fd2734661e89f18ac6014b5dd1ef2f') |
12 | 16 | version('3.5.2', 'ad170802b3b058b5deb9cd1f968e7e13') |
13 | 17 | version('3.5.1', 'a557e029711ebf425544e117ffa44d8f') |
14 | 18 |
|
15 | | - depends_on("python @2.6:2.9") # requires Python for building |
| 19 | + variant('shared', default=True, description='Enables the build of shared libraries') |
| 20 | + variant('mpi', default=True, description='Activates MPI support') |
| 21 | + variant('double', default=True, description='Switches between single and double precision') |
| 22 | + |
| 23 | + variant('metis', default=True, description='Activates support for metis and parmetis') |
| 24 | + variant('hdf5', default=True, description='Activates support for HDF5 (only parallel)') |
| 25 | + variant('boost', default=True, description='Activates support for Boost') |
| 26 | + variant('hypre', default=True, description='Activates support for Hypre') |
| 27 | + |
| 28 | + # Build dependencies |
| 29 | + depends_on('python @2.6:2.9') # requires Python for building |
| 30 | + |
| 31 | + # Virtual dependencies |
| 32 | + depends_on('blas') |
| 33 | + depends_on('lapack') |
| 34 | + depends_on('mpi', when='+mpi') |
16 | 35 |
|
17 | | - depends_on("boost") |
18 | | - depends_on("blas") |
19 | | - depends_on("lapack") |
20 | | - depends_on("hypre") |
21 | | - depends_on("parmetis") |
22 | | - depends_on("metis") |
23 | | - depends_on("hdf5+mpi") |
24 | | - depends_on("mpi") |
| 36 | + # Other dependencies |
| 37 | + depends_on('boost', when='+boost') |
| 38 | + depends_on('metis', when='+metis') |
| 39 | + |
| 40 | + depends_on('hdf5~cxx~unsupported+mpi', when='+hdf5+mpi') |
| 41 | + depends_on('parmetis', when='+metis+mpi') |
| 42 | + depends_on('hypre', when='+hypre+mpi') |
| 43 | + |
| 44 | + def mpi_dependent_options(self): |
| 45 | + if '~mpi' in self.spec: |
| 46 | + compiler_opts = [ |
| 47 | + '--with-cc=%s' % os.environ['CC'], |
| 48 | + '--with-cxx=%s' % (os.environ['CXX'] if self.compiler.cxx is not None else '0'), |
| 49 | + '--with-fc=%s' % (os.environ['FC'] if self.compiler.fc is not None else '0'), |
| 50 | + '--with-mpi=0' |
| 51 | + ] |
| 52 | + error_message_fmt = '\t{library} support requires "+mpi" to be activated' |
| 53 | + errors = [error_message_fmt.format(library=x) for x in ('hdf5', 'hypre') if ('+'+x) in self.spec] |
| 54 | + if errors: |
| 55 | + errors = ['incompatible variants given'] + errors |
| 56 | + raise RuntimeError('\n'.join(errors)) |
| 57 | + else: |
| 58 | + compiler_opts = [ |
| 59 | + '--with-mpi=1', |
| 60 | + '--with-mpi-dir=%s' % self.spec['mpi'].prefix, |
| 61 | + ] |
| 62 | + return compiler_opts |
25 | 63 |
|
26 | 64 | def install(self, spec, prefix): |
27 | | - configure("--prefix=%s" % prefix, |
28 | | - "--with-blas-lib=%s/libblas.a" % spec['blas'].prefix.lib, |
29 | | - "--with-lapack-lib=%s/liblapack.a" % spec['lapack'].prefix.lib, |
30 | | - "--with-boost-dir=%s" % spec['boost'].prefix, |
31 | | - "--with-hypre-dir=%s" % spec['hypre'].prefix, |
32 | | - "--with-parmetis-dir=%s" % spec['parmetis'].prefix, |
33 | | - "--with-metis-dir=%s" % spec['metis'].prefix, |
34 | | - "--with-hdf5-dir=%s" % spec['hdf5'].prefix, |
35 | | - "--with-mpi-dir=%s" % spec['mpi'].prefix, |
36 | | - "--with-shared-libraries=0") |
| 65 | + options = [] |
| 66 | + options.extend(self.mpi_dependent_options()) |
| 67 | + options.extend([ |
| 68 | + '--with-precision=%s' % ('double' if '+double' in spec else 'single'), |
| 69 | + '--with-shared-libraries=%s' % ('1' if '+shared' in spec else '0'), |
| 70 | + '--with-blas-lapack-dir=%s' % spec['lapack'].prefix |
| 71 | + ]) |
| 72 | + # Activates library support if needed |
| 73 | + for library in ('metis', 'boost', 'hfd5', 'hypre', 'parmetis'): |
| 74 | + options.append( |
| 75 | + '--with-{library}={value}'.format(library=library, value=('1' if library in spec else '0')) |
| 76 | + ) |
| 77 | + if library in spec: |
| 78 | + options.append( |
| 79 | + '--with-{library}-dir={path}'.format(library=library, path=spec[library].prefix) |
| 80 | + ) |
| 81 | + |
37 | 82 |
|
| 83 | + configure('--prefix=%s' % prefix, *options) |
38 | 84 | # PETSc has its own way of doing parallel make. |
39 | 85 | make('MAKE_NP=%s' % make_jobs, parallel=False) |
40 | 86 | make("install") |
0 commit comments