Main Content

netcdf.sync

Synchronize netCDF file to disk

Syntax

netcdf.sync(ncid)

Description

netcdf.sync(ncid) synchronizes the state of a netCDF file to disk. The netCDF library normally buffers accesses to the underlying netCDF file, unless you specify the NC_SHARE mode when you opened the file with netcdf.open or netcdf.create. To call netcdf.sync, the netCDF file must be in data mode.

This function corresponds to the nc_sync 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 netCDF file for write access, performs an operation on the file, takes the file out of define mode, and then synchronizes the file to disk.

% Create a netCDF file.
ncid = netcdf.create('foo.nc','NC_WRITE');

% Perform an operation.
dimid = netcdf.defDim(ncid,'Xdim',50);

% Take file out of define mode.
netcdf.endDef(ncid);

% Synchronize the file to disk.
netcdf.sync(ncid)