Advanced visualisation of Fortran variables while debugging

One thing missing (AFAIK) from the commonly used Fortran editors is visualisation of numerical data structures like arrays, matrices, trees, etc. whilst debugging.

In VS Code in particular, one extension has caught my eye, Debug Visualizer - Visual Studio Marketplace, I have had a play with it and I have been able to get it working for Fortran + GDB but at the moment I have to manually wrap my arrays into json formatted plottly snippets cast as strings, see Visualization Playground.

I also know that GDB has the ability to use Python scripts for pretty printing, I believe @zedthree wrote one for polymorphic types a while back. My general train of thought, is to use Python scripts at the VS Code extension level or at the GDB level to visualise arrays.

I am still in the brainstorming phase and I have yet to take a deep dive at Debug Visualizer’s code but I was wondering if:

  1. that is something people are interested
  2. there are tools already doing this (I think CLion might have one just for matrices)
  3. you have any ideas or comments on how to implement this
4 Likes

https://www.gnu.org/software/ddd/

Haven’t used it in years and not sure how it holds up, but DDD used to be THE tool for visualizing data while debugging. You might find some inspiration there.

In any case, this capability would be super helpful for my day to day work.

I’m not in a place I can try right now, but I wonder if Gdbplotlib works with Fortran out of the box

@gnikit, really no need to ask if “is something people are interested”!!

“Advanced visualization” aka graphical debugging is a must anyone coding “in anger” with modern Fortran will realize sooner or later.

You can assuredly enter the field of dreams and confidently be mindful of that inner voice telling you “build it and they will come”!!

ddd is still available in modern Linux versions (RHEL/RockyLinux 8.5, Ubuntu 20.04) and in Homebrew for MacOS but its last released version (3.3.12) is … 13 years old.

This would be so useful! I often resort to print based debugging in Fortran especially when debugging code that is part of a numerical iteration loop. Failing procedures will then often be called many times before the actual failure occurs. Having the opportunity to plot arbitrary variables across multiple calls would be a really useful tool in such cases.

Absoft (a company specialized in Fortran compilers) offers their own Fx3 Source Level Debugger which comes with graphical variable display. According to their website it can be used also with compilers from other vendors.

Thanks, I will have a look at gdbplotlib, as for ddd I haven’t used it in years but I recall serious limitations from the limited time I spent using it.

Thanks for the link, Fx3 seems to have some of the functionality I want to implement. The major problem I see with it (and a lot of other Fortran solutions) is that they require paid licenses.

My personal opinion is that hiding basic tooling like intuitive visualisation of data or Language Server-like functionality, behind paywalls is actively contributing to the decline in popularity of Fortran.

It sure made my life a lot harder when I started coding in Fortran back in 2017 and there were little to no supporting tools to get a novice up and running.

I will have a play with the VS Code extension and see if we can interface with it or highjack its API and pass Fortran data structures without having to compile our own Fortran codes to convert things into plottly requests

2 Likes

Attention @mkonecny , @greenrongreen : with respect to the thread at the Intel Fortran forum and with Intel Support opening a feature request (FR), you may be interested in engaging with @gnikit toward any collaboration opportunities.

It appears for the sake of Fortran this is crucially a matter of avoiding situations that can only otherwise be seen as “failure of imagination”.

If one can imagine up a debugger adapter of some kind that Intel can offer along with oneAPI, the open-source Community led by @gnikit et al. can really run with it and do a lot of heavy-lifting that then frees up Intel monumentally in this aspect.

This will be a major improvement compared to the situation with Intel Fortran debugging with Visual Studio on Windows where Intel simply has arrived at a place where the maintenance and support itself appear untenable, let alone introducing additional graphical capabilities. The users will be ill-served if things go the way with ArrayVisualizer that was dropped.

1 Like

Couldn’t agree more with this and other posts. It would help hugely.

I often use a fully fledged GIS program (and debug printouts) for debugging but that is basically static unlike the visualisation linked in the OP. Also much more limited in the types of display (I think!).

My ‘static’ comment may be more my lack of DB experience. Fairly certain the GIS software can be dynamically linked to a database (with a wide variety of DB options). However, I have never used it that way so I am not certain if it is a practical option for debugging.