From 75bfdc73351ae02a4a95de305a7af6d58287c7ab Mon Sep 17 00:00:00 2001 From: Sergey Kosukhin Date: Mon, 19 Oct 2020 23:12:09 +0200 Subject: netcdf-fortran: support for Cray compiler (#18971) --- .../builtin/packages/netcdf-fortran/package.py | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/netcdf-fortran/package.py b/var/spack/repos/builtin/packages/netcdf-fortran/package.py index cd6ed11146..1178de8d57 100644 --- a/var/spack/repos/builtin/packages/netcdf-fortran/package.py +++ b/var/spack/repos/builtin/packages/netcdf-fortran/package.py @@ -4,6 +4,9 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) from spack import * +import os +import glob +from shutil import copyfile, Error class NetcdfFortran(AutotoolsPackage): @@ -69,6 +72,14 @@ class NetcdfFortran(AutotoolsPackage): if self.spec.satisfies('%gcc@10:'): # https://github.com/Unidata/netcdf-fortran/issues/212 flags.append('-fallow-argument-mismatch') + elif self.compiler.name == 'cce': + # Cray compiler generates module files with uppercase names by + # default, which is not handled by the makefiles of + # NetCDF-Fortran: + # https://github.com/Unidata/netcdf-fortran/pull/221. + # The following flag forces the compiler to produce module + # files with lowercase names. + flags.append('-ef') elif name == 'ldflags': # We need to specify LDFLAGS to get correct dependency_libs # in libnetcdff.la, so packages that use libtool for linking @@ -129,3 +140,28 @@ class NetcdfFortran(AutotoolsPackage): def check(self): with working_dir(self.build_directory): make('check', parallel=False) + + @run_after('install') + def cray_module_filenames(self): + # Cray compiler searches for module files with uppercase names by + # default and with lowercase names when the '-ef' flag is specified. + # To avoid warning messages when compiler user applications in both + # cases, we create copies of all '*.mod' files in the prefix/include + # with names in upper- and lowercase. + if self.spec.compiler.name != 'cce': + return + + with working_dir(self.spec.prefix.include): + for f in glob.glob('*.mod'): + name, ext = os.path.splitext(f) + try: + # Create a copy with uppercase name: + copyfile(f, name.upper() + ext) + except Error: + # Assume that the exception tells us that the file with + # uppercase name already exists. Try to create a file with + # lowercase name then: + try: + copyfile(f, name.lower() + ext) + except Error: + pass -- cgit v1.2.3-60-g2f50