FORTRAN 77 to Modern Fortran conversion script
programming codeSome time ago, I had posted to bitbucket my code for translating FORTRAN 77 into modern Fortran (Fortran >= 90). I guess at some point bitbucket deleted the repository. So I’m reposting it to github. f2f was originally written in about 2003, when I was in grad school, writing Fortran code for my thesis. I was too young to appreciate the syntax of Fortran 77, and too stubborn to just accept my fate. So I wanted to convert all the Fortran 77 code I had to use into Fortran 90. That’s what prompted me to write this script, and I learned Perl to do it. At the time, Perl seemed to be the obvious language to use for this purpose (and might still be), and yet the other attempts to make conversion scripts were written in Fortran, if I recall. I think Fortran is a terrible language to use for translating a long chunk of text into a different chunk of text. Some years later, Bob Apthorpe rewrote my Perl code and sent it to me. Given that f2f was the first Perl script I had ever written, and his version just looked better, I figured it was probably better, and I just accepted his “pull request” without very much testing (pull request in quotes because git did not even exist then). Even so, since it was essentially a complete rewrite, and since the version control at the time seemed particularly archaic and convoluted to me, I just kept them both and made both available. And since I don’t have any other history of the code, I’ll just post both of them here for historical purposes. Most likely you won’t need the older version, but if one version mangles your code, then maybe give the other a try. But given that it was my first Perl script, it has a special place in my heart. There are no formal tests, and there are so many edge cases in Fortran 77 that it very well might not produce correct output for your very specific code. I’ve never actually seen it produce run-time bugs, only fairly obvious syntax errors that the compiler catches. But it has always been useful to me, when I needed it, and to some of you, too. So here it is.