Live data from Hacker News

Why physicists still use Fortran (2015)

moreisdifferent.com

101–110 of 300 posts

Re: Why physicists still use Fortran (2015)

#101
post #94
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.

Well, that Fortran codebase probably also was written in large parts by PhD students, not export Fortran programmers.

C++ is a more efficient language to write difficult to track down bugs in than Fortran.

Re: Why physicists still use Fortran (2015)

#102
post #48

Earlier quoted context omitted.

>Unless you're passing arrays of pointers That seems to be the context from his example: for(i = 0; i I suppose the counterpoint is that he's doing it wrong. But again, maybe physicists just don't want a tool with that much flexibility.

Fair enough then, I suppose that in C you have to do something like that if you want both that your matrix size is decidable at runtime, and to be able to index it with m[x][y] rather than some function.

That’s not strictly true. You can malloc an m*n sized array and then assign to another array the pointer to the head of each column, allowing you standard style indexing.

Re: Why physicists still use Fortran (2015)

#103
post #100

One of the key points of the article is that there is a lot of legacy code written in Fortran. As a former high energy physicist, I have an anecdote here that some people might find interesting. There was a library written in Fortran called CERNLIB which included a broad variety of miscellaneous numerical algorithm implementations ( e.g. minimization, integration, special functions, random number generation) [1]. I c…

Getting locked to a particular compiler isn't usually a quality of the language, but the development team. It happens to all languages where the underlying platform remains fixed a site, it evolves into every capability of the instance, not the spec. This is why it is important to have platform diversity from the start. Run your unit tests on at least two toolchains, hopefully on at least two different distros if not kernels. I like to use GCC/Clang and Centos/Ubuntu as my base platform matrix.

Re: Why physicists still use Fortran (2015)

#104
post #91

Earlier quoted context omitted.

Yes, the electronic structure community is rapidly moving away from Fortran. In my opinion, Fortran will fall behind as newer hardware, libraries, etc, will drop Fortran support. Also, newer grad students are all much more interested in C/C++/Python. I think this is in part because the newer languages are widely used outside of science and therefore there is much more documentation and tutorials/guides. Not to mentio…

> Yes, the electronic structure community is rapidly moving away from Fortran. Really? Seems to me that with very few exceptions (e.g. GPAW which is python/C and nwchemEx which I've never heard about until the parent poster mentioned it), electronic structure is pretty much a Fortran bastion. (Source: I did a Phd doing mostly electronic structure calculations, graduated ~5 years ago)

Well, it's moving, not moved yet.

New libraries are being written in C/C++, and maybe Python. This includes libraries that should form the foundation of the QM community (matrix/tensor and integral libraries). These are meant to take advantage of newer hardware and libraries which themselves are written in C/C++, and often in a way that is inaccessible from Fortran.

The old Fortran code will be around for a long time, but I don't know of any large-scale, serious efforts to develop new packages or major new functionality that are starting with Fortran.

(I'm not totally against Fortran - I just spend a week devloping in it. But I still much prefer C++ and Python)

Re: Why physicists still use Fortran (2015)

#105
post #97
post #21

Earlier quoted context omitted.

I may be mistaken but I believe the Intel Fortran compiler supports the MS Fortran extensions

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

Re: Why physicists still use Fortran (2015)

#106
post #34

Be careful about performance comparisons: If you are using the GNU compilers (and the appropriate compiler flags with gcc), there isn't much difference in performance --- and there shouldn't be. There are a few FORTRAN-only compilers out there; I'd be curious to see how well they do.

I think the Intel compiler has a reputation of producing the fastest code, and Intel makes both C++ and Fortran compilers.

Re: Why physicists still use Fortran (2015)

#107
post #93

Earlier quoted context omitted.

TensorFlow is for machine learning, not general purpose computations. And no, you will not get better results from a neural network than state of the art computational fluid dynamics. As for general purpose GPU programming, some parts physics are GPU friendly put not all of them.

IIRC there was some project doing more or less real-time weather forecasts for small areas (think airports and such) that used deep learning instead of traditional CFD style simulations. They were able to do it with several orders of magnitude less CPU usage than the CFD calculations.

But was it more accurate? Was it for the same purpose? Getting within a few percent of a CFD model might be good enough for industrial use. For studying systems (from the perspective of scientific investigation) it's not even close.

Re: Why physicists still use Fortran (2015)

#108
post #26

Earlier quoted context omitted.

Yep. Most of my programming classes were either in pascal or c when I was in undergrad, but in my physics courses, all the way through my graduate education, I used FORTRAN. It's because physics doesn't change that much over the years, FORTRAN code that is time-tested and that works exists and there's no need to re-invent the wheel in another language when more interesting and important problems exist to solve.

David Baker's Rosetta code, which made him a pile of money, is IMO a spectacular example of craptastic C++ written by people who really didn't understand C++ but didn't let that deter them from using every single feature of the language, badly. Some years back we tried to port it to CUDA but there were so many levels of indirection, dereferencing, and virtual functions that it was nearly impossible to make any progre…

That's the whole trick. Good code makes complex stuff look simple. Bad code makes simple stuff look complex.

Re: Why physicists still use Fortran (2015)

#109

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

Lawrence Berkeley Lab has a C++ to Fortran compiler called FABLE: http://cci.lbl.gov/fable/

Curious if anyone in your group considered using it?

Re: Why physicists still use Fortran (2015)

#110
post #86
post #80

Earlier quoted context omitted.

I don't know. Having "rewrote X kloc of scientific Fortran to modern idiomatic C++" on your CV should get you to the head of the line in many places when looking for a job.

Only if you go after run of the mill coding jobs after your phd, in which case why bother at all. When applying for a postdoc, you'll very much want to bury that part of your work.

Or you could be applying for a HPC research job in one of the countless non-university setting that also does that sort of thing. Then having both a relevant PhD and some relevant hands on experience will be extremely helpful.
Post reply on HN