diff --git a/var/spack/repos/builtin/packages/g2/package.py b/var/spack/repos/builtin/packages/g2/package.py index 1d47e4ee3b89cf..ea3bb603442dd1 100644 --- a/var/spack/repos/builtin/packages/g2/package.py +++ b/var/spack/repos/builtin/packages/g2/package.py @@ -59,6 +59,19 @@ def cmake_args(self): return args + # https://github.com/JCSDA/spack/issues/475 + def flag_handler(self, name, flags): + if self.spec.satisfies("@3.5.1") and name == "fflags" and "gfortran" in self.compiler.fc: + with self.compiler.compiler_environment(): + gfortran_major_version = int( + spack.compiler.get_compiler_version_output( + self.compiler.fc, "-dumpversion" + ).split(".")[0] + ) + if gfortran_major_version < 10: + flags.append("-fno-range-check") + return (None, None, flags) + def setup_run_environment(self, env): precisions = ( self.spec.variants["precision"].value if self.spec.satisfies("@3.4.6:") else ("4", "d")