PDA

View Full Version : Fortran vs. C



Clyde
10-28-2003, 06:07 PM
My supervisor tells me that Fortran is faster at number crunching than C.

From the various benchmarks i've see on the web he appears to be right, however the tests i've found were done several years ago, so anyone know whether it's still the case?

confuted
10-28-2003, 06:10 PM
Do they still make new fortran compilers? If they don't, I'd guess that the latest optimized C/C++ compiler would produce faster code than an ancient fortan compiler.

Zach L.
10-28-2003, 06:38 PM
That is what Fortran is designed for. C is more general purpose. Well written C can compare roughly equally to Fortran (though for the purpose, the Fortran code will likely be more readable).

Object-oriented C++ can compare to Fortran (though it usually doesn't because of implementation issues). This is through C++ templates. Here's a link ( http://www.oonumerics.org/blitz/ ). You might find the benchmarks fairly interesting as well.

Cheers

joshdick
10-28-2003, 09:21 PM
Fortran literally means Formula Translator. It was made for engineers to do number crunching, so it's no wonder that it beats a language like C.

DavidP
10-28-2003, 10:01 PM
All of the above is correct.

Also, to add on: C was originally made for programmers to develop compilers and operating systems.

grady
10-28-2003, 10:04 PM
Fortran 77 can do better optimizations when dealing with arrays. They are all fixed length. There is no dynamically allocated memory, and no pointers. This makes it possible for the fortran compiler to assume things that a C compiler cannot assume. These optimizations are where the speed comes from. Fortran is faster when solving big linear systems and when doing other things that require array manipulation. It is not faster in any other aspects of number crunching that I know of, nevertheless this is a real real big chunk of the numbering crunching business.

adrianxw
10-29-2003, 02:10 AM
>>> Do they still make new fortran compilers?

Yes, of course they do. The Fortran standard is also a continually evolving beast. Most Fortran compilers sold these days will adhere to one of the newer Fortran 9x standards but have a 77 backward compatibility.

For some weeks last year, the new version of Compaqs, (lets be honest DEC's), Fortran compiler topped the best sellers list at GreyMatter.

You certainly can create pointers in Fortran, it is just done differently than C/C++.

Many scientists , engineers and mathematicians use Fortran as their tool of choice. For that reason, there are a lot of very large mathematical libraries available for Fortran.

I used Fortran 77 for plant automation and process control systems until quite recently.

Clyde
10-29-2003, 08:48 AM
I was hoping the answer would be "No, C is much faster now" so i could happily ignore Fortran...... guess not. Oh well its seems fairly similar to C, though somehow to my eyes it looks messier. (I suppose that's just because i'm less familiar with it)

Anyway thanks for all the input.

SMurf
10-29-2003, 11:21 AM
Can Visual C++ do Fortran, or was that my imagination being fuelled by alcohol and a few other bad things (Again)?

Brian
10-29-2003, 02:32 PM
Originally posted by SMurf
Can Visual C++ do Fortran, or was that my imagination being fuelled by alcohol and a few other bad things (Again)?

Surprisingly, no. And for some strange reason many other C compilers also can't compile Fortran code.

Gosh, you might have to use a Fortran compiler!

Fahrenheit
10-29-2003, 03:47 PM
Hmm.. I never really see Fortran used much. Mostly C/Perl/PHP/Java/ASP. Maybe I don't look in the right places.

DavidP
10-29-2003, 05:12 PM
>Oh well its seems fairly similar to C, though somehow to my eyes it looks messier.

It is actually closer to BASIC than C. In fact, according to what I have read (correct me if I am wrong), BASIC is a child of Fortran.

Clyde
10-29-2003, 05:56 PM
It is actually closer to BASIC than C


I see, well i have only ever learned C (and C++ syntax), so perhaps its nothing like C bar the fact that its a programming language and they all have some base similarities. (I was suprised at how easy it was to read, i guess the old saying that learning to program is much harder than learning a new language is true :))

axon
10-29-2003, 08:16 PM
My friend who is a mechanical engineering major is taking a fortran class...He asked me for help a few times, and based on my still fairly small knowledge of C++ I picked up basic fortran very quick! I don't like it much thought, and I'm surprised that my school requires engineering majors other than CS to take that class. IMO all engineers should take a basic c++ class.

adrianxw
10-30-2003, 02:35 AM
>>> though somehow to my eyes it looks messier.

If you come the other way, i.e. are a Fortran programmer learning C, (like I did), you'd think exactly the same thing. All those semi colons and curly brackets??? What a mess! Reserved words??? What on Earth do you need reserved words for??? It goes no...

It is as easy to write good Fortran code as it is good C/C++. Equally, it is as easy to write messy Fortran code as it is messy C/C++ code.

If you know C, learning Fortran will take you a very short time.