netcdf-fortran: support for Cray compiler (#18971)

This commit is contained in:
Sergey Kosukhin 2020-10-19 23:12:09 +02:00 committed by GitHub
parent c31e96dcd7
commit 75bfdc7335
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,9 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT) # SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import * from spack import *
import os
import glob
from shutil import copyfile, Error
class NetcdfFortran(AutotoolsPackage): class NetcdfFortran(AutotoolsPackage):
@ -69,6 +72,14 @@ def flag_handler(self, name, flags):
if self.spec.satisfies('%gcc@10:'): if self.spec.satisfies('%gcc@10:'):
# https://github.com/Unidata/netcdf-fortran/issues/212 # https://github.com/Unidata/netcdf-fortran/issues/212
flags.append('-fallow-argument-mismatch') 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': elif name == 'ldflags':
# We need to specify LDFLAGS to get correct dependency_libs # We need to specify LDFLAGS to get correct dependency_libs
# in libnetcdff.la, so packages that use libtool for linking # in libnetcdff.la, so packages that use libtool for linking
@ -129,3 +140,28 @@ def configure_args(self):
def check(self): def check(self):
with working_dir(self.build_directory): with working_dir(self.build_directory):
make('check', parallel=False) 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