Anyone know of any tricks to tease out unused STRUCTURE variables from the compiler? I know you can use "-warn unused" to get a list of unused variables that are declared, but this doesn't seem to work with structure members. I have a number of structures that are included via external files that are very old, and I would like to strip out all of the variables in those structures that are unused.
I'm running out of ideas; the paths that have been abandoned thus far include:
- Downloading the gfortran source and attempting to a) modify it to even accept the STRUCTURE statement, and then use the parser in a custom program that builds an array of variable names, etc. This was a complete failure due to the complexity of the gcc parser.
- Doing a temporary global replace of FOO.BAR with FOO_BAR to make the compiler think they aren't structure members at all, but due to the number of variables (approximately 3000), and files (approximately 1200) involved, this became prohibitively time-consuming.
The latest path I'm wandering down is to declare all of the structures as COMMON, and then use the -fverbose-asm feature of ifort and use perl or something to search for the "$struct_name" keywords (where the code is either assigning data to or pulling data from the common block). The line also includes an offset inside that common, which using some yet-undetermined method, can be used to reverse-engineer a list of "holes" in the COMMON that are never referenced. Then it's just a few days of painful math to translate those offsets to variable names.