Skip to content

Instantly share code, notes, and snippets.

@Beliavsky
Last active June 24, 2018 02:22
Show Gist options
  • Save Beliavsky/d37121a95f2fea77643e56798d86ad05 to your computer and use it in GitHub Desktop.
Save Beliavsky/d37121a95f2fea77643e56798d86ad05 to your computer and use it in GitHub Desktop.
Python 2/3 script to list unused variables from gfortran compiler messages
# 2018-06-23
# list unused variable from gfortran output
# valid Python 2 and Python 3
from sys import argv
compiler_message_file = argv[1] # produced by command such as gfortran 2> err_msg.txt -c -Werror=unused_variable source.f90
fp = open(compiler_message_file,"r")
err_str = "Error: Unused variable"
print("unused variables:")
for line in fp:
text = line.strip()
if err_str in text:
print(text.strip(err_str).split()[0].strip("'"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment