Live data from Hacker News

Why physicists still use Fortran (2015)

moreisdifferent.com

121–130 of 300 posts

Re: Why physicists still use Fortran (2015)

#121
post #91

Earlier quoted context omitted.

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

Large-scale Atomic/Molecular Massively Parallel Simulator (LAMMPS) is written in C++ and it's over 20 years old. The FORTRAN codebases seem to be centered around the finite elements/difference methods and the fluid dynamics community.

Re: Why physicists still use Fortran (2015)

#122
The article is wrong or misleading in a number of respects. For instance, OpenMPI doesn't define the language interfaces -- the MPI standard does. It talks about "no aliasing of memory" -- the rules actually concern "storage association" -- and then claims Fortran passes by reference, misunderstanding the whole thing. The Benchmarks Game is pretty useless generally, but it's clearly useless to compare supposed language speed by using two different compilers anyway. I don't mean to knock Fortran.

Re: Why physicists still use Fortran (2015)

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

Plenty of high-paying quantitative jobs requires such a degree and experience. The majority of phd’s don’t go on to support their family with a tenure-track academic salary.

Re: Why physicists still use Fortran (2015)

#124
Some of the points brought up here are in fact correct, mainly legacy, testing, and awesome compilers tuned for supercomputers. However, a lot of these "why fortran" articles (on both sides) I find are written by people who don't dabble enough on both sides of the fence, and are ignorant of what either side offers. For example, numpy implements a lot of the stuff from fortran the author listed, like broadcasting operations across arbitrarily shaped arrays, striding and negative indices, etc, not to mention the scipy library that contains leagues of the famous fortran codes...you get all that with a quick and easy to prototype language for the stuff that isn't bottle neck.

Another issue is computational people think C++ is about OOP, ffs, what a way to sell C++ short and ignore the more significant tool C++ brings to the table: generic programming. Whenever I talk to my computational colleagues, they talk about "C++ and OOP" as if they are two peas in a pod; what if I told you you didn't need to use inheritance to leverage the best of what C++ offers (what if I told you you didn't need inheritance to even leverage OOP!?). Templates have the potential to be a powerhouse for performance in codes I feel, just no one in the computational side has leveraged them because they quite simply don't understand it.

The same sort of thing is true for cs people and their critique of Fortran usage, but I'll leave scathing comments on one of those stories that are shared here.

Re: Why physicists still use Fortran (2015)

#125
post #122

The article is wrong or misleading in a number of respects. For instance, OpenMPI doesn't define the language interfaces -- the MPI standard does. It talks about "no aliasing of memory" -- the rules actually concern "storage association" -- and then claims Fortran passes by reference, misunderstanding the whole thing. The Benchmarks Game is pretty useless generally, but it's clearly useless to compare supposed langua…

Briefly stated, the Gell-Mann Amnesia effect works as follows ...

https://calhounpress.net/blogs/blog/78070918-wet-streets-cau...

Re: Why physicists still use Fortran (2015)

#126
post #121

Earlier quoted context omitted.

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…

Large-scale Atomic/Molecular Massively Parallel Simulator (LAMMPS) is written in C++ and it's over 20 years old. The FORTRAN codebases seem to be centered around the finite elements/difference methods and the fluid dynamics community.

Sorry, I wasn't specific. My comment mostly applies to the quantum mechanics (QM) community, rather than molecular dynamics. In QM, many people still run Gaussian/GAMESS/ADF/MolCAS/MolPro/Dalton, which are all Fortran (or majority Fortran). And most are Fortran 90 or earlier.

My background is in QM, so I guess that's my bias showing through :)

Re: Why physicists still use Fortran (2015)

#127
post #50

Speaking from a government contracting point of view: Nobody is going to pay you to rewrite existing code that's already working. Nobody. The customer doesn't give a flying shit about the implementation. He'd be happy with a box of diodes as an implementation, as long as it worked and came in on time and on budget. When you're writing up your proposal for a contract or a grant, the theme should always be that you're…

The one thing that helps I think is writing of codes that are open source. Yes, it's a sticky point regarding getting funding, but in that imaginary world where you are funded well, transitioning to open codes (save the things that are...export controlled) would be beneficial for all of us.

I hate how I can't publish easily on modifications I make to our PIC code because it isn't open source; eventually I'm planning to switch to another code (and might implement a needed solver for it) just for the sake of my publications.

Re: Why physicists still use Fortran (2015)

#128
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…

Huh, funny thing. I had to use a heavy-ion collision simulation program written in fortran, which had to be compiled using a certain compiler implementation (1). After a 2-3 weeks of debugging and trying different compilers in vein, my supervisor had put me on a phone with a guy that was more successful than me and told me which fortran compiler to use.

(1) Each compiler gave different results: compilation errors, code that goes in an infinite loop.

Re: Why physicists still use Fortran (2015)

#129
post #5

> Interestingly, C/C++ beats Fortran on all but two of the benchmarks, although they are fairly close on most. I think this is fairly recent that C/C++ wins. I don’t know how recent exactly, but I remember a colloquium not too long ago by a compiler researcher who said that cross-compiling to Fortran and then optimizing almost always produced faster code than the C/C++ compiler could. Fortran is apparently easier to…

Fortran is easier to optimize compared to c/++ if you don’t use restrict for the c end. If you do use restrict (iirc) the compilers are competitive.

What I don't get is why someone doesn't make a superb template library with C++ that hides the restricts; it would make writing performant codes in C++ easier and you'd get the host of what C++ has to offer

Re: Why physicists still use Fortran (2015)

#130

As someone working on an Exascale project for electronic structure calculations, I have a theory about the longevity of Fortran. It's the fact that many of these codes were started years ago and the people who have the credentials and ability to get funding for super computing projects learned on Fortran and stayed with Fortan because they were scientist first and programmers second. Modern Fortran has many nice feat…

I makes no sense for people to have moved to C for things that have recently appeared in Fortran. What are the features they've been missing which have appeared in Fortran in the last 10 years?

So why is NWChem being re-written in C++, and what relationship does that have to exascale? Richard O'Keefe said 10 years ago ago "Why not start by rewriting the Fortran code _in_ Fortran? Fortran 90 is a very pleasant language." (NWChem is just in Fortran77 as far as I remember.)

I work in HPC, though I don't write numerical code these days, but I'd definitely prefer to write it in Fortran than C, and I'm not clever enough to use C++. I'd also much rather maintain typical scientific Fortran.

Post reply on HN