Why should I use "use, only" in Fortran

In python a statement like this:

from module import function354

makes sense, because Python is an interpreter language and I don't want python to load all 353 other functions.

Fortran has a similar construct:

use module, only : function354

Why would I use this? The compiler creates a *.mod file anyway, compiling all function. Is there any performance advantage (in compile or run time) if I specify an only-statement?

I can see that it might be helpful to avoid naming conflict, but other than that I don't really see the point.


  • Two main reasons

    1. To avoid name conflicts, as you mention but seem to think unimportant. In a large, complex code anything that helps maintainability is a bonus, so use, only is a useful addition to aid this
    2. It automatically documents where an entity comes from. Given a large, complex code to read for the first time I can almost guarantee you'll be spending time working out what comes from which module, so use, only is a nice feature to aid code readability

    You don't just want fast code - as important is maintainability, and more important is correctness!