Fortran still Rulz! It ain't Basic. Nii!
guigirl last edited by
Why are most climate models in Fortran? (partee.io)
Climate models like the Community Earth System Model (CESM) are made of up multiple models each responsible for their own part of the world: the ocean, atmosphere, ice, rivers, etc.1 Each of these various components communicate with each other to update the state of the global climate. This is why climate models are often referred to as “coupled climate models”.
Climate models often work on massive grids. There are many types of these grids, but for simplicity sake just think of a piece of graph paper. Each little square of the grid is responsible for a section of the world’s climate being modeled.
Model grids can be made finer or courser in resolution. Going back to the example of the graph paper, increasing the resolution equates to dividing up each square of the paper into a number of other squares. The picture below shows two grids sizes (1 degree and 1/4 degree) that are commonly used in climate modeling.
Not only do these models require computational power, they also require massive storage capacity. As the resolution is increased, the output goes from gigabytes to hundreds of terabytes very quickly. For example, the aforementioned CESM model when run for 55 model years, with a 1/4 degree grid in the atmosphere (as show on the right in the above picture) and 1/10 degree grid in the ocean, produces over 140 terabytes of output data.
So why Fortran for our climate models?
It is true that Fortran can scare off newly minted developers and even some seasoned developers. Fortran is not an easy language to write or read by any standards.
However, Fortran is actually very good at what it does. Fortran stands for Formula Translation. The language was designed to turn math equations on paper into code in a computer. Fortran stands in stark contrast to more modern languages like Python that practically read like English.
Arrays are a first-class citizen in Fortran. A higher level abstraction for arrays, compared to C, makes it easier for scientists to describe their domain. Fortran supports multi-dimensional arrays, slicing, reduction, reshaping, and many optimizations for array based calculations like vectorization.
Because of this abstraction for arrays, Fortran is uniquely suited for scientific numerical calculation. The way I like to explain this to non-fortran programmers who are familiar with C++ is that arrays are to Fortran what std containers are to C++: a convenient abstraction that makes working with groups of numerical values easier. Now, I’ll admit that it’s not the best analogy, but the point I’m trying to drive home is the convenience gained from the abstraction.
In fact, if you like Python, you might be surprised to hear that some of your favorite Python libraries, like Scipy, are partially written in Fortran
Just goes to show you, once again, how supremely talented those six boys were!