- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, the application that I am developing has grown over a number of years and my programming has improved with time. I have many modules in my application many of which are simply declarations and contain no routines or functions. In the process of tidying my code I would like to remove USE statements where applicable, i.e. where the declarations in the module are not used in the routine. To do this I could look at each routine, comment out a USE statement and then see if it compiles - removing it if it does and retaining it if it does not compile. As I have some 5000 routines this will take me some considerable time to perform. I wonder whether, like in the Fortran=>Diagnostics of the project properties page, there is an option/switch somewhere to warn the user if a routine is using a module that is not required?
Thanks,
Angus.
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, there is not a diagnostic like that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think if you declare a variable in a module and USE it in a routine where you also declare the variable, you will get a compilation error message that the declaration clashes with one in a USE statement.
On the other hand, if you always declare IMPLICIT NONE in your routines and remove a USE statement for a module from the routine, on compilation you will get warnings about all the variables that are now not declared that were previously declared in the module.
On the other hand, if you always declare IMPLICIT NONE in your routines and remove a USE statement for a module from the routine, on compilation you will get warnings about all the variables that are now not declared that were previously declared in the module.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That's correct, I use IMPLICIT NONE always and then hunt for unused modules by commenting out and recompiling. But it is a time consuming task to perform manually and I was hoping there might be a facility within the compiler to map module usage. However, Steve thinks not so I shall revert to manual.
Thanks,
ACAR.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How many modules are you talking about?
What about taking a module, creating a copy, renaming and saving the original under a temporary name then edit the copy to be empty. Delete the original module from your project and add the edited empty copy to the project. Compile and USE this empty module. Then, compile the routines and where you actually need the module, using the empty module will give you (alot of) diagnostics?
What about taking a module, creating a copy, renaming and saving the original under a temporary name then edit the copy to be empty. Delete the original module from your project and add the edited empty copy to the project. Compile and USE this empty module. Then, compile the routines and where you actually need the module, using the empty module will give you (alot of) diagnostics?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
One of the free fortran compilers at least (g95) has some capability in this area (I know it can warn at least about symbols from modules that are USE'd but not used, I'm not so sure about the modules themselves). If your codes are f95 only you may be able to use it in parallel with ifort. For some projects I maintain a build system that allows changing the compiler primarily for the opportunity to see different diagnostics and checks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A good suggestion but it is all a little manual. I was hoping for an automated approach to module management from Intel. This seems unavailable at this time so I shall probably resort to a method like this or, depending on available time, I shall ignore and assume/hope that USEing modules within a routine from which no variables are actually used does not incur any overhead. Thanks for your suggestion anthonyrichards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That is a good idea IanH. My code is f95 and so I might give this a try. Thanks, ACAR.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page