Why is fortran used for scientific computing?

I read that Fortran is still widely used for scientific computing. For code that has already been heavily invested in Fortran, this makes sense to me.

But is there any reason to use Fortran over other modern languages ​​for a new project? Are there Fortran language design solutions that make it much more suitable for scientific computing compared to more popular languages ​​(C ++, Java, Python, Ruby, etc.)? For example, are there any Fortran specific language functions that can possibly increase numerical optimization in compilers to a much greater degree than other languages ​​that I talked about?

+46
fortran
Jan 25 '12 at 2:05
source share
5 answers

Fortran, for better or worse, is the only core language specifically designed for scientific computing. Array handling is good, with brief array operations on both all arrays and slices comparable to a matrix or numpy, but very fast. The language is carefully designed to make it very difficult to accidentally write slow code pointers, which are limited in such a way that it is immediately obvious if aliases can be used as a standard example - and therefore the optimizer can go to the city using your code. Current incarnations have things like coarray fortran, and do parallel and inline language, allowing distributed memory and shared memory parallelism, and vectorization.

Fortran's drawbacks are basically the flip side of one of the aspects mentioned above; Fortran has a huge long history. Potential: tons of large libraries. Disadvantages: tons of historical baggage.

If you need to crunch a lot, Fortran remains one of the best options, which is why it contains many of the most complex simulation codes running in supercomputer centers around the world. But, of course, it would be a terrible, scary language to write a web browser. For each task its tool.

+73
Jan 25 '12 at 2:50
source share

The main reason for me is the excellent array notation and many other design decisions that simplify the writing and debugging of scientific code. The fact that this is usually the best choice in terms of performance for the corresponding tasks (operations with arrays) will not hurt :)

Honestly, I would not consider most of the languages ​​named as real competitors for Fortran. Java and Ruby are far behind in terms of convenience and performance, and C ++ is too complex and complicated to recommend to anyone whose main job over the past few years has been something other than daily programming in C ++. However, Python with numpy might be an option. I personally am not a big fan of the language, but I know a few people who regularly use numpy and seem very happy with it.

The real competition that I see is not from these, but from Matlab, R and similar languages, which offer similar convenience in combination with many standard libraries. Fortunately, you can usually run a project in R or Matlab and write critical components in Fortran later.

+15
Jan 25 '12 at 22:40
source share

Several projects are completely new projects. I'm not sure that this is specific to scientific computing, but, at least in this area, you usually create your applications based on existing (scientific) models, possibly created by other groups / people. You will always have to deal with some outdated code, whether you want it or not.

Fortran is something that many scientists have taught, and which has many libraries that they need. Some of them may not be computer or IT specialists, but computer scientists. Their main task is rarely to calculate, this is their science in the first place. While a large number of programmers will tend to learn a new programming language or structure when they get a chance (including in their free time), most scientists will use this time to learn new ideas about their science.

A domain expert trained in Fortran (or any other language) and surrounded by people in a similar situation will have no incentive to move away from him. It’s not only that other languages ​​can now be as good as Fortran in terms of performance, they should be much better: you need to be a good reason to move away from what you have and know.

It is also a vicious circle to a certain extent. I have always found comparisons between Java and Fortran a bit complicated, simply because a number of scientific Java applications are not programmed in the Java way. Some of the Java Grande applications look exactly like Fortran programs converted to C programs, copied / pasted / modified into Java programs (in a method that passes the length of the array as an additional parameter next to the array itself gives the key, if I remember well). Because of this, Java (for example) does not have a great reputation in the scientific community, although its performance is getting better . The consequence of this is that there is little overlap between the HPC experts and the Java experts, for example. Even for hardware or library developers, little user demand leads to little support, which in turn repels users who might be interested in switching to other languages.

Please note that this does not prevent the same (or other) scientists from using other languages ​​for other purposes (for example, workflow management, data management, faster modeling using Matlab, Numpy, ...).

+12
Jan 25 '12 at 3:17
source share

As I understand it, there are libraries that are among the most efficient implementations of their algorithms, which makes Fortran popular for this kind of work, despite language restrictions.

+2
Jan 25 2018-12-12T00:
source share

One reason is how arrays were built. They are distinguished by a large footer, unlike most other languages. This provides faster calculation for their calculations.

-8
Jan 25 '12 at 2:10
source share



All Articles