Revert recent netCDF file definitions
netcdf.abort(ncid) reverts a netCDF file to its previous state, backing out any definitions made since the file last entered define mode. A file enters define mode when you create it (using netcdf.create) or when you explicitly enter define mode (using netcdf.redef). Once you leave define mode (using netcdf.endDef), you cannot revert the definitions you made while in define mode. ncid is a netCDF file identifier returned by netcdf.create or netcdf.open. A call to netcdf.abort closes the file.
This function corresponds to the nc_abort function in the netCDF library C API. To use this function, you should be familiar with the netCDF programming paradigm. See netcdf for more information.
This example creates a new file, performs an operation on the file, and then reverts the file back to its original state. To run this example, you must have write permission in your current directory.
% Create a netCDF file ncid = netcdf.create('foo.nc','NC_NOCLOBBER'); % Perform an operation, such as defining a dimension. dimid = netcdf.defDim(ncid, 'lat', 50); % Revert the file back to its previous state. netcdf.abort(ncid) % Verify that the file is now closed. dimid = netcdf.defDim(ncid, 'lat', 50); % should fail ??? Error using ==> netcdflib NetCDF: Not a valid ID Error in ==> defDim at 22 dimid = netcdflib('def_dim', ncid,dimname,dimlen);