Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Refactoring code based on coverage

awa5114
Beginner
434 Views

I have inherited a large, messy Fortran code developed at different stages in time by different people. The code is poorly documented and many of the individuals responsible for development are not available (i.e they do not work at the company anymore).

One application I would like to achieve is to refactor the code based on coverage for a particular test. Each individual test covers only 10-20 percent of the code at any given time. If I'm fixing one test at a time it is truly overkill to have to go through the entire code. I need a reduced version of the same code which is guaranteed to run that particular test, but which doesn't contain all the extra crap I don't need. This would enable fast and efficient determination of how the parameters influence one another. It would save an enormous amount of time because I would know for sure that everything I'm looking at in this reduced version of the code is relevant.

I have tried many things, such as:

  • writing python codes to read the Intel generated HTML coverage files and sort the contents by coverage
  • Looked into automatic refactoring tools. There are a lot of publications regarding this, but nothing of any practical value. The closest thing I have seen is https://github.com/Yelp/undebt. But I think this package is a long shot. A steep learning curve, but not too sure whether it would help.
  • Learned to use regex to better target search queries in Find and Replace
  • Looked into f2py python package, but it turns out this is really more of a tool to call fortran routines from python. Not designed for static analysis or similar other applications.

So far I have been refactoring the code manually using the test of interest, a coverage analysis result and tracking changes using a local svn repository so I don't get lost. This takes an unrealistic amount of time for each test. I realize this is a highly specific problem case but at the same time I know many legacy fortran codes are just as huge, and possibly encounter the same problems. Am I doomed to having to custom-develop something for this use-case or are there efficient tools out there that can alleviate my misery?

0 Kudos
1 Reply
Joachim_Herb
Beginner
434 Views

I guess you know it, but just for reference:

https://sourceforge.net/projects/pfunit/?source=typ_redirect

is a framework for creating and executing Unit Tests for Fortran.

0 Kudos
Reply