News: 1742212149

  ARM Give a man a fire and he's warm for a day, but set fire to him and he's warm for the rest of his life (Terry Pratchett, Jingo)

Flang-tastic! LLVM's Fortran compiler finally drops the training wheels

(2025/03/17)


The latest version of the LLVM compiler suite has promoted its Fortran front end. "Flang" is now official.

[1]LLVM 20.1 appeared last week. This is a major release following LLVM 19.1, which came out in September 2024 (the project's [2]version numbering scheme is a little idiosyncratic). One of the headline features in this release is that the Fortran front end received a promotion. LLVM has [3]included Fortran since LLVM 11 in October 2020, but until now, the compiler was called flang-new . Now its name has changed, and it's just the [4]Flang Compiler , or Flang for short.

There are other modern open source versions of Fortran out there, such as [5]GNU Fortran , which is part of the GCC suite. The blog post [6]announcing Flang's renaming is long, detailed, and highly informative. It goes into the project history, and why it's important to have at least two independent FOSS implementations, Flang and GFortran.

[7]

As for compilers called Flang, though, things do start to get confusing. The new Flang compiler is not the first or only Fortran compiler with that name. (The name comes from "F" for Fortran, plus "lang" from language, by analogy with LLVM's C compiler, which is called [8]Clang . Scrabble fans may wish to know that "flang" is a [9]miner's double-headed pickaxe .)

[10]

There was already another Fortran compiler based on LLVM that is also called Flang, now known as [11]Classic Flang . The Portland Group [12]started work in 2009 and it went [13]open source a decade ago , when PGI was already being [14]digested by Nvidia . Classic Flang still exists and it's still getting occasional code contributions. In its former commercial incarnation, it was called pgfortran. Just for added entertainment value, that Flang wasn't [15]the first either.

Far back in the mists of ancient times when this vulture learned Fortran at university, the dominant standard was [16]FORTRAN-77 , but even in the 1980s, reference books still talked about FORTRAN IV from 1961. Things have moved on, and [17]Fortran 2018 was agreed a while ago. The newly appointed Flang compiler is mostly compatible with Fortran 18, and indeed was [18]called F18 while it was in development – the documentation [19]still uses that name in places. Since then, that standard has been superseded by Fortran-2023. For some light reading, it is [20]a mere 688 pages [PDF], although there's a more digestible 25-page [21]summary of the new features [PDF]. If that's still too much, there's a [22]summary of the summary here .

[23]GCC 15 is close: COBOL and Itanium are in, but ALGOL is out

[24]The latest language in the GNU Compiler Collection: Algol-68

[25]How a good business deal made us underestimate BASIC

[26]BASIC co-creator Thomas Kurtz hits END at 96

If you fancy updating your skills, there's an interactive compiler called [27]LFortran – although it is still in alpha. Not only can LFortran generate WebAssembly, if that's your thing, it also means you can experiment with a [28]REPL in Fortran. The 18-year-old version of this Reg scribe would have given good money for that, if he'd had any.

The [29]Fortran language never went away. Indeed, it's looking healthier than it has for decades, in part thanks to the [30]efforts of Ondřej Čertík . Since [31]Fortran 90 , the rather ugly, old-fashioned, punched card-based layout has gone. Modern versions are much more flexible. It even has its [32]own package manager now. Some of [33]SciPy is written in Fortran, and thanks to free, highly optimized libraries like [34]LAPACK and [35]BLAS , even modern languages that don't include a line of Fortran call Fortran code to do numerical computation. ®

Get our [36]Tech Resources



[1] https://releases.llvm.org/20.1.0/docs/ReleaseNotes.html

[2] https://blog.llvm.org/2016/12/llvms-new-versioning-scheme.html

[3] https://releases.llvm.org/11.0.0/tools/flang/docs/ReleaseNotes.html

[4] https://flang.llvm.org/docs/

[5] https://gcc.gnu.org/fortran/

[6] https://blog.llvm.org/posts/2025-03-11-flang-new/

[7] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/oses&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=2&c=2Z9hVMu8-7pcEO11KTVVb1AAAAI8&t=ct%3Dns%26unitnum%3D2%26raptor%3Dcondor%26pos%3Dtop%26test%3D0

[8] https://clang.llvm.org/

[9] https://www.merriam-webster.com/dictionary/flang

[10] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/oses&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=4&c=44Z9hVMu8-7pcEO11KTVVb1AAAAI8&t=ct%3Dns%26unitnum%3D4%26raptor%3Dfalcon%26pos%3Dmid%26test%3D0

[11] https://github.com/flang-compiler/flang

[12] https://www.scientific-computing.com/news/pgi-and-nvidia-collaborate-fortran-language-support

[13] https://www.llnl.gov/article/41756/nnsa-national-labs-team-nvidia-develop-open-source-fortran-compiler-technology

[14] https://www.theregister.com/2013/07/30/nvidia_buys_the_portland_group/

[15] https://github.com/isanbard/flang

[16] https://fortranwiki.org/fortran/show/FORTRAN+77

[17] https://fortranwiki.org/fortran/show/Fortran+2018

[18] https://github.com/flang-compiler/f18

[19] https://flang.llvm.org/docs/Parsing.html

[20] https://j3-fortran.org/doc/year/24/24-007.pdf

[21] https://wg5-fortran.org/N2201-N2250/N2212.pdf

[22] https://degenerateconic.com/the-new-features-of-fortran-202x.html

[23] https://www.theregister.com/2025/03/13/gcc_15_is_close/

[24] https://www.theregister.com/2025/01/07/algol_68_comes_to_gcc/

[25] https://www.theregister.com/2025/01/03/reevaluating_basics_legacy/

[26] https://www.theregister.com/2024/11/20/rip_thomas_kurtz/

[27] https://lfortran.org/

[28] https://www.theregister.com/2021/11/30/asmrepl/

[29] https://fortran-lang.org/

[30] https://ondrejcertik.com/blog/2021/03/resurrecting-fortran/

[31] https://www.fortran90.org/

[32] https://github.com/fortran-lang/fpm

[33] https://scipy.org/

[34] https://netlib.org/lapack/

[35] https://www.netlib.org/blas/

[36] https://whitepapers.theregister.com/



Flangs for the memory

Apocalypso - a cheery end to the world

no text

Re: Flangs for the memory

steelpillow

Flangtastic joke there, buddy.

Doctor Syntax

I wonder how they'd name compilers for F*, Forth or Foxbase.

find users who cut cat tail

F* does not really compile (AFAIK). It can be translated into another language which can then be compiled.

4lang

And, of course, 狐lang (even though it does not compile either). Unicode also has U+1F98A which is a nice alternative. Alas, El Reg does not accept it in comments.

FORTRAN IV rings an ancient memory bell

John Sager

I did a FORTRAN IV course in the last term at university and actually managed to write a functioning program - punched card stack and all! The debug-recompile cycle was a bit tortuous then! I've hacked on Fortran occasionally since along with several other languages, but I'm now down to C and Python mostly.

Re: FORTRAN IV rings an ancient memory bell

Sam not the Viking

As an engineering student we had to do a computing project. We used Fortran to write a Finite-Element program which was the up-and-coming analysis method at the time. A huge bunch of punched cards, the program took ages to process; we had to get special permission to avoid having the batch rejected for using too much run-time. To us, the results were spectacular. Fortran was the god. Happy memories ---->

I find it shameful that my latest batch of engineering graduates had nil training in writing code of any type.

Give it WATFOR

Spoobistle

I'm afraid when my attempts at FORTRAN were fed to the Waterloo compiler, they generally got Blownaparte...

Re: FORTRAN IV rings an ancient memory bell

steelpillow

My first code was Fortran IV on porta-punch cards. Slip a pre-perforated card into the tablet and knock out little rectangles with a stylus. Don't laugh, it was the latest hi-tech hobby at school, that Autumn of 1968. Real geek power. Have never taken to curly-bracket languages since.

Re: FORTRAN IV rings an ancient memory bell

elDog

I remember those handheld card punchers. They were sometimes needed to fix (patch) a binary punch-card deck that was used to cold boot one of those room-filling beasts (in my case GE-635.

It was an extremely difficult task on one or more cards that needed patch tape (to turn an on-bit to off) and use of the punch. One small error and your dead cold machine wouldn't start back up.

As I always say...

Uncle Slacky

If it can't be done in Fortran, it's not worth doing.

And yes, I can write Fortran in any language...

Great!

HuBo

This official widening of the freedom of free choice space for worshippers of the manifest colexicographic destiny is good news indeed. May this algorithmic resurrection (linked under "efforts of Ondřej Čertík") last for longer than 3 days!

I quite enjoyed the Degenerate Conic 's tongue-in-cheek summary of F202x (linked under "summary of the summary here"), including his take on the "dreadful" "abomination" that is the ternary conditional operator (C-style), with supporting picture (just before the References), that made its way into F202x. Personally, I do love this operator though, and am glad it's pretty much part of ARM's Aarch64 assembly, mapping to "CSEL Xd, Xn, Xm, cond", and corresponding "FCSEL Dd, Dn, Dm, cond" (for floats).

Flang-tastic indeed to see this without training wheels (imho)!

The adjuration to be "normal" seems shockingly repellent to me; I see neither
hope nor comfort in sinking to that low level. I think it is ignorance that
makes people think of abnormality only with horror and allows them to remain
undismayed at the proximity of "normal" to average and mediocre. For surely
anyone who achieves anything is, essentially, abnormal.
-- Dr. Karl Menninger, "The Human Mind", 1930