I need a Fortran source code beautifier developed in Python.
- case: options
= everything uppercase
= only keywords uppecase
= everything lowercase
= same, but preserve variables that are already mixed case
but: leave comments and strings intact
- indentation: size of indent is a parameter
= if- statement, do- loops, select case- statements
= continued long subroutine calls and long variable declaration list: after continuation lines should be indented as +n wrt starting line,
- variable declarations: rewrite variable declarations to Fortran 90 style:
integer n, m(10,20)
integer :: n, m(10,20)
same for all other types (real, complex)
option to convert back and forth between
character(len=10) :: str
Feature to reformat back and forth between F77 fixed format and F90 free source format
(in F77 line continuation character must be '&')
= option of space/no space after ',' in variable declarations, subroutine parameters, etc
= if (stmt1 .and. stmt2) then ...
= spacing arithmetic expressions is same as in all well-established languages (a + b*c), a = 3
= option (default=no spaces) in array dimensions: a(1,2)
= no space in subrotine calls around '(', ')':
call foo(1, b, c(2,3))
= option: space/no space in 'end do enddo', 'end if endif'
In case of doubt follow common sense, refer to Google C++ or Python style guide or ask me.
UPDATE: Additional features
- in case of IMPLICIT REAL*8 (A-H,O-Z) replace by IMPLICIT NONE and construct corresponding explicit variable declarations: all variables used in given subroutine should be grouped by type and explicitly declared
- remove unused variables
NOTE: as example of beautiful Fortran code refer to http://www.cp2k.org/. By the way, as part of CP2K there is Python normalizer which performs good Fortran beautification and can be used as a baseline.
3 freelancers are bidding on average $244 for this job
Cross platforms code rewrite engineering is among my passionate IT subjects. Based on this clear check-list requirements, I can deliver for you a high quality code as I am teaching it to my students.