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

[netCDF #JJL-124364]: Importing data without endianness conversion



Hi Peter,

Sorry to have taken so long to respond to your question ...
> Is there any way in which dataset can be created from binary big-endian
> data on a little-endian host without endianness conversion applied?
> 
> I have data in big-endian, and I would like to import it into a
> H5T_IEEE_F64BE dataset as is. Sadly, the function nc_def_var_endian is
> not good enough - although it creates a H5T_IEEE_F64BE dataset, the
> interpretation of the raw data is still little-endian, and a conversion
> is done (leading to incorrect values).

Are you reading the data from an HDF5 file, or from a netCDF-4 file?  Is
the little endian data marked as little endian in the file you are trying
to read?  That is, if you run

  ncdump -s -v VAR INPUTFILE

where the "-s" is for showing special virtual attributes such as endianness
and the "-v VAR" is for looking at a specific variable named VAR in the input 
file, do you see the attribute

  VAR:_Endianness = "little" ;

where, again, VAR is the name of the variable (HDF5 dataset) you're looking for.

> Both nc_put_var and nc_pur_vara behave the same in this respect.

If this is a bug, we'd like to fix it.  But we have tests for endianness, and
would need a small program that demonstrates this bug, so we could duplicate
it here and fix it.  Note that setting the endianness for a netCDF variable
only affects its representation on disk when writing values.  It does not
affect the way data is decoded and represented in native types when reading.
That is always determined by how HDF5 has labelled the data type, as little-
endian or big-endian.

> With HDF5 API this is easily achieved by setting the type to
> H5T_IEEE_F64BE, but I would prefer to use the netcdf API.

--Russ

Russ Rew                                         UCAR Unidata Program
address@hidden                      http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: JJL-124364
Department: Support netCDF
Priority: High
Status: Closed