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

USE ONLY question

Intel_C_Intel
Employee
1,206 Views
I been looking at the fortwan_winprint.f90 example and it contains USE ONLY statements.

In my programs I have only used USE statements.

Is the only reason for using the ONLY statement is to stop the clash of subroutine names.
Or does using the ONLY statement speed up compilation time, reduce execution time, or make a smaller executable file?

Thanks,

David
0 Kudos
9 Replies
llynisa
Beginner
1,206 Views
As far as I can remember from the documentation, USE ONLY certainly speeds up compilation. But I use it every time because I find it a very useful way of documenting which routines & constants have been imported from what modules into my source code.

Regards

Alan
0 Kudos
Steven_L_Intel1
Employee
1,206 Views
ONLY does speed compilation, especially with very large modules, and I also like the documentation issue.

Steve
0 Kudos
Intel_C_Intel
Employee
1,206 Views
I have been going through my code changing USE to USE ONLY.

I find in some places I have to replace USE dfwin with USE dfwin, ONLY : WM_HELP,WM_INITDIALOG, etc.

In other places where WM_HELP & WM_INITDIALOG are used I can remove USE dfwin completely and it compiles OK - I am not using any other USE statements.

Any ideas why this occurs ?

Thanks,
David
0 Kudos
Steven_L_Intel1
Employee
1,206 Views
Got IMPLICIT NONE?

The WM_ symbols are defined in DFWINTY, which is implicitly used by all of the various DFWIN modules. If you aren't using IMPLICIT NONE, then the symbols are undeclared variables and get default typing - probably not what you want.

Steve
0 Kudos
Intel_C_Intel
Employee
1,206 Views
I haven't used IMPLICIT NONE - but in Project Settings - Compilation Diagnostics, I have ticked undeclared symbols.

I'm still confused.

Dsvid
0 Kudos
Steven_L_Intel1
Employee
1,206 Views
How about posting a short example that doesn't use USE statements? I'm interested in seeing it. Do you USE any other modules that USE DFWIN and friends?

Steve
0 Kudos
Intel_C_Intel
Employee
1,206 Views
It's my mistake.
I was sometimes using a "USE MyModule" which I hadn't realised included a USE dfwin.

Thanks,
David
0 Kudos
Steven_L_Intel1
Employee
1,206 Views
Ok - thought it might be something like that.

I strongly suggest that in your modules you use ONLY clauses, and/or use PRIVATE and then make PUBLIC only the symbols you want to export. ONLY is better than PRIVATE for restricting module namespaces, from the compiler's viewpoint, however. (Both is fine!)

Steve
0 Kudos
Intel_C_Intel
Employee
1,206 Views
I replaced my "Use dfwin" with "use dfwin, only:" and found compilation time INCREASED from 10 to 24 minutes.
So I have just gone back to how it was before.

David
0 Kudos
Reply