Modern language with the advantages of FORTRAN?

后端 未结 12 1993
灰色年华
灰色年华 2021-02-05 19:04

I\'ve been working with a lot of FORTRAN 77 lately, and though I had reservations at first, I now see some great qualities of the language. It is:

  • Simple to learn
相关标签:
12条回答
  • 2021-02-05 19:11

    For the most direct answer to your question, I think that kemiisto's answer is correct, with the caveats identified by Idigas.

    That said, I've found more of my numerical code coming into contact with things like FTP, web, and closer to graphics. I've seen MATLAB suggested in another answer, but I've been writing more and more Python (with NumPy) and calling out to Fortran when I need the speed. I'd almost certainly not write a whole system (e.g. an entire numerical weather prediction model) this way, but it does allow me to have the best of both worlds in many respects.

    0 讨论(0)
  • 2021-02-05 19:15

    @S.Lott: Cannot imagine Fortran users such as scientists, having to switch over and dump all their Fortran work..... :S The OP is looking for input on what's new...

    To the OP: Have you read up on Wikipedia which details the changes made to Fortran, for 2003 version, allows interoperability with C, so maybe S.Lott does have a point, perhaps, bit by bit, gently port some stuff over or write a wrapper in C to call the Fortran modules? I'll quote from that Wikipedia page...

    Interoperability with the C programming language.

    0 讨论(0)
  • 2021-02-05 19:18

    I'm surprised that the consensus here is for modern Fortran, and I grudgingly agree.

    Whatever its failings, Fortran is the only language out there being designed explicitly for scientific programming. Scientific programming is both more subtle (per line) and less complicated (in structure) than, say, a web server, and it just needs different tools. Garbage collection, for instance, is almost never useful for solving large 2d/3d PDEs where your primary data structures are fixed.

    Any programming language that doesn't even have multi-d arrays as first-class objects can be dismissed immediately for scientific programming. and that's all of the C-based languages. Any programming language which is inherently god-awful slow -- Java, I'm looking at you -- can be dismissed immediately. Any programming language which is proprietary and requires thousands of dollars of licensing fees -- Matlab -- can be dismissed immediately.

    Python and related languages are good for prototyping, and plotting is easy, and once you've got things working can write the numerical kernels in compiled languages for speed; but it again suffers from the lack of real arrays (Numpy is good, but not great) and it is s..l..o..w.

    By the way -- don't ever by the Numerical Recipes books. They're crap, the algorithms they pitch are of date, and the code ranges from poor to wrong. Take a real numerical algorithms course - there's good ones on line - or buy a real numerical algorithms book -- and for the love of God, don't type in code from a book to do linear algebra or whatever; use the zillions of real, professional quality libraries out there.

    0 讨论(0)
  • 2021-02-05 19:19

    Or is the answer Fortran 90, 95, 2003 . . . ? Yes. For scientific computing, Fortran >=90 removes the limitations of FORTRAN 77. Learn how to use allocatable arrays to have dynamically sizable arrays. Learn how to use modules to organize your procedures and variables -- and easily provide automatic consistency checking between actual and dummy arguments. Starting from FORTRAN 77, you can gradually learn Fortran 90/95/2003, using whichever features seem useful to you. You don't have to learn the OO features and can ignore that portion of the language, until perhaps someday it offers utility to you.

    I recommend the Metcalf, Reid and Cohen book.

    0 讨论(0)
  • 2021-02-05 19:19

    I think Fortran 95 should be your choice it looks more modern and extends Fortran 77 quite significantly. The Fortran 2003 standard is not completely supported by most compilers. The great advantage of Fortran is that there is an optimized subroutine for every mathematical problem (such as root finding, matrix multiplication, eigenvalue problems, etc.). Other people mentioned legacy libraries and lapack is just one very powerful example. A major disadvantage of Fortran is that nobody is using it in the real world.

    The best book around is is my opinion "Fortran 90/95 for Scientists and Engineers".

    Of course all other suggestions are valid, but matlab is not free while Fortran is.

    Python is free and has support for a lot of scientific applications through extra packages such as Numpy and Scipy. Python is however rather slow when it comes to numerical performance. It's probably a good option for small projects that don't require a lot of computational power. The syntax is very easy to understand.

    C is of course also a free option and has a lot of (constantly updated) scientific libraries available. However, when it comes to readability it cannot beat Fortran. Fortran is well set-up to work with vectors and arrays.

    C++ is a superset of C so it's definitely also a possible choice. However, it is a language that might be to complex for the problems that you're looking at. The number of scientific C++ libraries is rather limited. There are some around but they cannot beat the Fortran versions (or are just wrappers of those). It's probably a very good option for very big projects but some very big programs that run on the world's fastest computers are written in Fortran. C++ is definitely worth learning since it is used for a broad number of real world applications.

    There are of course other languages or tools but I think these are the most commonly used across scientific disciplines.

    0 讨论(0)
  • 2021-02-05 19:23

    I've worked recently with a lot of Matlab, and I can see it's benefits today. Yes is is slow because it is an interpreted language, but it's matrix algorithms are fast. And I like it exactly because of that behavior. The slowness of the for loops and the performance of the matrix operations encourage you to think in a more mathematical way instead of sticking to loop oriented programming. But I can agree that Matlab can be dismissed, because it is not open.

    Currently I am looking forward to the Julia language. It is heavily inspired by Matlab except that it does want to be fast. Also it has static types which is also a very big advantage. But Julia is still very young, so do not expect that does already fulfill all your requirements.

    0 讨论(0)
提交回复
热议问题