Go to the previous, next section.

NetCDF Data Types

The current set of primitive types supported by the netCDF interface are:

byte
Eight-bit data; especially good for saving space when only a few values are possible or resolution is low.
character
Currently synonymous with byte; intended for representing text strings as arrays of ASCII characters.
short
16-bit integers.
long
32-bit integers.
float
32-bit IEEE floating-point.
double
64-bit IEEE floating-point.

Except for the added byte and the lack of unsigned types, netCDF supports the same primitive data types as C. The names for the primitive data types are reserved words in CDL, so the names of variables, dimensions, and attributes must not be type names. Whether byte, short, or long data is interpreted as signed or unsigned is not part of the netCDF interface; since no netCDF operations depend on the sign or order of variable data, you are free to interpret a byte, for example, as holding values between 0 and 255 or between -128 and 127. For convenience, short and long constants are interpreted as signed in the CDL notation. See section Attribute Conventions for more information on representing signedness of values.

These types were chosen because they are familiar to C and FORTRAN programmers, they have well-defined external representations independent of any particular computers (using XDR), and they are sufficient for providing a reasonably wide range of trade-offs between data precision and number of bits required for each datum.

Additional primitive types may be added in the future, but only in a way that is compatible with existing programs and files. For example, hyperlong for 64-bit integers will eventually be needed, along with a new type for multibyte characters, but these can both be added without affecting existing netCDF files or applications, and with only minor changes required for generic applications that will support them.

Go to the previous, next section.