J3/04-248 To: J3 From: Craig Dedo Date: February 16, 2004 Subject: Alignment Directives Number: Title: Alignment Directives Submitted By: Craig Dedo Status: For Consideration References: Basic Functionality: There should be one or more alignment directives that would allow users to control the storage alignment of sequence structure components, array elements, and COMMON block members. Rationale: Currently, the Fortran standard does not allow the user to specify the storage alignment of COMMON block members, array elements, or sequence structure components. It would be useful to enable the programmer to be able to specify the storage alignment. This is especially true in cases of access to data structures defined in other languages. In most cases, such data structures have very precise ordering and alignment requirements. These alignment requirements may not match the default alignment rules used by the Fortran processor. Estimated Impact: There is no impact on existing codes. It should be relatively easy for vendors to implement this feature since implementors have to do storage space calculations anyway. It should not be difficult to write the specification in the standard. Detailed Specification: We would need to develop a new keyword with a scalar numeric expression as the value. An example of possible syntax is: ALIGN scalar-numeric-expr The scalar-numeric-expr could be of any numeric data type and kind parameter. It would need to be either a constant. If different from integer, it would be converted to integer using the usual rules of numeric conversion. If the magnitude of the result after conversion is too large for the largest kind of integer or is less than 1, an error occurs. If there is no alignment directive in effect, the default value would be processor dependent. Evaluation of the alignment directive would result in subsequent COMMON block members, array elements, and structure members being aligned at a memory storage location that is an integer multiple of the specified alignment value beyond the starting location. The alignment directive would be modal. I.e., it would remain in effect until the processor encounters a different alignment directive or until the end of the scoping unit of the COMMON block, array, or structure, whichever occurs first. Alignment directives of inner structure definitions would take priority over alignment directives of outer structure definitions, but would extend only to the end of the inner structure definition. Arrays could have only one alignment directive, which must be a property of the array. COMMON blocks and structures could have any number of alignment directives. It would be necessary to define the concept of memory storage unit independent of any other storage unit concept such as file storage unit, character storage unit, and numeric storage unit. It would be strongly recommended but not required for the memory storage unit to be an 8 bit octet, where such a definition is practical. History: