Endianness Issues

The endianness issue is one of the most common problems when running codes that, like DP, needs (also) a binary input file. DP relying on a qplda or a kss file (of course this problem doesn't occur if the ETSF_IO interface is used), which are binary files, the endianness of the input file and the endianness of the compiler/environment have to be the same. If you try to read a big-endian file with a little-endian compiled executable, it won't work.

Fortunately most of the machines host compilers that permit to change the endianness either at compilation time or, even better, at runtime. Notable exception are IBM machines and NEC (these are the only ones I know for sure) where the intrinsic big-endian format cannot be changed (this is the reason why the binary files given into the tests directory are big-endian).

Here there's a list of known FLAGS or ENV variable to change the endianness for several compilers

  • Endianness change at compilation time
    • SUNSTUDIO: add ``-xfilebyteorder=big16:\%all'' to F90FLAGS
    • PGI: add ``-byteswapio'' to F90FLAGS
    • Compaq f90: add ``-convert big-endian'' to F90FLAGS

  • Endianness change at runtime
    • Ifort: ``export F_UFMTENDIAN=big''
    • G95: ``export G95_ENDIAN=BIG''
    • Pathscale: ``export FILENV=.filenv'', where .filenv is a file containing
      assign -F f77.mips -N mips g:su
      assign -F f77.mips -N mips g:du
      
    • Open64: same as Pathscale

  • Endianness change at configure time
    • gfortran: add --with-gfortran-endianness=big at your configure command to impose the big endianness.