Repository: spack/spack

Issue:
`spack install mfem` installs hypre 2.14.0 by default, then throws hypre-related compile-time errors in building mfem
Summary

### Expected Result

`spack install mfem` builds successfully.

### Actual Result

`spack install mfem` fails to build

### Steps to reproduce the issue

```console
# Assumes hypre hasn't yet been installed
$ spack install mfem
# hypre should be mandatory
```

### Information on your system

This spack installation is on RZTopaz, which I believe is running RHEL7. I'm using the default configuration, but did run `spack compiler find`, which found GCC 4.9.3 successfully.

The errors I see look like

```console
/collab/usr/gapps/librom/spack/opt/spack/linux-rhel7-x86_64/gcc-4.9.3/openmpi-3.0.1-mag6eiw5hvarj2johuj4dbx3locaxxma/bin/mpic++  -O3 -I/collab/usr/gapps/librom/spack/opt/spack/linux-rhel7-x86_64/gcc-4.9.3/hypre\
-2.14.0-r2ndcvyvdfp4qtqhm244zg5hyojd4xfr/include -I/collab/usr/gapps/librom/spack/opt/spack/linux-rhel7-x86_64/gcc-4.9.3/metis-5.1.0-vlsznfyilnoevbrbt72f3262kjxvo4kz/include  -I/collab/usr/gapps/librom/spack/op\
t/spack/linux-rhel7-x86_64/gcc-4.9.3/netcdf-4.4.1.1-2t22niwuxdtodgu3a4gh2rbagyec2mt6/include  -c fem/pgridfunc.cpp -o fem/pgridfunc.o

 >> 129    linalg/hypre_parcsr.cpp:209:68: error: macro "hypre_CTAlloc" requires 3 arguments, but only 2 given
     130        HYPRE_Real *eliminate_row = hypre_CTAlloc(HYPRE_Real, diag_nrows);
     131                                                                        ^
  >> 132    linalg/hypre_parcsr.cpp:210:68: error: macro "hypre_CTAlloc" requires 3 arguments, but only 2 given
     133        HYPRE_Real *eliminate_col = hypre_CTAlloc(HYPRE_Real, offd_ncols);
     134                                                                        ^
  >> 135    linalg/hypre_parcsr.cpp:239:71: error: macro "hypre_CTAlloc" requires 3 arguments, but only 2 given
     136                                                                 num_sends));
     137                                                                           ^
  >> 138    linalg/hypre_parcsr.cpp:271:70: error: macro "hypre_CTAlloc" requires 3 arguments, but only 2 given
     139        offd_cols_to_elim = hypre_CTAlloc(HYPRE_Int, num_offd_cols_to_elim);
     140                                                                          ^
  >> 141    linalg/hypre_parcsr.cpp:272:69: error: macro "hypre_CTAlloc" requires 3 arguments, but only 2 given
     142        eliminate_coefs = hypre_CTAlloc(HYPRE_Real, num_offd_cols_to_elim);
     143                                                                         ^
  >> 144    linalg/hypre_parcsr.cpp:287:24: error: macro "hypre_TFree" requires 2 arguments, but only 1 given
     145        hypre_TFree(buf_data);
     146                            ^
  >> 147    linalg/hypre_parcsr.cpp:288:29: error: macro "hypre_TFree" requires 2 arguments, but only 1 given
     148        hypre_TFree(eliminate_row);
     149                                 ^
  >> 150    linalg/hypre_parcsr.cpp:289:29: error: macro "hypre_TFree" requires 2 arguments, but only 1 given
     151        hypre_TFree(eliminate_col);
     152                                 ^
  >> 153    linalg/hypre_parcsr.cpp:306:33: error: macro "hypre_TFree" requires 2 arguments, but only 1 given
     154        hypre_TFree(offd_cols_to_elim);
# Similar compile-time errors continue for many more lines
```

My guess is that mfem 3.3.2 is meant to be built with a specific version range of hypre. The current default version of hypre installed by spack is 2.14.0, as of commit `82ac1571c227adb0af665332396b9b3afff5853f`.


Discussion:
cc: @tzanio @v-dobrev
Version 2.14.0 of hypre changed the `hypre_*` memory allocation API, so it will break all codes that directly construct hypre objects, such as mfem.

We have a fix, that just got merged into https://github.com/mfem/mfem/pull/469 and will be available in mfem-3.4 to be released in a couple of weeks.

We can either hardcode the hypre version required in MFEM, or make a different version the default in the `hypre` package (which IMHO is preferable at this point).

@rfalgout, @ulrikeyang, what do you think?
Just put the version restrictions into the `mfem/package.py`, i.e. 
```
depends_on('hypre@:2.13.99', when='@:3.3.99')
depends_on('hypre@2.14.0:', when='@3.4:')
```
Dependency resolution/tracking is what spack is for
Does someone want to submit this as a PR?
Sure, I can do it; I just need to know the bounds. For now, I can add the
known upper version, but it would be preferable to have a lower bound on
the version number also. I can use 2.13.0 as a placeholder lower bound, but
I think encoding a better approximation of the version range would be
preferable.

On Wed, Apr 25, 2018 at 08:20 Adam J. Stewart <notifications@github.com>
wrote:

> Does someone want to submit this as a PR?
>
> —
> You are receiving this because you authored the thread.
>
>
> Reply to this email directly, view it on GitHub
> <https://github.com/spack/spack/issues/7900#issuecomment-384326330>, or mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/AATnx8whDj-7NDt2YNWMvsF02Neuuf7vks5tsJRPgaJpZM4TjdUY>
> .
>
-- 
Geoffrey Oxberry, Ph.D., E.I.T.
goxberry@gmail.com


Resolving patch:
diff --git a/var/spack/repos/builtin/packages/mfem/package.py b/var/spack/repos/builtin/packages/mfem/package.py
--- a/var/spack/repos/builtin/packages/mfem/package.py
+++ b/var/spack/repos/builtin/packages/mfem/package.py
@@ -164,6 +164,8 @@ class Mfem(Package):
 
     depends_on('mpi', when='+mpi')
     depends_on('hypre', when='+mpi')
+    depends_on('hypre@2.10.0:2.13.999', when='@:3.3.2')
+
     depends_on('metis', when='+metis')
     depends_on('blas', when='+lapack')
     depends_on('lapack', when='+lapack')


Test patch: