Intel® Fortran Compiler 18.0 Developer Guide and Reference

OPTIONS Directive

General Compiler Directive: Affects data alignment and warnings about data alignment. Also controls whether a target attribute is assigned to a section of program declarations.

!DIR$ OPTIONS option[option]

...

!DIR$ END OPTIONS

option

Is one (or more) of the following:

/OFFLOAD_ATTRIBUTE_TARGET=target-name

Controls whether a target attribute is assigned to a section of program declarations. The declarations can contain interface definitions and variable declarations. This option enables statements to execute on the target.

Currently, the only supported value for target-name is mic.

This option is useful for properly declaring variables and function names used in offloaded code within the subprogram in which the directive appears. You cannot use it for offloading a complete routine.

/WARN=[NO]ALIGNMENT

Controls whether warnings are issued by the compiler for data that is not naturally aligned. By default, you receive compiler messages when misaligned data is encountered (/WARN=ALIGNMENT).

/[NO]ALIGN[= p]

Controls alignment of fields in record structures and data items in common blocks. The fields and data items can be naturally aligned (for performance reasons) or they can be packed together on arbitrary byte boundaries.

p

Is a specifier with one of the following forms:

[class=]rule

(class= rule,...)

ALL

NONE

class

Is one of the following keywords:

  • COMMONS: For common blocks

  • RECORDS: For records

  • STRUCTURES: A synonym for RECORDS

rule

Is one of the following keywords:

PACKED

Packs fields in records or data items in common blocks on arbitrary byte boundaries.

NATURAL

Naturally aligns fields in records and data items in common blocks on up to 64-bit boundaries (inconsistent with the Standard Fortran).

This keyword causes the compiler to naturally align all data in a common block, including INTEGER(KIND=8), REAL(KIND=8), and all COMPLEX data.

STANDARD

Naturally aligns data items in common blocks on up to 32-bit boundaries (consistent with the Standard Fortran).

This keyword only applies to common blocks; so, you can specify /ALIGN=COMMONS=STANDARD, but you cannot specify /ALIGN=STANDARD.

ALL

Is the same as specifying OPTIONS /ALIGN, OPTIONS /ALIGN=NATURAL, and OPTIONS /ALIGN=(RECORDS=NATURAL,COMMONS=NATURAL).

NONE

Is the same as specifying OPTIONS /NOALIGN, OPTIONS /ALIGN=PACKED, and OPTIONS /ALIGN=(RECORDS=PACKED,COMMONS=PACKED).

The OPTIONS (and accompanying END OPTIONS) directives must come after OPTIONS, SUBROUTINE, FUNCTION, and BLOCK DATA statements (if any) in the program unit, and before the executable part of the program unit.

The OPTIONS directive supersedes the compiler option align and the compiler option [q or Q]offload-attribute-target.

For performance reasons, Intel® Fortran aligns local data items on natural boundaries. However, EQUIVALENCE, COMMON, RECORD, and STRUCTURE data declaration statements can force misaligned data. If /WARN=NOALIGNMENT is specified, warnings will not be issued if misaligned data is encountered.

NOTE

Misaligned data significantly increases the time it takes to execute a program. As the number of misaligned fields encountered increases, so does the time needed to complete program execution. Specifying /ALIGN (or compiler option align) minimizes misaligned data.

If you want aligned data in common blocks, do one of the following:

If you want packed, unaligned data in a record structure, do one of the following:

Example

! directives can be nested up to 100 levels
  !DIR$ OPTIONS /ALIGN=PACKED     ! Start of Group A
    declarations
  !DIR$ OPTIONS /ALIGN=RECO=NATU     ! Start of nested Group B
    more declarations
  !DIR$ END OPTIONS                  ! End of Group B
    still more declarations
  !DIR$ END OPTIONS               ! End of Group A

The OPTIONS specification for Group B only applies to RECORDS; common blocks within Group B will be PACKED. This is because COMMONS retains the previous setting (in this case, from the Group A specification).

In the following example that applies only when targeting Intel® Xeon Phi™ products, the target attribute is passed to function h and real variables a and b.

SUBROUTINE f(x)
REAL x
INTERFACE
   SUBROUTINE g(y)
   REAL y
   END SUBROUTINE g
END INTERFACE
!DIR$ OPTIONS /OFFLOAD_ATTRIBUTE_TARGET=mic
INTERFACE
   FUNCTION h (z)
   REAL z
   END FUNCTION h
END INTERFACE
REAL a, b
!DIR$ END OPTIONS
...
END SUBROUTINE f

The following example demonstrates incorrect usage of the mic setting.

!DIR$ OPTIONS /OFFLOAD_ATTRIBUTE_TARGET=mic
SUBROUTINE INVALID()
...
END SUBROUTINE INVALID
!DIR$ END OPTIONS

See Also