Language
Fortran
- First appeared
- 1957
- Paradigm
- Imperative, procedural, array-oriented
- Toolchain
- GNU Fortran 14.2
- Container image
debian:trixie-20261027-slim + gfortran-14 14.2.0-19
Fortran (FORmula TRANslation) came out of IBM in 1957, and it is the oldest language on this site. It was built for numerical work and is still used for it, in weather and physics simulations, and in LAPACK, the linear-algebra library that NumPy and R build on. Here it is compiled with gfortran using the 2018 standard.
Modern Fortran works on whole arrays at once: x - mean subtracts from
every element, and sum, minloc, dot_product, and matmul are
built-in intrinsics. What it lacks is everything outside the numbers. There
is no sort, no CSV reader, and no string splitting, so the implementations
write their own. LAPACK itself is a separate library and isn’t installed
here.
Quirks
- Without
implicit none, a variable whose name starts with i through n is silently an integer:index_var = 2.9stores 2. Every program here starts withimplicit none, which makes an undeclared name a compile error. - Arrays count from 1, and 2-D arrays are stored column by column.
7 / 2is integer division, giving 3;7.0 / 2gives 3.5.- The
f0.6format drops the zero before the point, printing 0.5 as.500000, so a smallsayhelper puts it back.
Concepts in Fortran
- Cross-validation
- Decision tree
- Descriptive statistics
- k-means clustering
- k-nearest neighbors
- Linear regression
- Logistic regression
- Naive Bayes
- Principal component analysis
Run the examples locally
You need Docker and Python 3. The harness builds the pinned container and runs every Fortran example:
git clone https://github.com/qnixon/dswithx.git
cd dswithx
python3 harness/run_tests.py --language fortran