Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for issue #1209 #1210

Merged
merged 42 commits into from Nov 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
8ad370a
fix for issue #1209
jswhit Nov 12, 2022
b67c0f7
update
jswhit Nov 12, 2022
b088979
add new test with older netcdf-c (4.7.4)
jswhit Nov 12, 2022
9ade9ad
fix typo
jswhit Nov 12, 2022
6db3ce7
fix formatting
jswhit Nov 12, 2022
21f49f5
remove whitespace
jswhit Nov 12, 2022
c6fee37
fix download url
jswhit Nov 12, 2022
87667e8
add 'oversubscribe' option to mpirun
jswhit Nov 12, 2022
e544923
bump version number
jswhit Nov 12, 2022
1edc331
add -v to pip install
jswhit Nov 12, 2022
6176b3b
try again to get verbose pip output
jswhit Nov 12, 2022
3a9cd06
try again
jswhit Nov 12, 2022
df65aa2
get nc-config output
jswhit Nov 12, 2022
a751198
add debug print to diagnose mpi failure
jswhit Nov 12, 2022
8389895
add more debug prints
jswhit Nov 12, 2022
6ad7e43
update
jswhit Nov 12, 2022
7cd8ee8
fix typo
jswhit Nov 12, 2022
baa3d3b
check mpi4py import
jswhit Nov 12, 2022
db5c635
don't try to import mpi4py
jswhit Nov 12, 2022
54fa91c
add --no-build-isolation to run-mpi test, since mpi4py not in
jswhit Nov 12, 2022
1cbac5a
update
jswhit Nov 12, 2022
d99ad14
try moving pyproject.toml out of the way for mpi build
jswhit Nov 12, 2022
02f3c10
update
jswhit Nov 12, 2022
3aa712b
new file
jswhit Nov 12, 2022
d2a518b
try again with pyproject.toml that includes mpi4py
jswhit Nov 12, 2022
ba28488
revert previous change
jswhit Nov 12, 2022
f637321
update
jswhit Nov 12, 2022
eacd6e6
add mpi4py import
jswhit Nov 12, 2022
171bf16
try --no-build-isolation again
jswhit Nov 12, 2022
e64e36a
update
jswhit Nov 12, 2022
7e72caa
update
jswhit Nov 12, 2022
4235343
add --no-build-isolation to Tarball
jswhit Nov 12, 2022
8160a9a
catch mpi4py ImportError
jswhit Nov 12, 2022
13f4a5b
update
jswhit Nov 12, 2022
34cc9b9
disable tarball step
jswhit Nov 12, 2022
d4001e5
update
jswhit Nov 12, 2022
82f4acb
test setting MPI4PY_INCLUDE in environment
jswhit Nov 13, 2022
8540310
add debug prints
jswhit Nov 13, 2022
fb9cdc7
try again
jswhit Nov 13, 2022
6cba9d2
update
jswhit Nov 13, 2022
e0fed04
try again
jswhit Nov 13, 2022
c5b630a
revert
jswhit Nov 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 11 additions & 11 deletions .github/workflows/build.yml → .github/workflows/build_latest.yml
@@ -1,4 +1,4 @@
name: Build and Test Linux
name: Build and Test Linux with latest netcdf-c
on: [push, pull_request]
jobs:
build-linux:
Expand All @@ -13,7 +13,7 @@ jobs:
#NO_NET: 1
strategy:
matrix:
python-version: ["3.9"]
python-version: ["3.10"]
steps:

- uses: actions/checkout@v2
Expand All @@ -36,7 +36,7 @@ jobs:
make install
popd
echo "Download and build netCDF version ${NETCDF_VERSION}"
wget https://downloads.unidata.ucar.edu/netcdf-c/4.9.0/netcdf-c-${NETCDF_VERSION}.tar.gz
wget https://downloads.unidata.ucar.edu/netcdf-c/${NETCDF_VERSION}/netcdf-c-${NETCDF_VERSION}.tar.gz
tar -xzf netcdf-c-${NETCDF_VERSION}.tar.gz
pushd netcdf-c-${NETCDF_VERSION}
export CPPFLAGS="-I/usr/include/hdf5/mpich -I${NETCDF_DIR}/include"
Expand Down Expand Up @@ -94,11 +94,11 @@ jobs:
echo "pnetcdf mpi test passed!"
fi

- name: Tarball
run: |
export PATH=${NETCDF_DIR}/bin:${PATH}
python setup.py --version
check-manifest --version
check-manifest --verbose
pip wheel . -w dist --no-deps
twine check dist/*
# - name: Tarball
# run: |
# export PATH=${NETCDF_DIR}/bin:${PATH}
# python setup.py --version
# check-manifest --version
# check-manifest --verbose
# pip wheel . -w dist --no-deps
# twine check dist/*
2 changes: 1 addition & 1 deletion .github/workflows/build_master.yml
Expand Up @@ -10,7 +10,7 @@ jobs:
#NO_NET: 1
strategy:
matrix:
python-version: ["3.9"]
python-version: ["3.10"]
steps:

- uses: actions/checkout@v2
Expand Down
104 changes: 104 additions & 0 deletions .github/workflows/build_old.yml
@@ -0,0 +1,104 @@
name: Build and Test Linux with older netcdf-c
on: [push, pull_request]
jobs:
build-linux:
name: Python (${{ matrix.python-version }})
runs-on: ubuntu-latest
env:
PNETCDF_VERSION: 1.12.1
NETCDF_VERSION: 4.8.1
NETCDF_DIR: ${{ github.workspace }}/..
NETCDF_EXTRA_CONFIG: --enable-pnetcdf
CC: mpicc.mpich
#NO_NET: 1
strategy:
matrix:
python-version: ["3.10"]
steps:

- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install Ubuntu Dependencies
run: |
sudo apt-get update
sudo apt-get install mpich libmpich-dev libhdf5-mpich-dev libcurl4-openssl-dev bzip2 libsnappy-dev libblosc-dev libzstd-dev
echo "Download and build PnetCDF version ${PNETCDF_VERSION}"
wget https://parallel-netcdf.github.io/Release/pnetcdf-${PNETCDF_VERSION}.tar.gz
tar -xzf pnetcdf-${PNETCDF_VERSION}.tar.gz
pushd pnetcdf-${PNETCDF_VERSION}
./configure --prefix $NETCDF_DIR --enable-shared --disable-fortran --disable-cxx
make -j 2
make install
popd
echo "Download and build netCDF version ${NETCDF_VERSION}"
wget https://downloads.unidata.ucar.edu/netcdf-c/${NETCDF_VERSION}/netcdf-c-${NETCDF_VERSION}.tar.gz
tar -xzf netcdf-c-${NETCDF_VERSION}.tar.gz
pushd netcdf-c-${NETCDF_VERSION}
export CPPFLAGS="-I/usr/include/hdf5/mpich -I${NETCDF_DIR}/include"
export LDFLAGS="-L${NETCDF_DIR}/lib"
export LIBS="-lhdf5_mpich_hl -lhdf5_mpich -lm -lz"
./configure --prefix $NETCDF_DIR --enable-netcdf-4 --enable-shared --enable-dap --enable-parallel4 $NETCDF_EXTRA_CONFIG
make -j 2
make install
popd

# - name: The job has failed
# if: ${{ failure() }}
# run: |
# cd netcdf-c-${NETCDF_VERSION}
# cat config.log

- name: Install python dependencies via pip
run: |
python -m pip install --upgrade pip
pip install numpy cython cftime pytest twine wheel check-manifest mpi4py

- name: Install netcdf4-python
run: |
export PATH=${NETCDF_DIR}/bin:${PATH}
export NETCDF_PLUGIN_DIR=${{ github.workspace }}/netcdf-c-${NETCDF_VERSION}/plugins/plugindir
python setup.py install
- name: Test
run: |
export PATH=${NETCDF_DIR}/bin:${PATH}
python checkversion.py
# serial
cd test
python run_all.py
# parallel (hdf5 for netcdf4, pnetcdf for netcdf3)
cd ../examples
mpirun.mpich -np 4 python mpi_example.py
if [ $? -ne 0 ] ; then
echo "hdf5 mpi test failed!"
exit 1
else
echo "hdf5 mpi test passed!"
fi
mpirun.mpich -np 4 python mpi_example_compressed.py
if [ $? -ne 0 ] ; then
echo "hdf5 compressed mpi test failed!"
exit 1
else
echo "hdf5 compressed mpi test passed!"
fi
mpirun.mpich -np 4 python mpi_example.py NETCDF3_64BIT_DATA
if [ $? -ne 0 ] ; then
echo "pnetcdf mpi test failed!"
exit 1
else
echo "pnetcdf mpi test passed!"
fi

# - name: Tarball
# run: |
# export PATH=${NETCDF_DIR}/bin:${PATH}
# python setup.py --version
# check-manifest --version
# check-manifest --verbose
# pip wheel . -w dist --no-deps
# twine check dist/*
13 changes: 7 additions & 6 deletions .github/workflows/miniconda.yml
Expand Up @@ -12,7 +12,7 @@ jobs:
# NO_NET: 1
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10" ]
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ]
os: [windows-latest, ubuntu-latest, macos-latest]
platform: [x64, x32]
exclude:
Expand All @@ -34,7 +34,7 @@ jobs:
micromamba create --name TEST python=${{ matrix.python-version }} numpy cython pip pytest hdf5 libnetcdf cftime zlib --channel conda-forge
micromamba activate TEST
export PATH="${CONDA_PREFIX}/bin:${CONDA_PREFIX}/Library/bin:$PATH" # so setup.py finds nc-config
pip install -e . --no-deps --force-reinstall
pip install -v -e . --no-deps --force-reinstall

- name: Debug conda
shell: bash -l {0}
Expand All @@ -53,7 +53,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [ "3.9" ]
python-version: [ "3.10" ]
os: [ubuntu-latest]
platform: [x64]
steps:
Expand All @@ -70,7 +70,8 @@ jobs:
micromamba create --name TEST python=${{ matrix.python-version }} numpy cython pip pytest mpi4py hdf5=*=mpi* libnetcdf=*=mpi* cftime zlib --channel conda-forge
micromamba activate TEST
export PATH="${CONDA_PREFIX}/bin:${CONDA_PREFIX}/Library/bin:$PATH" # so setup.py finds nc-config
pip install -e . --no-deps --force-reinstall
nc-config --all
pip install -v -e . --no-build-isolation --no-deps --force-reinstall

- name: Debug conda
shell: bash -l {0}
Expand All @@ -88,8 +89,8 @@ jobs:
export PATH="${CONDA_PREFIX}/bin:${CONDA_PREFIX}/Library/bin:$PATH"
which mpirun
mpirun --version
#mpirun -np 4 --oversubscribe python mpi_example.py # for openmpi
mpirun -np 4 python mpi_example.py
mpirun -np 4 --oversubscribe python mpi_example.py # for openmpi
#mpirun -np 4 python mpi_example.py
if [ $? -ne 0 ] ; then
echo "hdf5 mpi test failed!"
exit 1
Expand Down
5 changes: 3 additions & 2 deletions Changelog
@@ -1,10 +1,11 @@
version 1.6.2 (Unrelease)
==========================
version 1.6.2 (not yet released)
==============================
* Added ``netCDF4.__has_set_alignment__`` property to help identify if the
underlying netcdf4 supports setting the HDF5 alignment.
* Slicing multi-dimensional variables with an all False boolean index array
now returns an empty numpy array (instead of raising an exception - issue #1197).
Behavior now consistent with numpy slicing.
* fix problem with compiling using netcdf-c < 4.9.0 (issue #1209)

version 1.6.1 (tag v1.6.1rel)
==============================
Expand Down
8 changes: 2 additions & 6 deletions include/netCDF4.pxi
Expand Up @@ -367,7 +367,6 @@ cdef extern from "netcdf.h":

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


IF HAS_QUANTIZATION_SUPPORT:
cdef extern from "netcdf.h":
cdef enum:
Expand All @@ -377,6 +376,8 @@ IF HAS_QUANTIZATION_SUPPORT:
NC_QUANTIZE_BITROUND
int nc_def_var_quantize(int ncid, int varid, int quantize_mode, int nsd) nogil
int nc_inq_var_quantize(int ncid, int varid, int *quantize_modep, int *nsdp) nogil

IF HAS_NCFILTER:
cdef extern from "netcdf_filter.h":
int nc_inq_filter_avail(int ncid, unsigned filterid) nogil

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

IF HAS_ZSTANDARD_SUPPORT:
cdef extern from "netcdf_filter.h":
cdef enum:
H5Z_FILTER_ZSTD
int nc_def_var_zstandard(int ncid, int varid, int level) nogil
int nc_inq_var_zstandard(int ncid, int varid, int* hasfilterp, int *levelp) nogil
int nc_inq_filter_avail(int ncid, unsigned id) nogil

IF HAS_BZIP2_SUPPORT:
cdef extern from "netcdf_filter.h":
cdef enum:
H5Z_FILTER_BZIP2
int nc_def_var_bzip2(int ncid, int varid, int level) nogil
int nc_inq_var_bzip2(int ncid, int varid, int* hasfilterp, int *levelp) nogil
int nc_inq_filter_avail(int ncid, unsigned filterid) nogil

IF HAS_BLOSC_SUPPORT:
cdef extern from "netcdf_filter.h":
cdef enum:
H5Z_FILTER_BLOSC
int nc_def_var_blosc(int ncid, int varid, unsigned subcompressor, unsigned level, unsigned blocksize, unsigned addshuffle) nogil
int nc_inq_var_blosc(int ncid, int varid, int* hasfilterp, unsigned* subcompressorp, unsigned* levelp, unsigned* blocksizep, unsigned* addshufflep) nogil
int nc_inq_filter_avail(int ncid, unsigned filterid) nogil

IF HAS_NC_OPEN_MEM:
cdef extern from "netcdf_mem.h":
Expand Down
26 changes: 19 additions & 7 deletions setup.py
Expand Up @@ -70,6 +70,7 @@ def check_api(inc_dirs,netcdf_lib_version):
has_zstandard = False
has_bzip2 = False
has_blosc = False
has_ncfilter = False
has_set_alignment = False

for d in inc_dirs:
Expand Down Expand Up @@ -116,6 +117,8 @@ def check_api(inc_dirs,netcdf_lib_version):
has_bzip2 = True
if line.startswith('EXTERNL int nc_def_var_blosc'):
has_blosc = True
if line.startswith('EXTERNL int nc_inq_filter_avail'):
has_ncfilter = True

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


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

# disable parallel support if mpi4py not available.
try:
import mpi4py
except ImportError:
has_parallel4_support = False
has_pnetcdf_support = False
#try:
# import mpi4py
#except ImportError:
# f.write('disabling mpi parallel support because mpi4py not found\n')
# has_parallel4_support = False
# has_pnetcdf_support = False

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

if has_ncfilter:
sys.stdout.write('netcdf lib has nc_inq_filter_avail function\n')
f.write('DEF HAS_NCFILTER = 1\n')
else:
sys.stdout.write('netcdf lib does not have nc_inq_filter_avail function\n')
f.write('DEF HAS_NCFILTER = 0\n')

f.close()

if has_parallel4_support or has_pnetcdf_support:
import mpi4py
inc_dirs.append(mpi4py.get_include())
# mpi_incdir should not be needed if using nc-config
# (should be included in nc-config --cflags)
Expand Down
24 changes: 15 additions & 9 deletions src/netCDF4/_netCDF4.pyx
@@ -1,5 +1,5 @@
"""
Version 1.6.1
Version 1.6.2
-------------

# Introduction
Expand Down Expand Up @@ -1230,7 +1230,7 @@ if sys.version_info[0:2] < (3, 7):
# Python 3.7+ guarantees order; older versions need OrderedDict
from collections import OrderedDict

__version__ = "1.6.1"
__version__ = "1.6.2"

# Initialize numpy
import posixpath
Expand Down Expand Up @@ -3543,15 +3543,21 @@ returns True if bzip2 compression filter is available"""
**`has_szip_filter(self)`**
returns True if szip compression filter is available"""
cdef int ierr
IF HAS_SZIP_SUPPORT:
with nogil:
ierr = nc_inq_filter_avail(self._grpid, H5Z_FILTER_SZIP)
if ierr:
IF HAS_NCFILTER:
IF HAS_SZIP_SUPPORT:
with nogil:
ierr = nc_inq_filter_avail(self._grpid, H5Z_FILTER_SZIP)
if ierr:
return False
else:
return True
ELSE:
return False
else:
return True
ELSE:
return False
IF HAS_SZIP_SUPPORT:
return True
ELSE:
return False

cdef class Group(Dataset):
"""
Expand Down