8.4.4 Recursive Inlining Examples

The /inline_depth qualifier sets the maximum level of subprogram nesting that KAP will attempt to inline. Higher values cause KAP to trace calls and function references further.

Consider the following simplified example:

  PROGRAM EXDDEM
  REAL  A,B,C,D,E,F,G

  CALL S1 (A,B)
  CALL S2 (C,D,E,F)
  CALL S3 (G)

  PRINT *,A,B,C,D,E,F,G
  END

  SUBROUTINE S1 (W,X)
  REAL W,X
  W=1.0
  CALL S4(X)
  RETURN
  END
  SUBROUTINE S2 (Q,R,S,T)
  REAL Q,R,S,T
  Q = 2.0
  CALL S1 (R,S)
  CALL S3 (T)
  RETURN
  END

  SUBROUTINE S3 (U)
  REAL U
  U = 137.0
  RETURN
  END

  SUBROUTINE S4 (V)
  REAL V
  V = 2.7
  RETURN
  END

When run with /inline and /inline_depth=4 , all the subroutines are inlined, including calls to calls to calls, and the main program becomes:

 PROGRAM EXDDEM
 REAL  A,B,C,D,E,F,G
 EXTERNAL S4

 A = 1.0
 B = 2.7
 C = 2.0
 D = 1.0
 E = 2.7
 F = 137.0
 G = 137.0

 PRINT *, A, B, C, D, E, F, G
 END

When run with /inline and /inline_depth=1 , meaning inline only one routine deep, all the calls in the main program and subroutines are expanded, but calls in inlined routines are not. The main program becomes:

 PROGRAM EXDDEM
 REAL  A,B,C,D,E,F,G
 EXTERNAL S4

 A = 1.0
 CALL S4 (B)
 C = 2.0
 CALL S1 (D,E)
 CALL S3 (F)
 G = 137.0

 PRINT *, A, B, C, D, E, F, G
 END

When run with /inline and /inline_depth=- 1 (inline only routines that do not contain calls or function references), the main program becomes:

PROGRAM EXDDEM
REAL  A,B,C,D,E,F,G

CALL S1 (A,B)
CALL S2 (C,D,E,F)
G = 137.0

PRINT *, A, B, C, D, E, F, G
END

In this last case, only subroutines S3 and S4 could be inlined. Repeated runs with /inline_ depth=1 can be used to inline additional levels of routines.


Previous Page | Next Page | Contents | Index |
Command-Line Qualifiers

Copyright © Digital Equipment Corporation. 1999. All Rights Reserved.