# Static analysis tools for Fortran source code and call graph visualization

**URL:** <https://fortran-lang.discourse.group/t/static-analysis-tools-for-fortran-source-code-and-call-graph-visualization/10395>\
**Category:** Uncategorized\
**Created:** [September 10, 2025, 9:31am UTC](https://fortran-lang.discourse.group/t/static-analysis-tools-for-fortran-source-code-and-call-graph-visualization/10395 "2025-09-10T09:31:03Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simo](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@Simo](https://fortran-lang.discourse.group/u/Simo)\
**Post date:** [September 10, 2025, 9:31am UTC](https://fortran-lang.discourse.group/t/static-analysis-tools-for-fortran-source-code-and-call-graph-visualization/10395/1 "2025-09-10T09:31:03Z")

</div>

Hello everyone,

Is there a free and reliable tool similar to [GNU cflow](https://www.gnu.org/software/cflow/) for Fortran that can generate call graphs? I am aware of Doxygen and profiling based workarounds using Valgrind Callgrind and KCachegrind ( **dynamic** tools), but I would prefer **static** analysis tool, something like cflow that reads the source code directly and can generate Graphviz DOT output.

Best,

Simo

---

<div class="post-metadata">

**Author:** ![hkvzjal](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/hkvzjal/32/3055_2.png) [@hkvzjal](https://fortran-lang.discourse.group/u/hkvzjal)\
**Post date:** [September 10, 2025, 9:45am UTC](https://fortran-lang.discourse.group/t/static-analysis-tools-for-fortran-source-code-and-call-graph-visualization/10395/2 "2025-09-10T09:45:05Z")

</div>

> [@Visualizing Fortran Projects with fpm: Create Stunning Module Dependency Charts](https://fortran-lang.discourse.group/t/visualizing-fortran-projects-with-fpm-create-stunning-module-dependency-charts/9838):
>
> I just created the project [fpm-modules](https://github.com/davidpfister/fpm-modules), a fpm plugin to generate module dependency graphs. Since it took me some time and research to create it, I wrote a tutorial out of it, hoping it could be useful for anyone else willing to try to use the fpm api. Any comments about this tutorial are more than welcome. Introduction Ever tried to untangle a complex Fortran project? It’s like navigating a maze without a map. Dependency charts can be a lifesaver, showing how modules and source files connect,…

You might want to read that thread

---

<div class="post-metadata">

**Author:** ![Simo](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@Simo](https://fortran-lang.discourse.group/u/Simo)\
**Post date:** [September 10, 2025, 9:48am UTC](https://fortran-lang.discourse.group/t/static-analysis-tools-for-fortran-source-code-and-call-graph-visualization/10395/3 "2025-09-10T09:48:26Z")

</div>

Thanks for sharing that. I have already read it, but my understanding is that it deals with dependencies. Whereas I am asking about generating call graphs: i.e., the **function/subroutine** call relationship extracted from the source code.

---

<div class="post-metadata">

**Author:** ![ivanpribec](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ivanpribec/32/3290_2.png) [@ivanpribec](https://fortran-lang.discourse.group/u/ivanpribec)\
**Post date:** [September 10, 2025, 9:50am UTC](https://fortran-lang.discourse.group/t/static-analysis-tools-for-fortran-source-code-and-call-graph-visualization/10395/4 "2025-09-10T09:50:20Z")

</div>

The **NAG Fortran Compiler** can do this: [NAG Fortran Compiler, Release 7.2: Producing a Call Graph](https://support.nag.com/nagware/np/r72_doc/manual/compiler_2_21.html#CALLGRAPH)

So can **FPT** : [https://www.simconglobal.com/fpt\_ref\_show\_call\_structure.html](https://www.simconglobal.com/fpt_ref_show_call_structure.html)

Edit: I’ve tested the NAG one before on the entire LAPACK and BLAS. I used some custom Python script for post-processing and plotting. Here showing the procedures as randomly positioned nodes with calls represented as edges between them (the arrows can’t be seen because of the poor image resolution; in case someone wants to create a string and nail art I can forward the SVG image 😉, it would make a nice present for Jack Dongarra ).

 ![lapack_and_blas](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/6/6f9bd0d5772bf26eb0efbe785510cc7d44d50346.jpeg)

The top 10 most called procedures are

XERBLA 1381  
LSAME 1174  
SLAMCH 344  
DLAMCH 342  
ILAENV 298  
SROUNDUP\_LWORK 211  
CABS1 162  
SSCAL 121  
DSCAL 120  
SCOPY 107

---

<div class="post-metadata">

**Author:** ![Beliavsky](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Beliavsky](https://fortran-lang.discourse.group/u/Beliavsky)\
**Post date:** [September 10, 2025, 11:46am UTC](https://fortran-lang.discourse.group/t/static-analysis-tools-for-fortran-source-code-and-call-graph-visualization/10395/5 "2025-09-10T11:46:51Z")

</div>

Searching my [list of Fortran tools](https://beliavsky.github.io/Fortran-Tools/), which has a Static Analysis category, for call.\*graph gives the projects below. I don’t know how closely they meet your preferences.

[fortrancallgraph](https://github.com/fortesg/fortrancallgraph): static source code analysis for Fortran, tracking variables in a routine’s callgraph, from fortesg  
[fortran-callgraph](https://github.com/hydro-jules/fortran-callgraph): Tool to create call graphs from JULES source code  
[FORTRAN\_callgraph\_browser](https://github.com/cemac/FORTRAN_callgraph_browser): browsing tool that reads in a directory of Fortran code and displays it as an interactive graph, by Dan Ellis and Richard Rigby  
[FortranTree](https://github.com/imaliyov/FortranTree): parses Fortran source code and creates a call tree graph with Python, by imaliyov. The code relies on pygraphviz and fparser.

---

<div class="post-metadata">

**Author:** ![davidpfister](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/davidpfister/32/3949_2.png) [@davidpfister](https://fortran-lang.discourse.group/u/davidpfister)\
**Post date:** [September 10, 2025, 12:12pm UTC](https://fortran-lang.discourse.group/t/static-analysis-tools-for-fortran-source-code-and-call-graph-visualization/10395/6 "2025-09-10T12:12:27Z")

</div>

You can also have a look at [Doxygen](https://www.doxygen.nl/manual/diagrams.html). Here is a minimal doxyfile to get you started:  
```txt

```auto
INPUT = ./src
HAVE_DOT = YES
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
EXTRACT_STATIC = YES
CALL_GRAPH = YES
CALLER_GRAPH = YES
DISABLE_INDEX = YES 
GENERATE_TREEVIEW = YES
RECURSIVE = YES
COLLABORATION_GRAPH = YES
GRAPHICAL_HIERARCHY = YES
DOT_CLEANUP = NO
GENERATE_HTML = YES
GENERATE_LATEX = NO

```

```

And this is what you can expect (the sample corresponds to the callgraph of daskr)

 ![image](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/b/b4a20a64e2eab970da11caf1d1750378f36fb63c.png)

It works nicely on functional codes (i.e. f77 style).

---

<div class="post-metadata">

**Author:** ![Simo](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@Simo](https://fortran-lang.discourse.group/u/Simo)\
**Post date:** [September 10, 2025, 6:34pm UTC](https://fortran-lang.discourse.group/t/static-analysis-tools-for-fortran-source-code-and-call-graph-visualization/10395/7 "2025-09-10T18:34:13Z")

</div>

Thank you for the suggestion. Actually, your repository was the first thing I looked at, but unfortunately I was disappointed because those tools seem unmaintained (last updated 5 years ago, and I doubt they are still reliable or even working).

@davidpfister

Thanks for the suggestion and your Doxygen example.As I mentioned in my first post, I am already familiar with Doxygen and dynamic tools.

What comes closest to cflow is what @ivanpribec already suggested: the NAG Fortran compiler and fpt.

---

<div class="post-metadata">

**Author:** ![urbanjost](https://avatars.discourse-cdn.com/v4/letter/u/0ea827/32.png) [@urbanjost](https://fortran-lang.discourse.group/u/urbanjost)\
**Post date:** [September 11, 2025, 1:01am UTC](https://fortran-lang.discourse.group/t/static-analysis-tools-for-fortran-source-code-and-call-graph-visualization/10395/8 "2025-09-11T01:01:44Z")

</div>

> **[egypt](https://www.gson.org/egypt/)**

creates a graph for RTL input, and “gfortran -fdump-rtl-expand” should generate RTL from Fortran. You would need Graphviz, gfortran, egypt, perl at least.

---

<div class="post-metadata">

**Author:** ![CRquantum](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/crquantum/32/730_2.png) [@CRquantum](https://fortran-lang.discourse.group/u/CRquantum)\
**Post date:** [September 11, 2025, 3:56am UTC](https://fortran-lang.discourse.group/t/static-analysis-tools-for-fortran-source-code-and-call-graph-visualization/10395/9 "2025-09-11T03:56:25Z")

</div>

If you installed Intel OneAPI, you can run Intel Fortran under Visual Studio. In its debug mode, show ‘call stack‘, when you pause the code, it will generate the plot which is similar (or perhaps even better in my opinion) with what @davidpfister showed above.

---

<div class="post-metadata">

**Author:** ![davidpfister](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/davidpfister/32/3949_2.png) [@davidpfister](https://fortran-lang.discourse.group/u/davidpfister)\
**Post date:** [September 11, 2025, 5:16am UTC](https://fortran-lang.discourse.group/t/static-analysis-tools-for-fortran-source-code-and-call-graph-visualization/10395/10 "2025-09-11T05:16:56Z")

</div>

Indeed and if you are to use the intel suite you can also go for vTune. It generates a flame chart that is a graphical representation of the call stack + elapsed time per function. But the method is dynamic and depends on the runtime option. The OP asked for something static though.

---

<div class="post-metadata">

**Author:** ![davidpfister](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/davidpfister/32/3949_2.png) [@davidpfister](https://fortran-lang.discourse.group/u/davidpfister)\
**Post date:** [September 11, 2025, 10:22am UTC](https://fortran-lang.discourse.group/t/static-analysis-tools-for-fortran-source-code-and-call-graph-visualization/10395/11 "2025-09-11T10:22:19Z")

</div>

There is also [cally](https://github.com/chaudron/cally), which is essentially the same as egypt but in Python.

---

<div class="post-metadata">

**Author:** ![Simo](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@Simo](https://fortran-lang.discourse.group/u/Simo)\
**Post date:** [September 11, 2025, 6:22pm UTC](https://fortran-lang.discourse.group/t/static-analysis-tools-for-fortran-source-code-and-call-graph-visualization/10395/12 "2025-09-11T18:22:19Z")

</div>

That’s perfectly what I was looking for! It works like a charm.

---

<div class="post-metadata">

**Author:** ![Dauptain](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/dauptain/32/680_2.png) [@Dauptain](https://fortran-lang.discourse.group/u/Dauptain)\
**Post date:** [September 11, 2025, 6:39pm UTC](https://fortran-lang.discourse.group/t/static-analysis-tools-for-fortran-source-code-and-call-graph-visualization/10395/13 "2025-09-11T18:39:05Z")

</div>

There is also [marauder’s map](https://gitlab.com/cerfacs/maraudersmap/-/blob/main/docs/explanations/expl.md?ref_type=heads), for Fortran, Python and C.

Far from perfect, with docs a bit outdated, and approximate static callgraph…

but you can read a full example [here](https://gitlab.com/cerfacs/maraudersmap/-/blob/main/docs/howto/fullanalysis.md?ref_type=heads).  
It uses [tucan](https://gitlab.com/cerfacs/tucan/-/blob/main/docs/explanations/complexities.md?ref_type=heads) underneath, which computes several interesting metrics

Will update the mmap pypi version soon  
If you are interested or need assistance contact me.
