Skip to content

Commit

Permalink
Merge pull request #966 from Unidata/issue964
Browse files Browse the repository at this point in the history
fix detection of parallel HDF5 support in netcdf-c 4.6.1
  • Loading branch information
jswhit authored Sep 3, 2019
2 parents 5bf0184 + c7e4431 commit 3f57d7f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
1 change: 1 addition & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* remove newlines from string representation (pull request #960).
* fix for issue #957 (size of scalar var is a float since numpy.prod(())=1.0).
* make sure Variable.setncattr fails to set _FillValue (issue #959).
* fix detection of parallel HDF5 support with netcdf-c 4.6.1 (issue #964).

version 1.5.1.2 (tag v1.5.1.2rel)
==================================
Expand Down
17 changes: 9 additions & 8 deletions netCDF4/_netCDF4.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3094,8 +3094,10 @@ this `netCDF4.Dataset` or `netCDF4.Group`, as well as for all
variables in all its subgroups.
**`True_or_False`**: Boolean determining if automatic conversion of
masked arrays with no missing values to regular ararys shall be
applied for all variables.
masked arrays with no missing values to regular numpy arrays shall be
applied for all variables. Default True. Set to False to restore the default behaviour
in versions prior to 1.4.1 (numpy array returned unless missing values are present,
otherwise masked array returned).
***Note***: Calling this function only affects existing
variables. Variables created after calling this function will follow
Expand Down Expand Up @@ -5135,12 +5137,11 @@ The default value of `mask` is `True`
turn on or off conversion of data without missing values to regular
numpy arrays.
If `always_mask` is set to `True` then a masked array with no missing
values is converted to a regular numpy array.
The default value of `always_mask` is `True` (conversions to regular
numpy arrays are not performed).
`always_mask` is a Boolean determining if automatic conversion of
masked arrays with no missing values to regular numpy arrays shall be
applied. Default is True. Set to False to restore the default behaviour
in versions prior to 1.4.1 (numpy array returned unless missing values are present,
otherwise masked array returned).
"""
self.always_mask = bool(always_mask)

Expand Down
22 changes: 17 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ def check_ifnetcdf4(netcdf4_includedir):
return isnetcdf4


def check_api(inc_dirs):
def check_api(inc_dirs,netcdf_lib_version):
has_rename_grp = False
has_nc_inq_path = False
has_nc_inq_format_extended = False
has_cdf5_format = False
has_nc_open_mem = False
has_nc_create_mem = False
has_parallel_support = False
has_parallel4_support = False
has_pnetcdf_support = False

Expand Down Expand Up @@ -91,10 +92,20 @@ def check_api(inc_dirs):
for line in open(ncmetapath):
if line.startswith('#define NC_HAS_CDF5'):
has_cdf5_format = bool(int(line.split()[2]))
elif line.startswith('#define NC_HAS_PARALLEL4'):
if line.startswith('#define NC_HAS_PARALLEL'):
has_parallel_support = bool(int(line.split()[2]))
if line.startswith('#define NC_HAS_PARALLEL4'):
has_parallel4_support = bool(int(line.split()[2]))
elif line.startswith('#define NC_HAS_PNETCDF'):
if line.startswith('#define NC_HAS_PNETCDF'):
has_pnetcdf_support = bool(int(line.split()[2]))
# NC_HAS_PARALLEL4 missing in 4.6.1 (issue #964)
if not has_parallel4_support and has_parallel_support and not has_pnetcdf_support:
has_parallel4_support = True
# for 4.6.1, if NC_HAS_PARALLEL=NC_HAS_PNETCDF=1, guess that
# parallel HDF5 is enabled (must guess since there is no
# NC_HAS_PARALLEL4)
elif netcdf_lib_version == "4.6.1" and not has_parallel4_support and has_parallel_support:
has_parallel4_support = True
break

return has_rename_grp, has_nc_inq_path, has_nc_inq_format_extended, \
Expand Down Expand Up @@ -182,7 +193,7 @@ def getnetcdfvers(libdirs):
use_ncconfig = None
if USE_SETUPCFG and os.path.exists(setup_cfg):
sys.stdout.write('reading from setup.cfg...\n')
config = configparser.SafeConfigParser()
config = configparser.ConfigParser()
config.read(setup_cfg)
try:
HDF5_dir = config.get("directories", "HDF5_dir")
Expand Down Expand Up @@ -494,7 +505,8 @@ def _populate_hdf5_info(dirstosearch, inc_dirs, libs, lib_dirs):
# this determines whether renameGroup and filepath methods will work.
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 = check_api(inc_dirs)
has_parallel4_support, has_pnetcdf_support = \
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"):
Expand Down

0 comments on commit 3f57d7f

Please sign in to comment.