Reputation: 1715
Is there any way to list all the variables that are defined in a Fortran 77 program, including
I was hoping there might either be some dedicated software that could do this, or some compiler flags with e.g. gfortran.
Upvotes: 1
Views: 394
Reputation: 18098
Have you tried grep
? This is a short snippet to give you the occurrences of the base types:
for i in byte character integer logical \
real "double[[:blank:]]+precision" \
complex "double[[:blank:]]+complex" ; do
grep -Ein "^[[:blank:]]*${i}[[:blank:]\*(,:]" $(find . -name "*.[fF]*")
done
Of course, this will only work if you are using explicit type declaration throughout your code.
Explanation:
Use grep
with regular expressions (-E
) and case-insensitive matches (-i
) to print out the line number and file (-n
) on all Fortran files *.[fF]*
in the current folder.
The Regex is:
"^[[:blank:]]* Only whitespaces (if any) in the beginning
${i} Followed by the variable type
[[:blank:]\*(,:]" Followed immediately by a whitespace, "*",
"(", ",", or ":"
Upvotes: 1