add NetCDF
This commit is contained in:
parent
939c00a972
commit
71cffa67fa
|
@ -257,7 +257,9 @@ libraries that have been compiled for single-threaded use instead.
|
|||
|
||||
## Fortran Coarrays
|
||||
|
||||
As of 0.50.0 Coarrays are a Fortran language intrinsic feature, enabled by
|
||||
*(added 0.50.0)*
|
||||
|
||||
Coarrays are a Fortran language intrinsic feature, enabled by
|
||||
`dependency('coarray')`.
|
||||
|
||||
GCC will use OpenCoarrays if present to implement coarrays, while Intel and NAG
|
||||
|
@ -286,6 +288,9 @@ test('gtest test', e)
|
|||
```
|
||||
|
||||
## HDF5
|
||||
|
||||
*(added 0.50.0)*
|
||||
|
||||
HDF5 is supported for C, C++ and Fortran. Because dependencies are
|
||||
language-specific, you must specify the requested language using the
|
||||
`language` keyword argument, i.e.,
|
||||
|
@ -349,6 +354,20 @@ are not in your path, they can be specified by setting the standard
|
|||
environment variables `MPICC`, `MPICXX`, `MPIFC`, `MPIF90`, or
|
||||
`MPIF77`, during configuration.
|
||||
|
||||
## NetCDF
|
||||
|
||||
*(added 0.50.0)*
|
||||
|
||||
NetCDF is supported for C, C++ and Fortran. Because NetCDF dependencies are
|
||||
language-specific, you must specify the requested language using the
|
||||
`language` keyword argument, i.e.,
|
||||
* `dependency('netcdf', language: 'c')` for the C NetCDF headers and libraries
|
||||
* `dependency('netcdf', language: 'cpp')` for the C++ NetCDF headers and libraries
|
||||
* `dependency('netcdf', language: 'fortran')` for the Fortran NetCDF headers and libraries
|
||||
|
||||
Meson uses pkg-config to find NetCDF.
|
||||
|
||||
|
||||
## OpenMP
|
||||
|
||||
*(added 0.46.0)*
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
## NetCDF
|
||||
|
||||
NetCDF support for C, C++ and Fortran is added via pkg-config.
|
|
@ -18,7 +18,7 @@ from .base import ( # noqa: F401
|
|||
ExternalDependency, NotFoundDependency, ExternalLibrary, ExtraFrameworkDependency, InternalDependency,
|
||||
PkgConfigDependency, CMakeDependency, find_external_dependency, get_dep_identifier, packages, _packages_accept_language)
|
||||
from .dev import GMockDependency, GTestDependency, LLVMDependency, ValgrindDependency
|
||||
from .misc import (CoarrayDependency, HDF5Dependency, MPIDependency, OpenMPDependency, Python3Dependency, ThreadDependency, PcapDependency, CupsDependency, LibWmfDependency, LibGCryptDependency)
|
||||
from .misc import (CoarrayDependency, HDF5Dependency, MPIDependency, NetCDFDependency, OpenMPDependency, Python3Dependency, ThreadDependency, PcapDependency, CupsDependency, LibWmfDependency, LibGCryptDependency)
|
||||
from .platform import AppleFrameworks
|
||||
from .ui import GLDependency, GnuStepDependency, Qt4Dependency, Qt5Dependency, SDL2Dependency, WxDependency, VulkanDependency
|
||||
|
||||
|
@ -35,6 +35,7 @@ packages.update({
|
|||
'coarray': CoarrayDependency,
|
||||
'mpi': MPIDependency,
|
||||
'hdf5': HDF5Dependency,
|
||||
'netcdf': NetCDFDependency,
|
||||
'openmp': OpenMPDependency,
|
||||
'python3': Python3Dependency,
|
||||
'threads': ThreadDependency,
|
||||
|
@ -58,5 +59,6 @@ packages.update({
|
|||
_packages_accept_language.update({
|
||||
'hdf5',
|
||||
'mpi',
|
||||
'netcdf',
|
||||
'openmp',
|
||||
})
|
||||
|
|
|
@ -2286,6 +2286,7 @@ display_name_map = {
|
|||
'hdf5': 'HDF5',
|
||||
'llvm': 'LLVM',
|
||||
'mpi': 'MPI',
|
||||
'netcdf': 'NetCDF',
|
||||
'openmp': 'OpenMP',
|
||||
'wxwidgets': 'WxWidgets',
|
||||
}
|
||||
|
|
|
@ -117,6 +117,35 @@ class HDF5Dependency(ExternalDependency):
|
|||
except Exception:
|
||||
pass
|
||||
|
||||
class NetCDFDependency(ExternalDependency):
|
||||
|
||||
def __init__(self, environment, kwargs):
|
||||
language = kwargs.get('language', 'c')
|
||||
super().__init__('netcdf', environment, language, kwargs)
|
||||
kwargs['required'] = False
|
||||
kwargs['silent'] = True
|
||||
self.is_found = False
|
||||
|
||||
pkgconfig_files = ['netcdf']
|
||||
|
||||
if language not in ('c', 'cpp', 'fortran'):
|
||||
raise DependencyException('Language {} is not supported with NetCDF.'.format(language))
|
||||
|
||||
if language == 'fortran':
|
||||
pkgconfig_files.append('netcdf-fortran')
|
||||
|
||||
self.compile_args = []
|
||||
self.link_args = []
|
||||
self.pcdep = []
|
||||
for pkg in pkgconfig_files:
|
||||
pkgdep = PkgConfigDependency(pkg, environment, kwargs, language=self.language)
|
||||
if pkgdep.found():
|
||||
self.compile_args.extend(pkgdep.get_compile_args())
|
||||
self.link_args.extend(pkgdep.get_link_args())
|
||||
self.version = pkgdep.get_version()
|
||||
self.is_found = True
|
||||
self.pcdep.append(pkgdep)
|
||||
|
||||
class MPIDependency(ExternalDependency):
|
||||
|
||||
def __init__(self, environment, kwargs):
|
||||
|
|
|
@ -498,6 +498,10 @@ def skippable(suite, test):
|
|||
if test.endswith('10 gtk-doc'):
|
||||
return True
|
||||
|
||||
# NetCDF is not in the CI image
|
||||
if test.endswith('netcdf'):
|
||||
return True
|
||||
|
||||
# No frameworks test should be skipped on linux CI, as we expect all
|
||||
# prerequisites to be installed
|
||||
if mesonlib.is_linux():
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
#include "netcdf.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int ret, ncid;
|
||||
|
||||
if ((ret = nc_create("foo.nc", NC_CLOBBER, &ncid)))
|
||||
return ret;
|
||||
|
||||
if ((ret = nc_close(ncid)))
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
#include <iostream>
|
||||
#include "netcdf.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int ret, ncid;
|
||||
|
||||
if ((ret = nc_create("foo.nc", NC_CLOBBER, &ncid)))
|
||||
return ret;
|
||||
|
||||
if ((ret = nc_close(ncid)))
|
||||
return ret;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
use netcdf
|
||||
|
||||
implicit none
|
||||
|
||||
integer :: ncid
|
||||
|
||||
call check( nf90_create("foo.nc", NF90_CLOBBER, ncid) )
|
||||
|
||||
call check( nf90_close(ncid) )
|
||||
|
||||
contains
|
||||
|
||||
subroutine check(status)
|
||||
integer, intent (in) :: status
|
||||
|
||||
if(status /= nf90_noerr) error stop trim(nf90_strerror(status))
|
||||
end subroutine check
|
||||
|
||||
end program
|
|
@ -0,0 +1,35 @@
|
|||
project('netcdf_test', 'c', 'cpp')
|
||||
|
||||
|
||||
# --- C tests
|
||||
nc_c = dependency('netcdf', language : 'c', required : false)
|
||||
if not nc_c.found()
|
||||
error('MESON_SKIP_TEST: NetCDF C library not found, skipping NetCDF framework tests.')
|
||||
endif
|
||||
exec = executable('exec', 'main.c', dependencies : nc_c)
|
||||
|
||||
test('NetCDF C', exec)
|
||||
|
||||
# --- C++ tests
|
||||
nc_cpp = dependency('netcdf', language : 'cpp', required : false)
|
||||
if nc_cpp.found()
|
||||
execpp = executable('execpp', 'main.cpp', dependencies : nc_cpp)
|
||||
test('NetCDF C++', execpp)
|
||||
endif
|
||||
|
||||
# --- Fortran tests
|
||||
if build_machine.system() != 'windows'
|
||||
add_languages('fortran')
|
||||
|
||||
nc_f = dependency('netcdf', language : 'fortran', required : false)
|
||||
if nc_f.found()
|
||||
exef = executable('exef', 'main.f90', dependencies : nc_f)
|
||||
|
||||
test('NetCDF Fortran', exef)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Check we can apply a version constraint
|
||||
if nc_c.version() != 'unknown'
|
||||
dependency('netcdf', version: '>=@0@'.format(nc_c.version()))
|
||||
endif
|
Loading…
Reference in New Issue