[netCDF #OKU-828902]: big endian, little endian question
Sorry to have taken so long to respond to your question ...
> I'm using a fortran code to convert my data file to netcdf. The data values
> going in to the fortran code are sensible, but the netcdf output is quite
> wonky. I'm thinking it could be a big endian vs. little endian problem. Is
> there an easy way to correct the netcdf file?
The netCDF classic format or 64-bit offset variant always stores the data in
XDR (Big Endian)
form, and the library takes care of the conversions on reading or writing, so
using the library alsways deal with the data in native form. That's one of the
the netCDF library, to insulate programmers from having to know anything about
characterisitics of the computer on which the data was written.
The netCDF-4 format by default stores the data in native format of the writing
the library converts this to native form of the reading machine when the data
is read, so
again the library insulates you from differences in endian-ness, in this case
with a "reader
makes right" approach.
If the data looks "wonky", could it be that it's packed with "scale_factor" and
attributes, that you have to apply after reading to reverse the packing? You
can see such
attributes in the output of "ncdump -c" on the netCDF file. ncdump without the
should also show you the packed values, so you can verify your Fortran program
is reading the
same values as seen by the C library. If packing is the problem, the formulas
the data are here:
If you're still having problems, try compiling and linking one of the example
to see if those work OK with your netCDF library:
Russ Rew UCAR Unidata Program
Ticket ID: OKU-828902
Department: Support netCDF