diff options
-rw-r--r-- | var/spack/repos/builtin/packages/petsc/package.py | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/var/spack/repos/builtin/packages/petsc/package.py b/var/spack/repos/builtin/packages/petsc/package.py index 2e2c19d6b8..26779fe0b9 100644 --- a/var/spack/repos/builtin/packages/petsc/package.py +++ b/var/spack/repos/builtin/packages/petsc/package.py @@ -113,11 +113,11 @@ class Petsc(Package, CudaPackage, ROCmPackage): # which is not portable to all HPC systems variant('mumps', default=False, description='Activates support for MUMPS (only parallel)') - variant('superlu-dist', default=True, - description='Activates support for SuperluDist (only parallel)') + variant('superlu-dist', default=True, when='+fortran', + description='Activates support for superlu-dist (only parallel)') variant('strumpack', default=False, description='Activates support for Strumpack') - variant('scalapack', default=False, + variant('scalapack', default=False, when='+fortran', description='Activates support for Scalapack') variant('trilinos', default=False, description='Activates support for Trilinos (only parallel)') @@ -170,6 +170,8 @@ class Petsc(Package, CudaPackage, ROCmPackage): description='Activates support for hwloc') variant('kokkos', default=False, description='Activates support for kokkos and kokkos-kernels') + variant('fortran', default=True, + description='Activates fortran support') # 3.8.0 has a build issue with MKL - so list this conflict explicitly conflicts('^intel-mkl', when='@3.8.0') @@ -199,6 +201,12 @@ class Petsc(Package, CudaPackage, ROCmPackage): 'petscvariables', relative_root='lib/petsc/conf' ) + @run_before('configure') + def check_fortran_compiler(self): + # Raise error if +fortran and there isn't a fortran compiler! + if '+fortran' in self.spec and self.compiler.fc is None: + raise InstallError("+fortran requires a fortran compiler!") + # temporary workaround Clang 8.1.0 with XCode 8.3 on macOS, see # https://bitbucket.org/petsc/petsc/commits/4f290403fdd060d09d5cb07345cbfd52670e3cbc # the patch is an adaptation of the original commit to 3.7.5 @@ -261,6 +269,9 @@ class Petsc(Package, CudaPackage, ROCmPackage): depends_on('mmg', when='+mmg') depends_on('parmmg', when='+parmmg') depends_on('tetgen+pic', when='+tetgen') + # hypre+/~fortran based on wheter fortran is enabled/disabled + depends_on('hypre+fortran', when='+hypre+fortran') + depends_on('hypre~fortran', when='+hypre~fortran') # Hypre does not support complex numbers. # Also PETSc prefer to build it without internal superlu, likely due to # conflict in headers see @@ -344,16 +355,21 @@ class Petsc(Package, CudaPackage, ROCmPackage): '--with-cc=%s' % os.environ['CC'], '--with-cxx=%s' % (os.environ['CXX'] if self.compiler.cxx is not None else '0'), - '--with-fc=%s' % (os.environ['FC'] - if self.compiler.fc is not None else '0'), '--with-mpi=0' ] + if '+fortran' in self.spec: + compiler_opts.append('--with-fc=%s' % os.environ['FC']) + else: + compiler_opts.append('--with-fc=0') else: compiler_opts = [ '--with-cc=%s' % self.spec['mpi'].mpicc, '--with-cxx=%s' % self.spec['mpi'].mpicxx, - '--with-fc=%s' % self.spec['mpi'].mpifc, ] + if '+fortran' in self.spec: + compiler_opts.append('--with-fc=%s' % self.spec['mpi'].mpifc) + else: + compiler_opts.append('--with-fc=0') if self.spec.satisfies('%intel'): # mpiifort needs some help to automatically link # all necessary run-time libraries @@ -415,6 +431,12 @@ class Petsc(Package, CudaPackage, ROCmPackage): jpeg_sp = spec['jpeg'].name if 'jpeg' in spec else 'jpeg' scalapack_sp = spec['scalapack'].name if 'scalapack' in spec else 'scalapack' + # to be used in the list of libraries below + if '+fortran' in spec: + hdf5libs = ':hl,fortran' + else: + hdf5libs = ':hl' + # tuple format (spacklibname, petsclibname, useinc, uselib) # default: 'gmp', => ('gmp', 'gmp', True, True) # any other combination needs a full tuple @@ -432,7 +454,7 @@ class Petsc(Package, CudaPackage, ROCmPackage): ('scotch', 'ptscotch', True, True), ('suite-sparse:umfpack,klu,cholmod,btf,ccolamd,colamd,camd,amd, \ suitesparseconfig,spqr', 'suitesparse', True, True), - ('hdf5:hl,fortran', 'hdf5', True, True), + ('hdf5' + hdf5libs, 'hdf5', True, True), 'zlib', 'mumps', ('trilinos', 'trilinos', False, False), |