@@ -4041,9 +4041,10 @@ behavior is similar to Fortran or Matlab, but different than numpy.
40414041 If fill_value is set to `False`, then the variable is not pre-filled.
40424042 The default netCDF fill values can be found in the dictionary `netCDF4.default_fillvals`.
40434043 If not set, the default fill value will be used but no `_FillValue` attribute will be created
4044- (this is the default behavior of the netcdf-c library). `Variable.get_fill_value`
4045- can be used to retrieve the fill value, even if the `_FillValue` attribute is
4046- not set.
4044+ (this is the default behavior of the netcdf-c library). If you want to use the
4045+ default fill value, but have the `_FillValue` attribute set, use
4046+ `fill_value='default'` (note - this only works for primitive data types). ``Variable.get_fill_value`
4047+ can be used to retrieve the fill value, even if the `_FillValue` attribute is not set.
40474048
40484049 **`chunk_cache`**: If specified, sets the chunk cache size for this variable.
40494050 Persists as long as Dataset is open. Use `set_var_chunk_cache` to
@@ -4407,6 +4408,12 @@ behavior is similar to Fortran or Matlab, but different than numpy.
44074408 if ierr != NC_NOERR:
44084409 if grp.data_model != ' NETCDF4' : grp._enddef()
44094410 _ensure_nc_success(ierr, extra_msg = error_info)
4411+ elif fill_value == ' default' :
4412+ if self ._isprimitive:
4413+ fillval = numpy.array(default_fillvals[self .dtype.str[1 :]])
4414+ if not fillval.dtype.isnative: fillval.byteswap(True )
4415+ _set_att(self ._grp, self ._varid, ' _FillValue' ,\
4416+ fillval, xtype = xtype)
44104417 else :
44114418 if self ._isprimitive or self ._isenum or \
44124419 (self ._isvlen and self .dtype == str ):
0 commit comments