| |||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||
|
Porting Codes 1Default Data Sizes
The following tables show the default data sizes, in terms of the number of bits
or bytes, of Fortran and C/C++ standard data types. The Fortran table also shows the
changes to the default data sizes when applying the compiler flags
In Fortran 90, the difference in default sizes of real and integer variables between machines can be overcome by using parameterised data types. For example if you create a module with the following:
and use this as follows:
short_int will always have a type which permits integers of at least 10**6 and
However if you are converting codes which make calls to external libraries,
you may still need to change the names in calls to those library routines,
such as changing the BLAS
routine SGEMM for (Single precision) matrix multiplication on a Cray
T3E to (Double precision) DGEMM on the CSAR machines as single precision
Changing the Default Sizes in Fortran
Many Fortran codes, particularly legacy codes, have been written with
In order to make it easier to change the precision of floating point
calculations in Fortran codes, most compilers, including the MIPSpro and Intel
compilers on the Origin and Altix machines, use a standard compiler flag of
It should be noted that on modern processors 64 bit arithmetic is as fast as 32 bit arithmetic when carrying out floating point addition, subtraction and multiplication. Division and hardware square root calculations may be slower, but the impact on the execution time of an entire code of increasing precision from 32 bit to 64 bit floating point arithmetic is usually only one or two per cent.
Furthermore, on some computers, such as the Cray T3E, Fortran One other aspect of data which should be mentioned is the transfer of large amounts of binary information between different architectures and the endian nature of the data. Endian refers to the byte ordering of data such as integers and floating point numbers and can be little or big endian depending on whether the least or most significant byte is stored first. This concept is best illustrated by an example. Endian ExampleIf we have the 4 byte hexadecimal number 0x12345678 then we could store this in memory as the 4 byte sequence 0x12, 0x34, 0x56, 0x78 or it could be stored as the 4 byte sequence 0x78, 0x56, 0x34, 0x12, or any other combination. The first of these two sequences shows the byte ordering as big-endian whereas the second ordering is little-endian. Since either big-endian or little-endian storage is equally valid (although proponents of one or other storage system would say theirs is the best) , different manufactures of computer chips have selected one or the other storage mechanism and this is one of the main reasons why data can lose portability between machines. It should be noted that there are other differences between storage formats, particularly in how to delimit Fortran records, but the endian nature of storage is usually the most significant difference. On the Origin's MIPS processors, data is stored in a big-endian format, while on the Itanium chips on the Altix the format is little-endian, and this means that it is not straightforward to transfer binary files between the two systems.
In order to aid in the transfer of binary files between different architectures
where the intention is to use Fortran programs to read or write the data, the
compiler vendors have devised methods of modifying the behaviour of the
input/output routines on their systems. On the Origin machines it is possible to
use the Standard Precision in Fortran
A good way of writing new Fortran code in a manner which allows a quick change
of precision between standard
which defines the parameter sp to be refer to single precision
(i.e.
|
||||||||||||||||||||||||||||||||||||||||||||
Page maintained by csar-advice@cfs.ac.uk This page last updated: Tuesday, 17-Aug-2004 15:32:54 BST |