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. Thre is no postfix for characters. Use a quoted string.

     n4[$rlev]=.1      // n4 will be of type NC_DOUBLE
     n5[$lon_grd]=2.   // n5 will be of type NC_DOUBLE
     n6[$gds_crd]=2e3; // n6 will be of type NC_DOUBLE
     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 a 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 floating point number
d|D
NC_DOUBLE a double precision floating point number

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