Is there any Fortran keyword equivalent to the C “inline” keyword?
If some compiler-specific keyword exist, is there any for gfortran?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In general, the Fortran specifications grant the compiler writers enormous scope in how to implement things, so a language-level construct that forced (or even hinted) specific optimizations would be very un-Fortran-y.
What you typically do in modern Fortran is not specify optimizations, but tell the compiler things it can use to decide what optimizations to implement. So an example is labelling a side-effect-free function or subroutine
PURE, so that certain optimizations are enabled (and actually, this may make for easier inlining).Otherwise, as @Vladimir F points out, you can use compiler options which are presecriptive in this way.
In a similar vein, it seems that
CONTAINed subprogram are more aggressively inlined by gfortran, but that may or may not help.