The NCDF_CREATE function creates a new NetCDF file. By default, the file format is NetCDF version 3.

Note: To create NetCDF version 4 files, use the NETCDF4_FORMAT keyword.

Examples


; Open a new NetCDF File and destroy test.nc if it already exists:
id = NCDF_CREATE('test.nc',/CLOBBER)
 
id2 = NCDF_CREATE('test.nc', /NOCLOBBER)

This attempt to create a new version of the file test.nc produces the following error because the NOCLOBBER keyword was set:

nccreate: filename "test.nc": File exists
% NCDF_CREATE: Operation failed
% Execution halted at $MAIN$   (NCDF_CREATE).

Syntax


Result = NCDF_CREATE( Filename, /CLOBBER, /NOCLOBBER, /NETCDF3_64BIT, /NETCDF3_CDF5, /NETCDF4_FORMAT )

Return Value


If successful, the NetCDF ID for the file is returned. The newly-created NetCDF file is automatically placed into define mode. If you do not have write permission to create the specified Filename, NCDF_CREATE returns an error message instead of a NetCDF file ID.

Arguments


Filename

A scalar string containing the name of the file to be created.

Keywords


CLOBBER

Set this keyword to erase the existing file (if the file already exists) before creating the new version.

NOCLOBBER

Set this keyword to create a new NetCDF file only if the specified file does not already exist. This is the default.

NETCDF3_64BIT

Set this keyword to create a NetCDF-3 file using 64-bit file offsets inside the file. This keyword allows you to create NetCDF-3 files where some of the variables start beyond the 2 GB boundary.

Note: This keyword is ignored if either the NETCDF3-CDF5 or NETCDF4_FORMAT keyword is set.

Note: The NetCDF-3 64-bit format became available with version 3.6 of the NetCDF library. If you create a file using this keyword, you will not be able to read this file using software that contains earlier versions of the NetCDF library. It is recommended that you only use this keyword when you know that one of your variables will start at an offset beyond the 2 GB boundary.

NETCDF3_CDF5

Set this keyword to create a NetCDF-3 file using the CDF5 format, which allows arrays with more than 4-billion elements in a single dimension.

Note: This keyword is ignored if the NETCDF4_FORMAT keyword is set.

Note: IDL does not currently allow NetCDF-3 dimensions to have more than 2 billion elements in a single dimension, although the total number of elements in the array can be much greater. If you need an array with a single dimension greater than 2 billion, you should consider using the NetCDF-4 format.

Note: The NetCDF-3 CDF5 format became available with version 4.4 of the NetCDF library. If you create a file using this keyword, you will not be able to read this file using software that contains earlier versions of the NetCDF library. It is recommended that you only use this keyword when you know that one of your variables will have a dimension that is larger than 4 billion.

NETCDF4_FORMAT

Set this keyword to create a new NetCDF-4 file. In NetCDF-4 files, data is created and accessed with the HDF5 library. NetCDF-4 files are valid HDF5 files, and may be read with HDF5 routines.

Note: If a NetCDF-4 file is modified using the HDF5 routines, rather than with the NetCDF-4 routines, the file is no longer a valid NetCDF-4 file, and may no longer be readable with the NetCDF routines.

Version History


Pre 4.0

Introduced

8.0

Added the NETCDF4_FORMAT keyword

8.2.1 Added NETCDF3_64BIT keyword
9.3 Added NETCDF3_CDF5 keyword

See Also


NCDF_CLOSE, NCDF_CONTROL, NCDF_OPEN