fortran-src
fortran-src: Fortran static analysis infrastructure - Published in JOSS (2025)
Science Score: 100.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 4 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: joss.theoj.org -
✓Committers with academic emails
1 of 17 committers (5.9%) from academic institutions -
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
Scientific Fields
Repository
Fortran parsing and static analysis infrastructure
Basic Info
- Host: GitHub
- Owner: camfort
- License: other
- Language: Haskell
- Default Branch: main
- Homepage: https://hackage.haskell.org/package/fortran-src
- Size: 2.56 MB
Statistics
- Stars: 57
- Watchers: 10
- Forks: 21
- Open Issues: 66
- Releases: 29
Topics
Metadata Files
README.md
fortran-src
fortran-src is an open-source Haskell library and command-line application for the lexing, parsing, and static analysis of Fortran source code. It provides an interface to build other tools, e.g., for static analysis, automated refactoring, verification, and compilation. The following Fortran standards are covered:
- FORTRAN 66 (ANSI X3.9-1966)
- FORTRAN 77 (ANSI X3.9-1978 / ISO 1539:1980)
- Fortran 90 (ISO/IEC 1539:1991)
- Fortran 95 (ISO/IEC 1539-1:1997
- Fortran 2003 (partial)
Parsing is configurable, and you can select the Fortran standard to target, including special extended modes for nonstandard FORTRAN 77.
Various static analyses are provided including:
- Control-flow analysis (building a super graph) (Language.Fortran.Analysis.BBlocks);
- General data flow analyses (Language.Fortran.Analysis.DataFlow), including:
- Reaching definitions;
- Def-use/use-def;
- Constant evaluation;
- Constant propagation;
- Live variable analysis;
- Induction variable analysis.
- Type analysis (Language.Fortran.Analysis.Types);
- Module graph analysis (Language.Fortran.Analysis.ModGraph);
This package primarily exports a Haskell library, but also builds an executable that can be used for testing and debugging.
The library is the basis of the CamFort verification tool.
Statement of Need
Fortran remains a popular language in the international scientific community. It is not only a mainstay of legacy software, but is also used to write new software. Fortran is particularly notable for its prevalence in earth sciences, e.g., for implementing climate models that inform international policy decisions. In 2024, Fortran re-entered the Top 10 programming languages in the TIOBE Index, showing its enduring popularity. The continued use of Fortran, particularly in scientific contexts, was the catalyst for this software package. A challenge in writing language tools for Fortran is its long history. There have been several major language standards (FORTRAN I-IV, FORTRAN 66 and 77, Fortran 90, 95, 2003, 2008, etc.) Newer standards often deprecate features that are known to be a ready source of errors, or difficult to specify or understand. However, compilers often support an amalgam of features across standards, enabling developers to use deprecated features and mix language standards. This complicates the development of new tools for manipulating Fortran source code; one must tame the weight of decades of language evolution.
Our package, fortran-src, provides an open-source unified core for statically analysing Fortran code across language standards, with a focus on legacy code over cutting-edge modern Fortran. It is both a standalone tool and a library, providing a suite of standard static analyses as a basis for further programming language tools and systems.
Obtaining
We provide prebuilt binaries for Windows, Mac and Linux.
Usage
Add fortran-src as a dependency in your Haskell project. We're on
Hackage and also on
Stackage.
Command-line tool
You can also invoke fortran-src on the command line.
For features that output graphs, the intended usage is to pipe it into the
command dot -Tpdf and redirect that into a PDF file. The dot command is part
of the GraphViz project, please see their manual
for the many other options that can be explored for visualisation purposes.
Usage: fortran-src [OPTION...] <file>
--version show fortran-src version
-v VERSION, -F VERSION --fortranVersion=VERSION Fortran version to use, format: Fortran[66/77/77Legacy/77Extended/90/2003]
-a ACTION --action=ACTION choose the action, possible values: lex|parse
-t --typecheck parse and run typechecker
-R --rename parse and rename variables
-B --bblocks analyse basic blocks
-S --supergraph analyse super graph of basic blocks
-r --reprint Parse and output using pretty printer
--split-long when using pretty printer, split long lines via continuations
--dot output graphs in GraphViz DOT format
--dump-mod-file dump the information contained within mod files
-C[CPP-OPTS] --cpp[=CPP-OPTS] run the C Pre Processor on the Fortran files first
-I DIR --include-dir=DIR directory to search for precompiled 'mod files'
-c --summarise, --compile-mod build an .fsmod file from the input
-o FILE --output-file=FILE name of output file (e.g. name of generated fsmod file)
--make-mods, --make determine dependency order of modules and automatically build .fsmod files
--show-make-graph dump a graph showing the build structure of modules
--show-make-list dump a list of files in build dependency order (topological sort from the dependency graph)
--show-block-numbers[=LINE-NUM] Show the corresponding AST-block identifier number next to every line of code.
--show-flows-to=AST-BLOCK-ID dump a graph showing flows-to information from the given AST-block ID; prefix with 's' for supergraph
--show-flows-from=AST-BLOCK-ID dump a graph showing flows-from information from the given AST-block ID; prefix with 's' for supergraph
If you do not pass a --fortranVersion flag, the version will be guessed from
the file name:
- Files ending in
*.fare parsed with extended FORTRAN 77 syntax. - Files ending in
*.f90are parsed with Fortran 90 syntax (and respectively for*.f2003/*.f03,*.f2008/*.f08). - Unknown extensions are parsed like
*.ffiles.
Building
You will need the GMP library plus header files: on many platforms, this will be
via the package libgmp-dev.
Haskell library dependencies are listed in package.yaml. fortran-src supports
building with Stack or Cabal.
fortran-src supports GHC 9.0 through GHC 9.4. We regularly test at least the minimum and maximum supported GHCs. Releases prior to/newer than those may have issues. We welcome fixes that would let us support a wider range of compilers.
You will likely need at least 3 GiBs of memory to build fortran-src.
For installing GHC and build tools, we strongly recommend ghcup.
When latest recommended is used, it means the latest version of the tool
that ghcup tags with recommended. This sometimes lags behind the
latest-tagged version. With ghcup installed, run ghcup list for a better
understanding.
Following are general guides for any OS that provides the relevant tools. If you
have trouble, consider checking the CI workflow files in .github/workflows.
Stack
We support the latest recommended version of Stack (as of 2021-09-17, Stack 2.7). Generally, any Stack 2.x should work. (Stack 1.x may work with minor alternations -- you may have to download the resolver manually.)
stack build
For an interactive shell:
stack build
stack ghci
Note that running stack ghci before running stack build won't work properly,
due to stack ghci not running build tools like Alex and Happy. So parser
modules will not be built, and you'll receive an error after building the other
modules. You can cheat a bit and run stack build until you see Building
library for [...] (= preprocessing has finished), then hit <Ctrl-C> to stop
the build and run stack ghci as usual.
Cabal
We support the latest recommended version of Cabal (as of 2021-09-17, Cabal 3.4)
cabal build
You can leverage cabal to initialize a ghci session, and call the main function like such:
```shell cabal repl
:load app/Main.hs
:main --version ```
Testing
Unit tests are stored in test. Run with stack test or cabal test.
Usage
As a dependency
fortran-src is available on Hackage and Stackage, so for Cabal or Stack projects
you should only need to add fortran-src to your project dependencies.
If you need a specific version of fortran-src in a Stack setup, you can stuff a
Hackage reference into stack.yaml using extra-deps, like:
```yaml resolver: ... ...
extra-deps: - ... - fortran-src-$VERSION ```
As a CLI tool
If you have Cabal properly configured, you should be able install fortran-src from Hackage:
cabal install fortran-src
We provide prebuilt binaries for some platforms: see the Releases tab.
Otherwise, you can build from source and use convenience commands like cabal
run, stack run. See #Building for details.
Contributing
We welcome bug reports, fixes and feature proposals. Add an issue or create a pull request on the GitHub repository.
Support
You may be able to find maintainers on the Libera.Chat IRC network. Check in #fortran-src and #camfort . Otherwise, you could get into contact with one of the team on the CamFort team page -- or create an issue describing your problem and we'll have a look.
For maintainers
See doc/maintainers.md in
camfort/camfort.
Owner
- Name: camfort
- Login: camfort
- Kind: organization
- Website: http://camfort.github.io
- Repositories: 18
- Profile: https://github.com/camfort
Tooling for the static analysis and verification of Fortran code (joint project between the University of Kent, University of Cambridge, and Bloomberg LP)
JOSS Publication
fortran-src: Fortran static analysis infrastructure
Authors
Department of Computer Science and Technology, University of Cambridge, UK, Meta, London, UK
Tags
static analysis toolingCitation (CITATION.cff)
cff-version: "1.2.0"
authors:
- family-names: Contrastin
given-names: Mistral
orcid: "https://orcid.org/0000-0002-5409-7122"
- family-names: Charman
given-names: Raoul Hidalgo
orcid: "https://orcid.org/0000-0002-8401-7672"
- family-names: Danish
given-names: Matthew
orcid: "https://orcid.org/0000-0002-7186-387X"
- family-names: Orchard
given-names: Benjamin
orcid: "https://orcid.org/0000-0002-7543-7675"
- family-names: Orchard
given-names: Dominic
orcid: "https://orcid.org/0000-0002-7058-7842"
- family-names: Rice
given-names: Andrew
orcid: "https://orcid.org/0000-0002-4677-8032"
- family-names: Xu
given-names: Jason
orcid: "https://orcid.org/0000-0003-3310-0756"
doi: 10.5281/zenodo.14831853
message: If you use this software, please cite our article in the
Journal of Open Source Software.
preferred-citation:
authors:
- family-names: Contrastin
given-names: Mistral
orcid: "https://orcid.org/0000-0002-5409-7122"
- family-names: Charman
given-names: Raoul Hidalgo
orcid: "https://orcid.org/0000-0002-8401-7672"
- family-names: Danish
given-names: Matthew
orcid: "https://orcid.org/0000-0002-7186-387X"
- family-names: Orchard
given-names: Benjamin
orcid: "https://orcid.org/0000-0002-7543-7675"
- family-names: Orchard
given-names: Dominic
orcid: "https://orcid.org/0000-0002-7058-7842"
- family-names: Rice
given-names: Andrew
orcid: "https://orcid.org/0000-0002-4677-8032"
- family-names: Xu
given-names: Jason
orcid: "https://orcid.org/0000-0003-3310-0756"
date-published: 2025-02-07
doi: 10.21105/joss.07571
issn: 2475-9066
issue: 106
journal: Journal of Open Source Software
publisher:
name: Open Journals
start: 7571
title: "fortran-src: Fortran static analysis infrastructure"
type: article
url: "https://joss.theoj.org/papers/10.21105/joss.07571"
volume: 10
title: "fortran-src: Fortran static analysis infrastructure"
GitHub Events
Total
- Create event: 9
- Release event: 3
- Issues event: 18
- Watch event: 5
- Issue comment event: 33
- Push event: 26
- Pull request review comment event: 1
- Pull request review event: 3
- Pull request event: 16
- Gollum event: 4
- Fork event: 3
Last Year
- Create event: 9
- Release event: 3
- Issues event: 18
- Watch event: 5
- Issue comment event: 33
- Push event: 26
- Pull request review comment event: 1
- Pull request review event: 3
- Pull request event: 16
- Gollum event: 4
- Fork event: 3
Committers
Last synced: 5 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Matthew Danish | m****5@c****k | 387 |
| madgen | me@m****t | 292 |
| Ben Orchard | t****n@g****m | 260 |
| Dominic Orchard | d****d@g****m | 176 |
| TravelTissues | t****s@p****m | 47 |
| Raoul Hidalgo Charman | r****r@b****t | 33 |
| Anthony Burzillo | a****o@b****t | 13 |
| Eric Seidel | e****3@b****t | 9 |
| Bradley Hardy | b****y@l****m | 7 |
| Jason Xu | j****6@b****t | 6 |
| Ben Moon | s****e@g****m | 6 |
| Harry Clarke | h****e@o****m | 4 |
| Vaibhav Yenamandra | v****a@b****t | 3 |
| Azeem Bande-Ali | a****i@b****t | 2 |
| Gauthier Segay | g****y@g****m | 1 |
| Konstantin Romanov | k****1@b****t | 1 |
| Lukasz Kolodziejczyk | l****k@g****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 51
- Total pull requests: 103
- Average time to close issues: 8 months
- Average time to close pull requests: 18 days
- Total issue authors: 14
- Total pull request authors: 10
- Average comments per issue: 2.39
- Average comments per pull request: 1.17
- Merged pull requests: 82
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 12
- Pull requests: 24
- Average time to close issues: 3 months
- Average time to close pull requests: 7 days
- Issue authors: 5
- Pull request authors: 5
- Average comments per issue: 1.17
- Average comments per pull request: 0.5
- Merged pull requests: 17
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- raehik (16)
- dorchard (9)
- RaoulHC (7)
- NicolasAnquetil (5)
- uNouss (4)
- smoothdeveloper (2)
- madgen (1)
- deniseiras (1)
- dmikushin (1)
- ccotter (1)
- Boarders (1)
- envp (1)
- tclune (1)
- juhp (1)
Pull Request Authors
- raehik (61)
- dorchard (24)
- RaoulHC (15)
- smoothdeveloper (4)
- mrd (3)
- danielskatz (2)
- jasonqxu (1)
- ProgramFan (1)
- envp (1)
- ksromanov (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- hackage 9,627 total
- Total dependent packages: 4
- Total dependent repositories: 15
- Total versions: 34
- Total maintainers: 4
hackage.haskell.org: fortran-src
Provides lexing, parsing, and basic analyses of Fortran code covering standards: FORTRAN 66, FORTRAN 77, Fortran 90, Fortran 95, Fortran 2003 (partial) and some legacy extensions. Includes data flow and basic block analysis, a renamer, and type analysis. For example usage, see the CamFort project, which uses fortran-src as its front end.
- Homepage: https://github.com/camfort/fortran-src#readme
- License: Apache-2.0
-
Latest release: 0.16.7
published 6 months ago
Rankings
Maintainers (4)
Dependencies
- actions/cache v2 composite
- actions/checkout v2 composite
- actions/upload-artifact v2 composite
- haskell/actions/setup v1 composite
- actions/cache v2 composite
- actions/checkout v2 composite
- actions/upload-artifact v2 composite
- actions/checkout v3 composite
- cachix/cachix-action v12 composite
- cachix/install-nix-action v20 composite
- hspec-discover * build
- GenericPretty >=1.2.2 && <2
- array ==0.5.*
- base >=4.6 && <5
- binary >=0.8.3.0 && <0.11
- bytestring >=0.10 && <0.12
- containers >=0.5 && <0.7
- deepseq ==1.4.*
- directory >=1.2 && <2
- either >=5.0.1.1 && <5.1
- fgl ==5.*
- filepath ==1.4.*
- fortran-src *
- mtl >=2.2 && <3
- pretty >=1.1 && <2
- process >=1.2.0.0
- singletons >=3.0 && <3.2
- singletons-base >=3.0 && <3.2
- singletons-th >=3.0 && <3.2
- temporary >=1.2 && <1.4
- text >=1.2 && <2.1
- uniplate >=1.6 && <2
- GenericPretty >=1.2.2 && <2 test
- QuickCheck >=2.10 && <2.15 test
- array ==0.5.* test
- base >=4.6 && <5 test
- binary >=0.8.3.0 && <0.11 test
- bytestring >=0.10 && <0.12 test
- containers >=0.5 && <0.7 test
- deepseq ==1.4.* test
- directory >=1.2 && <2 test
- either >=5.0.1.1 && <5.1 test
- fgl ==5.* test
- filepath ==1.4.* test
- fortran-src * test
- hspec >=2.2 && <3 test
- mtl >=2.2 && <3 test
- pretty >=1.1 && <2 test
- process >=1.2.0.0 test
- singletons >=3.0 && <3.2 test
- singletons-base >=3.0 && <3.2 test
- singletons-th >=3.0 && <3.2 test
- temporary >=1.2 && <1.4 test
- text >=1.2 && <2.1 test
- uniplate >=1.6 && <2 test