Live data from Hacker News

Why are most climate models in Fortran?

partee.io

91–100 of 136 posts

Re: Why are most climate models in Fortran?

#91
post #27

I'm not familiar at all with the world of high performance scientific computing. Are C++, Rust, Nim, Zig, & co. even remotely considered as potential candidates in the future, or is it really only C and Fortran with no expectation to see much changes? Just curious.

C++ certainly, and I would not be surprised to see Rust in the near future.

I have not seen anyone use Nim or Zig yet. There are also some special-purpose languages like Fortress (apparently now defunct), Coarray-Fortran, and Chapel, though none seems to have achieved too much market-share.

Personally I have almost entirely switched to Julia (from mostly C), which lets me do my everyday plotting / analysis / interpretation and my HPC (via MPI.jl) in the same language. Fortran definitely still has some appeal as well though.

Re: Why are most climate models in Fortran?

#92
post #45
post #27

I'm not familiar at all with the world of high performance scientific computing. Are C++, Rust, Nim, Zig, & co. even remotely considered as potential candidates in the future, or is it really only C and Fortran with no expectation to see much changes? Just curious.

C++ is widely used for High Energy Physics. The ROOT framework [0], developed at CERN, is mostly C++. I'd be tempted to say that Rust could be used as well, but the equivalent of MPI and OpenMP for Rust is still not as fast as in C++/C/Fortran.[2] That's easy to understand: there are decades of investment in MPI/OpenMP for C/C++/Fortran, and Rust is not there yet. Also, in some cases where high throughput is needed,…

Thanks, discord’s article is fascinating.

Re: Why are most climate models in Fortran?

#93
Has anyone LOOKED at fortran recently?

Some excerpts from https://en.wikipedia.org/wiki/Fortran

Fortran 90:

- Ability to operate on arrays (or array sections) as a whole, thus greatly simplifying math and engineering computations.

- whole, partial and masked array assignment statements and array expressions, such as X(1:N)=R(1:N)*COS(A(1:N))

Fortran 2003:

- Object-oriented programming support: type extension and inheritance, polymorphism, dynamic type allocation, and type-bound procedures, providing complete support for abstract data types

Fortran 2008:

- Sub-modules—additional structuring facilities for modules; supersedes ISO/IEC TR 19767:2005

- Coarray Fortran—a parallel execution model

- The DO CONCURRENT construct—for loop iterations with no interdependencies

- The BLOCK construct—can contain declarations of objects with construct scope

Fortran 2018:

- Further interoperability with C

Re: Why are most climate models in Fortran?

#95

The actual title is, "Why are Climate models written in programming languages from 1950?". I think the assumption that "old is bad" is the cause of many, many, many foolish decisions. Useless code rewrites, company reorganizations that are not significant improvements, and many other bad ideas hinge on this Worship Of The New. Why are we using an alphabetic system originally developed c. 1800BC? It's old, we should s…

This. The OS I use dates back to BSD 4.4, which is a rewrite and rehasing on some OS which is about 50 years old.

The audio plug is over 100 years old, and modern TTY's date back to what, 80 years? If it works, it works.

Also, damn Calculus is over 200 years old. Or maybe 2000, depending if you compare it to the method of exhaustion or not.

Re: Why are most climate models in Fortran?

#96

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.

I remember some version of BASIC from the early 80's. You could create real multi-denominational arrays including sparse ones with any starting index(s) you wanted.

Matrix operations were first class.

Re: Why are most climate models in Fortran?

#97
post #18

Earlier quoted context omitted.

It took until C99 for C to have complex numbers and `restrict`. Those are two features FORTRAN has had for a much longer time, right?

And like in everything C, unlike Fortran, there is no way for the compiler to validate if restrict is being used properly. Use it wrong, break the compiler assumptions and the bug hunting fun starts.

Mostly the compiler won't catch violation of the storage association rules. Toolpack had a useful tool for strict F77 code which was a boon fixing stuff not to break with the Alliant compiler, which was the first one the project I inherited used that took advantage of the optimization opportunity. Possibly Cray's would have done, but hadn't been used for a while at that point.

The fact that people won't believe the rules exist, is a continual source of bug hunting in Fortran unfortunately. At least restrict is visible.

Re: Why are most climate models in Fortran?

#98
post #18

Earlier quoted context omitted.

And like in everything C, unlike Fortran, there is no way for the compiler to validate if restrict is being used properly. Use it wrong, break the compiler assumptions and the bug hunting fun starts.

How does Fortran enforce this, actually? Does it just not let you pass the same array to a function via multiple parameters?

It does, indeed, but that's not the only way to associate storage. Using INTENT to specify whether an array is updated is useful.

Re: Why are most climate models in Fortran?

#99

Earlier quoted context omitted.

How does Fortran enforce this, actually? Does it just not let you pass the same array to a function via multiple parameters?

Fortran didn't originally have pointers, and pointer based code is relatively rare in fortran, so making requirements about pointer aliasing doesn't have same potential to completely break your code that it does in c. The reason c can't actually restrict the restrict keywoard, is that the standard would break code!

The storage association rules have nothing to do with pointers like that. Code will typically break because arguments are passed with copy-in/copy-out semantics, not by reference.

Re: Why are most climate models in Fortran?

#100

1. There are thousands of scientific subroutines written in Fortran that are stable and well tested - in fact, there are well established formal libraries of them that go back over 60 years. The researchers know and trust them. 2. Despite the sneers and derision that Fortran has been subjected to from non-Fortran programmers over recent decades, Fortran is an excellent language to do intensive scientific and mathemat…

Ahem ;-) Somehow your mention of cowboys entering the field feels irritating, considering Kazushige Goto and his contributions to BLAS while being in Austin, TX. Banzai!

While Goto typically gets the plaudits (and obviously did good work there), you should credit van de Geijn in that area long term.
Post reply on HN