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?
20 C++ faster than Fortran
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
watch this
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.
That should be:
:-P
20 CONTINUE
25 C++ faster than Fortran
Remember, jumping to a line number that's not on a CONTINUE statement can break things.
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)
Why doesn't someone make a Fortran to C++ converter and help everyone out of their misery?
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)
Haggle over the technical merit of g77 all you want, but free software is not the same as "free-ware".
Digital Citizen
The extra "not" in that post made it almost impossible to understand since it gave the most important sentance the exact OPPOSITE meaning (although in poor english).
took me a while to understand what the heck was going on there.
What is this "aliasing" all about? Can you go into more detail regarding why fortran is better than C for numerical computing?
Bare in mind that I have NO knowledge of fortran, but I do compile fortran code for people doing scientific computing. I can see that at some point in the future I will probably have to learn a bit about fortran. It would be nice to know why bother? :)
Steve
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
Indeed. My mother still uses the Fortran v2 DOS compiler because it has no bugs and it does the job she needs (usually brute-force finanical model testing IIRC).
It is open source. It doesn't work if you sit there and cry about it not working the way you want. It works great if you decide it doesn't work so you fix it yourself.
I don't care how you fix it. You can write the code yourself, or you can hire someone to write the code for you.
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."
(I'd still use C because I've never used Fortran).
Why don't you read the basics of Fortran syntax before you pronounce that judgement? I never said that Fortran was unusable; I said it had major structural problems in the language. It's impossible to write a complex program without using GOTOs, for instance. It's okay for quick 'n dirty, small stuff, but for long-term use it can be a maintenance nightmare.
I was just joking. The reason you are stating is the reason I've never used g77.
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".
You can avoid aliasing in C. Use statically sized arrays instead of malloc'ed ones and don't take the addresses of things.
Everyone should see this! It rocks :-)
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.)
You want more, you write it. It's not like people using g77 don't know how to program.
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]
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.
I think the real issue is that people see languages such as java, C, C++, .net, and newer languages as more exciting to program in and fortran is percieved as archaic. Also there is only a small market for fortran programmers. Many people probably think that fortran is dean, not because of the compiler, but because fortran is like pascal and cobal. Old languages! Personally when you look at the number of java / C# / VB .net jobs out there, would you really want to learn a language that has such a small market share? Where are teh jobs for a fortran programmer vs C/C++/java, etc?
Only 'flamers' flame!
Does slashdot hate my posts?
As far as "why is it still being used at all" comments, two words for you: no aliasing.
If that's the only reason, then it should be relatively easy to get similar performance in C99 simply by adding restrict's all over the place, no?
Opus: the Swiss army knife of audio codec
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)
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?
I cut my teeth in computing 40 years ago on FORTRAN and used it for general engineering/scientific calculations until switching over to C language about 15 years ago. From my perspective, C seemed to offer everything that FORTRAN had, plus a lot more.
:-)
What advantages are there to using FORTAN over something like C for scientific/math/engineering calculations? Is it mainly just maintenance of legacy code? Or maintenance of legacy coders?
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.
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.
all these fortran coders and none of them are willing to fix the compiler? sheesh. go back to your parallel processing class.
I once considered writing real code in Fortran. It was a fairly limited library of functions that were supposed to do heavy computations. Other parts of my program was to be written in C.
When realising that G77 lacked many features that my documentation said I should find in Fortran 77 I gave up and wrote everything in C.
Not blaming anyone, I was still a bit disappointed. The feature I lacked was the possibiliyt to pass structures as arguments to F77 functions.
But of course, if G77 did not exist, I would not even have considered Fortran in the first place (this was an academic hobby project, not a commercial project).
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?
Stick Men
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
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.
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.
You can easily link modules of different languages. Why do you still work with a language which was long time obsolete when punch cards went out of fashion?
I mean, of course you can bloat the language with structures it originally didn't dream of, but you can't expect every compiler author implement the newest expansion, for free. Just because he wrote parts of an existing compiler years ago.
I'd say, like the old saying, if you don't find a software suiting your desires, why not writing it yourself?
There are some pretty smart mothers out there ;-)
Thanks. I have some routines in Fortran I would like to convert.
Do you happen to know if the IBM Scientific Subroutine Package is available on the Internet? This was a collection of math routines.
Well, be careful who you're calling old. C is older than F77 (although earlier versions of fortran are far older).
:Wq
Not an editor command: Wq
Here's a history lesson:
Once upon a time, every CPU second on a computer was precious (and charged out accordingly). Consequently, a lot of programmers' jobs involved hunting through source code and optimising it by hand. The quick and dirty fixes that folks like Microsoft can now get away with were not permissible then. You (OK, we) didn't have the resources to run code through just to see if it ran faster or not. The idea was to get it right the first time.
You mean Fortran 4, of course... :-)
Good for her, I hope you're proud of her :-)
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.
You mean gcc 3.5, not g77 3.5, right?
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).
Like others said, I think it is not so much the existance of G77 that hurts Fortran popularity, but rather the lack of free Fortran 90 or 95 compilers.
h ttp://g95.sourceforge.net/
The good news is that this is going to change. The G95 project is well on its way implementing a Fortran 95 frontend for GCC.
Alas, this is kind of clouded by sad news. In fact, the G95 development has split up and there are now 2 separate projects:
http://gcc-g95.sourceforge.net/
and
While sometimes competition is good, I think this is not the case here. In fact, there are not so many people with enough knowledge on Fortran 95 and on compiler development, and so this project splitting is just a terrible waste of scarse resources.
Marcel
If you're willing to totally sacrifice legiblity, sure.
FORTRAN was designed for physicists and engineers to get good performance out of supercomputers.
Hey, if you don't like it or don't understand it, then shut up and use something else. Don't embarass yourself with the fact that you either didn't learn the language and you can't express an intelligent statment about it, or that you jumped head-first onto the OO bandwagon and drank the KoolAid, or that Fortran isn't the flavor-of-the-month "modern" computer language and you gotsta show how l33t you are by using something kewl.
We'll make a deal: I'll keep my Fortran out of your gui apps if you keep your scripting languages out of my high-performance computations.
Actually, what I was saying is that I was under the impression that there was more to it than the aliasing rules. As for sacrificing legiblity, I don't think adding a couple restrict's where it really matters (in most places, it won't) would be that bad.
:)
Of course, the extreme solution is to preprocess your code with s/int \*/restrict int \*/ s/float \*/restrict float \*/ and so on...
Opus: the Swiss army knife of audio codec
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.
Afaik Fortran is still used because there are many programs and library that are still in this language and noone wants to convert them. This is a great reason indeed, mabye it is not a good reason for a free compiler by the way, and I don't know if someone in the OpenSource community will miss fortran so badly. Maybe it SHOULD die :D
There's a tremendous amount of high quality numerical code at netlib.org much (most?) of which is in F77. It's crazy to rewrite it. Dynamically
allocate in C or C++, call the library routine and get on with the job.
It would be nice to have structures in g77 and the ability to access elements in COMMON in gdb.
g77 lets people get work done w/o spending as much for their compiler as they spend on the computer.
F77 shares w/ C a major virtue. The languages are simple enough to understand and remember.
I'd be very sceptical of claims that someone can remember a large fraction of the C++ standard. It's too big and complex.
Let's not forget the old quip about Algol 60 being a great improvement on it's successor
Well there's always "languages" like Matlab which IMHO are a lot nicer than Fortran. Though my experience with Fortran was charred by converting VAX programs to Win32 and Unix. And the original coder was apparently unaware that there were such a thing as commenting and that "three-way goto" could be a bad idea for readability.
Most engineering places I've seen have used tools like Matlab, Matematica and Maple for computational stuff. And in my experience it's a lot nicer to do it in Matlab. (Though that language suffers from it's share of braindeadness as well: Begin arrays on 1 when all matemathics and engineering disiplines begin at 0?)
but the g77 compliler is indeed much less archaic than you make it sound. it does correctly support a number of F90/F95 constructs, though not in completeness.
my big disappointment is that i have to use two separate fortran compilers (Intel and G77) to get anything done, and that is *GREATLY* stifling my work, vbecause one compiler will compile correctly, and the other will not. and the roles switch continuously.
the problem isn't that G77 is stifling fortran development. i think the problem is that Fortran fans are stifling the development of a decent compiler.
what's worse, is that the code i'm being forced to maintain was literally written in the 70's and is so damned sloppy i can't read it, much less work with it. it makes me hate the FCC.
i would save hundreds of manhours simply by REWRITING the damn code in a real language. screw bounds checking and fast math code. i want maintainable code. not a pile of dog shit.
grey wolf
LET FORTRAN DIE!
... it is natural death... ageing may be?
The parent is dead on.
FORTRAN in its modern instantiations (F95) is completely unlike F77.
I've worked on lots of numerical computing projects, and have been attracted to many of the features of FORTRAN.
Yes, you can achieve many things in C++ through the use of templates and libraries like Blitz, and yes C++ is comparable in speed to FORTRAN.
However, I still think FORTRAN gets it right with numerical computation. For all the gains C++ has made in numerical computing, it still doesn't have the resources--in terms of libraries, etc--of FORTRAN. All the benchmarks I've seen suggest that FORTRAN is still a hair faster than C++. And the syntax of even the best C++ matrix libraries doesn't compare to FORTRAN. FORTRAN has numerical computing built right into the language, and anyone who has dealt with these things can't really deny its appeal that way.
And yet, whenever I sit down to work on a project, C++ wins. Why? Because of the great features of C++ not available in FORTRAN? Not really, because most of the things I want are in F95.
The reason why I go to C++ again and again is simply because I don't have a F95 compiler available for me to use.
So the choice comes down to C++ versus F77, when it should come down to C++ versus F95.
If a F95 compiler were avaiable, I would probably use that. But it's not there, so I use C++.
I personally think the FORTRAN community's biggest obstacle right now is its identity crisis. There's really no such thing as programming in "FORTRAN." You either do F77 or F95. And yes, they're both FORTRAN. But they're not the same language.
FORTRAN advocates have got to stop using F95 as an argument against using C++ when F77 is what people actually use. F77 is woefully behind. F95 is not. But very few people, even in the FORTRAN community, use F95.
How are you going to attract young FORTRAN developers when they can't compile their code? Just compare the number of free F95 compilers to the number of free C++ compilers, or the number of Java compilers.
FORTRAN isn't being killed off by g77. The lack of g95 is killing off both of them.
If the GNU compiler not implementing the DEC extensions is what it takes to kill FORTRAN, than more power to them.
I've seen enough legacy FORTRAN code to last me the rest of my career. What an ugly language.
It's fortran 95 compliant and is targetting legacy compability (g77 ), and f2k.
:-) ... funny ...
It has everything and more.
Also I write in fortran because numerical code ( math ) is silly hard to write in C, I use C for os and system programming.
Write a CFD or CAE app in C
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.
:-P
"Any sufficiently-complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."
Lisp is the Tengwar of programming languages.
yes this is true, but C is also more powerful and there is a C99 (99 or 2000?) spec out that makes a few updates.
Only 'flamers' flame!
Does slashdot hate my posts?
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;
/= 0.0)
,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.
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,:)
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
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.
The only intel product I see is a free-for-30 days compiler. please provide a link.
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.
Youre missing the point. The point is if you wat to write and share portable code you dont want all the people who get it to have to buy a compiler. Imagine if Linux was not distributed with a gCC complier so you have to buy a compiler to compile linux. This would be unacceptable. Now suppose that the only free complier was K+R C, with no extensions. Would people be writing all applicaitons in K+R C rather than say java or c++ because they had to have it able to be compiled by the end user. yes they would. That's the problem with issuing non-standard compilers.
Now as for the second part of your screed, people with big computers preumably are not running data bases, word processors or games. They are doing numerical calculations. and they are not pro prgrammers they are sceintist. So they want results not well designed programs. Fortran is the language of choice for multi-processor ad hoc programming.
Fortran knows how to parallelize it self. the language explicitly indicates to the compiler if it can ignore loop order dependencies, and can factor out contisionals and if subroutines will change data values. Memory is stored in predictiable fashions and thus can be shared more effectively.
So if you have a big box and are using C++ you may not be getting all the benefits you could from your investment.
say that agian less crytpically. Is there a usable g95 out??? where??? how? please explain at the end-user level. thanks!
Couldn't you design a language that had features specifically designed to enable this type of in-line compile-time code expansion?
Yes its called fortran 95. Nearly the same stament is available in fortran but its a langauge intenisic and thus will always beat the template.
Seems to make its points well and adds to the discussion even if you might disagree....
Man that is sad you mean there are people still programming in fortran? Man and I thought learning ada in college was bad.
Sorry to have to point this out but did you read the article you tell the parent poster to read?
if you did then you would know the article was about optimzed fortran77. Fortan 95 indeed has all the functionality they were trying to re-invent as meta-templates right in the language definition. parallelism is assumed for array assignments, for loops and even for conditional tests. Looping is implicitly done by the complier.
There's no way a meta-template could ever out perform that because the level of hinting is so much higher in the the fortran 95 syntax
Some drink at the fountain of knowledge. Others just gargle.
Do you have any idea how much more hardware we could buy with the money that would be burned up by license fees?
oh about 500 to $1000 dollars is what a fortran lic costs. we have one and share it with 40 people. its a compiler lic not a run time lic, not a per seat lic. it is a processor lic and you can share it.
also if g77 did not exist, I think the number of compilers sold would be at least 100 fold larger, making the price presumably 10 or more times smaller. (the cost of support would not allow it to drop 100 fold) I base this on the empirical fact that indeed fortran compiler lic used to be fairly cheap and ubiquitous prior to g77.
also I think part of the disagreement here is just what is meant by scientific computing. THe fact that you mention a graphical interface at all shows you are thinking of personal scientific software or at best larger scale visualization.
Whereas true large scale number crunching happens on remote servers in batch jobs running in long queues. there is no concept of an interactive command line let alone a graphical interface. Thus much of your comments are off base because they are talking about an entirely different arena in scientific computing ins which C++ is indeed adequate and in some ways more useful due to its better interactivity.
Likewise, as for disk writes being not slow, I have to disagree. And its not uncommon in processing time seriees or genetic data to have writes exceeding four gigbytes, which is not something your are going to cache or even copy. this is compounded because diskwrites across network servers can be quite slow. So again you are imagining scientific computing to be something entirely different than I am.
Some drink at the fountain of knowledge. Others just gargle.
In C we have a wonderful preprocessor built in, you can just use:
/* and so on */
#IFDEF NO_ALIAS
#DEFINE int restrict int
#DEFINE float restrict float
#ENDIF
Then why not make a "Fortran-like" code generator and a "C-like" code generator, run them both on a particular C function's parse tree (assuming the code is in C99 and uses __restrict properly), profile the crap out of the resulting code, and accept whatever's faster?
Will I retire or break 10K?
Or at least they don't use Pascal. I'm surprised that no one has mentioned this yet. Just a bunch of yunguns.
un-ALTERED reproduction and dissimination of this IMPORTANT information is ENCOURAGED
> myobject->hash_get(key)
> in fortran you would say:
> hash_get(myObjectStructure, key)
> is there any important difference?
Other than one is monolithic and one is object oriented?
It's kinda buried - you have to click the "list of evaulation editions" link. But it most certainly exists.
f lin/noncom.htm
http://www.intel.com/software/products/compilers/
However, it's listed as non-commercial only - which means (extracting from the license agreement) "If you are using the Materials under the control of a Noncommercial-Use license, you as an individual may use the Materials for only personal, noncommercial and research purposes"
But to a commercial entity, the fees aren't really that steep anyway, and it is a Fortran 95 Compiler, with all kinds of high-performance features that will make you drool. (For example, it can use SIMD/SIMD-II/MMX parellelizing instructions for the loops in your code without any explicit parallelization instructions in the code.)
There's an equilivent version of the Intel C++ compiler too.
I was looking at the state of development of the FORTRAN compiler in gcc today and found this project to implement a more modern GNU FORTRAN compiler. It looks like it's a proper cross-platform complier, using gcc's back end for code generation.
Stick Men
err, every looked a perl. if you had you would see there's no difference. just style and data hiding.
Did it many, many times in F77.
Real Scientist != Computer Scientist. What C++ compiler are you using? Even VC++ makes those calls in-line and optimized the heck out of them so they become direct memory access. Also, if you needed that kind of control over an array, you can create an encapsulating class with in-line methods to achieve the same effect. I've looked at the assembly GCC generates for this kind of thing. It's indistinguishable from the equivalent C code.
Your argument rests on gross assumptions of how C++ compilers really work.
As for unparallelizable, there is a project to create a C++ for parallel computing.
Relying on changing the language syntax instead of using libraries is called the PL/1 trap in computing science cicles.
It doesn't matter what I think. I check what the compiler actually generates, and the matrix library I wrote in C++ made tight use of memory and in-line calls. Matrix addition was done in situ and looked exactly like the code generated for the equivalent in-line C code. Unfortunately, my workplace only has F77 compilers (commercial ones), so I can't check the matrix operations in F95 and higher, but I'll take your word for it that it is effecient and doesn't use a function call.
I wasn't complaining that FORTRAN stole it, I was responding to the original post that made the implicit slam that C did not do that.
No, you can't. The STL is templated and largely in-lined code. As well, the STL derives its strength from creating ad-hoc code for the specific data type. You can write a wrapper for that for FORTRAN.
Polymorphism.
I do get it, you don't. I'm saying modern compilers have caught up. From the tone of your post, it sounds like you have access to a souped-up F95 compiler with extensions out the wazzoo, but only access to a cruddy first-generation C++ compiler that probably still uses cfront. Get a real C++ compiler and check the generated assembly.
All stuff introduced in F95. Most code and people are still at the F90 level.
Care to post an example?
The bitter lessons of a veteran coder: http://bitterprogrammer.blogspot.com
But there is also fortran 90, 95, and the new 2000 spec.
"Open the pod by doors, Hal" > "I'm afraid I can't do that, Dave" sudo "Open the pod bay doors, Hal" > alright
It came from commercial roots so it is likely to be a better compiler in many ways compared to g77. They are actively porting it to Linux and Watcom was always known as generating terrific code. For x86 scientific computing it may be just the thing!
The article uses FORTRAN 77, not the modern Fortran 95 which has a concise loop syntax, which allows the compiler to generate the best code with no reliance on the compiler understanding correctly what the templates are meant to achieve.
:: N = 64 :: DBL = SELECTED_REAL_KIND(15,364) :: A(N,N,N), B(N,N,N)
Equivalent Fortran 95 code:
INTEGER, PARAMETER
INTEGER, PARAMETER
REAL(DBL)
A(2:N-1,2:N-1,2:N-1) = (B(2:N-1,2:N-1,2:N-1) + B(3:N,2:N-1,2:N-1) + B(2:N-1,2:N-1,2:N-1) + B(2:N-1,1:N-2,2:N-1) + B(2:N-1,3:N,2:N-1) + B(2:N-1,2:N-1,1:N-2) + B(2:N-1,2:N-1,3:N)) / 7.0
(by default array dimensions have lower bound 1 in Fortran, instead of setting the lower bound to 0, as in the C++ example, I chose to adapt the code to the Fortran convention; instead of choosing the real data type on the requested precision I could have used DOUBLE PRECISION, of course; I used uppercase out of tradition, against popular belief, Fortran understands lowercase)
For expressions like this it would be nice if one could deal with index ranges as in the C++ code, but this can also be achieved by means of a preprocessor.
This is in fact, not true. Superficially Perl may look like its just hiding streight function calls in method calls, but in fact its not. Ie:
$object->method_call;
Is not the same as:
method_all($object);
Because the first figures out what subroutine to call at runtime (based on the class of the $object variable) and the second figures out what subroutine to call at compile time.
C is only marginally more powerful than Fortran, and only in areas that really matter for system-specific stuff (namely, pointers, which are much more circumscribed in Fortran).
For the kinds of stuff I do as a higher-level developer, Fortran would be at least as suitable as C.
(As it is, I use C++ because the advantages in expressiveness outweight Fortran's advantages in execution, but that has more to do with templates than anything else.)
Yes, and I could simulate simple classes in C with structs and passing a this pointer to all the attached functions... but I would rather abstract that further by using actual C++.