contact: Jörg Wegner
wegner @dkrz.de
tel.: +49 40 41173 178

 

From Little to Big Endian and vice versa

Some problems with service and extra formatted data appear because of different byte order between some computer architectures. So what is UNIX on a SUN Workstation becomes "XINU" on a LINUX computer. In the old days this was called the NUXI problem (On 16bit computers UNIX will swap to NUXI). GRIB and NetCDF formatted data are machine independent and will cause no problem due to the byteorder. So how to solve this problem for extra and service data?

  • Case 1:
  • Some FORTRAN compiler accept files of the different byte order:

    open(1,file='u10.80.srv', form='unformatted',convert='big_endian')

    This open-statement works on a little-endian machine (LINUX) and reads big-endian files.

  • Case 2:
  • Use cdo (climate data operators) to work with your files. cdo reads little and big endian files on all machine architectures. No problems!

  • Case 3:
  • If you want to work with the PINGO package you have to convert the data! Use

    extra infile.ext outfile.ext

    or

    serv infile.srv outfile.srv

    to change to the machine used byte order. Then use the PINGO package as usual.

    The binaries of this small programs are in the same directory as the pingo binary.

Here's what extra and serv can do:

       exa 28%serv
           usage : serv  [-options]  [ifile]  [ofile]
           with:
                -info         display contents of file
                -4            write 4 byte SERVICE format
                -8            write 8 byte SERVICE format
                -swap         swap byte ordering
                -move         move record
                -debug        debugging mode
                -Version      display version number
       

swap swaps from machine known byte order to unknown; move does not really do anything, and the rest I guess is self explanatory.

       exa 29%extra
           usage : extra  [-options]  [ifile]  [ofile]
           with:
                -info         display contents of file
                -4            write 4 byte EXTRA format
                -8            write 8 byte EXTRA format
                -swap         swap byte ordering
                -debug        debugging mode
                -Version      display version number