Slashdot Mirror


Is GNU g77 Killing Fortran?

goombah99 asks: "I've come to believe that the existence of GNU g77 (and f2c) is holding back Fortran development. You might think that a free-ware compiler would be good for promoting the language. But it's not because the GNU flavor does not implement the de-facto standard DEC extensions to the language that give it dynamic memory allocation, pointers, and data structures. Without these Fortran 77 is indeed barbaric, but with them it is quite pleasant to work with. The problem is everyone writing new code is now afraid to use these commands in because of the desire to have their applications compilable by the teeming masses who may not want to pay $500 to $1000 dollars for a professional Fortran compiler (all of which do implement the DEC extension). F95 is being held back by the same considerations. Do you agree? Does anyone have some library extensions or pre-compilers that provide these capabilities to g77?" Are the DEC extensions so widespread and common that language survival is dependent on their inclusion, as the submitter suggests, in "every professional compiler". Assuming there aren't comparable features already available in g77, are there plans on eventually implementing similar?

41 of 195 comments (clear)

  1. 10 GOTO 20 by Dancin_Santa · · Score: 5, Informative
    1. Re:10 GOTO 20 by Spy+Hunter · · Score: 3, Interesting
      Wow. That article is awesome. This code made my jaw drop:

      const int N = 64;
      Array<double,3> A(N,N,N), B(N,N,N);
      Range I(1,N-2), J(1,N-2), K(1,N-2);

      A(I,J,K) = (B(I,J,K) + B(I+1,J,K) + B(I-1,J,K) + B(I,J-1,K) + B(I,J+1,K) + B(I,J,K-1) + B(I,J,K+1)) / 7.0;

      You can do that with C++?!? And it's super-efficient!?! The article explains that this code actually expands automatically into this loop that traverses the arrays in a convoluted manner designed specifically to improve cache-hit performance. All this complexity is hidden inside the library. Now I see what all these people have been raving about with template metaprogramming and expression templates.

      Seems to me that template metaprogramming is a rather awkward way to go about these things though. Couldn't you design a language that had features specifically designed to enable this type of in-line compile-time code expansion?

      --
      main(c,r){for(r=32;r;) printf(++c>31?c=!r--,"\n":c<r?" ":~c&r?" `":" #");}
    2. Re:10 GOTO 20 by jaoswald · · Score: 4, Insightful

      Sure, but it expands into C++ code. You still need a very wise C++ compiler to turn this into efficient machine code.

      A decent Fortran compiler knows more about the original statement than the C++ compiler can, and also, a Fortran compiler's number one reason for existence is to optimize array accesses.

      A C++ compiler is lucky to correctly compile all of the heinous complexity of the C++ language, much less aggressively optimize this type of array access.

      I'd be much more impressed if the poster had shown the resulting machine code.

    3. Re:10 GOTO 20 by Dr.+Photo · · Score: 3, Informative

      Seems to me that template metaprogramming is a rather awkward way to go about these things though. Couldn't you design a language that had features specifically designed to enable this type of in-line compile-time code expansion?

      There's something like that already, called ANSI Common Lisp. (Yes, I'm serious.)

    4. Re:10 GOTO 20 by Spy+Hunter · · Score: 3, Interesting

      Why do you need to see the machine code? Doesn't the performance of the compiled code speak for itself? He benchmarks the code against hand-optimized Fortran code for the same task, and it beats Fortran. Did you even read the link?

      --
      main(c,r){for(r=32;r;) printf(++c>31?c=!r--,"\n":c<r?" ":~c&r?" `":" #");}
    5. Re:10 GOTO 20 by t · · Score: 2, Informative

      I've seen this before and its complete crap. Change the first line to
      const int N = rand();
      Then see how fast it runs. All that uber special loop expanding trickery usually doesn't work when you don't know the sizes of your arrays beforehand.

  2. Want "modern" features? Don't use F77 by GuyMannDude · · Score: 4, Insightful

    But it's not because the GNU flavor does not implement the de-facto standard DEC extensions to the language that give it dynamic memory allocation, pointers, and data structures. Without these Fortran 77 is indeed barbaric, but with them it is quite pleasant to work with.

    You can mock Fortran 77 all you want but the "barbaric" striped-down version can be highly optimized. And for a lot of the legacy scientific code out there, you just don't need dynamic memory allocations, etc. If you really do need all these fancy, modern features, why the hell are you using Fortran 77? Fortran 77 is a simple yet highly effective, stripped-down language that is appropriate for a limited number of applications. But it does those applications really damn well. Don't blame Fortran 77 if you're trying to use the wrong tool for the job.

    GMD

  3. Old age. by t · · Score: 2, Funny
    Seriously, that is what is really killing fortran. When I was in undergrad about ten years ago they had stopped teaching fortran and had switched to C. Since then everyone falls into a couple of categories. (1) Those who learned fortran first and still use it. (2) Those who learned C first and thus have no reason to ever use Fortran. (3) Those who are forced by their jobs to use Fortran.

    Of these, group (1) is all the old foggies who are retiring, leaving group (2) people to continue the work. Typically what is done is C wrappers are made to call the legacy fortran code and all subsequent work is done in C. Group (3) people are always desperately trying to migrate their projects to C.

    That is why fortran is dieing.

  4. Re:Wrong... by Dancin_Santa · · Score: 2, Funny

    I made the switch after that Physics course that required Fortran. I haven't used Fortran since, and I haven't looked back.

    I learned Emacs in that course as well. I haven't used that since, either.

  5. Eventually? How about currently? by devphil · · Score: 4, Informative
    Assuming there aren't comparable features already available in g77, are there plans on eventually implementing similar?

    There's already a team of very capable -- and young, not ancient/retired/whatever -- programmers implementing the Fortran 9x language, which defines some really interesting constructs. The current plan is for an initial release as part of 3.5.

    Fortran 2000 has a spec, but I don't know of any implementations for it.

    As far as "why is it still being used at all" comments, two words for you: no aliasing. The same reason why numerical computation in Fortran continues to chew C's head off.

    --
    You cannot apply a technological solution to a sociological problem. (Edwards' Law)
  6. Oh come on by BoomerSooner · · Score: 4, Insightful

    You can develop software in any language. Fortran, C, Visual Basic, Assembly, ...

    99% of the problem is the programmer not the language. Every language has an advantage in its specific area. VB/Delphi Quick & Dirty Interface or Prototype (quick development time). C/C++ Portability & Speed of Program. Assembly True low level programming. Wait what is fortran used for again? (lol just kidding). Excellent math modeling for quick and dirty precision calculations (I'd still use C because I've never used Fortran).

    I guess g77 is holding it back because that is one of the reasons I've never used it. I thought there was a Fortran 85 or 90 spec as well?

    Boomer Sooner (way to choke one off early Tejas)

    1. Re:Oh come on by BrokenHalo · · Score: 2, Insightful
      FORTRAN, especially in its older incarnations e.g. FORTRAN-77, reall is that bad. Having learned C as a teenager...

      You said it yourself. If you learned C as a teenager, you would not have been forced to spend the time with Fortran that it takes to get proficient enough with it to appreciate its elegance, power and simplicity.

      I'm not going to get on the tired old hobbyhorse of "Real Programmers Don't Use Pascal" (if you're not following me, google for the title), but if you cut your teeth on mainframe assembly code, FTN is a fabulous language.

      Trouble is, FTN was designed for people who were assembly programmers first and knew how it all worked, and that doesn't sit well with a generation that can't/won't take the trouble.

      As for the "worst one prevailing", I have to ask "worst at what?". If you're doing heavy-duty maths, Fortran is much quicker to code, and the resulting objects are nearly always extremely efficient. (Boeing math library, anyone?) Having said that, I remember coding financial packages in FTN back in 1978...

  7. It's "free software" not "free-ware". by jbn-o · · Score: 4, Informative
    You might think that a free-ware compiler would be good for promoting the language.

    Haggle over the technical merit of g77 all you want, but free software is not the same as "free-ware".

  8. Let it go... by AJWM · · Score: 3, Insightful

    The last time I programmed in Fortran it was still Fortran IV. (Oh, wait, I did write a version of "Asteroids" for a VAX with a graphics unit and AD/DA hardware in DEC's Fortran 77 -- but that wasn't serious programming.)

    When I wanted structures and records and fields (oh my!) I went with PL/I or Pascal or C or C++ or Java (in roughly that chronological order). Let it go. If you want to do Fortranish things, use (standard) Fortran. If you want to do Pascalish or Cish or Adaish (etc) things, use that language.

    There's probably a corollary of Henry Spencer's law about ignorant OS designers reinventing Unix (poorly) that applies to programming languages, although I haven't quite figured what the "target" language (the way Unix is the target OS) is. (Probably Algol68 ;-)

    --
    -- Alastair
  9. Re:Fortran to C++ converter? by trouser · · Score: 2, Funny

    and into Bjarne's.

    --
    Now wash your hands.
  10. Fortran Standards by aster_ken · · Score: 2, Informative

    The gropu that works on the Fortran standard is J3.

    The current standard is Fortran 95 which, as another poster pointed out, is currently being developed into g77. However, work is progressing nicely on Fortran 2003. From the web site above:

    "Fortran 2003 is an upwardly-compatible extension of the current Fortran standard, Fortran 95, adding, among other things, support for exception handling, object-oriented programming, and improved interoperability with the C language."

  11. So little logic from a programmer by Crashmarik · · Score: 4, Insightful

    How can anyone think that the free availability of a vital resource impedes the progress of anything ? Is the availability of free C,pascal,forth etc implementations killing off those languages. Is the availability of GCC for win 32 stopping anyone from using Visual C ? Is the availability of freepascal killing delphi ?

    The answer is no. A free implementation of fortran makes it that much easier for the language to be taught. If there are people that know the language they will use it. If people use the language it will grow and develop.

    If you wan't to know what's hurting fortran you might try readin Dijkstra's "Goto Considered Harmful".

    1. Re:So little logic from a programmer by edwdig · · Score: 2, Insightful

      How can anyone think that the free availability of a vital resource impedes the progress of anything ?

      Did you see much C++ code being written that took full advantage of the standard, and did not violate it in any way before GCC 3.0 was released? I certainly didn't. The two biggest C++ projects I can think of are KDE and Mozilla. KDE took work to get working with gcc 3.0. Mozilla's decision from the start was to only use a minimal subset of C++ to avoid compiler issues.

      Or how about this one... how many people write fully HTML compliant web pages? Not many, compared to the numbers that don't. Why not? Thank the freely available Internet Explorer for that.

  12. Re:Eventually? How about currently? by Jerf · · Score: 3, Informative

    I went poking around on Google and could not find an answer in 30 seconds, so you are forgiven. ;-)

    I think this page on aliasing should answer most of your good question.

    Add to that page the fact that if a compiler can't be sure about something, the answer is typically to copy the thing it can't be sure about into a safe location, and either copy it back somewhere after the "unsafe" thing or explicitly check it for changes.

    For instance, if you're calling a function and the compiler can't know what it's going to do to the caller's registers, the compiler must painstakingly copy the registers out to main memory (well, it'll probably land in L1 cache but still it could be very expensive compared to the function itself), call the function, and copy the registers back in, whereas if the compiler can know it's a little function that only uses registers X and Y, it can only save those. If you're calling lots of little functions, this can add up.

    A real example of this? If you're making a static call in C to a function, the compiler can go look at the function and do this analysis. If you're calling through a pointer, a common operation (at least, I can't stand using C without it...), it can't, because that pointer could be pointing at anything, up to and including a dynamically constructed function (if you're brave). To maintain its promises to the programmer that a function call never changes the variables in the caller (which may be located in registers), it has to protect all the registers.

    Aliasing is a nasty problem because it's completely opaque to the compiler; the compiler can't see through that indirect function call to the function beyond, not even in theory. As the page mentions, other techniques are being developed that don't involve that sort of opacity by working around aliasing, and the JIT compilers take a different, more dynamic tack that in theory lets them do this analysis dynamically. (The Transmeta processors can also do some of this stuff, which is one of the ways they can speed up code when they run it a lot; they can do this more expensive analysis and dynamically optimize the code.)

  13. Re:Flame on! -- wrong perspective by Alinabi · · Score: 4, Insightful

    You are looking at the issue from the wrong perspective. Unlike a software engineer, scientists does not consider the software they write a final product. Their product is the result of the computation performed using the software. That's what brings them grant money. Thus, they would like to spend as little time as possible writing software and dedicate most of their time to interpreting those results. Since most of the numerical libraries out there are written in FORTRAN and that they are already familiar with the language, I think FORTRAN will remain their darling for a long time. It's a fact of life, not a matter of policy.

    By the way, most of them use commercial compilers rather than g77, because they need the optimizing features which g77 does not provide (think parallel computing).

    --
    "You can't allow somebody to commit the crime before you detain them." [Condoleezza Rice]
  14. Re:Eventually? How about currently? by jaoswald · · Score: 2, Insightful

    You mean, write Fortran-style programs in a crippled sub-dialect of C?

    Plus, how many C compilers are made to optimize for this case that is extremely common in Fortran, but extremely rare in C code?

    Fortran compilers are the best compilers for Fortran programs. C compilers are best for C programs. Fortran compilers can be expected to perform poorly on "C-like" structures, and C compilers are likely to perform poorly with "Fortran-like" programs.

  15. Aliasing, Fortran, C, and C++ by devphil · · Score: 4, Informative


    Yeah... I thought the CS community at large mostly knew about this. Okay:

    Fortran specifies that Thou Shalt Not Alias, so in the example on the page that you linked to, the function-calling programmer, the function-implementing programmer, and the compiler can all assume that everything refers to non-overlapping memory, and can optimize the hell out of read/write memory accesses.

    When Dennis Ritchie designed C, it was a deliberate decision to not prohibit aliasing. (C's ancestor languages may have allowed aliasing as well, and DMR just decided to continue that; I don't actually know. But the question was brought up and considered; it's not an accident.)

    When C was first being standardized by ANSI, a really sloppy proposal was made to add a 'noalias' keyword. It was so bad that DMR sent a public letter to the ANSI committee stating, "noalias must go; this is non-negotiable." So C89 has no way of restricting aliasing.

    C++98 and C99 do, sort of. C99 added the __restrict keyword to the language. C++98 left the core language alone and defined a library type, std::valarray, that is free of aliasing by definition, opening up a number of optimization possibilities.

    Valarray didn't quite work out; its design is semi-broken. Far more hopeful is using expression templates to expose more of the numerical computations to the compiler, so that more optimizations can be done on visible numbers. Check out Blitz++ at oonumerics.org for an example.

    --
    You cannot apply a technological solution to a sociological problem. (Edwards' Law)
    1. Re:Aliasing, Fortran, C, and C++ by James+Lanfear · · Score: 3, Informative

      C's ancestor languages may have allowed aliasing as well, and DMR just decided to continue that; I don't actually know.

      C's ancestors were untyped, so I don't know if it would have been possible to prevent aliasing. At best you give hints when pointers were copied, and hope no one deref's anything else.

      C99 added the __restrict keyword to the language.

      It's restrict in C99. __restrict is a GNU C extension.

  16. Sad but (mostly) true. by Professor+D · · Score: 2, Interesting
    In my former life as a grad student in the sciences the lack of a free f90 compiler definately prevented adoption of GNU/Linux as an alternate/cheap platform. We had code that simply could not be compiled because g77 lacked features that are older than some people reading this post!

    The vendor compilers however had all the f90 options, which 'forced' us to pay for the expensive developer packages instead.

    At the time, the two extensions we needed (IIRC) were STRUCT and POINTER, which were on g77's to-do list. Now, the better part of a decade later, they _still_ are AFAIK.

    I wonder why none of the many high-budget science projects that use open-source extensively have never properly funded g77 development?

  17. Re:Flame on! by pyrrhonist · · Score: 3, Informative
    Fortran has too many structural problems to use for major applications.

    Fortran is the language used in the communication terminals the Navy uses to send and receive data through the Milstar satellite communication network.
    These devices are used in ground stations, ships, and boomers. That's a pretty major application.

    --
    Show me on the doll where his noodly appendage touched you.
  18. Fortran 95. by Bill,+Shooter+of+Bul · · Score: 3, Interesting

    Frotran 95 includes the For each programming construct that allows the compiler to perform each action in the loop on a different proccessor. And thats just darn cool.

    --
    Well.. maybe. Or Maybe not. But Definitely not sort of.
  19. This is Depressing by turgid · · Score: 3, Interesting
    When I was doing Physics at Uni they forced me to use FORTRAN 77 for "portability" despite the fact that I already knew C.

    However, 10 years ago, FORTRAN compilers were very much more advanced in terms of optimisation for numerical work than C (e.g. the Cray compiler could do automatic vectorisation.)

    I would have thought that if you had a big, expensive supercomputer, you can afford the compiler. Not buying the compiler is silly, because you'll probably end up with an order of magnitude less performance out of it with a compiler whose primary goal is portability and has been designed to work well on totally different hardware architectures.

    Having said that, though, if you've got a low end box, you probably want a cheap or free compiler. Why spend $1000+ on a compiler when the box probably cost less? The low end box can probably sustain 100+MFLOPS (easily) and peak well into the GFLOPS. That's a cheap Athlon we're talking about. So you probably don't want to buy a fancy FORTRAN compiler. Why not just stick to C or even C++ nowadays? Legacy code :-(

    So you have a problem. The big supercomputer you bough 5 years ago probably has a "slow" C/C++ compiler. The nice cheap box you have on your desk has arubbishy FORTRAN compiler and a reasonable C/C++ compiler.

    So, you can convert all your legacy code to C and C++, you can buy a commercial FORTRAN compiler or why don't you universities cough up some time and money to give to the GNU FORTRAN people to help them improve their compiler? Or is that too radical and lefty?

  20. Re:Fortran to C++ converter? by turgid · · Score: 2, Informative

    Not C++ but C: f2c

  21. what about the intel compiler ? by dario_moreno · · Score: 3, Informative


    The Intel Fortran compiler supports F90, dynamical allocation, works better than Absoft or Portland Fortran, and is free for Linux...and for all of you complaining about Fortran, do you have a job ? I know someone who ended with a very nice job just because he had mentioned "Fortran" on his resume, and had spent maybe 1 week of work on " Numerical Recipes in Fortran" and the Intel/g77 compiler.

    --
    Google passes Turing test : see my journal
  22. In other news by Chelloveck · · Score: 4, Insightful
    But it's not because the GNU flavor does not implement the de-facto standard DEC extensions to the language that give it dynamic memory allocation, pointers, and data structures. Without these Fortran 77 is indeed barbaric, but with them it is quite pleasant to work with.

    Yeah, there's a lot of that going around in the open source world. I've heard of this other project that's stifling growth in a major segment of industry by not implementing the de-facto standard extensions that its commercial competitor uses. You might have heard of it, it's called Mozilla.

    I admit that I haven't touch FORTRAN since about 1985, so forgive me if I'm not exactly up on the state of the art. From a little googling, it looks to me like g77 is pretty much an orphaned project. This is free software, man, developed and supported by the community. Have you considered volunteering to fix the parts you think are broken? Or volunteering to work on the f95 compiler effort?

    --
    Chelloveck
    I give up on debugging. From now on, SIGSEGV is a feature.
  23. Wrong conclusion by Anonymous Coward · · Score: 2, Insightful

    You've started with a conclusion (g77 is holding back the adoption of F95) then found evidence to support it. However, if we look at the situation logically, a better conclusion would be that non free software is holding back the adoption of F95. F77 is being more widely used because there is a free compiler available for it. In conclusion, the finger should be firmly pointed at vendors who refuse to release an open source or free as in beer F95 compiler.

  24. Re:I'm serious by etcshadow · · Score: 2, Insightful

    It's impossible to write a complex program without using GOTOs

    I call bullshit on you. There is <b>nothing</b> about fortran that makes GOTOs any more necessary than they are in C (which is an argument in and of itself... however I come down on the side of "never use them").

    I taught two beginner's programming classes between 1995 to 1999, one in F77 and one in C (with the last week talking about C++). Apart from the lack of pointers and structures, F77 has (essentially) all of the language structure C (or any other procedural language) does. I never allowed my students to write GOTO statements, and it was never necessary (beyond the same caveats C programmers have when saying that). As a side note, we got significantly further in programming with the fortran groups than the C groups, despite the fact that the fortran class was taught to freshman chemial and mechanical engineers, and the C class was taught to electrical engineers (who, as demographic cross-section, had somewhat more of a bent towards programming to begin with).

    It's true that C is made far more capable (and difficult to learn) because of pointers. It's also true that the lack of structures makes F77 a bit of a pain in the butt at times (but not in any way less capable). However, complex data structures are still <i>possible</i> in F77, if a pain in the ass. I've written binary search trees, recursive descent parse trees, and linked lists in vanilla F77 (no DEC extensions). Granted, the F77 idiom for doing this kind of stuff is really kind of sad. However, I could argue that there are similarly lots of things that C programmers do every day which are horribly fugly because they can't use the idioms of perl (for example).

    Anyway, maybe it's pointless to argue because, in the end, I really... <b>really</b> wouldn't recommend anybody program with F77 any more.

    --
    :Wq
    Not an editor command: Wq
  25. what is killing fortran by Mark+Muller · · Score: 4, Interesting

    What is really killing fortran is the perception that fortran == f77. Tell someone you program
    in fortran, and they immediately think of old,ugly f77.

    I write code (both reasearch and commercial vibration analysis) in fortran90/95 every day - I
    use modules, I use pointers, and I get great performance. A few things I also get:

    1) clean, neat code that is easy to read by non-programmers.

    2) Array bounds checking by the compiler - try that with C++. Array bounds checking saves me
    huge amounts of time in development.

    3) Compiler checking of function calls, via encapsulation of functions in modules.

    4) Easy use of BLAS and LAPACK routines for real computational work.

    5) The actual function definition used for the function prototype - I don't have to maintain a
    separate prototype for my functions to get the advantages of prototyping!

    Fortran isn't perfect (yet). It still lacks the ability to make a function part of a data
    structure (ie, classes). It current i/o abilities still suck. It's ability to handle characters and
    character strings is terrible. But it does have advantages other than producing fast code, and it
    isn't your father's fortran77.

    1. Re:what is killing fortran by MagikSlinger · · Score: 2, Interesting

      1) clean, neat code that is easy to read by non-programmers.

      *snort* I'll believe that when I see it.

      2) Array bounds checking by the compiler - try that with C++. Array bounds checking saves me huge amounts of time in development.

      I use the STL and not think about bounds ever again.

      3) Compiler checking of function calls, via encapsulation of functions in modules.

      Unless you're badly describing another feature, that was one of the first features of C++ and ANSI C.

      4) Easy use of BLAS and LAPACK routines for real computational work.

      Two words: C wrapper.

      5) The actual function definition used for the function prototype - I don't have to maintain a separate prototype for my functions to get the advantages of prototyping!

      Some argue that having a separate prototype prevents the implementor from arbitrarily changing the interface without warning their other team member.

      Fortran isn't perfect (yet). It still lacks the ability to make a function part of a data
      structure (ie, classes). It current i/o abilities still suck. It's ability to handle characters and
      character strings is terrible. But it does have advantages other than producing fast code, and it
      isn't your father's fortran77.


      You just said the two most important capabilities of any programming environment in most problem domains (I/O and character handling) suck, so what advantages does FORTRAN have have? Native complex number support? The rest of FORTRAN's "advantages" have long since been added to every other programming language on the planet.

      And as for native complex number support, I might point out with C++, you can create identical functionality with a class and operator overloading.

      --
      The bitter lessons of a veteran coder: http://bitterprogrammer.blogspot.com
  26. Is this really a bad thing? by yandros · · Score: 3, Insightful

    Let me get this straight:

    1) People don't want to pay $500-$1000 for a compiler.
    2) The existance of g77 means that they don't have to.

    What's the problem again? Shouldn't people be able to make a ``less featureful, less money'' decision? (..and that totally ignores the other values of having a free-as-in-speach compiler).

  27. Re:OK, you asked... by Spy+Hunter · · Score: 2, Informative
    Nice history lesson. Let me tell you a story about today. Today, we use libraries. We trust the library authors to write efficient code, and we don't worry about machine code anymore because programmer time is more expensive than CPU time. Modern compilers take care of most of the optimization for us. If our applications turn out too slow, we use profiling tools and change our algorithms instead of optimizing instruction sequences.

    The author of Blitz++ has proven, through these benchmarks, that his code, when compiled with an actual C++ compiler (gasp, horror, so inefficient!), is more efficient than Fortran at tasks in which Fortran excels. I sure don't think he needs to show any machine code to convince me. In this particular case, the C++ machine code would be much longer and more complex, in fact, since it uses a complex algorithm to traverse the arrays. Therefore, looking at the machine code would be totally missing the point.

    --
    main(c,r){for(r=32;r;) printf(++c>31?c=!r--,"\n":c<r?" ":~c&r?" `":" #");}
  28. Fortran 77 is just fine. by tsphere · · Score: 2, Insightful

    The only reason to learn Fortran today is to work with old code. The old code is invariably written in F77, since it is without a doubt from the 70s itself.

    there is no good reason to develop a new application on fortran today.

    well, except for massively parrallel calcuations using parallel optimizing compilers.

    but write it in F77 anyway, it's all you need.

    if you really need dynamic memory or pointers, write it in C. it's faster, easier to optimize with plain gcc, and also from the 70s.

    or just buy freaking matlab or mathmatica or something.

    --
    Tetris rules.
  29. Re:Why not use gfortran ? by cimetmc · · Score: 2, Informative

    Why not use gfortran ?

    Well, I think it's still a bit early for production use. In its current state, it may be fine to play around with and help the developers, but I don't think it is good enough yet for real world programming.

    Marcel

  30. Re:Greenspun's 10th rule of programming by AJWM · · Score: 2, Insightful

    Heh, thanks.

    But that's almost a tautology: any C or Fortran program that doesn't contain "an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp" is clearly not "sufficiently-complicated" ;-)

    --
    -- Alastair
  31. Fotran is still better for scientific numerics by goombah99 · · Score: 2, Informative

    I fully agree that Fortran is NOT for every day programming of word processors, opertating systems, games, device drivers, and GUIs, and that there is a resistance to learning it in schools these days. However I believe the Modern Fortran Language is a better choice for most scientific and numerical programming by non-computer scientists;

    Consider the following....
    perhaps the biggest complaint in the cutting edge of computing is that no one knows how to effectively program for multi-processors for ad-hoc, scientific programming. Duals are already ubiquitous at the low end consumer market, and of course IBM, sun and sgi have long made units with dozens of cores. Its only going to increase. Likewise Intels now all have hyperthreading to increase the efficiency of their instruction pipeline.

    An unsolved problem is how to write custom code for end use in multi-processors that does not depend on knowing the architecture or require special libraries or the very complicated bussiness of writing thread-safe code (locking variables etc...). Shared Memory management is a major bottleneck: How to distribute arrays to multi-processors and keep caches up-to-date after writes is a huge problem.

    For parallel processing fortran 95 boasts many language level features that give ANY code implicit parallelism and implicit multi-threading and implicit distribution of memory WITHOUT the programmer cognizantly invoking multiple threads or having to use special libraries or overloaded commands.
    An example of this is the FORALL and WHERE statements that replace the usual "for" and "if" in C.

    FORALL (I = 1:5)
    WHERE (A(I,:) /= 0.0)
    A(I,:) = log(A(i,:))
    ENDWHERE
    call some_slow_disk_write(A(I,:))
    END FORALL

    the FORALL runs the loop with the variable "i" over the range 1 to 5 but in any order not just 1,2,3,4,5 and also of course can be done in parallel if the compiler or OS, not the programmer, sees the opportunity on the run-time platform. The statement is a clue from the programmer to the compiler not to worry about loop-order dependencies. Moreover the compiler now knows it can fork off the slow-disk-write operation so it does not halt the loop on each interation.

    The WHERE is like an "if" but tells the compiler to map the if operation over the array in parallel. What this means is that you can place conditional test inside of loops and the compiler knows how to factor the conditional out of the loop in a parallel and non-dependent manner.

    Moreover, since the WHERE and FORALL tell the compiler that the there are no memory dependent interactions it must worry about. thus it can simply distibute just minimal and orthogonal pieces of the A array to different processors, without having to do maintain concurrency between the array segments used by different processcors, thus elminating shared memory bottlenecks.

    Another parallelism feature is that the F95 header declaration not only declare the "type" of variable ,as C does, but also if the routine will change that variable. This lets the compiler know that it can multi-thread and not have to worry about locking an array against changes. In the example, the disk-write subroutine would declare the argument (A) to be immutable. Again the multi-threading is hidden from the user, no need for laborious "synchronize" mutex statements. It also allows for the concept of conditionally-mutable data.

    Other rather nice virutes of FORTRAN is that it uses references rather than pointers (like java), so less ways to spend your time debugging.

    The sad reason the world does not know about these wonderful features, or repeats the myths about the fortran language missing features is due to GNU releasing a non DEC-compatible language. I think the world would be better off if g77 did not exist. By doing so they undercut the affordable fortran compiler market and forced everyone to write for the lowest common denominator to have their code

    --
    Some drink at the fountain of knowledge. Others just gargle.
  32. Computer "sceintist" != Real Sceintist by goombah99 · · Score: 3, Informative

    Numerical recipies said it best. Scientist solve next years problems on last years computer. Computer "scientists" solve last years computer problem on next years computer. You appear to have no clue that all your statements about will slow the code and the memory management ot a crawl.

    1) clean, neat code that is easy to read by non-programmers.

    >*snort* I'll believe that when I see it.


    double snort. Did you know its not possible to make a typo type syntax error in fortran 77 that will compile? hard to believe I know but its true. ( You cant misplace a plus sign or comma or leave off a [] and have it compile.
    when I try to debug faulty c-code and see something like
    i = --j
    I have to try to figure out if they could have meant to write
    i = -j or i = j-- or i = --j
    yuck.

    2) Array bounds checking by the compiler - try that with C++. Array bounds checking saves me huge amounts of time in development.

    I use the STL and not think about bounds ever again.


    SLOOOOW. And unparallelizable. and it kills multi-processing dead. and loss of control over memory management. loss of memory mapped sub arrays, strides etc.... Sure you can do strides in c++ but now they are function calls not direct-to-memory. In fortran you can often pull contionals outside of loops using the WHERE syntax. Its much better to have a good syntax in the language than make up for it with a bunch of function calls and object instantiation. e.g. both languages can write
    A = B*C where A,B and C are matricies but C has to do it with objects and overloads. fortran does not. which do you think is going to be faster.

    3) Compiler checking of function calls, via encapsulation of functions in modules.

    Unless you're badly describing another feature, that was one of the first features of C++ and ANSI C.


    So fortran steals a good thing from C and you complain? In fact fortran 95 implemented headers much better than the asanine way C does it. If fortran you can declare the headers for the called functions right in the code that will call the function so fewere prototype mismatches occur. and fortran also lets you specify the not just the type defs but also whether the subroutine will change the arguments or not (without having to pass by value or declate things final). Thus the compiler can know for example if a cache will need to be written back or how to share memeory between two processors. or if it can multi-thread past a subroutine call.

    4) Easy use of BLAS and LAPACK routines for real computational work.

    >Two words: C wrapper.


    whoopee. I can say it in reverse: take the STL and put a fortran wrapper on it. now fortran has the STL.

    5) The actual function definition used for the function prototype - I don't have to maintain a separate prototype for my functions to get the advantages of prototyping!

    >Some argue that having a separate prototype prevents the implementor from arbitrarily changing the interface without warning their other team member.

    well fortran90 can either derive its prototype or you can specify them your call. its nice to have it both ways and not pay any price.

    >Fortran isn't perfect (yet). It still lacks the ability to make a function part of a data
    structure (ie, classes).

    not really true. You can program in an object oriented fashion if you wish. but its more like perl-objects where the data is explicitly passed rahter than C where its hidden from the user.
    in C++ you would say

    myobject->hash_get(key)
    in fortran you would say:
    hash_get(myObjectStructure, key)

    is there any important difference?
    It current i/o abilities still suck. It's ability to handle characters and
    character strings is terrible.

    Well fortran90 does have nice string handling. and of course it lacks the C string terminator problems that account for so many buffer overflow issues. But I w

    --
    Some drink at the fountain of knowledge. Others just gargle.