2019-12-31 14:36:56 +08:00
|
|
|
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
|
2018-10-08 04:52:23 +08:00
|
|
|
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
2016-05-12 12:22:25 +08:00
|
|
|
#
|
2018-10-08 04:52:23 +08:00
|
|
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
|
|
|
|
2016-03-01 11:59:28 +08:00
|
|
|
from spack import *
|
|
|
|
|
2016-06-22 22:52:17 +08:00
|
|
|
|
2017-01-08 10:07:00 +08:00
|
|
|
class NetcdfFortran(AutotoolsPackage):
|
2019-10-29 09:27:54 +08:00
|
|
|
"""NetCDF (network Common Data Form) is a set of software libraries and
|
|
|
|
machine-independent data formats that support the creation, access, and
|
|
|
|
sharing of array-oriented scientific data. This is the Fortran
|
|
|
|
distribution."""
|
2016-03-01 11:59:28 +08:00
|
|
|
|
2019-10-25 04:21:13 +08:00
|
|
|
homepage = "https://www.unidata.ucar.edu/software/netcdf"
|
|
|
|
url = "https://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-fortran-4.5.2.tar.gz"
|
2016-03-01 11:59:28 +08:00
|
|
|
|
2019-10-25 04:21:13 +08:00
|
|
|
version('4.5.2', sha256='b959937d7d9045184e9d2040a915d94a7f4d0185f4a9dceb8f08c94b0c3304aa')
|
2019-10-11 13:44:41 +08:00
|
|
|
version('4.4.5', sha256='2467536ce29daea348c736476aa8e684c075d2f6cab12f3361885cb6905717b8')
|
|
|
|
version('4.4.4', sha256='b2d395175f8d283e68c8be516e231a96b191ade67ad0caafaf7fa01b1e6b5d75')
|
|
|
|
version('4.4.3', sha256='330373aa163d5931e475b5e83da5c1ad041e855185f24e6a8b85d73b48d6cda9')
|
2016-03-01 11:59:28 +08:00
|
|
|
|
2019-11-07 01:14:35 +08:00
|
|
|
variant('mpi', default=True,
|
|
|
|
description='Enable parallel I/O for netcdf-4')
|
2018-11-13 13:54:11 +08:00
|
|
|
variant('pic', default=True,
|
|
|
|
description='Produce position-independent code (for shared libs)')
|
|
|
|
|
2019-11-07 01:14:35 +08:00
|
|
|
# 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')
|
2017-04-07 17:18:34 +08:00
|
|
|
|
2018-08-02 21:32:20 +08:00
|
|
|
# The default libtool.m4 is too old to handle NAG compiler properly:
|
|
|
|
# https://github.com/Unidata/netcdf-fortran/issues/94
|
|
|
|
patch('nag.patch', when='@:4.4.4%nag')
|
|
|
|
|
2020-01-29 05:13:51 +08:00
|
|
|
# Parallel builds do not work in the fortran directory. This patch is
|
|
|
|
# derived from https://github.com/Unidata/netcdf-fortran/pull/211
|
|
|
|
patch('no_parallel_build.patch', when='@4.5.2')
|
|
|
|
|
2018-11-13 13:54:11 +08:00
|
|
|
def flag_handler(self, name, flags):
|
|
|
|
if name in ['cflags', 'fflags'] and '+pic' in self.spec:
|
|
|
|
flags.append(self.compiler.pic_flag)
|
|
|
|
elif name == 'cppflags':
|
2019-10-29 09:27:54 +08:00
|
|
|
flags.append(self.spec['netcdf-c'].headers.cpp_flags)
|
2018-11-14 23:40:16 +08:00
|
|
|
elif name == 'ldflags':
|
|
|
|
# We need to specify LDFLAGS to get correct dependency_libs
|
|
|
|
# in libnetcdff.la, so packages that use libtool for linking
|
|
|
|
# could correctly link to all the dependencies even when the
|
|
|
|
# building takes place outside of Spack environment, i.e.
|
|
|
|
# without Spack's compiler wrappers.
|
2019-10-29 09:27:54 +08:00
|
|
|
flags.append(self.spec['netcdf-c'].libs.search_flags)
|
2018-11-14 23:40:16 +08:00
|
|
|
|
|
|
|
return None, None, flags
|
2018-05-22 05:23:35 +08:00
|
|
|
|
2017-04-07 17:18:34 +08:00
|
|
|
@property
|
|
|
|
def libs(self):
|
|
|
|
libraries = ['libnetcdff']
|
|
|
|
|
|
|
|
# This package installs both shared and static libraries. Permit
|
|
|
|
# clients to query which one they want.
|
|
|
|
query_parameters = self.spec.last_query.extra_parameters
|
|
|
|
shared = 'shared' in query_parameters
|
|
|
|
|
|
|
|
return find_libraries(
|
2017-08-03 23:21:40 +08:00
|
|
|
libraries, root=self.prefix, shared=shared, recursive=True
|
2017-04-07 17:18:34 +08:00
|
|
|
)
|
2019-11-07 01:14:35 +08:00
|
|
|
|
|
|
|
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
|