Live data from Hacker News

Why physicists still use Fortran (2015)

moreisdifferent.com

41–50 of 300 posts

Re: Why physicists still use Fortran (2015)

#41

Earlier quoted context omitted.

Potentially your "rival groups" will have a long term advantage now though. This might be bad for the graduate students that did the work, but could be good for the professor and group over the next decade. Graduate students need to think in terms of 4-6 years while forward looking professors might want to think in terms of 5-15 years.

That was without a doubt pretty bad for those grad students' careers. That kind of work shouldn't have been done by anyone without tenure.

Not necessarily. It was definitely bad if they want to become academics and needed to publish papers. But if they knew from the start what they were getting into and wanted to transition from physics to software development then it might not have been so bad (although there might have been a more optimal path).

A bad advisor wouldn't care what his students wanted, but a good advisor might still have students work on this kind of project as long as they were aware it wasn't going to help them get a tenure track position in the future. If they wanted to go work at a national lab doing HPC work and programing it might have been plenty ok for their career (This is what I am transitioning to now) or if they want to go work for a hedge fund or apple it might also be an okay option.

Re: Why physicists still use Fortran (2015)

#42

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…

Specifically on the topic of HPC, I know of a lot more GPU stuff happening in C/C++ than in Fortran.

Re: Why physicists still use Fortran (2015)

#43
post #38

> The benchmarks where Fortran is much slower than C/C++ involve processes where most of the time is spent reading and writing data, for which Fortran is known to be slow. Why would IO be slow in any language? What does the language have to do besides buffering and system calls? > In Fortran, variables are usually passed by reference, not by value. Under the hood the Fortran compiler automatically optimizes the passi…

>Why would IO be slow in any language? I believe many Fortran implementations default to unbuffered io. Which is probably easy enough to change. But I think that's really the core issue. Physicists don't want to learn more about programming languages. They want whatever mostly works out of the box and has local documentation and expertise specific to their problem domain. >Aren't arrays implicitly passed by reference…

Unless you're passing arrays of pointers to things about, the individual elements in a C array should be contiguous.

Re: Why physicists still use Fortran (2015)

#44

A lot of the arguments in this post can simply be rebutted with basic abstractions. Things like "Dynamically allocating and deallocating ... 2D array" is easy in C++. You could easily have someone define a MathArray class and turn this messy fortran code: real, dimension(:,:), allocatable :: name_of_array allocate(name_of_array(xdim, ydim)) Into something that looks like auto *my_matrix = new MathArray (); The code t…

I think your 3. and 4. are phrased a bit dismissively, though I don't entirely disagree. Not every workload in scientific computing maps cleanly into the GPGPU paradigm. Though that's not really a compelling reason to use Fortran over C++

An additional reason I've heard (I don't personally use Fortran) for keeping Fortran around is that it's straightforward to convert Matlab prototype code into Fortran

Re: Why physicists still use Fortran (2015)

#45

Earlier quoted context omitted.

Potentially your "rival groups" will have a long term advantage now though. This might be bad for the graduate students that did the work, but could be good for the professor and group over the next decade. Graduate students need to think in terms of 4-6 years while forward looking professors might want to think in terms of 5-15 years.

That was without a doubt pretty bad for those grad students' careers. That kind of work shouldn't have been done by anyone without tenure.

I might actually disagree on this one. If it was the first year of their PhD, then yes, it does seem like grunt work which is dissatisfying, but they will have fully learned the ins and outs of their group's code framework.

In the process, they would have understood nearly every approach taken by the group towards producing the results that it does, and I bet that has helped them when they've ended up modifying that same code later for their research. And with fewer supervisor meetings to work out exactly what X, Y and Z part of the code does because they will have worked on it themselves.

I'd say I've easily spent 6 months just spending time getting my head around all the code we work with anyway, so at the very least, I hope that made their following years of research more productive.

Re: Why physicists still use Fortran (2015)

#46

Earlier quoted context omitted.

Potentially your "rival groups" will have a long term advantage now though. This might be bad for the graduate students that did the work, but could be good for the professor and group over the next decade. Graduate students need to think in terms of 4-6 years while forward looking professors might want to think in terms of 5-15 years.

I do wonder about this a little, but so far I haven't seen anything implemented elsewhere in my field that hasn't been possible to do with our existing code. In fact, I have spent a fair bit of my time replicating others' results with our code and getting sub-percent level agreement. However, I guess one drawback is that a lot of the things we currently implement are all written from scratch (for very standard things…

I agree, it is very project/field dependent. There are times when a painful redesign might pay off in the future, but I am sure there are also times when it is a waste of effort. In your case a redesign might have been a waste, you are in the best position to judge this.

Re: Why physicists still use Fortran (2015)

#47
post #39

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

His response was "You could do that and it would probably be enough to earn your PhD, since it'll take you at least three years. But I suspect you'll want to work on something else during that time". as someone who had contact with that codebase, do you have any insights as to why that is? Was it the sheer size of the thing? Was it some nuance that Fortran had as an advantage over other languages? was the math just d…

Pretty much just size! There was about 20,000 lines of it, it's legacy code that has been gradually added to since the 1980s, so it would have taken a while to rewrite all the parts to work with each other. Perhaps some day though.

Re: Why physicists still use Fortran (2015)

#48
post #38

Earlier quoted context omitted.

>Why would IO be slow in any language? I believe many Fortran implementations default to unbuffered io. Which is probably easy enough to change. But I think that's really the core issue. Physicists don't want to learn more about programming languages. They want whatever mostly works out of the box and has local documentation and expertise specific to their problem domain. >Aren't arrays implicitly passed by reference…

Unless you're passing arrays of pointers to things about, the individual elements in a C array should be contiguous.

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

Re: Why physicists still use Fortran (2015)

#49
I wish there was a clean nomenclature for the context of program use. My world of programming is academia and industrial research. In that setting the vast majority of software is fashioned for ad-hoc use. There is no expectation that a large population will ever make use of what we code except to adapt it to some new specific related need. Scientific publishing promotes novel investigations, novel investigations promote one-off programs. And the user interface doesn't have to be, and is very seldom, "elegant" in any sense. It's in that context of "rapid cycle until it works then seldom use it again" that Fortran (or in my hands, python scripts which call Fortran numerical libraries) still makes sense. Understanding the context will free us from the head-scratching.

Re: Why physicists still use Fortran (2015)

#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 "adding capabilities" (which should be well-defined and constrained) to the existing codebase. If you get the money, then you've got carte blanche to rewrite to your heart's content - just don't tell the customer that this is what you're doing. Just make sure that those new capabilities indeed make it into the re-write and that you introduce no regressions in the new code.

Post reply on HN