News for hackers. Stuff that matters.
Re:Differentiable Fortran with LFortran and Enzyme by srean on Tuesday July 14, 2026 @10:03AM (#48907080)
Very interesting. Does LFortran have the same internal array layout as the standard C runtime ?

A shared layout and a shared calling convention would be very nice.

Sorry about my naive question. Haven't touched Fortran directly in three decades I think.

EDIT: thanks for your reply. For some reason it has been flagged dead. So am responding here. You can mail dang hn at ycombinator dot co m about the flagging. He is very nice.

Re:Differentiable Fortran with LFortran and Enzyme by kmaitreys on Tuesday July 14, 2026 @11:59AM (#48908845)
I would also like to know this. Fortran itself is column-major, so I would guess the internal layout isn't same for multi-dimensional arrays when compared to row-major C? I'm not sure how LFortran represents arrays internally though.
Re:Differentiable Fortran with LFortran and Enzyme by assemmedhat on Tuesday July 14, 2026 @12:33PM (#48909386)
LFortran internally uses column-major, so interchanging data with C should be done carefully for multi-dimensional arrays. If row-major representation is highly needed feature, We can introduce a flag to do that. I'm not totally sure about that but it's doable under some conditions for sure.
Re:Differentiable Fortran with LFortran and Enzyme by certik on Tuesday July 14, 2026 @04:13PM (#48912397)
We can internally do both row-major and column-major arrays. For Fortran we enable the column-major flag by default, but the door is open to have both at the same time.
Re:Differentiable Fortran with LFortran and Enzyme by wombatpm on Tuesday July 14, 2026 @10:30AM (#48907506)
Lots of scientific code in Fortran has sparse arrays, so a NxN array that only has values on 5 diagonals will store that as 5xN array to save memory allowing you to run a larger problem.
Re:Differentiable Fortran with LFortran and Enzyme by srean on Tuesday July 14, 2026 @10:34AM (#48907579)
That's a very orthogonal issue.

Sparse arrays are supported on C libraries too. I have done my time with CSC and CSR even inside Python that called out to C libraries.