This is a question I originally posted on Stackoverflow, and got the recommendation to put it here instead:

In the past I have used ohcount to count the number of lines in our Fortran projects, and that works reasonably fine.

Recently, I stumbled upon Your Code as a Crime Scene by Adam Tornhill and think it is interesting. Code metrics are an essential part of the approach described in the book. It introduces code-maat by the author to analyse code revision history, but also points to the CodeCity tool to map the source code itself. Unfortunately, this kind of mapping is language specific, and CodeCity seems to be relying models produced by InFusion, which in turn is only applicable to C/C++ and Java, as far as I can see (and appears to be discontinued and not for sale anymore).

Is anybody aware of something like CodeCity or InFusion for a Fortran code base? Maybe these tools are just outdated? If there is nothing like that, what kind of recommendable code-metric analysis tools exist at all for Fortran?

I did some searching on the internet and did not find anything, but maybe I am just looking in all the wrong places.


1 Answer 1


Semantic Designs' (my company) Source Code Search Engine (SCSE) provides this capability.

SCSE is mainly used to search large source code bases in many files in multiple programming languages efficiently. It provides a query language that lets one pose an interactive query in terms of the target language(s), and typically finds all the query matches in 1-2 seconds even for 10 million lines of code. Matches are shown as in single lines; one can select a specific match and a page of code surrounding the match will be shown in a window.

SCSE accomplishes this by scanning the code base offline before interactive query usage, and building an index of the various tokens (using language specific lexers) to speed up the queries.

The act of building the index and extracting the tokens provides a surprising opportunity to compute code metrics. SCSE counts:

  • Source Lines of code (nonblank lines containing source code)
  • Lines of comments
  • Blank Lines
  • McCabe Cyclomatic complexity
  • Halstead computation complexity

and builds a summary report in XML and HTML of these facts for each of the many files in the code base provided to it.

SCSE has scanners for some 50 languages, including Fortran77, Fortran95 and more modern dialects.

SCSE runs natively on Windows, but will run on Linux under Wine using a few provided shell scripts to act as if it were native to Linux, including the interactive search GUI.

An unusual metric, the degree of code duplication, can be obtained from Semantic Designs' CloneDR. This tool automatically finds and reports where exact or near-miss clones occur in a code base for a specific language. CloneDR is available for Fortran, for Windows and Linux (seamlessly under Wine).


  • [SCSE] Per file metrics for many languages, including Fortran, C, C++, Java, PHP, ...
  • [SCSE] SLOC, CLOC, BlankLines, Cyclomatic, Halstead measures
  • [SCSE] Free interactive search included :-}
  • [CloneDR] Duplicated code statistics and report
  • Windows native or Linux (under Wine)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.