FORTRAN code browser
A tool to effectively explore the source code structure of a program.
<a href=”https://zenodo.org/badge/latestdoi/390411763″><img src=”https://zenodo.org/badge/390411763.svg” alt=”DOI”></a>
- Project Length – n/a
- CEMAC Output – A tool that can be used by developers to understand the structure of complex programs, and identify areas for improvement.
- Funding Body – National Environment Research Council as part of the JCWRP collaboration
- Project Sites – UoL Site
In development work, an understanding of code structure is often needed when making changes that may impact other areas of the codebase. This is particularly true when working with large collections such as the UM – a unified Earth Simulation suite. To overcome this we developed a platform-agnostic app that can parse a large number of FORTRAN files, identify subroutines/calls and ultimately graph of the program structure. This then not only allows the dynamic exploration of subroutines but also the direct identification of their usage within the source code.
The Call Graph
The main section of the App shows the call schema of all the parsed FORTRAN files. In this case, we have coloured the nodes depending on their grouping – i.e. Orange is the chemistry part of the UKCA (ASAD), blue is the main UKCA function and purple denotes the FastJX photolysis routines. Any nodes in grey are either auxiliary functions or ones not defined in the coded corpus.
This provides a general overview of the structure, and gives the subroutine names when scrolling over each individual node.
In clicking on a node/subroutine, we are able to see all the other functions which call it, as well as those which it calls. This allows us to manually build a dependency list, and locate areas where changes might be propagated to.
The other usage of selecting a node is that it then opens the corresponding Fortran code within a separate code window. This allows us to see the structure of the subroutine we have selected.
Hovering over any subroutines which are called within this (the red links) also scrolls the code window the lines where they are defined. For more information on this see below.
Code Viewer / Editor
The code window is a fully functional code editor. This allows us to make comments or changes and save them in a separate copy of the original file. This means we can then work with this if changing the original source code.
In addition to the self highlighting of calls when exploring the graph window, we are also able to make use of its regex searching capabilities and highlight patterns or words we are interested in.
The power of this tool comes from the ability to not only see the structure of the compiled program but also to intuitively gain a deeper understanding of the subroutines being called or calling the one we are interested in. Although this has been designed with the UKCA in mind. The tool has the capacity to work with any given Fortran codebase.