Skip Nav

Performing Endian Conversion on ERDC Cray Systems

The storage in memory of multibyte variables, like longs, floats, reals, and integers, has different byte ordering depending on the system's architecture, which is identified by the endianness of the system. Little Endian byte ordering has the most significant byte ordered last, where Big Endian byte ordering has the most significant byte ordered first. The type of processor used in a system generally indicates the endianness of the system.

PGI Compiler

The PGI compiler has a "-Mbyteswapio" flag to swap the byte ordering. Note: on all HPC systems with Intel and AMD processors, use of this flag will read and write binary files as big-endian. For example:

% ftn -Mbyteswapio convert_data.f90

Intel Compiler

The Intel compiler has a "-convert big_endian" flag to read and write big-endian files. To use the Intel compiler on the Cray X Series systems, you need to swap your programming environment from PGI (which is the default) to Intel. For example:

module swap PrgEnv-pgi PrgEnv-intel
% ifort -convert big_endian convert_data.f90

Cray Compiler Environment (CCE)

The CCE compiler has a "-h byteswapio" flag to swap the byte ordering. This compiler is only available on Cray Inc. architectures. Note: all routines compiled with this option will process all binary files, input or output, as big-endian. To use the Cray compiler on the Cray X Series systems, you need to swap your programming environment from PGI (which is the default) to Cray. For example:

module swap PrgEnv-pgi PrgEnv-cray
% ftn -h byteswapio convert_data.f90

Cray CCE also provides access to the FFIO Assign library. Read the man page on the assign command after you swap your default programming environment from PGI to Cray for an explanation of its use.

GNU Compiler Collection (GNU)

The GNU Fortran compiler has a "-fconvert=swap" flag to swap the byte ordering. Note: all routines compiled with this option will process binary files with opposite byte ordering. To use the GNU compiler on the Cray X Series systems, you need to swap your programming environment from PGI (which is the default) to GNU. For example:

module swap PrgEnv-pgi PrgEnv-gnu
% ftn -fconvert=swap convert_data.f90