Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/31/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

INLINE, FORCEINLINE, and NOINLINE

General Compiler Directives: Tell the compiler to perform the specified inlining on routines within statements or DO loops.

!DIR$ INLINE [RECURSIVE]

!DIR$ FORCEINLINE [RECURSIVE]

!DIR$ NOINLINE

The INLINE directive specifies that the routines can be inlined.

The FORCEINLINE directive specifies that a routine should be inlined whenever the compiler can do so. This condition can also be specified by using compiler option [Q]inline-forceinline.

The NOINLINE directive specifies that a routine should not be inlined.

These directives apply only to the immediately following statement or DO construct. All statements within the immediately following DO construct are affected.

If keyword RECURSIVE is specified, the specified inlining is performed when the routine calls itself directly or indirectly.

The inlining can be ignored by the compiler if inline heuristics determine it may have a negative impact on performance or will cause too much of an increase in code size.

CAUTION:

When you use directive FORCEINLINE, the compiler may do so much additional inlining that it runs out of memory and terminates with an "out of memory" message.

Example

Consider the following:

!DIR$ INLINE
A = F(B) + G(C)  ! inline the call to function F and inline the call to function G
 
!DIR$ INLINE
   DO I = 1, N
      CALL F1 ( G1(A), G2(A)) ! inline the call to F1 and the function executions of G1 and G2
      !DIR$ NOINLINE
         DO J = 1, M
            M(J) = F (M(J))   ! do not inline this call to F {M is a data array}
         END DO
      M(I) = F2 (X)           ! F2 gets inlined from the directive before DO I

      !DIR$ FORCEINLINE RECURSIVE
      CALL F3 ()       ! F3 must be inlined and it calls itself recursively so inline those calls too
   END DO