Live data from Hacker News

Why physicists still use Fortran (2015)

moreisdifferent.com

211–220 of 300 posts

Re: Why physicists still use Fortran (2015)

#211
post #63

Earlier quoted context omitted.

When people say that FORTRAN is faster than C++ it is obviously for numerical code, since general systems code is very hard to do in FORTRAN. Many people will complain that C++ can be faster than FORTRAN, however the problem is that you need to know a lot of C++ or have access to the right libraries to write competitive numeric code. In FORTRAN you can do that out of the box.

Moreover, the article mentions this point, references the benchmarks game, and says "However, the two benchmarks where Fortran wins (n-body simulation and calculation of spectra) are the most physics-y".

>> where Fortran wins spectral-norm

    1.99s Fortran Intel 

    1.99s C++ g++ 
URL provided @quickben

Re: Why physicists still use Fortran (2015)

#212
post #120
post #8

Physicists / engineers / mathematicians are the target audience for Fortran. For heavy number crunching it's still quite good, it's people trying to use it for other stuff that causes problems. That said, Fortran really is dying. Scientific code is much larger nowadays with more functionality and scientists want to do everything in one language. C++ and Python are taking over.

Vast majority of scientists is not able to write idiomatic Fortran, yet alone idiomatic C++. Scientific C++ code that didn't have an oversight from a professional C++ developer will be always horrible. Scientific Fortran code written without such oversight can sometimes be bearable. This is perhaps the main advantage of Fortran.

Eh, I'm talking mostly about the large scientific code packages that are being developed with millions of dollars in funding and large, organized teams. The people writing these sorts of codes know what they are doing and a lot of migration to C++ is because they are more familiar with it and it's easier to hire skilled people.

Re: Why physicists still use Fortran (2015)

#213
Fortran and Cobol both orginated in the late 1950s and are still in widespread use in certain domains. It's extraordinarily cheap in these domains to keep using legacy Fortran and Cobol software. These folks are passionate about their domains, but they probably couldn't care less about so-called modern software languages, new development tools, and new hardware. Those of us who thrive on change find this very hard to accept. We need to get over it.

Re: Why physicists still use Fortran (2015)

#214
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. Would you know if there are enough examples of two groups who have diverged like this to get meaningful (as in statistically significant) results on the cost benefit of porting / not porting?

> 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.

They are both typically pretty bad - but there are many more ways to shoot yourself in the foot in c++

Re: Why physicists still use Fortran (2015)

#215

"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…

It's not just that the code is already written and debugged; in many cases results have been published using analysis done with this legacy software. Using the same code ensures a certain amount of consistency between experiments from the same lab.

From this point of view, rewriting code is an extremely high-risk proposition. As we know, the likelihood of discovering bugs during this process is quite high.

Re: Why physicists still use Fortran (2015)

#216
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. Would you know if there are enough examples of two groups who have diverged like this to get meaningful (as in statistically significant) results on the cost benefit of porting / not porting?

> 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++. :-)

Re: Why physicists still use Fortran (2015)

#217
Modern fortran is quite awesome for matrix manipulation. The ease of using it for math makes me wonder why we don't use it more often. The main downside to modern fortran is its I/O capabilities are quite stunted. I honestly think we need an open source fortran95 to gpu compiler.

Re: Why physicists still use Fortran (2015)

#218
post #82

Why not create a DSL in C++ that gives you the same syntax as Fortran for doing array/matrix manipulations? That's really the one main advantage I gleaned from this article

Things like this exist but there are two issues. They aren’t part of the standard and Fortran compilers are better at optimizing built in Fortran abstractions than c++ compilers are at optimizing user made abstractions.

I suspect it’s the lack of standardization that’s really the issue.

Re: Why physicists still use Fortran (2015)

#219
post #105
post #97

Earlier quoted context omitted.

Interesting -- I'll look into it. Is it open-source (in the spirit of future-proofing)? Answering my own question: It doesn't appear to be.

It's not, unfortunately. But how are you "keeping the lights on" with your old MS Fortran based code? Still using an ancient Powerstation? compiler, or Compaq Visual Fortran, or ... ?

We're still running the old compiler, probably within DOSBox or something similar. There are one or two boxes on which the executable can currently be built.

Re: Why physicists still use Fortran (2015)

#220

Earlier quoted context omitted.

Just because python is slow doesn't necessarily mean that every library is also slow. With numpy/scipy, which are written in C with python bindings, scientific computation is pretty fast. Python is fast becoming standard language for data science with so many tools like notebooks that make it extremely easy to do many things. I am not sure how well it compares to Fortran but it is no brainer to use it over C++, espec…

Isn’t numpy written in Fortran?

Scipy is where a lot of the fortran is.
Post reply on HN