netcdf-fortran: Fix parallel builds (#13612)

netcdf-fortran@4.5: will error if netcdf-c has been built with MPI
support:
```
configure: error:
      -----------------------------------------------------------------------
        The NetCDF C library is built with parallel I/O feature enabled, but
        the Fortran compiler '.../lib/spack/env/gcc/gfortran' supplied in this configure command
        does not support MPI-IO. Please use one that does. If parallel I/O
        feature is not desired, please use a NetCDF C library with parallel
	I/O feature disabled. Abort.
      -----------------------------------------------------------------------
```

Copy logic from netcdf-c to add an `mpi` variant.
This commit is contained in:
Michael Kuhn 2019-11-06 18:14:35 +01:00 committed by Adam J. Stewart
parent 95bc677445
commit 52eba8fb00

View file

@ -20,10 +20,17 @@ class NetcdfFortran(AutotoolsPackage):
version('4.4.4', sha256='b2d395175f8d283e68c8be516e231a96b191ade67ad0caafaf7fa01b1e6b5d75') version('4.4.4', sha256='b2d395175f8d283e68c8be516e231a96b191ade67ad0caafaf7fa01b1e6b5d75')
version('4.4.3', sha256='330373aa163d5931e475b5e83da5c1ad041e855185f24e6a8b85d73b48d6cda9') version('4.4.3', sha256='330373aa163d5931e475b5e83da5c1ad041e855185f24e6a8b85d73b48d6cda9')
variant('mpi', default=True,
description='Enable parallel I/O for netcdf-4')
variant('pic', default=True, variant('pic', default=True,
description='Produce position-independent code (for shared libs)') description='Produce position-independent code (for shared libs)')
depends_on('netcdf-c') # 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', when='~mpi')
depends_on('netcdf-c+mpi', when='+mpi')
# The default libtool.m4 is too old to handle NAG compiler properly: # The default libtool.m4 is too old to handle NAG compiler properly:
# https://github.com/Unidata/netcdf-fortran/issues/94 # https://github.com/Unidata/netcdf-fortran/issues/94
@ -56,3 +63,13 @@ def libs(self):
return find_libraries( return find_libraries(
libraries, root=self.prefix, shared=shared, recursive=True libraries, root=self.prefix, shared=shared, recursive=True
) )
def configure_args(self):
config_args = []
if '+mpi' in self.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)
return config_args