filedimdef
Defines dimension names, dimension sizes, unlimited dimensions on a supported file.
Prototype
procedure filedimdef ( thefile [1] : file, dim_names [*] : string, dim_sizes [*] : integer, dim_unlimited [*] : logical )
Arguments
thefileThe reference to the file that you want to write the dimensions to. This reference must be created by the addfile function.
dim_namesAn array of dimension names you want to write to thefile.
dim_sizesAn array of dimension sizes of the dimensions you want to write to thefile.
dim_unlimitedAn array of logical values indicating whether the corresponding dimensions are unlimited in size, note netCDF only allows one unlimited dimension.
Description
The filedimdef procedure is used to pre-define dimensions in a file. The supported file must have been opened as either read/write ("w") or create ("c"). The fourth argument allows the dimension to be defined as unlimited. Currently, netCDF files only allow one dimension to be unlimited. Unlimited dimensions can grow while normal dimensions can not. A typical use of unlimited dimensions is to create a data from multiple input files. For unlimited dimensions the size value is ignored. Unlimited dimensions have a size of 0 until a variable with the unlimited dimension name is assigned to the file.
Using this procedure is much more efficient than writing a variable's dimensions one at a time.
See Also
fileattdef, filevarattdef, filevardef, filedimdef
Examples
Write dimensions "lon", "lat", "lev, and "time" to a netCDF file, with "time" being an unlimited dimension:
ncf = addfile("myfile.nc","c") ; ; Define dimensions. ; nlon = 64 nlat = 128 nlev = 10 ntim = -1 dim_names = (/ "lon", "lat", "lev", "time" /) dim_sizes = (/ nlon , nlat , nlev , ntim /) dimUnlim = (/ False , False, False , True /) filedimdef( ncf, dim_names, dim_sizes, dimUnlim )"ncdump myfile.nc" produces the following output:
netcdf myfile {
dimensions:
lon = 64 ;
lat = 128 ;
lev = 10 ;
time = UNLIMITED ; // (0 currently)
}