Skip to content

Commit dd744a3

Browse files
author
Jeff Whitaker
authored
Merge pull request #1210 from Unidata/issue1209
fix for issue #1209
2 parents 55d19c1 + c5b630a commit dd744a3

File tree

8 files changed

+162
-42
lines changed

8 files changed

+162
-42
lines changed

.github/workflows/build.yml renamed to .github/workflows/build_latest.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Test Linux
1+
name: Build and Test Linux with latest netcdf-c
22
on: [push, pull_request]
33
jobs:
44
build-linux:
@@ -13,7 +13,7 @@ jobs:
1313
#NO_NET: 1
1414
strategy:
1515
matrix:
16-
python-version: ["3.9"]
16+
python-version: ["3.10"]
1717
steps:
1818

1919
- uses: actions/checkout@v2
@@ -36,7 +36,7 @@ jobs:
3636
make install
3737
popd
3838
echo "Download and build netCDF version ${NETCDF_VERSION}"
39-
wget https://downloads.unidata.ucar.edu/netcdf-c/4.9.0/netcdf-c-${NETCDF_VERSION}.tar.gz
39+
wget https://downloads.unidata.ucar.edu/netcdf-c/${NETCDF_VERSION}/netcdf-c-${NETCDF_VERSION}.tar.gz
4040
tar -xzf netcdf-c-${NETCDF_VERSION}.tar.gz
4141
pushd netcdf-c-${NETCDF_VERSION}
4242
export CPPFLAGS="-I/usr/include/hdf5/mpich -I${NETCDF_DIR}/include"
@@ -94,11 +94,11 @@ jobs:
9494
echo "pnetcdf mpi test passed!"
9595
fi
9696
97-
- name: Tarball
98-
run: |
99-
export PATH=${NETCDF_DIR}/bin:${PATH}
100-
python setup.py --version
101-
check-manifest --version
102-
check-manifest --verbose
103-
pip wheel . -w dist --no-deps
104-
twine check dist/*
97+
# - name: Tarball
98+
# run: |
99+
# export PATH=${NETCDF_DIR}/bin:${PATH}
100+
# python setup.py --version
101+
# check-manifest --version
102+
# check-manifest --verbose
103+
# pip wheel . -w dist --no-deps
104+
# twine check dist/*

.github/workflows/build_master.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
#NO_NET: 1
1111
strategy:
1212
matrix:
13-
python-version: ["3.9"]
13+
python-version: ["3.10"]
1414
steps:
1515

1616
- uses: actions/checkout@v2

.github/workflows/build_old.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Build and Test Linux with older netcdf-c
2+
on: [push, pull_request]
3+
jobs:
4+
build-linux:
5+
name: Python (${{ matrix.python-version }})
6+
runs-on: ubuntu-latest
7+
env:
8+
PNETCDF_VERSION: 1.12.1
9+
NETCDF_VERSION: 4.8.1
10+
NETCDF_DIR: ${{ github.workspace }}/..
11+
NETCDF_EXTRA_CONFIG: --enable-pnetcdf
12+
CC: mpicc.mpich
13+
#NO_NET: 1
14+
strategy:
15+
matrix:
16+
python-version: ["3.10"]
17+
steps:
18+
19+
- uses: actions/checkout@v2
20+
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Install Ubuntu Dependencies
27+
run: |
28+
sudo apt-get update
29+
sudo apt-get install mpich libmpich-dev libhdf5-mpich-dev libcurl4-openssl-dev bzip2 libsnappy-dev libblosc-dev libzstd-dev
30+
echo "Download and build PnetCDF version ${PNETCDF_VERSION}"
31+
wget https://parallel-netcdf.github.io/Release/pnetcdf-${PNETCDF_VERSION}.tar.gz
32+
tar -xzf pnetcdf-${PNETCDF_VERSION}.tar.gz
33+
pushd pnetcdf-${PNETCDF_VERSION}
34+
./configure --prefix $NETCDF_DIR --enable-shared --disable-fortran --disable-cxx
35+
make -j 2
36+
make install
37+
popd
38+
echo "Download and build netCDF version ${NETCDF_VERSION}"
39+
wget https://downloads.unidata.ucar.edu/netcdf-c/${NETCDF_VERSION}/netcdf-c-${NETCDF_VERSION}.tar.gz
40+
tar -xzf netcdf-c-${NETCDF_VERSION}.tar.gz
41+
pushd netcdf-c-${NETCDF_VERSION}
42+
export CPPFLAGS="-I/usr/include/hdf5/mpich -I${NETCDF_DIR}/include"
43+
export LDFLAGS="-L${NETCDF_DIR}/lib"
44+
export LIBS="-lhdf5_mpich_hl -lhdf5_mpich -lm -lz"
45+
./configure --prefix $NETCDF_DIR --enable-netcdf-4 --enable-shared --enable-dap --enable-parallel4 $NETCDF_EXTRA_CONFIG
46+
make -j 2
47+
make install
48+
popd
49+
50+
# - name: The job has failed
51+
# if: ${{ failure() }}
52+
# run: |
53+
# cd netcdf-c-${NETCDF_VERSION}
54+
# cat config.log
55+
56+
- name: Install python dependencies via pip
57+
run: |
58+
python -m pip install --upgrade pip
59+
pip install numpy cython cftime pytest twine wheel check-manifest mpi4py
60+
61+
- name: Install netcdf4-python
62+
run: |
63+
export PATH=${NETCDF_DIR}/bin:${PATH}
64+
export NETCDF_PLUGIN_DIR=${{ github.workspace }}/netcdf-c-${NETCDF_VERSION}/plugins/plugindir
65+
python setup.py install
66+
- name: Test
67+
run: |
68+
export PATH=${NETCDF_DIR}/bin:${PATH}
69+
python checkversion.py
70+
# serial
71+
cd test
72+
python run_all.py
73+
# parallel (hdf5 for netcdf4, pnetcdf for netcdf3)
74+
cd ../examples
75+
mpirun.mpich -np 4 python mpi_example.py
76+
if [ $? -ne 0 ] ; then
77+
echo "hdf5 mpi test failed!"
78+
exit 1
79+
else
80+
echo "hdf5 mpi test passed!"
81+
fi
82+
mpirun.mpich -np 4 python mpi_example_compressed.py
83+
if [ $? -ne 0 ] ; then
84+
echo "hdf5 compressed mpi test failed!"
85+
exit 1
86+
else
87+
echo "hdf5 compressed mpi test passed!"
88+
fi
89+
mpirun.mpich -np 4 python mpi_example.py NETCDF3_64BIT_DATA
90+
if [ $? -ne 0 ] ; then
91+
echo "pnetcdf mpi test failed!"
92+
exit 1
93+
else
94+
echo "pnetcdf mpi test passed!"
95+
fi
96+
97+
# - name: Tarball
98+
# run: |
99+
# export PATH=${NETCDF_DIR}/bin:${PATH}
100+
# python setup.py --version
101+
# check-manifest --version
102+
# check-manifest --verbose
103+
# pip wheel . -w dist --no-deps
104+
# twine check dist/*

.github/workflows/miniconda.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
# NO_NET: 1
1313
strategy:
1414
matrix:
15-
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10" ]
15+
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ]
1616
os: [windows-latest, ubuntu-latest, macos-latest]
1717
platform: [x64, x32]
1818
exclude:
@@ -34,7 +34,7 @@ jobs:
3434
micromamba create --name TEST python=${{ matrix.python-version }} numpy cython pip pytest hdf5 libnetcdf cftime zlib --channel conda-forge
3535
micromamba activate TEST
3636
export PATH="${CONDA_PREFIX}/bin:${CONDA_PREFIX}/Library/bin:$PATH" # so setup.py finds nc-config
37-
pip install -e . --no-deps --force-reinstall
37+
pip install -v -e . --no-deps --force-reinstall
3838
3939
- name: Debug conda
4040
shell: bash -l {0}
@@ -53,7 +53,7 @@ jobs:
5353
runs-on: ${{ matrix.os }}
5454
strategy:
5555
matrix:
56-
python-version: [ "3.9" ]
56+
python-version: [ "3.10" ]
5757
os: [ubuntu-latest]
5858
platform: [x64]
5959
steps:
@@ -70,7 +70,8 @@ jobs:
7070
micromamba create --name TEST python=${{ matrix.python-version }} numpy cython pip pytest mpi4py hdf5=*=mpi* libnetcdf=*=mpi* cftime zlib --channel conda-forge
7171
micromamba activate TEST
7272
export PATH="${CONDA_PREFIX}/bin:${CONDA_PREFIX}/Library/bin:$PATH" # so setup.py finds nc-config
73-
pip install -e . --no-deps --force-reinstall
73+
nc-config --all
74+
pip install -v -e . --no-build-isolation --no-deps --force-reinstall
7475
7576
- name: Debug conda
7677
shell: bash -l {0}
@@ -88,8 +89,8 @@ jobs:
8889
export PATH="${CONDA_PREFIX}/bin:${CONDA_PREFIX}/Library/bin:$PATH"
8990
which mpirun
9091
mpirun --version
91-
#mpirun -np 4 --oversubscribe python mpi_example.py # for openmpi
92-
mpirun -np 4 python mpi_example.py
92+
mpirun -np 4 --oversubscribe python mpi_example.py # for openmpi
93+
#mpirun -np 4 python mpi_example.py
9394
if [ $? -ne 0 ] ; then
9495
echo "hdf5 mpi test failed!"
9596
exit 1

Changelog

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
version 1.6.2 (Unrelease)
2-
==========================
1+
version 1.6.2 (not yet released)
2+
==============================
33
* Added ``netCDF4.__has_set_alignment__`` property to help identify if the
44
underlying netcdf4 supports setting the HDF5 alignment.
55
* Slicing multi-dimensional variables with an all False boolean index array
66
now returns an empty numpy array (instead of raising an exception - issue #1197).
77
Behavior now consistent with numpy slicing.
8+
* fix problem with compiling using netcdf-c < 4.9.0 (issue #1209)
89

910
version 1.6.1 (tag v1.6.1rel)
1011
==============================

include/netCDF4.pxi

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,6 @@ cdef extern from "netcdf.h":
367367

368368
int nc_inq_enum_ident(int ncid, nc_type xtype, long long value, char *identifier) nogil
369369

370-
371370
IF HAS_QUANTIZATION_SUPPORT:
372371
cdef extern from "netcdf.h":
373372
cdef enum:
@@ -377,6 +376,8 @@ IF HAS_QUANTIZATION_SUPPORT:
377376
NC_QUANTIZE_BITROUND
378377
int nc_def_var_quantize(int ncid, int varid, int quantize_mode, int nsd) nogil
379378
int nc_inq_var_quantize(int ncid, int varid, int *quantize_modep, int *nsdp) nogil
379+
380+
IF HAS_NCFILTER:
380381
cdef extern from "netcdf_filter.h":
381382
int nc_inq_filter_avail(int ncid, unsigned filterid) nogil
382383

@@ -388,32 +389,27 @@ IF HAS_SZIP_SUPPORT:
388389
int nc_inq_var_quantize(int ncid, int varid, int *quantize_modep, int *nsdp) nogil
389390
int nc_def_var_szip(int ncid, int varid, int options_mask, int pixels_per_bloc) nogil
390391
int nc_inq_var_szip(int ncid, int varid, int *options_maskp, int *pixels_per_blockp) nogil
391-
cdef extern from "netcdf_filter.h":
392-
int nc_inq_filter_avail(int ncid, unsigned filterid) nogil
393392

394393
IF HAS_ZSTANDARD_SUPPORT:
395394
cdef extern from "netcdf_filter.h":
396395
cdef enum:
397396
H5Z_FILTER_ZSTD
398397
int nc_def_var_zstandard(int ncid, int varid, int level) nogil
399398
int nc_inq_var_zstandard(int ncid, int varid, int* hasfilterp, int *levelp) nogil
400-
int nc_inq_filter_avail(int ncid, unsigned id) nogil
401399

402400
IF HAS_BZIP2_SUPPORT:
403401
cdef extern from "netcdf_filter.h":
404402
cdef enum:
405403
H5Z_FILTER_BZIP2
406404
int nc_def_var_bzip2(int ncid, int varid, int level) nogil
407405
int nc_inq_var_bzip2(int ncid, int varid, int* hasfilterp, int *levelp) nogil
408-
int nc_inq_filter_avail(int ncid, unsigned filterid) nogil
409406

410407
IF HAS_BLOSC_SUPPORT:
411408
cdef extern from "netcdf_filter.h":
412409
cdef enum:
413410
H5Z_FILTER_BLOSC
414411
int nc_def_var_blosc(int ncid, int varid, unsigned subcompressor, unsigned level, unsigned blocksize, unsigned addshuffle) nogil
415412
int nc_inq_var_blosc(int ncid, int varid, int* hasfilterp, unsigned* subcompressorp, unsigned* levelp, unsigned* blocksizep, unsigned* addshufflep) nogil
416-
int nc_inq_filter_avail(int ncid, unsigned filterid) nogil
417413

418414
IF HAS_NC_OPEN_MEM:
419415
cdef extern from "netcdf_mem.h":

setup.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def check_api(inc_dirs,netcdf_lib_version):
7070
has_zstandard = False
7171
has_bzip2 = False
7272
has_blosc = False
73+
has_ncfilter = False
7374
has_set_alignment = False
7475

7576
for d in inc_dirs:
@@ -116,6 +117,8 @@ def check_api(inc_dirs,netcdf_lib_version):
116117
has_bzip2 = True
117118
if line.startswith('EXTERNL int nc_def_var_blosc'):
118119
has_blosc = True
120+
if line.startswith('EXTERNL int nc_inq_filter_avail'):
121+
has_ncfilter = True
119122

120123
ncmetapath = os.path.join(d,'netcdf_meta.h')
121124
if os.path.exists(ncmetapath):
@@ -143,7 +146,7 @@ def check_api(inc_dirs,netcdf_lib_version):
143146
return has_rename_grp, has_nc_inq_path, has_nc_inq_format_extended, \
144147
has_cdf5_format, has_nc_open_mem, has_nc_create_mem, \
145148
has_parallel4_support, has_pnetcdf_support, has_szip_support, has_quantize, \
146-
has_zstandard, has_bzip2, has_blosc, has_set_alignment
149+
has_zstandard, has_bzip2, has_blosc, has_set_alignment, has_ncfilter
147150

148151

149152
def getnetcdfvers(libdirs):
@@ -557,19 +560,20 @@ def _populate_hdf5_info(dirstosearch, inc_dirs, libs, lib_dirs):
557560
has_rename_grp, has_nc_inq_path, has_nc_inq_format_extended, \
558561
has_cdf5_format, has_nc_open_mem, has_nc_create_mem, \
559562
has_parallel4_support, has_pnetcdf_support, has_szip_support, has_quantize, \
560-
has_zstandard, has_bzip2, has_blosc, has_set_alignment = \
563+
has_zstandard, has_bzip2, has_blosc, has_set_alignment, has_ncfilter = \
561564
check_api(inc_dirs,netcdf_lib_version)
562565
# for netcdf 4.4.x CDF5 format is always enabled.
563566
if netcdf_lib_version is not None and\
564567
(netcdf_lib_version > "4.4" and netcdf_lib_version < "4.5"):
565568
has_cdf5_format = True
566569

567570
# disable parallel support if mpi4py not available.
568-
try:
569-
import mpi4py
570-
except ImportError:
571-
has_parallel4_support = False
572-
has_pnetcdf_support = False
571+
#try:
572+
# import mpi4py
573+
#except ImportError:
574+
# f.write('disabling mpi parallel support because mpi4py not found\n')
575+
# has_parallel4_support = False
576+
# has_pnetcdf_support = False
573577

574578
f = open(osp.join('include', 'constants.pyx'), 'w')
575579
if has_rename_grp:
@@ -671,9 +675,17 @@ def _populate_hdf5_info(dirstosearch, inc_dirs, libs, lib_dirs):
671675
sys.stdout.write('netcdf lib does not have nc_set_alignment function\n')
672676
f.write('DEF HAS_SET_ALIGNMENT = 0\n')
673677

678+
if has_ncfilter:
679+
sys.stdout.write('netcdf lib has nc_inq_filter_avail function\n')
680+
f.write('DEF HAS_NCFILTER = 1\n')
681+
else:
682+
sys.stdout.write('netcdf lib does not have nc_inq_filter_avail function\n')
683+
f.write('DEF HAS_NCFILTER = 0\n')
684+
674685
f.close()
675686

676687
if has_parallel4_support or has_pnetcdf_support:
688+
import mpi4py
677689
inc_dirs.append(mpi4py.get_include())
678690
# mpi_incdir should not be needed if using nc-config
679691
# (should be included in nc-config --cflags)

src/netCDF4/_netCDF4.pyx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Version 1.6.1
2+
Version 1.6.2
33
-------------
44
55
# Introduction
@@ -1230,7 +1230,7 @@ if sys.version_info[0:2] < (3, 7):
12301230
# Python 3.7+ guarantees order; older versions need OrderedDict
12311231
from collections import OrderedDict
12321232

1233-
__version__ = "1.6.1"
1233+
__version__ = "1.6.2"
12341234

12351235
# Initialize numpy
12361236
import posixpath
@@ -3543,15 +3543,21 @@ returns True if bzip2 compression filter is available"""
35433543
**`has_szip_filter(self)`**
35443544
returns True if szip compression filter is available"""
35453545
cdef int ierr
3546-
IF HAS_SZIP_SUPPORT:
3547-
with nogil:
3548-
ierr = nc_inq_filter_avail(self._grpid, H5Z_FILTER_SZIP)
3549-
if ierr:
3546+
IF HAS_NCFILTER:
3547+
IF HAS_SZIP_SUPPORT:
3548+
with nogil:
3549+
ierr = nc_inq_filter_avail(self._grpid, H5Z_FILTER_SZIP)
3550+
if ierr:
3551+
return False
3552+
else:
3553+
return True
3554+
ELSE:
35503555
return False
3551-
else:
3552-
return True
35533556
ELSE:
3554-
return False
3557+
IF HAS_SZIP_SUPPORT:
3558+
return True
3559+
ELSE:
3560+
return False
35553561

35563562
cdef class Group(Dataset):
35573563
"""

0 commit comments

Comments
 (0)