The IntelŪ compiler can write unformatted sequential files in big-endian format and can also read files produced in big-endian format by using the little-endian-to-big-endian conversion feature.
Both on IA-32-based processors and on ItaniumŪ-based processors, Intel Fortran handles internal data in little-endian format. The little-endian-to-big-endian conversion feature is intended for Fortran unformatted input/output operations in unformatted sequential files. The feature enables the following:
Processing of the files developed on processors that accept big-endian data format
Producing big-endian files for such processors on little-endian systems.
The little-endian-to-big-endian conversion is accomplished by the following operations:
The feature enables the conversion of variables and arrays (or array subscripts) of basic data types. Derived data types are not supported.
In order to use the little-endian-to-big-endian conversion feature, specify the numbers of the units to be used for conversion purposes by setting the F_UFMTENDIAN environment variable. Then, the READ/WRITE statements that use these unit numbers, will perform relevant conversions. Other READ/WRITE statements will work in the usual way.
In the general case, the variable consists of two parts divided by a semicolon. No spaces are allowed inside the F_UFMTENDIAN value. The variable has the following syntax:
Example |
---|
F_UFMTENDIAN=MODE | [MODE;] EXCEPTION |
where the following conditions are true:
Conditions |
---|
MODE = big | little |
and the following conditions apply:
MODE defines current format of data, represented in the files; it can be omitted.
The keyword little means that the data have little endian format and will not be converted. This keyword is a default.
The keyword big means that the data have big endian format and will be converted. This keyword may be omitted together with the colon.
EXCEPTION is intended to define the list of exclusions for MODE; it can be omitted. EXCEPTION keyword (little or big) defines data format in the files that are connected to the units from the EXCEPTION list. This value overrides MODE value for the units listed.
Each list member U is a simple unit number or a number of units. The number of list members is limited to 64.
decimal is a non-negative decimal number less than 232.
Converted data should have basic data types, or arrays of basic data types. Derived data types are disabled.
Command lines for variable setting with different shells:
Shell |
Command Line |
---|---|
Sh |
export F_UFMTENDIAN=MODE;EXCEPTION |
Csh |
setenv F_UFMTENDIAN MODE;EXCEPTION |
Note
Environment variable value should be enclosed in quotes if semicolon is present.
The environment variable can also have the following syntax:
Example |
---|
F_UFMTENDIAN=u[,u] . . . |
Command lines for the variable setting with different shells:
Shell |
Command Line |
---|---|
Sh |
export F_UFMTENDIAN=u[,u] . . . |
Csh |
setenv F_UFMTENDIAN u[,u] . . . |
See error messages that may be issued during the little-endian to big-endian conversion. They are all fatal. You should contact Intel if such errors occur.
The following usage examples illustrate the concepts detailed above.
Example 1 |
---|
F_UFMTENDIAN=big |
All input/output operations perform conversion from big-endian to little-endian on READ and from little-endian to big-endian on WRITE.
Example 2 |
---|
F_UFMTENDIAN="little;big:10,20" |
In this case, only on unit numbers 10 and 20 the input/output operations perform big-little endian conversion.
Example 3 |
---|
F_UFMTENDIAN="big;little:8" |
In this case, on unit number 8 no conversion operation occurs. On all other units, the input/output operations perform big-little endian conversion.
Example 4 |
---|
4. F_UFMTENDIAN=10-20 |
Define 10, 11, 12...19, 20 units for conversion purposes; on these units, the input/output operations perform big-little endian conversion.
Assume you set F_UFMTENDIAN=10,100 and run the following program.
Example 5 |
---|
integer*4 cc4
open(100,file='big.tmp',form='unformatted') |
You can compare lit.tmp and big.tmp files to see the difference of the byte order in these files.
On Linux* systems you can use the od utility to compare the files.
Example output |
---|
> od -t x4 lit.tmp 0000000 00000008 00000315 00000000 00000008 > od -t x4 big.tmp 0000000 08000000 00000000 15030000 08000000 |
You can see that the byte order is different in these files. If info and od are installed on your Linux system, enter info od at the prompt to get more information about the utility.