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
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
連結已複製
9 回應
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
Regards
Alan
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
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
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
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
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
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
