Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29242 Discussions

Question on USE MODULEname, ONLY: specification

bmchenry
New Contributor II
497 Views

Does specifying each variable from each module in each routine by the

Use MODULEname, ONLY:

command produce code any different than simply including

Use MODULEname

in all routines that need members of a particular module?

I assume that the compiler/linker essentially does the same function as

USE MODULEname, ONLY:

by removing references to unused variables in a routine?

Just wondering if my time/effort spent on ONLY: is worth it? (aside from readability and of course when there is a duplicate variable and/or need to hide a variable)

Thanks

Brian

0 Kudos
3 Replies
Steven_L_Intel1
Employee
497 Views
There is no difference between a simple USE and a USE with ONLY that names all entities exported by a module. Remember that also includes any symbols visible through a nested USE. If the module is very large, such as the Win32 API modules, I like to use ONLY to cut down on the number of symbols the compiler has to cope with, and also for documentation purposes, but in general I don't recommend it unless you have a specific need to limit the symbols imported.
0 Kudos
bmchenry
New Contributor II
497 Views
Ifigured there probably wasn't any difference since it's essentially done by compiler/linker steps. I guess the only real savings is in the COMPILE/LINK step since the compiler and linker are told what varaiables to USE, ONLY: rather than have to sort/figure it out.
Thanks
0 Kudos
Steven_L_Intel1
Employee
497 Views
The linker is not involved here - it's all compiler. What ONLY does is limit the symbols imported from a module - it doesn't change how the compiler uses those symbols once imported.
0 Kudos
Reply