Next: , Previous: Attributes, Up: ncap2 netCDF Arithmetic Processor


4.1.7 Number literals

The table below lists the postfix character(s) to add to a number literal for type cohesion. To use the new netCDF4 types NCO must be compiled/linked to the netCDF4 library and the output file must be HDF5.

     n1[$time]=1UL; // n1 will now by type NC_UINT
     n2[$lon]=4b;   // n2 will be of type NC_BYTE
     n3[$lat]=5ull; // n3 will be of type NC_UINT64
     n3@a1=6.0d;   // attribute will be type NC_DOUBLE
     n3@a2=-666L;  // attribute will be type NC_INT

A floating point number without a postfix will default to NC_DOUBLE. An integer without a postfix will default to type NC_INT. There is no postfix for characters, use a quoted string instead.

     n4[$rlev]=0.1      // n4 will be of type NC_DOUBLE
     n5[$lon_grd]=2.0   // n5 will be of type NC_DOUBLE
     n6[$gds_crd]=2e3;  // n6 will be of type NC_DOUBLE
     n7[$gds_crd]=2e3f;  // n7 will be of type NC_FLOAT
     n6@a1=41;         // attribute will be type NC_INT
     n6@a2=-21;        // attribute will be type NC_INT
     n6@units="kelvin" // attribute will be type NC_CHAR
netCDF3/4 Types
b|B
NC_BYTE, a signed 1-byte integer
none
NC_CHAR, an ISO/ASCII character
s|S
NC_SHORT, a signed 2-byte integer
l|L
NC_INT, a signed 4-byte integer
f|F
NC_FLOAT, a single-precision (4-byte) floating point number
d|D
NC_DOUBLE, a double-precision (8-byte) floating point number

netCDF4 Types
ub|UB
NC_UBYTE, an unsigned 1-byte integer
us|US
NC_USHORT, an unsigned 2-byte integer
u|U|ul|UL
NC_UINT, an unsigned 4-byte integer
ll|LL
NC_INT64, a signed 8-byte integer
ull|ULL
NC_UINT64, an unsigned 8-byte integer