Why Fortran is a scientific powerhouse

People often are surprised to find out how prevalent Fortran is in the real world. For instance many climate models were originally written, and continue to be maintained in Fortran (languages like Julia are attempting to unseat it, but I think Julia would be a better language if it had an ISO standard associated with it).

One of the reasons Fortran still works is longevity. It’s much easier to build on something that was originally developed in Fortran (which is backwards compatible), rather than starting from scratch. People always make is seem so easy, but many a re-engineering project has come unstuck because of a failure to understand how the original software worked. Fortran is also exceptionally good at doing math, and climate models are nothing if not all about crunching data and doing math.

That’s not to say there aren’t challenges – but find me a language that doesn’t have some challenges. I don’t like it when people try to explain that “Python would be better”, because of some cockamamie idea that its syntax is better than Fortran. Sure it’s more succinct, but that’s purely for the benefit of the programmer, not the machine. And who is to say explicit typing doesn’t actually add some level of clarity, which is extremely important in programs that perform calculations.

So how many climate models are written in Fortran? Mendez et al. [1] analyzed 16 well known climate models in 2014, all were Fortran. So in reality, most if not all are written in Fortran. Why do they still use Fortran?

  • Performance – Fortran is fast, in cases faster than C, and climate modelling, like so much scientific computing is about speed. (Check out [2] for language benchmarks).
  • Parallelism – Performance necessitates parallelism, and Fortran was doing that before other languages even knew what it was.
  • Reuse – Backwards compatibility means that existing libraries can easily be reused.
  • Arrays – Fortran treats arrays with the respect they should have. It supports multi-dimensional arrays, slicing, reduction, reshaping, and many optimizations for array based calculations like vectorization.
  • Longevity – Climate models and the like can’t be implemented in languages that aren’t (i) backwards compatible, and (ii) always change. If you write code in Fortran today, it is still likely to work in 20 or 30 years time.
  • Effort – Do you know how much effort would be involved in re-engineering a model? New languages are problematic.
  • MPI – The message passing Interface (MPI) is the gateway to high-performance computing, and Fortran handles it very well.

Fortran was designed for scientific computing. Sure Fortran is old, but so is Unix, and C as well. Just because languages like Julia are newer, doesn’t mean it’s better. Everyone thought C++ would be some sort of coding saviour as well, and look how well that turned out. People sometimes think that if something is written in a language like R, then it is pure R… but fail to understand that R itself is not pure R. R is itself composed of code made up of R, C, and Fortran.

More info:

  1. Mendez, M., Tinetti, F.G., Overbey, J.L., “Climate models: Challenges for Fortran development tools”, in 2nd Int. Workshop on Software Engineering for High Performance Computing in Computational Science & Engineering (2014).
  2. The Computer Language Bennchmarks Game

P.S. Fortran often appears on those “outdated languages” lists, but the lists are often compiled by people who have little or no clue about anything to do with computing, let alone programming languages.