Arg. SPAM filter will not let me post text output from command window.
Latest cygwin version, trying to use ncap2 with rint and round operators.
I get the following error:
ncap2: WARNING prs_cls::ncap_var_init(): Unable to find variable round in bathy_level_AC_final.nc or bathy_level_AC_final_rounded.nc
floor and ceil work without issues.
The functions, rint() and round() were deprecated from NCO 10+ years
ago because, as noted in some source code,
/* 20020703: AIX, MACOSX, SGI*, WIN32 do not define rintf
Only LINUX* supplies all of these and I do not care about them enough
to activate them on LINUX* but not on MACOSX* and SUN* */
In other words, only Linux guaranteed native support for their single
precision versions. However, it should not be too hard to add support
back in the future, and they really are necessary for a fully featured
rounding environemnt. I have made this TODO nco1092 and will post again
when progress is made.
p.s. Investigating this led me to stumble upon the possible solution
to a longstanding problem with NCO, so thanks!
p.p.s. ncap2 prints the functions it supports with ncap2 -f
Thanks cz. I'll kludge up my own using a conditional ceil and floor. My values are all positive.
(BTW round, rint, nearbyint and trunc still in pdf docs after 10+ years. See Sec 4.1.25 Intrinsic mathematical methods)
I just started using the nco opendap functionality. Thanks for this.
The following always gives me ceil.
ncap2 -s Bathy_level=((Bathy_level - floor(Bathy_level)) < 0.5 ? floor(Bathy_level) : ceil(Bathy_level)) bathy_level_AC_final.nc bathy_level_AC_final_rounded.nc
Gah. Conditionals must be true for every element in array. Use where construct instead:
ncap2 -s 'where((Bathy_level-floor(Bathy_level)) < 0.5) Bathy_level=floor(Bathy_level); elsewhere Bathy_level=ceil(Bathy_level)' bathy_level_AC_final.nc bathy_level_AC_final_rounded.nc
ncap2 support for nearbyint(), rint(), round(), and trunc() has been committed.
It works on Linux, Mac, and native (Visual C) Windows, but has not been tested on cygwin.
Please try to give it a test and let us know if it works for you before we make the next NCO release.
Much too late to reply to this, but I only just noticed that you had asked me to test the rounding. I would not have been of much use since I am stuck using binary builds for (ick!) Cygwin.
Log in to post a comment.