From 78e0c1d5b83ff2874ec803ce25d08b014b5c8cc3 Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Thu, 5 Sep 2024 14:49:43 -0600 Subject: [PATCH] release/1.8.0: bug fix for compiling g2@3.5.1 with gfortran < 10 (#477) Bug fix for compiling g2@3.5.1 with gfortran < 10 --------- Co-authored-by: RatkoVasic-NOAA <37597874+RatkoVasic-NOAA@users.noreply.github.com> --- var/spack/repos/builtin/packages/g2/package.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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")