is a set of Python scripts to mark Fortran procedures as pure or elemental, add argument intents, and declare module procedures, constants, and variables as private when possible. The scripts test that the code still compiles after the changes. @rouson has advised that procedures should be pure.
4 Likes
I have a question: I notice the tool skips procedures defined in interface blocks:
subroutine test1(a)
integer, intent(in), value :: a
end subroutine
subroutine test2(a)
integer, intent(in), optional :: a
end subroutine
interface
module subroutine test3(a)
integer, intent(in), value :: a
end subroutine
end interface
subroutine test4(a)
integer, intent(in), value :: a
end subroutine
Then python xpure.py a.f90 --verbose show:
3 Likely PURE candidates (not currently marked pure/elemental):
- subroutine test1 [lines 1-3]
- subroutine test2 [lines 5-7]
- subroutine test4 [lines 15-17]
test3 is ignored here. Is it because the tools analyzes the contents of the function (calls, etc.), not only its arguments?
It does look at the body of a procedure to determine if it can be pure. For example, inserting print*,a in test1 causes it to no longer be a candidate for pure.
1 Like
Thank you. I was about to suggest to process interfaces for bind(c) procedures (I think they can be marked pure as well, and should be in order to be called by pure Fortran procedures), checking the arguments only. But on second thought this looks too dangerous.