Main Content

netcdf.setFill

Set netCDF fill mode

Syntax

old_mode = netcdf.setFill(ncid,new_mode)

Description

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.

Examples

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

ncid = netcdf.open('foo.nc','NC_WRITE');

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