The -inline_depth
switch sets the maximum level of
subprogram nesting that KAP will attempt to inline. Higher values
instruct 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, including calls to calls to calls, are
inlined, and the main program becomes the following:
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
(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 the following:
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
, meaning, inline only routines that do not contain CALLs or
FUNCTION references, the main program becomes the following:
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.