you may have come across a situation where you rename variables in large projects and it takes you a week to get it consistent such that the compiler doesn’t complain. For example, changing subroutine
subroutine s(foo,bar) to
subroutine s(fooo,bar) will require to change any
call s(foo=a,bar=b) to
call s(fooo=a,bar=b). The same holds for derived type member variables where the variable is accessed directly (so not through get/set).
I am wondering whether there is any automatic tool to do this job.
Maybe Photran, recommended here. I have not tried it.
And here I thought Photran was the name of an Asian restaurant near the University of Illinois (UIUC) campus.
CLion ($) features a Fortran plug-in and does quite well in source code refactoring.
Is anybody using eclipse/eclipse-photran actively?
We’re about evaluate it in a project I’m working on for doing (hopefully) removal of unused variables and arguments.
Isn’t there a compiler flag for unused variables?!
I just had a quick glance at the eclipse interface, and for somebody coming from the emacs/makefile league it looks all too much. However, I was wondering how I can attached an existing project to it which runs from an operational makefile, e.g. five hierachical libraries and several executables using those libraries. Any hint appreciated.
Yes, most compilers have flags that will tell you about unused variables and arguments, but if you’ve got lots of them, it’d be nice to have a tool that can automatically remove them all from your source code. Or at least make the process a lot easier.
I am interested in a tool that removes unused variables. They commonly arise in my code when I have refactored a chunk of code into a subroutine. Here is Python 3 code that splits declarations (after the
real :: part) into individual variables. One can use it to rewrite declarations after omitting specified variables.
str = "x,y(n),z(n,n),a(m)"
words = re.split('(,(?=[^\\)]*(?:\\(|$)))',str)
var = [w for w in words if w != ","]
['x', 'y(n)', 'z(n,n)', 'a(m)']. I know I am recreating the wheel.
Camfort/fortran-src is a currently maintained Haskell tool on GitHub that
Provides lexing, parsing, and basic analyses of Fortran code covering standards: FORTRAN 66, FORTRAN 77, Fortran 90, Fortran 95 and part of Fortran 2003. Includes data flow and basic block analysis, a renamer, and type analysis.
I have not tried it.
The web page is here:
A 1.0.1 release is in preparation. Does anyone already used that tool?