Fortran
The first high-level programming language, designed for scientific and engineering computation. Still actively used in high-performance computing.
Created by John Backus at IBM
Fortran (FORmula TRANslation) holds a unique place in computing history as the first widely adopted high-level programming language. Created when programs were still punched onto cards, Fortran proved that computers could efficiently execute code written in something resembling human mathematical notation rather than machine instructions.
History & Origins
In 1953, John Backus at IBM proposed developing a programming system that would allow scientists and engineers to write programs using familiar mathematical formulas. The skeptics were many - conventional wisdom held that no automatic coding system could produce machine code as efficient as hand-written assembly.
Backus and his team proved them wrong. When FORTRAN I shipped in 1957, its compiler produced code that often matched hand-optimized assembly in performance. This achievement was revolutionary: suddenly, programming was accessible to scientists and engineers who didn’t need to understand the intricate details of computer architecture.
The Name That Stuck
The original all-caps “FORTRAN” reflected the era’s convention of uppercase-only computer systems. Modern standards use “Fortran” with initial capitalization, though you’ll see both in practice. The name perfectly captures its purpose: translating mathematical formulas into executable code.
Why Fortran Still Matters
Despite being nearly 70 years old, Fortran remains essential in specific domains:
1. Unmatched Numerical Performance
Fortran compilers have been optimized for numerical computation longer than any other language. Features like:
- Array operations as first-class language features
- Column-major storage matching mathematical conventions
- Strict aliasing rules enabling aggressive optimization
2. Massive Legacy Codebases
Billions of lines of Fortran code power:
- Weather forecasting systems
- Climate models
- Computational chemistry packages
- Aerospace simulations
- Nuclear reactor calculations
Rewriting this code in another language would cost billions and introduce subtle bugs in safety-critical systems.
3. Modern Language Features
Fortran 2018/2023 is not your grandfather’s FORTRAN:
- Object-oriented programming
- Coarrays for parallel computing
- Interoperability with C
- Modern module system
- Generic programming (parameterized derived types)
The Two Fortrans
When working with Fortran, you’ll encounter two distinct styles:
Fixed-Form (Classic FORTRAN 77 Style)
| |
- Columns 1-6: Labels and continuation
- Column 7: Continuation character
- Columns 7-72: Code
- Columns 73-80: Ignored (originally for card sequence numbers)
Free-Form (Modern Fortran 90+ Style)
| |
- No column restrictions
- Comments with
! - Lowercase conventions
- Modern syntax
All modern Fortran code uses free-form, but you’ll encounter fixed-form in legacy codebases.
Modern Fortran Compilers
Several high-quality compilers exist:
| Compiler | Vendor | Platforms | Notes |
|---|---|---|---|
| gfortran | GNU/GCC | All | Free, excellent F2018 support |
| ifort/ifx | Intel | Linux, Windows, macOS | Commercial, best optimization for Intel CPUs |
| nvfortran | NVIDIA | Linux | GPU acceleration via OpenACC |
| flang | LLVM | Linux | New LLVM-based compiler |
| nagfor | NAG | All | Commercial, best standards compliance |
For this tutorial series, we’ll use gfortran via the official GCC Docker image.
Getting Started
Fortran code is stored in files with extensions:
.f90,.f95,.f03,.f08- Free-form source (use.f90by convention).f,.for,.f77- Fixed-form source
The typical workflow:
| |
Continue to the Hello World tutorial to write your first Fortran program.
Timeline
Notable Uses & Legacy
Weather Forecasting
Global weather prediction models like GFS and ECMWF run on millions of lines of Fortran code, processing petabytes of atmospheric data.
Computational Fluid Dynamics
NASA and aerospace companies use Fortran for airflow simulations that design aircraft, rockets, and spacecraft.
Nuclear Physics
Particle physics simulations at CERN and nuclear research facilities rely on decades of optimized Fortran libraries.
Climate Modeling
Climate change predictions from NOAA and IPCC use Fortran-based models that have been refined over 40+ years.
Financial Modeling
High-frequency trading systems and risk analysis tools use Fortran for its raw computational speed.
Language Influence
Influenced By
Influenced
Running Today
Run examples using the official Docker image:
docker pull gcc:latestExample usage:
docker run --rm -v $(pwd):/app -w /app gcc:latest sh -c 'gfortran -o hello hello.f90 && ./hello'