LFortran + Coding Agents

Hi everyone,

Way back in Fortran goals for 2022 I said I’d love to see LFortran usable for simple interactive tasks. It’s come a long way since then. Thanks to @certik’s hard work it seems like it is pretty much there!

I recently made a little tool to share REPLs between agents and humans (via Claude Code, Pi, Codex etc), and added an LFortran demo. This one is still in progress a little as LFortran develops but pretty cool to see IMO :slight_smile:

See Fortran section here

(For now, the RK4 step is written in scalars while some bug fixes are in progress.) Would be happy for any feedback if anyone tries it out!

Cheers,
Oliver

9 Likes

Thanks @omacl !

I am fixing all the issues you reported at Issues · lfortran/lfortran · GitHub, should be done soon.

3 Likes

amazing!

@omacl everything is fixed. If you find more bugs, please report them. Btw, great use of GitHub - fortran-lang/fplotlib: Fortran plotting library · GitHub. It’s all coming together!

You have used the LFortran’s REPL more than I did — it looks like you can use non-trivial projects like fplotlib just fine from it?

Everything you are doing I want to be the user of it too, those ideas I had in my head when I started LFortran, but it took exactly 9 years to get to this point, I believe I did the first (exploratory) commit in November 2017. Back then it was quite novel to think that Fortran could be interactive. Hopefully now it’s obvious that’s the way to do it.

And I wasn’t sure exactly what AI will do with the importance of REPL, but your idea to simply have an agent control a client and you (human) control another client and collaborate, that makes perfect sense. This will be amazing for exploratory work. The agent does all the hard work and you do the fun part of just playing with things.

I remember implementing Chebyshev filtering as an eigensolver right around 2017 or so, I did it in Python in a Jupyter notebook, did lots of plots, ensured that it works, then translated to Fortran, made some mistakes in the translation, had to fix those, etc. Now we can use LFortran’s REPL, fplotlib, jupyter and your agent as another client. The agent implements it and sets up some convergence plots, and I play with it, run it by hand, ensure the API is good and pleasant to use, and do different plots and iterate with the agent until I am happy. And then just copy & paste it to my production code.

4 Likes

Amazing, thank you! And yes it seems like you can… tho I have to admit I just asked my agent — it seems like this is a cool plotting library for fortran can we try using this? And it worked :slight_smile: (The embedded visualisation is from my agent-markdown-preview lib tho). Excited to keep working on this!

1 Like

BTW updated it so the Fortran demo now uses array-form RK4 and plot, no more scalars. (Still ran into the following when trying different versions btw: Interactive: second top-level DEALLOCATE of a class pointer fails with JIT 'Symbols not found: _finalize_...' · Issue #14395 · lfortran/lfortran · GitHub )

1 Like