Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

netcdf.endDef - End netCDF file define mode

Syntax

netcdf.endDef(ncid)
netcdf.endDef(ncid,h_minfree,v_align,v_minfree,r_align)

Description

netcdf.endDef(ncid) takes a netCDF file out of define mode and into data mode. ncid is a netCDF file identifier returned by netcdf.create or netcdf.open.

netcdf.endDef(ncid,h_minfree,v_align,v_minfree,r_align) takes a netCDF file out of define mode, specifying four additional performance tuning parameters. For example, one reason for using the performance parameters is to reserve extra space in the netCDF file header using the h_minfree parameter:

ncid = netcdf.endDef(ncid,20000,4,0,4);

This reserves 20,000 bytes in the header, which can be used later when adding attributes. This can be extremely efficient when working with very large files. To understand how to use these performance tuning parameters, see the netCDF library documentation.

This function corresponds to the nc_enddef and nc__enddef functions in the netCDF library C API. To use this function, you should be familiar with the information about netCDF contained in the NetCDF C Interface Guide for version 3.6.2.

Examples

When you create a file using netcdf.create, the functions opens the file in define mode. This example uses netcdf.endDef to take the file out of define mode.

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

% Define a dimension.
dimid = netcdf.defDim(ncid, 'lat', 50);

% Leave define mode.
netcdf.endDef(ncid)  

% Test if still in define mode.
dimid = netcdf.defDim(ncid, 'lon', 50);  % should fail
??? Error using ==> netcdflib
NetCDF: Operation not allowed in data mode

Error in ==> defDim at 22
dimid = netcdflib('def_dim', ncid,dimname,dimlen);

See Also

netcdf.create, netcdf.reDef

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS