A meta-post on twin presentations on F2PY and LFortran at FortranCon'21


I had the honor and pleasure to have two presentations at the second annual FortranCon in 2021. The fun part was both talks featured the language standard prominently, but were meant to form two sides of a coin.

f2py: Two Decades Later

Dr. Ralf Gommers (Quansight Labs), Dr. Melissa Mendonca (Quansight Labs), Dr. Pearu Peterson (Quansight Labs)
20 minutes (15 + 5)


f2py is the gold standard for interfacing Fortran and Python. The most famous downstream consumer of the generated wrappers is undoubtedly the scipy ecosystem. Crucially, f2py is not a compiler, and generates a best effort set of wrappers, aided by special comment lines. One of the key inter-operable approaches to compilation of the subsequent wrappers relies on numpy.distutils. Given the planned obsolescence of this module; we discuss the methodology by which the build phase can be split into a two phase process and document better the pyf enhancements made to facilitate callbacks. A brief outline of test suites and documentation within the numpy ecosystem and proposed enhancement proposals will be discussed as well. We lay out the roadmap towards f2py remaining relevant beyond f77 by implementing derived types and newer features like parallelism with co-arrays. Playing to its strengths as a code-enhancer and leveraging the flexibility of not being constrained by the actual compilation process allows for the reimagining of f2py as a tool and library.

Other Content



Implementing Fortran Standardese within LFortran

Dr. Ondřej Čertík (Los Alamos National Laboratory)
5 minutes


The Fortran standard is a rather imposing document; though with F2018 at around 600 pages it is significantly lighter than its C++ counterpart. The standard itself is rarely cited as a beginner resource, with a cottage industry of books designed to shed light on the dry prose and foreboding technical rigor. However, with LFortran, particularly viewed through the lens of the Abstract Semantic Representation (ASR) of any Fortran code, the standard suddenly gains clarity and rigor. Being as it is a Fortran-first representation, unlike GCC’s internal representations (parse trees and lowered GIMPLE) or opaque (proprietary) middle-layers of NAG/Intel; the ASR is meant to concretely represent the syntax in a way to make the Standard seem eminently rational. Implementing the intrinsic functions and standard computing models become pleasant C++ puzzles instead of pidgin nightmares of progressively lower representations. In this presentation, I will discuss the process of implementing Standard intrinsic functions, the lifeline of any applied physical science researcher. LFortran allows for further flexibility at runtime, which will come up briefly, but most of the focus for this short talk will be on the compile time evaluation of intrinsic functions and future directions.

Other Content

The whole GSoC series.

  1. Fortran, GSoC21 and Me

  2. GSoC21 W1: LFortran Kickoff

  3. GSoC21 W2: LFortran Unraveling

  4. GSoC21 W3: Kind, Characters, and Standards

  5. GSoC21 W4: LFortran, Backends and Bugs

  6. GSoC21 W5: LFortran Design Details and minidftatom

  7. GSoC21 W6: LFortran ASR and Values

  8. GSoC21 W7: LFortran Workflow Basics

  9. GSoC21 W8: LFortran Refactors, and Compile Time Evaluations

  10. GSoC21 W9: LFortran Bug Hunting Bonanza

  11. GSoC21 W10: LFortran Runtime Library Design

  12. GSoC21 LFortran and Computational Chemistry



From around 10:43 in.


I could go on about these topics all day, thankfully for the most part, I do.