Local Control Directives

The following directives provide local control over specific compiler features.

The following directives provide local control over specific compiler features. The -f and -R command line options apply to an entire compilation, but these directives override any command line specifications for source form or bounds checking.

[NO]BOUNDS

!DIR$ BOUNDS [ array [, array ] ... ]
!DIR$ NOBOUNDS [ array [, array ] ... ]
array
The name of an array. The name cannot be a subobject of a derived type. When no array name is specified, the directive applies to all arrays.

Array bounds checking provides a check of most array references at both compile time and run time to ensure that each subscript is within the array's declared size. Bounds checking behavior differs with the optimization level. Bounds checking is not performed on arrays dimensioned as 1. Enables -Ooverindex. Complete checking is guaranteed only when optimization is turned off by specifying -O 0 on the ftn command line.

The -R command line option controls bounds checking for a whole compilation. The BOUNDS and NOBOUNDS directives toggle the feature on and off within a program unit. Either directive can specify particular arrays or can apply to all arrays.

Equivalent to the -Rb option and added to improve C/Fortran command line compatibility.

BOUNDS remains in effect for a given array until the appearance of a NOBOUNDS directive that applies to that array, or until the end of the program unit. Bounds checking can be enabled and disabled many times in a single program unit.

To be effective, these directives must follow the declarations for all affected arrays. It is suggested that they be placed at the end of a program unit's specification statements unless they are meant to control particular ranges of code.

The bounds checking feature detects any reference to an array element whose subscript exceeds the array's declared size.
    REAL A(10)
C DETECTED AT COMPILE TIME:
     A(11) = X
C DETECTED AT RUN TIME IF IFUN(M) EXCEEDS 10:
     A(IFUN(M)) = W

The compiler generates an error message if it detects that an array element section reference with an out-of-bounds subscript attempts to reference memory. If the compiler cannot detect the out-of-bounds subscript (for example, if the subscript includes a function reference), a message is issued for out-of-bound subscripts when the program runs, but the program is allowed to complete execution.

Bounds checking does not inhibit vectorization but typically increases program run time. If an array's last dimension declarator is *, checking is not performed on the last dimension's upper bound. Arrays in formatted WRITE and READ statements are not checked.

Array bounds checking does not prevent operand range errors that result when operand prefetching attempts to access an invalid address outside an array. Bounds checking is needed when very large values are used to calculate addresses for memory references.

If bounds checking detects an out-of-bounds array reference, a message is issued for only the first out-of-bounds array reference in the loop.
DIMENSION A(10)
      MAX = 20
      A(MAX) = 2
      DO 10 I = 1, MAX
         A(I) = I
10    CONTINUE
      CALL TWO(MAX,A)
      END
      SUBROUTINE TWO(MAX,A)
      REAL A(*)  ! NO UPPER BOUNDS CHECKING DONE
      END
The following messages are issued for the preceding program:
lib-1961 a.out: WARNING
  Subscript 20 is out of range for dimension 1 for array
  'A' at line 3 in file 't.f' with bounds 1:10.
lib-1962 a.out: WARNING
  Subscript 1:20:1 is out of range for dimension 1 for array
  'A' at line 5 in file 't.f' with bounds 1:10.

FREE and FIXED

!DIR$ FREE
!DIR$ FIXED

The FREE and FIXED directives specify whether the source code in the program unit is written in free source form or fixed source form. The FREE and FIXED directives override the -f option, if specified, on the command line.

These directives apply to the source file in which they appear, and they allow for switching source forms within a source file.

Source form can be changed from within an INCLUDE file. After the INCLUDE file has been processed, the source form reverts back to the source form that was being used prior to processing of the INCLUDE file.

OPTIMIZE

!DIR$ OPTIMIZE (option option)

The OPTIMIZE directive enables/disables optimization in the program unit in which it appears, overriding the optimization level set via the compiler command line. This directive may only appear in the declarative section of a program unit. A program unit may be a program, subroutine, function, module, or submodule, but not block data program unit.

OPTIMIZE does not affect any modules invoked with the USE statement in the program unit that contains them. They do affect CONTAINed procedures that do not include an explicit OPTIMIZE directive.

The OPTIMIZE directive with no option specified is equivalent to OPTIMIZE -O2.

The OPTIMIZE directive accepts the following subset of the command line options which control optimization. Refer to crayftn(1) for a description of these options.

The OPTIMIZE directive accepts the following subset of the command line options which control optimization. Refer to crayftn(1) for a description of these options.
  • -O level
  • -h acc
  • -h acc_model=
  • -h add_paren
  • -h [no]aggress
  • -h align_arrays
  • -h [no]autothread
  • -h [no]autoprefetch
  • -h cache n
  • -h concurrent
  • -h contiguous
  • -h contiguous_assumed_shape
  • -h flex_mp=level
  • -h fp n
  • -h fp_trap
  • -h fusion n
  • -h infinitevl
  • -h loop_trips
  • -h msgs
  • -h negmsgs
  • -h nointerchange
  • -h omp
  • -h overindex
  • -h page_align_allocate
  • -h [no]pattern
  • -h scalar n
  • -h shortcircuit level
  • -h thread n
  • -h unroll n
  • -h vector n
  • -h zero

See the OPTIMIZE(7) man page.