>  Docs Center  >  IDL Reference  >  I/O - NetCDF  >  NCDF_CREATE



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.


; 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).



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.



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



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


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


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. This file format is also known as the 64-bit offset format, version 2, or CDF2. Note that you do not need to use this keyword if all of your variables start at a file offset less than 2 GB, even if the final variable goes beyond the 2 GB boundary. This keyword is only needed when another variable is added to the same file, and that new variable has a starting offset beyond the 2 GB boundary

This keyword is ignored if the NETCDF4_FORMAT keyword is set, because NetCDF 4 is automatically able to handle 64-bit file offsets.

Note: When reading in a NetCDF 3 file with 64-bit offsets, IDL's NetCDF library will automatically detect that it is in 64-bit format and will read the data successfully.

Note: The NetCDF 3 64-bit format became available with version 3.6 of the NetCDF library. If you create a file using the NETCDF3_64BIT 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.


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



Added the NETCDF4_FORMAT keyword.

8.2.1 Added NETCDF3_64BIT keyword.

See Also


© 2020 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us