cd /news/developer-tools/ported-a-c-code-to-fortran-etiquete-… · home topics developer-tools article
[ARTICLE · art-99076] src=fortran-lang.discourse.group ↗ pub= topic=developer-tools verified=true sentiment=· neutral

Ported a C code to Fortran, etiquete around it?

A developer ported the libcint quantum chemistry library from C to Fortran using Claude, finding a 5-8% performance penalty compared to C. The developer plans to create a new repository for the Fortran port, acknowledging the original code, and aims to use it to test the LFortran compiler and simplify dependency management with FPM.

read1 min views1 publishedAug 16, 2026

Hi all, over the weekend with the help of Claude I took a the libcint library for quantum chemistry whose main code is generated via a lisp script to produce Fortran instead of C. I did this mostly as an experiment to see the difference in performance between the C code and the Fortran code for my application. Especially since the evaluation of the integrals performed by libcint can scale around O(N^4) so fast integrals are always needed in the QC.

As of now, performance seems to get a 5-8% penalty compared to C and I have narrowed it down to the Fortran compiler generating a couple more instructions than the C compiler. I’ve verified this across gfortran and ifx.

Before I push this code, I realize that this is port might not be at home in the same repository, since not all code is autogenerated. I was thinking on creating a new repository and clearly adverting that this is a Fortran port of the original library (I kept the interface) and cite and acknowledge the original code. For those that have something similar to this, is this the best approach or does anyone have a suggestion?

Another interest for me is producing a large and rather complex codebase for LFortran to try to compile. Plus navigating Fortran deps is easier if I can use the FPM for this. I know that fpm can compile C but dealing with the macros and partial includes was a bit painful in the C.

Cheers

── more in #developer-tools 4 stories · sorted by recency
── more on @libcint 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/ported-a-c-code-to-f…] indexed:0 read:1min 2026-08-16 ·