[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDFPerl #DYO-422987]: BYTE data type and perl/netCDF



Andrew,

> When writing a BYTE data type to a netCDF file using perl/netCDF I am
> experiencing some odd behavior.
> 
> When writing an array to an output file as BYTE type, and the array
> contains negative values, the values in the resulting netCDF file are all
> numeric and are as expected.
> 
> When writing an array to an output file as BYTE type, and all array values
> are positive, I get an ASCII representation of the values that I expect,
> for example, there is a 48 where a zero is expected and a 49 where a one is
> expected.
> 
> I am curious to know why the library performs one way when the array
> contains values that are negative, and it encodes differently when the
> output array contains only non-negative values.
> 
> Do you possibly have a solution to this problem that can be implemented
> within the perl code?  I tried ensuring the values are numeric by adding
> and subtracting 1, but that was just silly!  :-)
> 
> With perl/netCDF am I be forced to store these numerical data as type =
> SHORT?  That does seem to work fine (SHORT) for both negative and positive
> numbers.

The netCDF-Perl module doesn't alter the bit patterns in byte values when 
writing to or reading from a netCDF file. The interpretation of the bit 
patterns can vary, however, depending on what's doing the interpretation (C 
program, Perl code, ncdump(1), etc.). How is the array defined and set in your 
Perl code? How does ncdump(1) interpret the relevant netCDF variable? What is 
the signedness of an unqualified C-language "char" on your system?

> Thank you, as always, for your great support!
> 
> -Andy
> 
> ---
> address@hidden
> NOAA/OAR/ESRL/GSD/ACE  R/GSD5
> 325 Broadway  Boulder, CO  80305-3328
> phone:303-497-6211   fax:303-497-6301

Regards,
Steve Emmerson

Ticket Details
===================
Ticket ID: DYO-422987
Department: Support netCDF Perl
Priority: Normal
Status: Closed