Live data from Hacker News

Why are most climate models in Fortran?

partee.io

71–80 of 136 posts

Re: Why are most climate models in Fortran?

#71
post #39
post #36

Earlier quoted context omitted.

This is absolutely correct - Fortran standards after 90/95 have mostly added extra features, rather than fundamental changes to how people write Fortran. Fortran 2003 added OO support, but I don’t believe that has seen widespread adoption.

Fortran 2003 also added BIND(C) and ISO_C_BINDING, which are massively useful in standardizing the C interop.

Oh, that's a nice thing. I still remember carefully appending underscores to names to thing to make C and FORTRAN talk in gcc/g77.

Re: Why are most climate models in Fortran?

#72

TFA would seem more reliable if it didn't have such a needlessly obscurantist Fortran-python code comparison. Nothing about the two languages calls for different base case logic! That is, in order to prevent confusion, the "Python3" code should have been this: def fibonacci(n): if n

From the other side, I thought the Fortran code had too much syntactic ceremony.

I haven't written Fortran in a while, but I was pretty sure that for illustrative examples like this, you could dispense with the entire MODULE declaration, the use of END FUNCTION Fibonacci instead of just END, and the usually-optional :: separator between the variable's type and name.

Something like this? Again, no recent experience:

  implicit none

  recursive function fibonacci(n) result (fib)
    integer n
    integer fib
    if (n 
(The IMPLICIT NONE has to stay because of the now-regrettable Fortran convention that without it, the type of a variable is determined by the first character of the name (n would be integer because variables starting with m, n, i, etc. are integer, while fib would be floating point).)

Re: Why are most climate models in Fortran?

#73

Earlier quoted context omitted.

Open question: why are multi-dimensional arrays, and matrices specifically, so neglected in almost every other language? They map well to practically freakin' everything , for what seems like.. not that much effort on the language design side, but an enormous amount of tedious, duplicated effort on the user side.

Because the only place you really need them is in mathematical/scientific computing, and while many scientists tend to pick up a little programming for their research, the vast majority of computer scientists and programmers, in particular the ones with the interest and ability to work on languages, are not concerned with mathematical modeling/processing. It is a fairly rare interdisciplinary combination.

Plenty of DSA work has more optimal representation and evaluation as matrix arithmetic. Particularly graph traversals and transforms which are heavily used in optimizing compilers.

Re: Why are most climate models in Fortran?

#74

I work at one of the labs mentioned and get paid for running not only the climate models but mesoscale models as well, which are also written in Fortran. The premise of the article is that Fortran, 70 years later is still an appropriate tool to use for crunching numbers which it absolutely is but it neglects one major problem. Like the COBOL issue that was all the rage 20 years ago, it is difficult to hire younger ge…

> I work at one of the labs... > ...it is difficult to hire younger generation programmers that want to and are excited to develop in Fortran. How much are you paying? Most often times I see this kind of reasoning, digging deeper shows that the salaries are not competitive. There's a large number of us that just want to work on interesting problems for adequate money and don't care what the toolset is. I'm fully on b…

Let's just say labs pay way better than universities.

Re: Why are most climate models in Fortran?

#75

Earlier quoted context omitted.

> I work at one of the labs... > ...it is difficult to hire younger generation programmers that want to and are excited to develop in Fortran. How much are you paying? Most often times I see this kind of reasoning, digging deeper shows that the salaries are not competitive. There's a large number of us that just want to work on interesting problems for adequate money and don't care what the toolset is. I'm fully on b…

Let's just say labs pay way better than universities.

For sure, but I mean compared to industry.

Re: Why are most climate models in Fortran?

#76

Earlier quoted context omitted.

Open question: why are multi-dimensional arrays, and matrices specifically, so neglected in almost every other language? They map well to practically freakin' everything , for what seems like.. not that much effort on the language design side, but an enormous amount of tedious, duplicated effort on the user side.

That is a great question, and while I don’t know for sure, I think a relevant anecdotal observation that stands out to me is that many languages which do have first-class multidimensional arrays also have one-based indexing. And I would speculate this in turn is because most people who wanted matrices badly enough to make them a language feature wanted to do linear algebra with them, where you generally also want one…

I don't get why a language can't have both 0 and 1 based indexing, just set it as a compiler flag or something. They are a homomorphism, it's not hard to add or subtract one.

Re: Why are most climate models in Fortran?

#78

Earlier quoted context omitted.

That is a great question, and while I don’t know for sure, I think a relevant anecdotal observation that stands out to me is that many languages which do have first-class multidimensional arrays also have one-based indexing. And I would speculate this in turn is because most people who wanted matrices badly enough to make them a language feature wanted to do linear algebra with them, where you generally also want one…

I don't get why a language can't have both 0 and 1 based indexing, just set it as a compiler flag or something. They are a homomorphism, it's not hard to add or subtract one.

You can actually switch starting indices fairly easily in Fortran [1], or for that matter Julia, but for some reason the option doesn’t seem to be particularly widely used. People seem to give a lot of weight to the default, even when the effort to change is minimal. Added complexity/ambiguity?

[1] https://stackoverflow.com/questions/48562873/zero-indexed-ar...

Re: Why are most climate models in Fortran?

#79
(disclaimer: I work in a Climate&Energy R&D Lab)

I don't entirely agree with the overall assertion of this article. The author has some valid points, but I think it misses the forest for the trees.

TLDR: I think Fortran tooling and HPC clusters are a self-reinforcing local maximum. They are heavily optimized for each other, but at the cost of innovation and extensibility.

For example, we'll never get a fully differentiable climate model in Fortran. The tooling does not exist, and there are not enough Fortran developers to make a serious dent in the tooling progress made outside of the HPC world. The MPI stacks these codes rely on are not great for hardware outside of a supercomputer, and Fortran codes basically are built around full interconnect. I have many PFLOPs at my disposal that I cannot use because these codes are too brittle without being entirely rewritten.

At the end of the day, everything is a Turing machine, so you can technically do whatever you want in Fortran or any other language (or mix and match), but strategically staying in Fortran leaves a lot of resources on the table.

Re: Why are most climate models in Fortran?

#80

I work at one of the labs mentioned and get paid for running not only the climate models but mesoscale models as well, which are also written in Fortran. The premise of the article is that Fortran, 70 years later is still an appropriate tool to use for crunching numbers which it absolutely is but it neglects one major problem. Like the COBOL issue that was all the rage 20 years ago, it is difficult to hire younger ge…

I wrote an addon for the MBS application Simpack[1] in Fortran as part of my master thesis and I have to say except for the stupid line length limit I enjoyed using Fortran (was first contact with Fortran then). My educational background is Mechatronics, so my cs background is not web/gui applications, but rather embedded systems.

[1] www.simpack.com

Post reply on HN