NetCDF: fix constraints. (#16719)

This commit is contained in:
Sergey Kosukhin 2020-08-22 23:06:17 +02:00 committed by GitHub
parent dc5176fbae
commit 9fdb945383
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 40 deletions

View file

@ -97,26 +97,15 @@ def url_for_version(self, version):
# High-level API of HDF5 1.8.9 or later is required for netCDF-4 support:
# http://www.unidata.ucar.edu/software/netcdf/docs/getting_and_building_netcdf.html
depends_on('hdf5@1.8.9:+hl~mpi', when='~mpi')
depends_on('hdf5@1.8.9:+hl+mpi', when='+mpi')
depends_on('hdf5@1.8.9:+hl')
# Starting version 4.4.0, it became possible to disable parallel I/O even
# if HDF5 supports it. For previous versions of the library we need
# HDF5 without mpi support to disable parallel I/O.
# The following doesn't work if hdf5+mpi by default and netcdf-c~mpi is
# specified in packages.yaml
# depends_on('hdf5~mpi', when='@:4.3~mpi')
# Thus, we have to introduce a conflict
conflicts('~mpi', when='@:4.3^hdf5+mpi',
msg='netcdf-c@:4.3~mpi requires hdf5~mpi')
# HDF5 without mpi support to disable parallel I/O:
depends_on('hdf5~mpi', when='@:4.3~mpi')
# We need HDF5 with mpi support to enable parallel I/O.
# The following doesn't work if hdf5~mpi by default and netcdf-c+mpi is
# specified in packages.yaml
# depends_on('hdf5+mpi', when='+mpi')
# Thus, we have to introduce a conflict
conflicts('+mpi', when='^hdf5~mpi',
msg='netcdf-c+mpi requires hdf5+mpi')
depends_on('hdf5+mpi', when='+mpi')
# NetCDF 4.4.0 and prior have compatibility issues with HDF5 1.10 and later
# https://github.com/Unidata/netcdf-c/issues/250

View file

@ -22,19 +22,12 @@ class NetcdfFortran(AutotoolsPackage):
version('4.4.4', sha256='b2d395175f8d283e68c8be516e231a96b191ade67ad0caafaf7fa01b1e6b5d75')
version('4.4.3', sha256='330373aa163d5931e475b5e83da5c1ad041e855185f24e6a8b85d73b48d6cda9')
variant('mpi', default=True,
description='Enable parallel I/O for netcdf-4')
variant('pic', default=True,
description='Produce position-independent code (for shared libs)')
variant('shared', default=True, description='Enable shared library')
variant('doc', default=False, description='Enable building docs')
# We need to build with MPI wrappers if parallel I/O features is enabled:
# https://www.unidata.ucar.edu/software/netcdf/docs/building_netcdf_fortran.html
depends_on('mpi', when='+mpi')
depends_on('netcdf-c~mpi~parallel-netcdf', when='~mpi')
depends_on('netcdf-c+mpi', when='+mpi')
depends_on('netcdf-c')
depends_on('doxygen', when='+doc', type='build')
# The default libtool.m4 is too old to handle NAG compiler properly:
@ -66,17 +59,15 @@ class NetcdfFortran(AutotoolsPackage):
def flag_handler(self, name, flags):
config_flags = None
if '+pic' in self.spec:
# Unlike NetCDF-C, we add PIC flag only when +pic. Adding the
# flags also when ~shared would make it impossible to build a
# static-only version of the library with NAG.
if name == 'cflags':
config_flags = [self.compiler.cc_pic_flag]
elif name == 'fflags':
config_flags = [self.compiler.f77_pic_flag]
if name == 'cppflags':
config_flags = [self.spec['netcdf-c'].headers.cpp_flags]
if name == 'cflags':
if '+pic' in self.spec:
flags.append(self.compiler.cc_pic_flag)
elif name == 'fflags':
if '+pic' in self.spec:
flags.append(self.compiler.f77_pic_flag)
if self.spec.satisfies('%gcc@10:'):
# https://github.com/Unidata/netcdf-fortran/issues/212
flags.append('-fallow-argument-mismatch')
elif name == 'ldflags':
# We need to specify LDFLAGS to get correct dependency_libs
# in libnetcdff.la, so packages that use libtool for linking
@ -84,11 +75,6 @@ def flag_handler(self, name, flags):
# building takes place outside of Spack environment, i.e.
# without Spack's compiler wrappers.
config_flags = [self.spec['netcdf-c'].libs.search_flags]
elif name == 'fflags' and self.spec.satisfies('%gcc@10:'):
# https://github.com/Unidata/netcdf-fortran/issues/212
if config_flags is None:
config_flags = []
config_flags.append('-fallow-argument-mismatch')
return flags, None, config_flags
@ -122,7 +108,11 @@ def configure_args(self):
config_args = self.enable_or_disable('shared')
config_args.append('--enable-static')
if '+mpi' in self.spec:
# We need to build with MPI wrappers if either of the parallel I/O
# features is enabled in netcdf-c:
# https://www.unidata.ucar.edu/software/netcdf/docs/building_netcdf_fortran.html
netcdf_c_spec = self.spec['netcdf-c']
if '+mpi' in netcdf_c_spec or '+parallel-netcdf' in netcdf_c_spec:
config_args.append('CC=%s' % self.spec['mpi'].mpicc)
config_args.append('FC=%s' % self.spec['mpi'].mpifc)
config_args.append('F77=%s' % self.spec['mpi'].mpif77)