Visualizing Fortran Projects with fpm: Create Stunning Module Dependency Charts

Me too, I thought Python was nearly ruling the world… But of course the Curly family :man_curly_hair: is large, and the young Rust is even rising.

I used to like curly braces a lot, when I was working with languages that used them.. but now after reading and writing a lot of Fortran I don’t think I like them anymore :slightly_smiling_face:

2 Likes

Curly brackets and everything is a pointer are two reasons I’ve always had a hate-hate relationship with C and all its children. As to readability, that has more to do with organizations or individuals not adopting consistent coding standards and practice and then rigidly applying them across their entire code base than it does with syntax. However, since a lot of code was written in academia by grad. students and post-docs with little adult supervision I can understand some peoples frustration with looking at old Fortran and thinking that’s how everyone does it.

Hi there! Thanks for mentioning my article and I’m glad you’ve been reading it. I’m quite new to Fortran but an experienced programmer and trainer in other languages and paradigms. I’ve been writing for people with similar experience to mine, hence the point about readability and curly braces. I totally understand how it will be different for you if you work with Python or Fortran and don’t miss it at all, of course. I also think files/modules quickly become too large, which on the other hand doesn’t seem to bother others.

I think Fortran is a great language by the way, with lots of potential too. The surrounding ecosystem is quickly evolving and this diagram tool is a great example of the snowball effect this causes.

If you have anything to share at any time, please send me a message. David already provided some useful suggestions, thanks again!

7 Likes

I just released a new version of the plugin.
As requested by @matthiasnoback, the submodule connection to the parent module is depicted with a dashed arrow in the opposite direction

In addition, I added a new layout engine named markmap

markmap

NB: There was a breaking change in the previous version.
The option -c, --chart has been renamed -K, --layout to be consistent with graphviz.
In addition, the default behavior has also been updated and normalized with fpm-deps. The default layout engine is dot. In the absence of an explicit output file, the stdout is used.
The following table of options is used

-K -o
(default: dot) *.json, *.dot, *.gv, *.svg, *.jpg, *.png, *.html
dot, fdp, sfdp, neato *.json, *.dot, *.gv, *.svg, *.jpg, *.png, *.html
circle *.json, *.html
force *.json, *.html
mermaid *.mmd, *.html
json *.json
toml *.toml
9 Likes

That looks amazing! Next time I have to document the structure of a combination of modules and submodules, I’m going to use this and will let you know how it went.

2 Likes

I’ve finally been able to use your updated fpm-modules plugin! Very nice work. The result is very useful too. I’m going to use the output in an upcoming article. I started a series on creating a test framework (first article: Fortran - Testing - Improving temporary test programs | Matthias Noback), and one of the upcoming articles will be about splitting the main module into smaller modules, including the use of a submodule (the facade_implementation). It’s nice how the diagram shows the effect: many dependencies are only dependencies of the submodule, not of the module. It also shows that test_result is a dependency heavily relied on. This has implications: it should be encapsulated well, and have a very stable interface.

4 Likes

fpm-modules now supports the latest version of fpm (0.13.0) as a dependency!

4 Likes

Just want to say thank you. This is VERY useful to me in what has become large project > 25,000 lines. I see clearly that I can remove some use statements now from some of my modules. :slight_smile:

It has run perfectly in Windows 11 using latest fpm and gfortran 15.2. fpm-deps was giving me backtrace errors so I’m very happy that you created this, and it is MUCH appreciated.

1 Like

I’m hoping to get some time to contribute…just so dang swamped with work and coding work stuff 10-12 hours a day, not much brain left….but fpm-modules runs perfectly for me in Windows 11, but I get runtime errors in Linux. fpm-dep gives the same exact errors. It compiles clean using FPM and latest gfortran. I have not run gdb or fpm-gdb, but I suspect it is something simple with how it gets the input files, so probably a very simple fix.

Thanks for trying it out. I’m really glad it’s useful.
I am sorry you found a bug. Can you open an issue on GitHub?
I do not have a Linux environment at the moment, I’ll try to set one up. If you manage to pinpoint the origin of the problem, that would be helpful, and than I’ll see what I can do.

I’ll try and do a bit of work on it.