Skip to content

Instantly share code, notes, and snippets.

@Beliavsky
Created August 22, 2021 00:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Beliavsky/1d56773afa9391738d3bd8cdc9b3be03 to your computer and use it in GitHub Desktop.
Save Beliavsky/1d56773afa9391738d3bd8cdc9b3be03 to your computer and use it in GitHub Desktop.
Convert free source form Fortran to lower case, except for comments
"""convert Fortran code to lower case except for comments
usage: python xlower_case_fortran.py <source_file>
The script writes lower case code to standard output.
"""
from sys import argv
source_file = argv[1]
fp = open(source_file,"r")
for line in fp:
text = line.rstrip()
ipos = text.find("!")
if ipos >= 0:
print(text[:ipos].lower() + text[ipos:])
else:
print(text.lower())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment