Reminisces and prophecies brought upon by LFortran and GSoC 2021

Background

I know not what the language of the future will look like, but I know it will be called FORTRAN…
— Charles Anthony Richard Hoare, circa 1982
– Daan Frenkel, 2020

This post is a little belated, given that the GSoC announcements were a few days ago. Therein lies the future, and much digital ink, sweat and blood shall be spilled towards accomplishing the goals outlined in my accepted project proposal. However, interestingly, it was an offhand comment at a CECAM MARVEL Classics webinar on free energy of solids 1 which triggered this.

Before Fortran..

Formula translation, or FORTRAN was not my first programming language. I grew up with the Logo turtle, and progressed naturally into C for coursework (as was the tradition back during my schooldays) and C++ for monkeying around with my Xperia devices (mostly Cyanogenmod stuff, some LineageOS). I shifted rather awkwardly in and out of Java (also a popular mainstay in different schools) and decided at some point during high school to pick up a high level language. I choose Ruby, because it was cuter than Python (still is!) and I had just been bitten by the web-design bug (Jekyll!!! Ruby on Rails!).

I was not unaware of Fortran, but I had little to no inclination to learn it, at the time, in my youth I was only interested in systems programming, web-design and other practical, visual activities.

Towards Fortran

As I grew older, my interest in crass physical things waned and my interest in the cool, calculating and sly discipline of simulation; fortune telling with confidence and code kept pace.

I almost came into contact with Fortran when I mistakenly stumbled onto Quantum Espresso in the course of my first summer undergraduate research project under Prof. Rajarshi Chakrabarti at IIT Bombay back in 2014….

Almost, but not quite, for I was hunting models for soft matter (eventually found them too Theeyancheri et al. (2020) ), and EsPReSSO MD is not Quantum Espresso.

First Encounter

I finally stumbled upon FORTRAN in all its free form f90 glory in the form of BigDFT during my stint in the 2015 Students-Undergraduate Research Graduate Excellence (SURGE) program of IIT Kanpur. A mere six years ago.

By then I had been programming, as perhaps many do, largely on the largess of the internet. It was my source of information, and even seeded some of my opinions. I immediately set out to discover as much about Fortran as I could. Back then I failed miserably. For the first time, I was confronted only with ridiculously ugly F77 code examples, and it seemed abundantly evident that most questions and projects were clearly related to coursework (poorly taught coursework no less).

The only ray of sunshine in a mess of poor content was Ondřej Čertík’s fortran90.org. I knew better than to write off Fortran though, I knew even then its pedigree (impossible to configure LAMMPS without touching upon BLAS and LAPACK…) 2.

I was not a chemist, and my dealings with elegant EsPReSSo and LAMMPS in no way prepared me for the horrific mess which was (and is) the codes of ab-initio chemistry. I was however, introduced to Redwine (1995) .

Fortran the stable

During my third year, I attempted to submit a project written in Julia. I spent the next couple of months convincing the instructor of the fact that Julia was a legitimate language and not a figment of my imagination. Little wonder then, when the time came to submit an undergraduate thesis, much of the computations were was inspired by the venerable Fortran codes of Kayode (1995) .

Ice, Fire and Fortran

The fortunate circumstances behind my position here in Iceland, are best left to other posts. One of my tasks, was the migration of existing code for the Single Center Multipole Expansion water model Wikfeldt et al. (2013) from Fortran (free form, but not modern) to C++ or at-least to write ISO_C_BINDING wrappers for incorporation into existing C++ libraries (with an eye towards LAMMPS integration). At the time, given my projects in C++ (Goswami, Goswami, and Singh 2020) and passable familiarity with Fortran, this seemed like an optimal use of time.

However, the force-field was and remains to be heavily under development Jónsson et al. (2020), Jónsson, Dohn, and Jónsson (2019), which made anything less than a hard fork unfeasible. Still on the books however, another Fortran project to look forward to!

Quantum Chemistry and Fortran

With collaborators at SURFSara I was involved in the port from MATLAB to C++, Gaussian Process Regression models Koistinen et al. (2019), Koistinen et al. (2017), Koistinen et al. (2020), Koistinen (2019) for accelerating saddle searches and coupling said methodologies to EON Chill et al. (2014) for long time scales. This was under my brilliant advisor’s ReaxPro project who also guided and encouraged me towards applying for a fellowship. As befitting a multiscale modeling project, this lead to an NDA and tweaks towards efficient workflows using potentials from the Amsterdam Modeling Suite, which naturally, is written in Fortran.

Tensors, IPAM and Fortran

Much has been said about NWChem’s pivot towards C++. However, this has quite a bit to do with HiParTI (a tensor library) being in C++. To throw away Fortran simply because Tensors are as yet easier to implement in other languages is treating a symptom, not fixing the cause. In any case, over the course of an IPAM fellowship (supported by my advisor) I was able to gain a broad overview of the underlying numerical complaints driving the schism; and there are already fantastic libraries which can be leveraged for multilinear algebra. Fortran is still one of the only language to have standardized parallel programming paradigms, and in the long run there is no way that won’t count in its favor.

Fortran Lang and LFortran

Around the same time frame, I was lucky enough to be involved in the documentation for SymEngine, and from there I was poised to witness the rapid rejuvenation and development of the Fortran ecosystem spearheaded in no small part by Ondřej Čertík (a fantastic person, mentor, and scientist; conversant in both algorithmic topics and quantum chemistry). LFortran is perhaps the most path-breaking of all the existing drives to fight the perceived obsolesce of Fortran. By bringing interactivity to the masses, the natural beauty of Fortran (recently reaffirmed by Milan Curic’s book) can come to the fore.

The Google Summer of Code project blends both my deep rooted interest in language semantics and flexible implementations; while also whetting my academic appetite by being so closely tied to the topics I love. Working on dftatom (and related quantum chemistry codes) while gaining familiarity with the LLVM based LFortran is fantastic. Being able to work closely with the rest of the team behind Fortran lang to bring about an “age of Fortran, as promised twenty years ago” is one of the most exciting premises I can imagine.

Conclusions

The picture painted here, like all nostalgic reminisces, is colored and deeply biased. My love for modern C++ and elegant R, my forays into other languages, none of these are mentioned. The sheer joy of using modern Fortran, of projects with fpm; is lost in translation. It is true, that my work, has more often involved production level C++ over Fortran, however, given everything, I can be certain of one thing:

The future is Fortran! (Or at-least involves a lot of Fortran)

References

Chill, Samuel T, Matthew Welborn, Rye Terrell, Liang Zhang, Jean-Claude Berthet, Andreas Pedersen, Hannes Jónsson, and Graeme Henkelman. 2014. “EON: Software for Long Time Simulations of Atomic Scale Systems.” Modelling and Simulation in Materials Science and Engineering 22 (5): 055002. https://doi.org/10.1088/0965-0393/22/5/055002.

Goswami, Rohit, Amrita Goswami, and Jayant K. Singh. 2020. “D-SEAMS: Deferred Structural Elucidation Analysis for Molecular Simulations.” Journal of Chemical Information and Modeling 60 (4): 2169–77. https://doi.org/10.1021/acs.jcim.0c00031.

Jónsson, Elvar Örn, Asmus Ougaard Dohn, and Hannes Jónsson. 2019. “Polarizable Embedding with a Transferable H2o Potential Function I: Formulation and Tests on Dimer.” Journal of Chemical Theory and Computation, November. https://doi.org/10.1021/acs.jctc.9b00777.

Jónsson, Elvar Örn, Soroush Rasti, Marta Galynska, Jörg Meyer, and Hannes Jónsson. 2020. “Transferable Potential Function for Flexible H$_2$O Molecules Based on the Single Center Multipole Expansion.” July 12, 2020. http://arxiv.org/abs/2007.06090.

Kayode, Coker, A. 1995. Fortran Programs for Chemical Process Design, Analysis, and Simulation. Elsevier. https://doi.org/10.1016/B978-0-88415-280-4.X5000-6.

Koistinen, Olli-Pekka. 2019. “Algorithms for Finding Saddle Points and Minimum Energy Paths Using Gaussian Process Regression.” Aalto University School of Science. https://opinvisindi.is/handle/20.500.11815/1460.

Koistinen, Olli-Pekka, Vilhjálmur Ásgeirsson, Aki Vehtari, and Hannes Jónsson. 2019. “Nudged Elastic Band Calculations Accelerated with Gaussian Process Regression Based on Inverse Interatomic Distances.” Journal of Chemical Theory and Computation 15 (12): 6738–51. https://doi.org/10.1021/acs.jctc.9b00692.

———. 2020. “Minimum Mode Saddle Point Searches Using Gaussian Process Regression with Inverse-Distance Covariance Function.” Journal of Chemical Theory and Computation 16 (1): 499–509. https://doi.org/10.1021/acs.jctc.9b01038.

Koistinen, Olli-Pekka, Freyja B. Dagbjartsdóttir, Vilhjálmur Ásgeirsson, Aki Vehtari, and Hannes Jónsson. 2017. “Nudged Elastic Band Calculations Accelerated with Gaussian Process Regression.” The Journal of Chemical Physics 147 (15): 152720. https://doi.org/10.1063/1.4986787.

Redwine, Cooper. 1995. Upgrading to Fortran 90. New York: Springer.

Theeyancheri, Ligesh, Subhasish Chaki, Nairhita Samanta, Rohit Goswami, Raghunath Chelakkot, and Rajarshi Chakrabarti. 2020. “Translational and Rotational Dynamics of a Self-Propelled Janus Probe in Crowded Environments.” Soft Matter, August. https://doi.org/10.1039/D0SM00339E.

Wikfeldt, K. T., E. R. Batista, F. D. Vila, and H. Jónsson. 2013. “A Transferable H2o Interaction Potential Based on a Single Center Multipole Expansion: SCME.” Physical Chemistry Chemical Physics 15 (39): 16542. https://doi.org/f2z5vm.


  1. I am after-all, actually secretly a computational chemist, whatever my degrees and blog posts might imply.. ↩︎

  2. Also a mentor and inspiration of mine (within my family) used Fortran for graduate research… ↩︎