Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename all files to .f90 #16

Merged
merged 1 commit into from
Jul 8, 2019
Merged

Rename all files to .f90 #16

merged 1 commit into from
Jul 8, 2019

Conversation

amlrg
Copy link
Contributor

@amlrg amlrg commented Jun 17, 2019

Later versions of gfortran think that the extension .f signifies a F77 file. This could be remedied by changing the Makefiles and CMakeLists, but I figured might as well change the extension to .f90 given it is F90 code. Ran the following:

find -name '*.f' -exec git mv {} {}90 \;
T=$(mktemp)
for i in $(find -name "CMakeLists.txt")
do
  cat $i | perl -ne 's/\.f(?!p)/.f90/g; print;' > $T && cp $T $i
done
for i in $(find -name "Makefile")
do
  cat $i | perl -ne 's/\.f(?!p)/.f90/g; print;' > $T && cp $T $i
done

Also, the preprocessing script had a few bits where it's python2 exclusive. Changing these allows the script to work for python3 as well (maybe there is a newer version of preprocessor out there somewhere, but the link in the documentation no longer works);

sed 's/Exception,/Exception as/g' -i tools/python/preprocess-0.6.1/preprocess.py
sed 's/Error,/Error as/g' -i tools/python/preprocess-0.6.1/preprocess.py
sed 's/os.chmod(outfile, 0777)/os.chmod(outfile, 0o777)/g' -i tools/python/preprocess-0.6.1/preprocess.py
sed 's/type(outfile) in types.StringTypes/isinstance(outfile, str)/g' -i tools/python/preprocess-0.6.1/preprocess.py
sed 's/type(streamOrFileName) == types.StringType/isinstance(streamOrFileName, str)/g' -i tools/python/preprocess-0.6.1/preprocess.py
sed 's/filenameMap.has_key(basename)/basename in filenameMap/g' -i tools/python/preprocess-0.6.1/preprocess.py
sed 's/suffixMap.has_key(suffix)/suffix in suffixMap/g' -i tools/python/preprocess-0.6.1/preprocess.py

@dmorse
Copy link
Owner

dmorse commented Jun 17, 2019

Thanks very much for this! People here (Univ. of Minnesota) had recently mentioned that
it isn't compiling with the latest gfortran, and I hadn't had a chance to look into why.

I don't know the differences between python 2 and python 3 well enough to see if the modified
code will work with both versions of the language. Have you tried running the preprocessor with
both python2 and python3 interpreters?

I will have to look at the current state of the master and devel branch, and may want to ask you to
request a merge into devel rather than master. I'll get back to you about that after checking the
history.

@amlrg
Copy link
Contributor Author

amlrg commented Jun 18, 2019

@dmorse

The modified script works with both Python3 and 2:
I tested by changing
FORPEDO=$(REPO)/tools/python/preprocess-0.6.1/preprocess.py
to
FORPEDO=python2 $(REPO)/tools/python/preprocess-0.6.1/preprocess.py
where

% python2 --version
Python 2.7.16

As for the branch, sorry for not noticing there was a devel. I can edit the pull request to point to devel if that's your preference, just let me know (or alternatively, I think you as the maintainer will probably be able to do it yourself as well).

@dmorse dmorse merged commit 51c719c into dmorse:master Jul 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants