fpt and WinFPT Reference Manual - Command-line Commands

| SimCon Home | Ref Manual Home |

ALIGN OBJECTS IN STRUCTURES

Syntax:

[DO NOT] ALIGN [OBJECTS] [IN] STRUCTURES

Function:

The command ALIGN OBJECTS IN STRUCTURES instructs fpt to compute addresses in structures so that all objects start on aligned addresses. Note that this command does NOT change the code. It changes the address allocation within the structure, which affects the way in which fpt determines COMMON block and EQUIVALENCE relationships. The command PAD STRUCTURES modifies the code to insert padding variables to enforce alignment.

An aligned address is an address which is a multiple of the alignment granularity of the object, where the first address of a COMMON block, of a group of equivalenced variables, or of a structure, is address zero.

The alignment granularity of a numeric object is computed as the system granularity or the data size of the object, whichever is the smaller. The system granularity is specified by the command ALIGNMENT GRANULARITY.

For the purpose of this command, the alignment granularity of an object of type character is one byte. This differs from the computation used in the CHECK ALIGNMENT command, but conforms to the behaviour of most compilers which force alignment. However, character variables are usually accessed more efficiently if they start on aligned addresses.

The alignment granularity of objects of type RECORD is computed as the granularity of the largest object within the record.

Note that some Fortran compilers have compilation switches to force alignment of objects, and that some force alignment silently, without warning. It is important to find the behaviour of the system in use. When new code is developed, it is recommended that users do not force the alignment of objects with this command, but check the alignment of objects with the command CHECK ALIGNMENT.

Where to Use this Command

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

Default

Alignment is not forced by default (Note that defaults may be changed in the configuration file)

Examples

The structure declaration:

STRUCTURE /PHAS_STR/ CHARACTER*30 GENERIC CHARACTER*30 SPECIFIC CHARACTER*30 SUB_SPECIFIC INTEGER*4 DAY CHARACTER*3 MONTH INTEGER*4 YEAR CHARACTER*30 MAP INTEGER*4 GRID_N INTEGER*4 GRID_E END STRUCTURE

forces some of the integers to mis-aligned addresses. With default packing for, for example, VAX/VMS, fpt reports the addresses:

Name Sub-prog/Struct Use/COMMON Address Type Size ---- --------------- ---------- ------- ---- ---- PHAS_STR MAIN Structure UNTYPED Field(s): GENERIC 0 CHARACTER *30 SPECIFIC 30 CHARACTER *30 SUB_SPECIFIC 60 CHARACTER *30 DAY 90 INTEGER *4 MONTH 94 CHARACTER *3 YEAR 97 INTEGER *4 MAP 101 CHARACTER *30 GRID_N 131 INTEGER *4 GRID_E 135 INTEGER *4

The command % align structures instructs FPT to compute aligned addresses:

Name Sub-prog/Struct Use/COMMON Address Type Size ---- --------------- ---------- ------- ---- ---- PHAS_STR MAIN Structure UNTYPED Field(s): GENERIC 0 CHARACTER *30 SPECIFIC 30 CHARACTER *30 SUB_SPECIFIC 60 CHARACTER *30 DAY 92 INTEGER *4 MONTH 96 CHARACTER *3 YEAR 100 INTEGER *4 MAP 104 CHARACTER *30 GRID_N 136 INTEGER *4 GRID_E 140 INTEGER *4

fpt also inserts warnings in the code where spaces are left in the memory allocation for the structure:

STRUCTURE /PHAS_STR/ CHARACTER*30 GENERIC CHARACTER*30 SPECIFIC CHARACTER*30 SUB_SPECIFIC INTEGER*4 DAY !---------------------^---------------------------------------------- !!! FPT - 2817 Space left in STRUCTURE by forced alignment of object !-------------------------------------------------------------------- CHARACTER*3 MONTH INTEGER*4 YEAR !----------------------^--------------------------------------------- !!! FPT - 2817 Space left in STRUCTURE by forced alignment of object !-------------------------------------------------------------------- CHARACTER*30 MAP INTEGER*4 GRID_N !------------------------^------------------------------------------- !!! FPT - 2817 Space left in STRUCTURE by forced alignment of object !-------------------------------------------------------------------- INTEGER*4 GRID_E END STRUCTURE

See Also:

ALIGN OBJECTS IN COMMON BLOCKS

ALIGNMENT GRANULARITY

CHECK ALIGNMENT

PAD STRUCTURES

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