Project

General

Profile

nelem in operator outputf

Added by Matthias Cuntz almost 14 years ago

Dear all,

happy New Year!

I do not grasp the use of nelem in the operator outputf.

I want to compare model output with station data. Therefore I want to extract the model output in a simple ascii format. So I thought using the outputf operator like this:
cdo -s outputf,%13.6g,3 -fldavg -sellonlatbox,0,10,0,10 -selvar,temp1,temp2,temp3 input.nc
This outputs each number on a single line instead of 3 numbers per line, as I expected.

The help says
outputf,format,nelem ifiles
outputf Formatted output
Prints all values to standard output.
The format and number of elements for each row have to be specified by the parameters
format and nelem.
format STRING C-style format for one element (e.g. %13.6g)
nelem INTEGER Number of elements for each row

Where is my mistake?

Thanks
Matthias


Replies (3)

RE: nelem in operator outputf - Added by Uwe Schulzweida almost 14 years ago

Dear Matthias,

The parameter nelem is the number of elements per field. So the maximum number for nelem is the gridsize. If the size of the fields is 1 then the maximum values per single line is also 1.

Best regards,
Uwe

RE: nelem in operator outputf - Added by Matthias Cuntz almost 14 years ago

Dear Uwe,

thanks a lot for the clarification.

justed wanted to post one solution to my little problem by using echo with xargs:
cdo -s outputf,%13.6g,1 -fldavg -sellonlatbox,0,10,0,10 -selvar,temp1,temp2,temp3 input.nc | xargs -L 3 echo

So xargs gives 3 (-L 3) lines to echo to print out, which it does in one line separated by space. If one wants another separator, e.g. ;, pipe further through tr ' ' ';' or sed 's/ /;/g'

Cheers
Matthias

RE: nelem in operator outputf - Added by Matthias Cuntz almost 14 years ago

P.S.: Just wanted to add for clarity if anyone ever finds this thread: the output is sorted in the order how the variables are stored in the input file not in the order of the selvar-list.
This means if one gives -selvar,var1,var2 but var2 is stored before var1 in the input file, output will give first the value of var2 and then the value of var1.

Cheers
Matthias

    (1-3/3)