Hi,
A quick question.
Over the years our application has acquired routines that I'm sure are no longer being used, but daren't just delete them! Is there a link switch that can list any un-called functions?
K
Welcome to our forums
Hi,
A quick question.
Over the years our application has acquired routines that I'm sure are no longer being used, but daren't just delete them! Is there a link switch that can list any un-called functions?
K
Kenny,
If you suspect a particular routine may not be called anywhere, then you could use the DOS command FIND to search through all your source code files for the name of the routine. This will list the subroutine itself plus any calls if they exist.
Cheers, John
What you need is the opposite of the SLINK switch /lure but I cannot find anything like it.
Plato has a 'Find in Files' command that may be useful.
I have a suspicion that SLINK doesn't link any routines that aren't called, so even if they appear in your source code, they don't make it (as dead code) into the EXE. So, if you can bear the (often negligible) overhead of recompiling them, then everything comes right in the end.
John's suggestion is a good one. You can also search with a text editor. The problem is that sometimes the call is there, but it is never actively pursued, e.g.
IF (KEYBOARD_MODE .EQ. 1) THEN
CALL BRUCE_BOWLER_CODE
ENDIF
does lead to the routine being linked, even if KEYBOARD_MODE is set to something other than 1, because that was an option you abandoned 6 years ago!
Eddie
Bruce has an idea, You could convert most of your code into a library and then use 'le code.lib' in slink. This would then only load the routines that are called. You could then import the .map file into excel and sort it to locate routines that are called. Note:
We realy need a call tree generator like FORCHK use to do for F77, providing a list of all routines that called each routine. SLINK should be able to provide this report.
Eddie's suggestion that SLINK does not load unused routines certainly was not the case with older versions of SLINK. I have not tested this recently, but I would suspect it is not that smart. SLINK could/should be a lot smarter!
John
Thanks for all the suggestions. Thought of most of them myself already - I'd even tried some of them (but got bored)!
Perhaps I'll write something to do it at one level (ie grep for all the SUBROUTINE/FUNCTIONs, output the list to a file, then search through all my source for each item and count how many times each one occurs...) but that wouldn't capture a routine that was called from an un-called routine, so may only be of limited use...
K
I have my own tool for doing this (written in Fortran 😃 ). It just looks for all occurances of MODULE, SUBROUTINE, FUNCTION across multiple files, extracts the names and checks there's at least one use somewhere. (USE, CALL or Function name).
I would be happy to post this here for people to use. (will do it when I'm near to my main machine).
David.