How can I visualize Fortran (90 or later) source code, e.g. using Graphviz?

EMiller picture EMiller · Jul 1, 2010 · Viewed 10.4k times · Source

I've been thrown into a large Fortran project with a large number of source files.

I need to contribute to this project and it would seem prudent that I first understand the source.

As a first step, I'd like to visualize the interdependences between the various source files, i.e. which source files need which modules. As far as I can tell, automated methods exist for other languages and result in a graph that can be built using Graphviz.

But is anyone aware of software out there that can do this for Fortran 90 code?

[Searching the interwebs for Fortran help is a real pain as you end up searching the inter-cobwebs thanks to the painfully ubiquitous FORTRAN 77.]

Answer

Chris picture Chris · Jan 17, 2012

I would recommend doxygen, which automatically generates documentation from source code (and is free). Usually you add some markup to comments describing your functions and variables. However, you can just run doxygen on undocumented source files, provided you set EXTRACT_ALL to YES in the configuration file, and have it create create relationship diagrams for all your functions (i.e. this function call these functions and is called by these other functions).

You need GraphViz installed to get diagrams generated and have the HAVE_DOT option set to YES in the configuration file.

See the doxygen documentation for graphs and diagrams for more information and this example class documentation for a example of the output generated.

Edit: Of course for Fortran you should set the OPTIMIZE_FOR_FORTRAN option to YES in the configuration file.