fpt and WinFPT Reference Manual - Command-line Commands

| SimCon Home | Ref Manual Home |

CHECK ALIGNMENT

Syntax:

[DO NOT] CHECK [MEMORY] ALIGNMENT

Function:

Checks that objects in COMMON blocks, and objects in local arrays, derived types, structures and groups of equivalenced variables, start on aligned memory addresses.

Many systems access memory in 4 or 8 byte units, which are read or written at addresses which must be multiples of 4 or 8. The number of bytes read or written is the 'alignment granularity' of the system. If the granularity is 4 bytes, for example, then a 4-byte integer which does not start on a 4-byte boundary must be read by reading two 4-byte regions, and then by shifting and combining the data. The consequence is that memory is accessed much more efficiently if objects start on 'aligned' addresses, addresses which are multiples of the alignment granularity. Some systems are actually unable to access 4 or 8 byte objects which do not start on aligned addresses. This issue therefore affects portability as well as efficiency.

The declaration of objects in a Fortran COMMON block, the declaration of Fortran derived types and structures or the explicit equivalencing of objects, rigidly defines the absolute or relative addresses of the objects. fpt checks that the addresses are aligned appropriately according to the following rules:

  1. The alignment granularity required for each object is computed as the data size of the object, or the system alignment granularity, whichever is the smaller. Thus, for example, if a variable is declared as COMPLEX*16 on a system with an alignment granularity of 8 bytes, the variable has an alignment granularity of 8. Therefore it should start on an 8 byte boundary. fpt reports a warning if any object starts on an address which is not a multiple of its alignment granularity. For example:

Name Sub-prog/Struct Use/COMMON Address Type Size Bounds ---- --------------- ---------- ------- ---- ---- ------ XDOT INTEG,BODY,INTINI POSITN 66 REAL *4

  1. Arrays of types CHARACTER and RECORD are checked to ensure that the second element of the array is not forced to an unaligned address. This occurs if a character array has a character string length which is not a multiple of the system alignment granularity, or if the number of bytes occupied by a record is not a multiple of the largest alignment granularity of its fields. fpt reports a warning if the second element is mis-aligned. Note that if the second element is aligned correctly, then all elements are aligned correctly. An example report is:

Name Sub-prog/Struct Use/COMMON Address Type Size Bounds ---- --------------- ---------- ------- ---- ---- ------ XTEN FILCHK Local CHARACTER *50 (1:4) (Second element of array)

  1. The fields of a structure are checked to ensure that no field is forced to an address within the structure which is not a multiple of the alignment granularity for that field.

The alignment granularity of a system is specified to fpt by the command ALIGNMENT GRANULARITY. By default it is set to 4 bytes.

Checking of the alignment of character variables and array elements may be enabled or suppressed by the command ALIGNMENT CHECK TO CHECK CHARACTER VARIABLES.

Some systems automatically impose a 4 or 8 byte alignment on objects in COMMON blocks, irrespective of the COMMON block declarations. The Gould-SEL (Now Encore) Concept compiler, for example, automatically pads COMMON blocks to force alignment. fpt may be instructed to align objects automatically by the command ALIGN OBJECTS IN COMMON BLOCKS.

Where to Use this Command

Operating system command line Yes
Configuration file, config.fsp Yes
Specification (fsp) files, *.fsp Yes
Interactively, to FPT> prompt Yes
Interactive command files Yes
Embedded in the Fortran code Yes

Default

The checks are not carried out by default (Note that defaults may be changed in the configuration file).

See Also

ALIGNMENT CHECK TO CHECK CHARACTER VARIABLES

ALIGNMENT GRANULARITY

ALIGN OBJECTS IN COMMON BLOCKS

CHECK

Copyright ©1995 to 2024 Software Validation Ltd. All rights reserved.