ArticleslgStudy

computer science

LFortran

LFortran is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand LFortran rather than just read about it. In short: LFortran is an open-source next-generation interactive Fortran compiler based on LLVM. A unique feature is that it can execute the user’s code interactively to allow exploratory work, in addition to compiling it to binaries to run the code on modern architectures such as multi-core CPUs and GPUs.

Key takeaways

  • LFortran belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect LFortran to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of LFortran from memory before moving on to harder problems.

Reference excerpt

LFortran is an open-source next-generation interactive Fortran compiler based on LLVM. A unique feature is that it can execute the user’s code interactively to allow exploratory work, in addition to compiling it to binaries to run the code on modern architectures such as multi-core CPUs and GPUs. It can be used via WebAssembly and is available on Compiler Explorer. LFortran is still in the alpha phase. It supports most of Fortran 95 and many features of later standards. It will reach beta when it can reliably compile 10 production-grade, third-party packages used in the scientific community and industry. The current status is 8/10:

Legacy (February, 2023) and modern Minpack (May, 2023) --- LFortran Breakthrough: Now Building Legacy and Modern Minpack fastGPT (September, 2023) --- LFortran Compiles fastGPT dftatom (October, 2023) --- LFortran Compiles dftatom SciPy (60%, January, 2024) --- LFortran Compiles 60% of SciPy stdlib (85%, April, 2024) --- LFortran Compiles stdlib SNAP (August, 2024) --- LFortran now compiles SNAP PRIMA (March, 2025) --- LFortran compiles PRIMA Despite being alpha, LFortran has been on the radar of NASA as a representative of compilers supporting type-safe generic programming in Fortran, and on that of SciPy, which hopes it can help deal with the large amount of Fortran libraries that SciPy relies on. The LFortran project works closely with the US Fortran Standards Committee (J3). It is a NumFOCUS Sponsored Project since 2020. LFortran is a member of the Lcompilers family, and its siblings include LPython and LC.

See also

Flang Fortran LLVM

References

External links Official website lfortran on GitHub Discussions about LFortran on the US Fortran Standards Committee Discussions about LFortran on the Fortran Discourse Discussions about LFortran on Hacker News Why We Created LFortran LFortran in web browsers using WebAssembly LFortran in Compiler Explorer

Worked examples

Example 1 — a first encounter with LFortran

Start with the simplest possible case. Write down what LFortran claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to LFortran before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about LFortran ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of LFortran

In research
LFortran appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses LFortran in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
LFortran is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computer programming tool stubs, Fortran compilers, Free and open-source software stubs, so understanding it makes those chapters shorter.
In everyday life
Look for LFortran outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “LFortran” →

How to study LFortran in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what LFortran means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain LFortran out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is LFortran in simple terms?

LFortran is an open-source next-generation interactive Fortran compiler based on LLVM. A unique feature is that it can execute the user’s code interactively to allow exploratory work, in addition to compiling it to binaries to run the code on modern architectures such as multi-core CPUs and GPUs.

Why does LFortran matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study LFortran?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on LFortran.

Tags

  • Computer programming tool stubs
  • Fortran compilers
  • Free and open-source software stubs
  • Free and open source compilers
  • Free software programmed in C++
  • Software using the BSD license

Keep exploring