LFortran is a modern open-source (BSD licensed) interactive Fortran compiler built on top of LLVM. It can execute user’s code interactively to allow exploratory work (much like Python, MATLAB or Julia) as well as compile to binaries with the goal to run user’s code on modern architectures such as multi-core CPUs and GPUs.
LFortran is in development (alpha stage), we have released a Minimum Viable Product (MVP) version at the end of the summer 2021, see the MVP announcement for more information.
Main repository at GitLab:
GitHub mirror: https://github.com/lfortran/lfortran Star
Any questions? Ask us on Zulip or our mailing list. You can also use the Fortran Discourse forum.
Google Summer of Code 2021: LFortran is participating in GSoC 2021 and we have three students, you can follow their progress here:
Advantages of Fortran
Simple, standard, fast
Fortran is fast
Fortran is built from the ground up to translate mathematics into simple, readable, and fast code.
Basic mathematics in the core language
Rich array operations, complex numbers, exponentiation, special functions, …
Simple but powerful
More restricting (and higher level) than languages like C or C++, so that the resulting code is easier to maintain and write and easier for the compilers to optimize. There is one canonical way to do things.
LFortran allows to use Fortran interactively just like Python, Julia or MATLAB. It works in a Jupyter notebook.
Fortran is an established language, building on 64 years of expertise. Widely used for High Performance Computing (HPC).
Fortran has many excellent open source compilers: GFortran for production; new compilers in development such as Flang and LFortran.
LFortran is in development, there are features that work today, and there are features that are being implemented.
Full Fortran 2018 parser
The LFortran’s parser should now be able to parse any Fortran 2018 syntax to AST (Abstract Syntax Tree) and format it back as Fortran source code (
Interactive, Jupyter support
LFortran can be used as a Jupyter kernel, allowing Python/Julia-style rapid prototyping and an exploratory workflow (
conda install jupyter lfortran). It can also be used from the command-line with an interactive prompt (REPL).
Clean, modular design, usable as a library
LFortran is structured around two independent modules, AST (Abstract Syntax Tree) and ASR (Abstract Semantic Representation), both of which are standalone (completely independent of the rest of LFortran) and users are encouraged to use them independently for other applications and build tools on top. See the Design and Developer Tutorial documents for more details.
Initial interoperation with GFortran
LFortran has a prototype parser for GFortran module files and generation of a Fortran wrapper that allows using the module with any Fortran compiler. This feature is still under development.
It can create executables just like other Fortran compilers.
Runs on Linux, Mac and Windows
All three platforms are regularly tested by our CI.
Several backends The LLVM can be used to compile to binaries and for interactive usage. The C++ backend translates Fortran code to a readable C++ code. The x86 backend allows very fast compilation directly to x86 machine code.
These features are under development:
Full Fortran 2018 support
The parser can now parse all of Fortran 2018 syntax to AST. A smaller subset can be transformed into ASR and even smaller subset compiled via LLVM to machine code. We are now working on extending the subset that LFortran can fully compile until we reach full Fortran 2018 support.
Native interoperation with other languages (and other Fortran compilers)
Import libraries written in other languages (such as C or Python) with the
usestatement, see #44. Add support for module files generated with other Fortran compilers, see #56. This will allow LFortran to run a large array of production codes. Provide automatic wrappers of any Fortran module to other languages.
Support for diverse hardware
LLVM makes it possible to run LFortran on diverse hardware and take advantage of native Fortran language constructs (such as
do concurrent) on multi-core CPUs and GPUs, see #57.
Please vote on issues in our issue tracker that you want us to prioritize (feel free to create new ones if we are missing anything). You can follow the issue boards to see what issues we are currently working on.