Repository: spack/spack

Issue:
Installation issue: fenics (petsc requires hdf5 variant +fortran, but spec asked for ~fortran)
Cannot install fenics because petsc requires hdf5 variant +fortran, but spec asked for ~fortran.

### Steps to reproduce the issue

```console
$ spack install fenics
==> Error: An unsatisfiable variant constraint has been detected for spec:

    hdf5@1.10.4%gcc@6.3.0~cxx~debug~fortran+hl+mpi+pic+shared~szip~threadsafe arch=linux-debian9-x86_64 
        ^openmpi@3.1.3%gcc@6.3.0~cuda+cxx_exceptions fabrics= ~java~legacylaunchers~memchecker~pmi schedulers= ~sqlite3~thread_multiple+vt arch=linux-debian9-x86_64 
            ^hwloc@:1.999
                ^pkgconf@1.5.4%gcc@6.3.0 arch=linux-debian9-x86_64 
            ^numactl
                ^autoconf@2.69%gcc@6.3.0 arch=linux-debian9-x86_64 
                    ^m4@1.4.18%gcc@6.3.0+sigsegv arch=linux-debian9-x86_64 
                        ^libsigsegv
                    ^perl@5.26.2%gcc@6.3.0+cpanm+shared+threads arch=linux-debian9-x86_64 
                        ^gdbm@1.18.1%gcc@6.3.0 arch=linux-debian9-x86_64 
                            ^readline@7.0%gcc@6.3.0 arch=linux-debian9-x86_64 
                                ^ncurses@6.1%gcc@6.3.0~symlinks~termlib arch=linux-debian9-x86_64 
                ^automake@1.16.1%gcc@6.3.0 arch=linux-debian9-x86_64 
                ^libtool@2.4.6%gcc@6.3.0 arch=linux-debian9-x86_64 
            ^zlib@1.2.11%gcc@6.3.0+optimize+pic+shared arch=linux-debian9-x86_64 


while trying to concretize the partial spec:

    petsc@3.10.3%gcc@6.3.0~X clanguage=C ~complex~debug+double+hdf5+hypre~int64+metis+mpi~mumps+shared~suite-sparse+superlu-dist~trilinos arch=linux-debian9-x86_64 
        ^hypre@2.14:~int64~internal-superlu
            ^openblas@0.3.4%gcc@6.3.0 cpu_target= ~ilp64+pic+shared threads=none ~virtual_machine arch=linux-debian9-x86_64 
        ^superlu-dist@6.1:6.1.99~int64
            ^cmake@3.13.2%gcc@6.3.0~doc+ncurses+openssl+ownlibs~qt arch=linux-debian9-x86_64 
                ^ncurses@6.1%gcc@6.3.0~symlinks~termlib arch=linux-debian9-x86_64 
                    ^pkgconf@1.5.4%gcc@6.3.0 arch=linux-debian9-x86_64 
                ^openssl@1.1.1%gcc@6.3.0+systemcerts arch=linux-debian9-x86_64 
                    ^perl@5.26.2%gcc@6.3.0+cpanm+shared+threads arch=linux-debian9-x86_64 
                        ^gdbm@1.18.1%gcc@6.3.0 arch=linux-debian9-x86_64 
                            ^readline@7.0%gcc@6.3.0 arch=linux-debian9-x86_64 
                    ^zlib@1.2.11%gcc@6.3.0+optimize+pic+shared arch=linux-debian9-x86_64 
            ^metis@5.1.0%gcc@6.3.0 build_type=Release ~gdb~int64~real64+shared arch=linux-debian9-x86_64 
            ^openmpi@3.1.3%gcc@6.3.0~cuda+cxx_exceptions fabrics= ~java~legacylaunchers~memchecker~pmi schedulers= ~sqlite3~thread_multiple+vt arch=linux-debian9-x86_64 
                ^hwloc@:1.999
                ^numactl
                    ^autoconf@2.69%gcc@6.3.0 arch=linux-debian9-x86_64 
                        ^m4@1.4.18%gcc@6.3.0+sigsegv arch=linux-debian9-x86_64 
                            ^libsigsegv
                    ^automake@1.16.1%gcc@6.3.0 arch=linux-debian9-x86_64 
                    ^libtool@2.4.6%gcc@6.3.0 arch=linux-debian9-x86_64 
            ^parmetis@4.0.3%gcc@6.3.0 build_type=RelWithDebInfo ~gdb+shared arch=linux-debian9-x86_64 


petsc requires hdf5 variant +fortran, but spec asked for ~fortran
```

### Platform and user environment

```commandline
$ uname -a 
Linux 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 GNU/Linux
$ lsb_release -d
Description:    Debian GNU/Linux 9.6 (stretch)
``` 

### Additional information

The following change seems to fix the issue:
```
diff --git a/var/spack/repos/builtin/packages/fenics/package.py b/var/spack/repos/builtin/packages/fenics/package.py
index f9707895f..ccc3607af 100644
--- a/var/spack/repos/builtin/packages/fenics/package.py
+++ b/var/spack/repos/builtin/packages/fenics/package.py
@@ -58,7 +58,7 @@ class Fenics(CMakePackage):
     depends_on('boost+filesystem+program_options+system+iostreams+timer+regex+chrono')
 
     depends_on('mpi', when='+mpi')
-    depends_on('hdf5+hl', when='+hdf5')
+    depends_on('hdf5+hl+fortran', when='+hdf5')
     depends_on('parmetis@4.0.2:^metis+real64', when='+parmetis')
     depends_on('scotch~metis', when='+scotch~mpi')
     depends_on('scotch+mpi~metis', when='+scotch+mpi')
```


Discussion:
It looks like dealii had a similar issue: https://github.com/spack/spack/pull/10217

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/fenics/package.py b/var/spack/repos/builtin/packages/fenics/package.py
--- a/var/spack/repos/builtin/packages/fenics/package.py
+++ b/var/spack/repos/builtin/packages/fenics/package.py
@@ -58,7 +58,9 @@ class Fenics(CMakePackage):
     depends_on('boost+filesystem+program_options+system+iostreams+timer+regex+chrono')
 
     depends_on('mpi', when='+mpi')
-    depends_on('hdf5+hl', when='+hdf5')
+    # FIXME: next line fixes concretization with petsc
+    depends_on('hdf5+hl+fortran', when='+hdf5+petsc')
+    depends_on('hdf5+hl', when='+hdf5~petsc')
     depends_on('parmetis@4.0.2:^metis+real64', when='+parmetis')
     depends_on('scotch~metis', when='+scotch~mpi')
     depends_on('scotch+mpi~metis', when='+scotch+mpi')


Test patch: