This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
> Hi Charlie, The bug you reported is now fixed in the snapshot release, with a test run to verify the fix. The bug was a range test against the maximum short rather than the maximum unsigned short, so the renge error was actually returned for all unsigned short values greater than 2**15-1, not 2**16-1, as was intended. Thanks again for reporting the problem! --Russ > > At some point in the past year or so, two very separate sets of code > > I maintain started producing errors when asked to write a netCDF4 > > variable of type unsigned short (NC_USHORT) with value = 65535. > > > > nco_err_exit(): ERROR netCDF library returned error code -60 > > nco_err_exit(): ERROR nco_put_var<unsigned short> failed with variable > > ushort_var > > NetCDF: Numeric conversion not representable > > > > Is it possible that such a problem has crept into the netCDF4 daily > > builds? I am using > > > > Linked to netCDF library version 4.1.2-beta1-snapshot2010080820, > > compiled Aug 9 2010 22:13:02 > > > > The rest of the max/min tests seem to work well, i.e., for INT64, > > UINT64. Only USHORT behaves oddly. > > I was able to reproduce this bug with the current snapshot, using the > function nc_put_var1_int() to convert and then write the integer 65535 to > an unsigned short variable, which produced the same message you are > seeing. > > The bug was also in the 4.1.1 release and the 4.0.1 release, but I > don't have a 4.0 release built to check whether it was OK for that > version. > > We'll try to fix it before the next beta release and let you know when > a fixed snapshot is available. > > A workaround for now would be to write 65535 as an unsigned short > value, rather than converting to unsigned short from another type, > because I just checked that just using nc_put_var1() works fine when > the data is the unsigned int 65535. > > --Russ > > Russ Rew UCAR Unidata Program > address@hidden http://www.unidata.ucar.edu > > Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: IIN-151372 Department: Support netCDF Priority: Normal Status: Closed