Download NCO User Guide

Transcript
Chapter 4: Reference Manual
137
var_out=array(val_srt,val_ncr,var_tpl); // Multi-dimensional output
where the arguments are the starting value val srt, incremental value val ncr, and, for
one-dimensional output, the single dimension $dmn_nm, or, for multi-dimensional output,
a template variable var_tpl, i.e., a variable with the same shape as the desired output.
The type of var_out will be the same as val_srt. Be sure to encode this type with
the appropriate decimal point and floating point suffix when val_srt is a “naked constant”
rather than a variable. For example, to produce an array of shorts (signed two-byte integers),
integers (signed four-byte integers), unsigned 64-bit integers, floats, or doubles use
var_out=array(1s,val_ncr,$dmn_nm); // NC_SHORT array
var_out=array(1,val_ncr,$dmn_nm); // NC_INT array
var_out=array(1ull,val_ncr,$dmn_nm); // NC_UINT64 array
var_out=array(1f,val_ncr,$dmn_nm); // NC_FLOAT array
var_out=array(1.,val_ncr,$dmn_nm); // NC_DOUBLE array
Once the associated dimensions have been defined, the start and increment arguments
may be supplied as values, mathmatical expressions, or variables:
var_out=array(1,1,$time); // 1,2,3,4,5,6,7,8,9,10
var_out=array(1+2-2,one,$time); // 1,2,3,4,5,6,7,8,9,10
var_out=array(1,2,three_dmn_rec_var); // 1,3,5,...155,157,159
Hyperslabs in ncap2 are more limited than hyperslabs with the other NCO operators.
ncap2 does not understand the shell command-line syntax used to specify multi-slabs,
wrapped co-ordinates, negative stride or coordinate value limits. However with a bit of
syntactic magic they are all are possible. ncap2 accepts (in fact, it requires) N-hyperslab
arguments for a variable of rank N :
var1(arg1,arg2 ... argN);
where each hyperslab argument is of the form
start:end:stride
and the arguments for different dimensions are separated by commas. If start is omitted,
it defaults to zero. If end is omitted, it defaults to dimension size minus one. If stride is
omitted, it defaults to one.
If a single value is present then it is assumed that that dimension collapses to a single value
(i.e., a cross-section). The number of hyperslab arguments MUST equal the variable’s rank.
Hyperslabs on the Right Hand Side of an assign
A simple 1D example:
($time.size=10)
od[$time]={20,22,24,26,28,30,32,34,36,38};
od(7);
od(7:);
// 34
// 34,36,38