Live data from Hacker News

Why physicists still use Fortran (2015)

moreisdifferent.com

241–250 of 300 posts

Re: Why physicists still use Fortran (2015)

#241

"Professors usually have this legacy code on hand (often code they wrote themselves decades ago) and pass this code on to their students. This saves their students time, and also takes uncertainty out of the debugging process." This is so true. I'm a PhD student in physics using Fortran for pretty much that reason. At the start of my PhD, in response to my supervisor telling me I should learn Fortran to modify our cu…

Trusting legacy code with few users is a dangerous proposition. My roommate was given some "state-of-the-art" code and told to run simulations with it. The only graphical output was postscript (for some reason), so every frame was 150 MiB and took minutes to dump - so usually, this was only done at the end to show the result. I managed to hack in a step which just dumped the memory of resulting frame to a file, and t…

It's going to have few users anyways, since it's so specialized. And that's also why it will be legacy.

Re: Why physicists still use Fortran (2015)

#243
post #83

> Even if old code is hard to read, poorly documented, and not the most efficient, it is often faster to use old validated code than to write new code. Amen. A one-character mistake might take a week to find as it exhibits only subtly wrong behavior (e.g. wrong grid convergence rate, overly noisy boundary condition, odd symmetry breaking beyond IEEE floating point). During that week no science happens.

Yup. Think of C as a rusty straight razor and Fortran as a barn full of rusty implements about ready to fall at any time. C++ maybe a rusty safety razor.

Originally, Fortran had manual memory management, as per the times. Thankfully, the language progressed.

Overall, the evolution of languages from assembly/raw instructional to procedural ones needed early languages like Fortran on which other higher-level languages, tools and OSes could be later built/bootstrapped.

Re: Why physicists still use Fortran (2015)

#244
post #88

Earlier quoted context omitted.

> Now you need to do a follow on study to see how much science the 'rival' group does with a more modern codebase than your 'legacy' group does. I would guess that a C++ codebase written by PhD students, not by seasoned C++ experts, is more complicated and much slower to debug, than a corresponding Fortran codebase.

Can verify that if you give numerical methods people C you may get wonders like (e.g.) main() functions that are 30 pages long. No, I'm not kidding. I shudder to think what they'd have done with C++. :-)

Don't be so assumptive that a 30 page long main function is bad code. The code still can be well organized and readable. Function is not the only method to organize code. Knuth's literate programming for example is invented to better organize code.

Function has its side effects. It's use as only once case is really questionable, justified by lack of other means.

Re: Why physicists still use Fortran (2015)

#245
post #157

Earlier quoted context omitted.

I have to be honest with you, as someone who writes in both C++ and Python, I really do not see Python being more of a candidate than C++ for displacing Fortran. Can you clarify why you think Python might be able to do it? For scientific computation with high performance requirements, Python is not competitive with Fortan or C++. For work that continues to happen in Fortran due to "academic inertia", my impression (a…

I worked as a programmer in a molecular dynamics research group for a while. I was asked to work in Python because it was what the boss was familiar with - so there's some of the same inertia happening again, just with a new(er) language, I guess. Speed is not a huge issue if you're happy to leave your simulation running overnight anyway, or if you have the option to just throw more and more cores at the problem (or…

> Speed is not a huge issue if you're happy to leave your simulation running overnight anyway, or if you have the option to just throw more and more cores at the problem

What about those cases that it's the matter between throwing at 1000 core cluster and wether we can have results before next conference in a couple months. That is what really defines the scientific programming -- it's about feasible and infeasible. For other jobs, isn't it just matter of taste?

Re: Why physicists still use Fortran (2015)

#246

The same reason many big systems still use COBOL: it works, it's well tested, why change it? Usually they just run it as long as they have hardware they can run it on...

Speaking of hardware, we're entering an era where custom ASICs are becoming popular (e.g. Apple's A11 chip, Google's TPU).

If we know the software libraries won't change (blas, lapack) then what chips can we build to make them run even faster?

Re: Why physicists still use Fortran (2015)

#247
post #89

So the article basically says: 1) Some stuff is already written in Fortran so they don't want to rewrite that. I dig it. 2) It's fast (except C sometimes) but easier to write than c. Like 100x faster than python. I'm not sure about number two. With the gpu processing revolution wouldn't a python/TensorFlow stack be faster than Fortran? Am I missing something? I remember talking to someone who had worked heavily on at…

Dude. https://developer.nvidia.com/cuda-fortran And no, neural networks aren't suitable for discrete problems.

What do you mean by "discrete problems"? By my understanding, weather prediction is basically solving a large system of partial differential equations. Sure the grid methods are a discrete approximation of the true problem, but it is not what I would normally think of as a "discrete problem".

Training a neural network to map "current state of atmosphere" to "state of atmosphere in the future" is definitely possible to do with a neural network, and sounds like a good idea to me.

Re: Why physicists still use Fortran (2015)

#248

"Professors usually have this legacy code on hand (often code they wrote themselves decades ago) and pass this code on to their students. This saves their students time, and also takes uncertainty out of the debugging process." This is so true. I'm a PhD student in physics using Fortran for pretty much that reason. At the start of my PhD, in response to my supervisor telling me I should learn Fortran to modify our cu…

Trusting legacy code with few users is a dangerous proposition. My roommate was given some "state-of-the-art" code and told to run simulations with it. The only graphical output was postscript (for some reason), so every frame was 150 MiB and took minutes to dump - so usually, this was only done at the end to show the result. I managed to hack in a step which just dumped the memory of resulting frame to a file, and t…

Another problem is that most people who wrote this code aren't programmers - they don't write clean code, no tests, etc. They don't really know those are important. Sometimes the code that is used and updated for years looks like a dirty prototype.

I don't know what can be done about it except hiring programmers to write code, which wouldn't be either easy or cheap

Re: Why physicists still use Fortran (2015)

#249
post #153

Earlier quoted context omitted.

C++'s generic-programming feature still has shortcomings - I think functional-programming has more relevance to scientific computing, but C++'s functional features are "okay" but still not as capable or proven as, say, Haskell's or OCaml's - for example for tail-recursion you still depend on the compiler supporting that optimization, you can't force it or necessarily assume it will happen, with fun consequences for y…

> I think functional-programming has more relevance to scientific computing What do you base this on?

Functional languages force you to be more correct, more often. Eliminates a bunch of classes of bugs which are anathema to scientific computing, and are generally so high level that compilers can optimize extremely aggressively. Also, scientific programming is usually much more about data flow and transformation, which is FP’s wheelhouse.

Re: Why physicists still use Fortran (2015)

#250
Often there are many (more or less reasonable) extrinsic reasons for non-tech domains staying with the stacks they use.

I've done some programming for cognitive psychology experiments, fMRI analysis etc, and although I didn't like the often proprietary systems used (E-Prime, Presentation etc), I could see it would have required hefty investments of very scarce time to switch to something 'better'. The vast bulk of the software was written by non-programmer grad students, for whom the tech was a very 3rd order issue: they just needed their experiments up and running. This was generally done by finding a close-enough prior experiment, and tweaking it in a hurry, often with limited understanding of how the system worked. There was in most cases no possibility of paying programmers to do the work.

Post reply on HN