Slashdot Mirror


Why Scientists Are Still Using FORTRAN in 2014

New submitter InfoJunkie777 (1435969) writes "When you go to any place where 'cutting edge' scientific research is going on, strangely the computer language of choice is FORTRAN, the first computer language commonly used, invented in the 1950s. Meaning FORmula TRANslation, no language since has been able to match its speed. But three new contenders are explored here. Your thoughts?"

17 of 634 comments (clear)

  1. Ten Reasons to use Modern Fortran by wispoftow · · Score: 5, Informative

    1) Modern Fortran is not all uppercase
    2) Modern Fortran does not have to start on column 7
    3) Modern Fortran has dynamic memory allocation
    4) Modern Fortran can use the same types as C (maximizes interoperability), hence can be called where C might be called
    5) Modern Fortran has an objects, polymorphism, etc.
    6) Modern Fortran has (a limited form of) pointers
    7) Modern Fortran has concise array/vector/matrix operations
    8) Modern Fortran has dynamically allocatable, multidimensional arrays that can be indexed starting with any integer
    8) Modern Fortran supports the complex type without higgery-jiggery
    9) Modern Fortran doesn't *need *pointers *in *all *the *places *that &C does, pass by reference is the norm
    10) Modern Fortran is blazingly fast and designed for sciene ....

    Some folks still write in Fortran 77, and the tired tales of woe that are bound to come from a language specification that is many decades old.

    But, that code/style still works, and who am I to judge how you want to get your work done?

  2. Re:Q: Why Are Scientists Still Using FORTRAN in 20 by Anonymous Coward · · Score: 5, Informative

    No, not just "legacy code." Fortran (yes, that's how it's spelt now, not "FORTRAN") was designed to be highly optimizable. Because of the way Fortran handles such things as aliasing, it's compilers can optimize expressions a lot better than other languages.

  3. Fortran is NOT the language of choice by Rostin · · Score: 3, Informative

    I have a PhD in engineering, and my dissertation involved writing lots of code. Now I work at a national lab in the US, and I and nearly all of my coworkers work on scientific or engineering codes of some sort. Although there is significant amounts of legacy code that was written in Fortran lying around (a project I work on uses a fortran library written in 1973), very little development is done in that language. It's all C++ or Python.

  4. Re:Q: Why Are Scientists Still Using FORTRAN in 20 by mbkennel · · Score: 5, Informative


    A: Legacy code, and because Fortran 2003+ is a very good modern language for scientific computation and maps very naturally to problems. As it turns out, the language semantics (both legacy and modern constructs) make it very good to parallelize. And it runs fast, as in, equalling C++ level of performance is considered a weak showing.

    If you haven't seen or used modern Fortran and think it's anything like Fortran 66/77 then you're mistaken. Except for I/O, which still tends to suck.

    In addition there are still some seemingly trivial but actually important features which make it better than many alternatives (starting from Fortran 90).

    There's some boneheaded clunkers in other languages which Fortran does right: obviously, built-in multi-dimensional arrays, AND, arrays whose indices can start at 0, 1 (or any other value) and of course know their size. Some algorithms are written (on paper) with 0-based indexing and others with 1-based and allowing either one to be expressed naturally lowers chance of bugs.

    Another one is that Fortran distinguishes between dynamically allocatable, and pointers/references. The history of C has constrained/brain-damaged people to think that to get the first, you must necessarily take the second. That doesn't happen in Fortran, you have ALLOCATABLE arrays (or other things) for run-time allocation of storage, and if you need a pointer (rarer) you can get that too. And Fortran provides the "TARGET" attribute to indicate that something *may be pointed to/referenced*, and by default this is not allowed. No making pointers/references to things which aren't designed to be referred to multiple times. This also means that the aliasing potential is highly controlled & language semantics constructed to make Fortran able to make very aggressive, and safe, optimization assumptions.

    The more parallel you want, the more of these assumptions you need to get fast code, and naturally written Fortran code comes this way out of the box than most other languages.

  5. not in the field, eh? by rubycodez · · Score: 4, Informative

    no, used because Fortran is the high level language that produces the fastest code for numeric computation, it is by far the most optimizable. Yes, it blows away C.

  6. Re:Q: Why Are Scientists Still Using FORTRAN in 20 by mbone · · Score: 3, Informative

    Yeah, I used to hear that argument a lot in 1978...

  7. Re:not in the field, eh? by InfoJunkie777 · · Score: 3, Informative

    OP here. This is what the article said. Compilers are the key. They have been around a long time. Another key is that commercial compilers (like Intel for example) further increase the speed, as the manufacturers know how to optomize the code for the specific CPU at hand.

    --
    Don't explain computers to laymen. Simpler to explain sex to a virgin. -- Robert A. Heinlein
  8. Re:Q: Why Are Scientists Still Using FORTRAN in 20 by Anonymous Coward · · Score: 2, Informative

    > it's[sic] compilers can optimize expressions a lot better than other languages.

    No. Wrong. C has had similar aliasing rules for a very long time. It's only recently that they got turned on in GCC by default. This is what all the -f(no-)strict-aliasing nonsense is all about. The problem is, people know that once, before C89, Fortran was faster. So of course it's still faster. Why would anyone ever modify C to be faster? That's just dumb.

    Also Blitz++ uses template metaprogramming and a DSL (that looks just like normal c-vector math) to optimize BLAS far beyond what fortran can do. A fairly minor example is rewriting the expression tree for (A+B)[2] to (A[2]+B[2]) at compile time.

  9. Re:Q: Why Are Scientists Still Using FORTRAN in 20 by edibobb · · Score: 5, Informative

    This is absolutely right. It's also easier to write, in many cases. Most scientific applications don't need things like lambda expressions or derived classes. Many people who write applications as tools in their research don't want to spend time learning esoteric aspects of languages.

  10. Re:Q: Why Are Scientists Still Using FORTRAN in 20 by K.+S.+Kyosuke · · Score: 4, Informative

    Blabbing on and on about vector based GPUs is idiocy, because not everything uses trig where vector based processing is beneficial. I have no confidence you have ever seen math intensive code based on what you are talking about. Nile from their own page is # The Nile Programming Language ## Declarative Stream Processing for Media Applications and NOT a language for Math.

    I find this view quite amusing, given that the whole scope of the VPRI project (of which Nile has been of the intermediate results) is to reduce everything in common personal computing into mathematics. And Nile in particular was designed precisely and explicitly to allow the VPRI people to express as wide an array of graphical operations using as short a high-level description as possible - a mathematical description, in equational form, to allow them to express the majority of Cairo (or any other Cairo-like 2D library) in a few hundred lines of these equations. Furthermore, nowhere have I made the claim that the semantics of Nile in its current form is a perfect replacement for any language for scientific computation, as opposed to the thought that there could be some lessons to be learned.

    And why don't you log in? There seem to be quite a few anonymous psychotic individuals running around here recently. It makes the conversation feel quite disingenuous.

    --
    Ezekiel 23:20
  11. Re:Q: Why Are Scientists Still Using FORTRAN in 20 by K.+S.+Kyosuke · · Score: 3, Informative

    Actually, you can get one for mere $35! ;) But no, the surface syntax is definitely something I didn't have in mind.

    --
    Ezekiel 23:20
  12. Arrays! by amaurea · · Score: 5, Informative

    The big thing Fortran has over C is proper support for multidimensional arrays, with powerful slicing operations built into the language. It was the inspiration for numpy arrays. My first languages were C++ and C, but when I do scientific programming, my languages of choice are now python and fortran (with f2py making it very easy to glue them together). Fortran is horrible at text processing, and has an almost absent standard library, but for scientific use, good arrays make up for that - especially when you can use python in the non-performance-critical parts.

    C++ has some multidimensional array classes, but none of them are as convenient as fortran arrays. Especially when it comes to slicing. At least that's how it was the last time I checked.

  13. Re:Q: Why Are Scientists Still Using FORTRAN in 20 by stenvar · · Score: 4, Informative

    Fortran has been an "APL style language" since Fortran 95, with most of the APL operations present. That was done both for optimization and for convenience. And other APL-style languages are very popular as well, foremost MATLAB.

  14. Re:Q: Why Are Scientists Still Using FORTRAN in 20 by amck · · Score: 4, Informative

    ALL CAPS has been optional since 1990, at least.

    Fortran has had modularisation, structured code since 1990, Classes and object-orientated since 2003. Please update your prejudices.

    --
    Anyone who believes exponential growth can go on forever in a finite world is either a madman or an economist
  15. Its not strange by nurb432 · · Score: 3, Informative

    Most scientists like to use tools that work, and they are proficient in.

    FORTRAN falls under both categories.

    --
    ---- Booth was a patriot ----
  16. Choice of language is secondary by gweihir · · Score: 4, Informative

    Yes, FORTRAN sucks, but it is stable, fast and well understood. It runs on a number of supercomputer architectures. It is way easier to program in FORTRAN than in C for non-CS people. So what is the issue? Oh, maybe that this is not a "modern" language? Here is news for you: Java sucks a lot more than FORTRAN.

    --
    Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  17. Re:Popular has a lot to do with installed base... by Athrac · · Score: 3, Informative

    Restrict keyword is not related to threading. C/C++ compilers have always assumed that data is not accessed from several threads without synchronization. It just wasn't standardized until the new memory model in C11 and C++11. So if you don't use mutexes, memory barriers etc, the compiler is allowed to assume a single thread of execution.

    What restrict does is it guarantees that two pointers do not point to same area in memory (aliasing). Let's say a function takes two pointers (char* a, char* b). If you write to the data pointed by a, then the compiler has to emit code to re-read data pointed by b, because a and b might refer to the same location. With restrict pointers the compiler doesn't have to do this.

    C/C++ have also always had the concept of strict aliasing, which basically says that pointers with different types may not be used to access the same memory location (char pointers are exception). It allows the same optimizations as the restrict keyword. However most compilers don't enforce the rule because programmers are stupid and use all kinds of noncompliant hacks with pointers.