July 14, 2026

Fortran enters its AI villain era

Differentiable Fortran with LFortran and Enzyme

Old-school science code just got a wild AI glow-up — and the comments are losing it

TLDR: A team showed that old Fortran simulation code can be turned into something modern AI systems can learn from, without rewriting it from scratch. Commenters were split between amazement and chaos-goblin delight, treating it like a brilliant hack held together by nerve and duct tape.

The big gasp from the community was basically: wait, you can make ancient Fortran code play nice with modern AI tools without rewriting the whole thing? That’s the fantasy this post is selling, and even the author sounded a little stunned it actually worked. In plain English, they took an old-school heat simulation written in Fortran — the kind of battle-tested code used in serious science and engineering — and found a way to get the “slopes” needed for machine learning out of it automatically. That means researchers may not have to throw away decades of trusted code just to join the AI party.

And yes, the comments had the exact energy you’d expect: part "this is amazing", part "this is cursed", and part "who gave these people duct tape and permission". The author jumped into the thread with a cheerful confession that the whole thing started as a nagging “what if this was possible” idea, which only added to the mad-scientist vibe. The funniest reaction was the sheer disbelief that a tiny 220-line Fortran solver could explode into a monstrous 6,900-line derivative version behind the scenes — the kind of reveal that inspires equal parts awe and “absolutely not.”

The drama here isn’t really people fighting; it’s the culture clash. One side sees a miracle bridge between dusty legacy science code and shiny AI workflows. The other sees a terrifying stack of old and new tools barely held together with hope, patience, and a willingness to hunt mysterious NaNs at 2 a.m. Either way, the community clearly agrees on one thing: it’s ridiculous, impressive, and weirdly exciting.

Key Points

  • The article presents an experimental method for differentiating existing Fortran, C, and C++ simulation code by applying Enzyme at the LLVM IR level.
  • The workflow combines LFortran, LLVM, and Enzyme, then wraps the result as a custom JAX primitive so a Fortran solver can be used inside JAX programs.
  • The article argues this approach avoids the main drawbacks of hand-written adjoints, finite differences, and full rewrites into JAX or PyTorch.
  • Its demonstration uses a roughly 220-line Fortran 90 program, `thermal_2d.f90`, that solves 2D transient heat conduction with temperature-dependent conductivity.
  • The article reports that gradients can be propagated through the full multi-step time loop and match an analytic answer, while emphasizing that the process remains experimental and can require substantial debugging.

Hottest takes

"what if this was possible" — dionhaefner
"I was surprised by how well this worked" — dionhaefner
"Pretty cool to see a 220-line Fortran heat solver turn into ~6,900-line" — dionhaefner
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.