Fortran Overview

Fortran is the world's oldest still-active programming language and the undisputed workhorse of high performance computing. This first lesson explains where it came from, what it is used for today, and why the rest of this track — nearly thirty topics from types to MPI clusters — is worth your time even in an industry that loves new languages.

A language that outlived every rival

John Backus and his team at IBM started designing a "Formula Translating System" in 1953 as a bet: a compiler could translate mathematical notation into machine code almost as efficiently as a human assembly programmer. The first FORTRAN compiler shipped in 1957 for the IBM 704, and it shocked the industry by producing object code within 20% of hand-written assembly. Every modern language you know — from C to Rust — inherited ideas that first appeared here: typed variables, subroutines, arrays, and compiler optimization.

The standard, maintained by ISO/IEC JTC1/SC22/WG5, has been revised ten times. Each revision is fully backward compatible: a FORTRAN 66 program about to celebrate its sixtieth birthday still compiles with today's compilers. That stability is a feature — a climate model written in the 1990s can be ported to a new supercomputer by recompiling it.

Fortran standard timeline from FORTRAN I in 1957 to Fortran 2023

Fig. 1 — Ten revisions in sixty-five years; Fortran 2023 is the current standard.

The 1980s barrier that kept it alive

Procedural languages split into two families in the 1980s. C and its descendants solved systems problems: operating systems, device drivers, compilers. Fortran 77 solved one narrow but enormous problem — fast arithmetic over arrays — and solved it so completely that scientists built weather centers, aircraft simulators, and particle physics detectors on it. When the rewrite attempts came (Ada, then C++ templates, then "Fortran killed by C++" articles every few years), the numerical libraries — BLAS, LAPACK, netCDF, MPI-based solvers — turned out to be the real product, and they were written in Fortran.

What Fortran is for today

The domains that adopted Fortran early are still its strongholds, because the problems are immutable physics and the codebases are priceless. Numerical weather prediction (ECMWF, NCEP), ocean and climate modelling, computational fluid dynamics in wind-tunnel and aircraft design, particle physics Monte Carlo (the LHC analysis stack), seismology, and quantitative finance all run critical loops in Fortran. The big telling fact: the LINPACK benchmark that ranks the world's top 500 supercomputers is written in Fortran, and for three decades the fastest supercomputers have stayed Fortran-first, most recently with GPU offload via OpenACC.

This is not nostalgia. CERN and ECMWF have both commissioned modern rewrites of their modelling frameworks to explore managed languages; both retained Fortran kernels because the numerical libraries and 30 years of validated numerics cannot be economically re-derived anywhere else.

Why Fortran still wins

Three design decisions made in 1957 still produce measurably faster scientific code than any general-purpose replacement:

  • Whole-array expressions. A = B + C is array add, element by element. The compiler knows the loop is a pure parallel reduction over contiguous memory and vectorizes it; in C or Rust you write the loop yourself and hope the optimizer recognizes it.
  • Column-major layout. Memory order is standardized, so the optimizer's cache analysis is deterministic, and BLAS/LAPACK kernels assume it.
  • No aliasing by default. Fortran assumes two arguments do not overlap memory unless you declare them pointer/target — the single biggest unlock for aggressive optimization, and something C had to wait decades for (restrict).

The next example shows the language at its best. The entire program — declaration, allocation, one vectorized statement — needs no explicit loop because the array expression is the loop. Read it top to bottom, then reflect on how the same computation reads in the language you know best.

program array_magic
  ! Demonstrate whole-array math: no explicit loop appears anywhere.
  use iso_fortran_env, only: real64
  implicit none
  real(real64), allocatable :: a(:), b(:), c(:)
  integer :: n = 1000000

  allocate (a(n), b(n), c(n))
  call random_number(a)        ! fills the whole array in one call
  b = 2.0_real64 * a           ! element-wise multiply by a scalar
  c = sqrt(a) + b              ! element-wise math, stored contiguous

  ! The compiler sees a pure element-wise kernel and vectorizes it,
  ! issuing SIMD instructions across the whole 8 MB of memory.
  print '(a,2f12.6)', 'c(1), c(n) =', c(1), c(n)
end program array_magic

Compile and run it with gfortran -O3 array_magic.f90 (the -O3 flag tells the optimizer to vectorize aggressively). On a multicore machine the same region can later be parallelized with one extra command, which you will study in the Parallel Computing lesson.

Where Fortran is not the best tool

Intellectual honesty matters in a tutorial. Fortran is a numerical domain language, and in the surrounding territory it is weak:

  • Systems programming. Device drivers, kernels, browsers, and security infra are written in C, C++, Rust, or Zig — Fortran has no memory-safety guarantees and no ecosystem there. (The comparison lesson answers "is Fortran a system language?" head-on.)
  • Web and tooling. No mainstream web framework, and the tooling (debuggers, IDEs, package managers) is decades behind the JavaScript/Rust world — improving fast with fpm and the VS Code extension, but honestly still catching up.
  • Scripting and glue. Fortran is compiled and verbose; orchestrating data pipelines belongs to Python or shell. The Python integration lesson shows the best of both worlds: Python drives, Fortran computes.

The remainder of this track is organized as six phases of increasing sophistication: foundations (overview, setup, syntax, types, expressions, control), programming (functions, arrays, strings, files, derived types, modules), reliability and data (pointers, errors, object orientation, C interop), HPC and parallel computing (performance, OpenMP and do concurrent, coarrays, MPI, GPUs), ecosystem and perspective (Python integration, fpm and stdlib, comparison with Rust and Zig), and finally practice: a lab of runnable demos, study projects, and a categorized references page.

Before moving on: visit fortran-lang.org/learn and skim the Quickstart tutorial. You do not need to memorize it — the next lesson installs your toolchain, and lesson 3 starts the real grammar. Everything official that this track teaches is cross-linked there.