nosideeffects
- Date:
02-09-2023
NAME
nosideeffects - declare that a called subprogram does not redefine selected variables
SYNOPSIS
!DIR$ NOSIDEEFFECTS f [, f ...]
DESCRIPTION
The NOSIDEEFFECTS directive allows the compiler to keep information in registers across a single call to a subprogram without reloading the information from memory after returning from the subprogram. This directive is not needed for intrinsic functions or VFUNCTIONS.
NOSIDEEFFECTS declares that a called subprogram does not redefine any variables that meet the following conditions:
Local to the calling program
Passed as arguments to the subprogram
Accessible to the calling subprogram through host association
Declared in a common block or module
Accessible through USE association
This directive supports one argument:
- f
Symbolic name of a subprogram that the user is sure has no side effects. f must not be the name of a dummy procedure, module procedure, or internal procedure.
A procedure declared NOSIDEEFFECTS should not define variables in a common block or module shared by a program unit in the calling chain. All arguments should have the INTENT(IN) attribute; that is, the procedure must not modify its arguments. If these conditions are not met, results are unpredictable.
The NOSIDEEFFECTS directive must appear in the specification part of a program unit and must appear before the first executable statement.
The compiler may move invocations of a NOSIDEEFFECTS subprogram from the body of a DO loop to the loop preamble if the arguments to that function are invariant in the loop. This may affect the results of the program, particularly if the NOSIDEEFFECTS subprogram calls functions such as the random number generator or the real-time clock.
The effects of the NOSIDEEFFECTS directive are similar to those that can be obtained by specifying the PURE prefix on a function or a subroutine declaration.
SEE ALSO
intro_directives(7)
Cray Fortran Reference Manual