Main Content


Set netCDF fill mode


old_mode = netcdf.setFill(ncid,new_mode)


old_mode = netcdf.setFill(ncid,new_mode) sets the fill mode for a netCDF file identified by ncid.

new_mode can be either 'FILL' or 'NOFILL' or their numeric equivalents, as retrieved by netcdf.getConstant. The default mode is 'FILL'. netCDF pre-fills data with fill values. Specifying 'NOFILL' can be used to enhance performance, because it avoids the duplicate writes that occur when the netCDF writes fill values that are later overwritten with data.

This function corresponds to the nc_set_fill function in the netCDF library C API. To use this function, you should be familiar with the netCDF programming paradigm.


This example creates a new file and specifies the fill mode used by netCDF with the file.

ncid ='','NC_WRITE');

% Set filling behavior
old_mode = netcdf.setFill(ncid,'NC_NOFILL');