Live data from Hacker News

Why physicists still use Fortran (2015)

moreisdifferent.com

11–20 of 300 posts

Re: Why physicists still use Fortran (2015)

#11
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 features in 2017, but the people that wanted these features moved to C/C++ long before the features became available in Fortran and those that are left using Fortran are usually scientist, not programmers, and so don't care so much about these features. I think it is largely the older generation that says they will never stop using Fortran, in the survey mentioned in the article.

Just to suggest where the field is moving though. NwChem is a large successful electronic structure package using Fortran. Its next gen version NwChemEx that is being designed for exascale will exclusively be written in C++ (https://www.pnnl.gov/science/highlights/highlight.asp?id=441...).

Also just from experience people who work in HPC mostly would rather be writing C/C++, but use Fortran because they have to not because they want to.

Re: Why physicists still use Fortran (2015)

#12
post #10

A slight gap in knowledge in the piece: Most Python libraries for numerical computation are written in C/C++ or... Fortran. Last time I had to compile scipy from scratch I had to install gfortran.

Some of the Numpy code is coming from 1970s: it uses BLAS that originates from 1979.

https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprogra...

Immense amount of effort was put in performance, correctness, feature set, and numerical stability of such widely used libraries. Replacing the without a very good reason is hardly feasible.

Re: Why physicists still use Fortran (2015)

#13
post #2

Our physics group has a core library, first written in 1987, that is in Fortran (a Microsoft dialect, to be specific). Why haven't we moved to something else? It works, it is time-tested, and the original author continues to maintain it. (P.S. I'd like to compile it with the gfortran tools, in order to preserve the library for the future. Is there any documentation for simple conversions from Microsoft's implementati…

> and the original author continues to maintain it.

What's the plan when they retire?

Re: Why physicists still use Fortran (2015)

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

For science codes, where Fortran is still used, the most expensive pieces (think DGEMM Kernel) are largely written in architecture dependent ASM anyways so programming language doesn't have that much of an effect on the most time critical pieces of large HPC programs.

If a specific function is important enough it will be hand optimized in a way that the language doesn't really matter. Sometimes that means calling MKL, or using Cuda, or writing your own assembly.

Re: Why physicists still use Fortran (2015)

#15
post #12
post #10

A slight gap in knowledge in the piece: Most Python libraries for numerical computation are written in C/C++ or... Fortran. Last time I had to compile scipy from scratch I had to install gfortran.

Some of the Numpy code is coming from 1970s: it uses BLAS that originates from 1979. https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprogra... Immense amount of effort was put in performance, correctness, feature set, and numerical stability of such widely used libraries. Replacing the without a very good reason is hardly feasible.

Blas is an interface, All performant blas libraries need to written to specifically take advantage of modern hardware. Things like NetLib exists as reference implementations, they are not high performance.

The point I am trying to make is that Numpy is unlikely to still be using the exact same code that was written in the 1970's unless its performance isn't critical. It is making the same function calls but the actual code will look pretty different.

Re: Why physicists still use Fortran (2015)

#16

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…

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 mention that skills in those languages are transferrable to other areas (data science, machine learning, etc).

As a side note: Wow someone working on the ECP on HN? I'm tangentially related to the project (and just visited PNNL last week)

Re: Why physicists still use Fortran (2015)

#17
post #2

Our physics group has a core library, first written in 1987, that is in Fortran (a Microsoft dialect, to be specific). Why haven't we moved to something else? It works, it is time-tested, and the original author continues to maintain it. (P.S. I'd like to compile it with the gfortran tools, in order to preserve the library for the future. Is there any documentation for simple conversions from Microsoft's implementati…

> and the original author continues to maintain it. What's the plan when they retire?

Is MS Fortran still a supported product? I'm not sure I'd call software that depends on unsupported and unmaintained other software properly maintained.

Re: Why physicists still use Fortran (2015)

#18
post #9

On array convenience: Fortran also supports optional runtime bounds checking of array indexes. I've worked writing signal processing code in Fortran, and it's really quite nice to have that when doing dev, even if you turn it off in prod for performance reasons.

GCC/G++ will remove bounds checking on O3 I think.

Re: Why physicists still use Fortran (2015)

#19
post #7

FORTRAN is still great for fast numerical applications and easier for me to read than C++. My industry is rewriting its FORTRAN base in C++ and a lot of physicists are switching to Python + Numpy for all but the most intensive tasks. I see FORTRAN being only used in legacy systems within the next 5-10 years.

FORTRAN is still in much of the R Core. Fortran is faster than C++ and I actually feel that many people are starting to realize why we still have FORTRAN around. Though there are many using Python + Numpy R still have a larger piece of user base in scientific and mathematical spaces.

"Fortran is faster than C++"

Whats your usecase?

It seems it is faster for some, but a lot slower in others:

https://benchmarksgame.alioth.debian.org/u64q/compare.php?la...

Re: Why physicists still use Fortran (2015)

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

[deleted]
Post reply on HN