Thread: Fortran vs. C

  1. #1
    The Earth is not flat. Clyde's Avatar
    Join Date
    Mar 2002
    Posts
    1,403

    Fortran vs. C

    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?

  2. #2
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    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.
    Away.

  3. #3
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    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
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  4. #4
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    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.
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  5. #5
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743
    All of the above is correct.

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

    "Circular logic is good because it is."

  6. #6
    Registered User grady's Avatar
    Join Date
    Oct 2003
    Posts
    27
    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.
    Last edited by grady; 10-28-2003 at 11:17 PM.

  7. #7
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>> 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.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  8. #8
    The Earth is not flat. Clyde's Avatar
    Join Date
    Mar 2002
    Posts
    1,403
    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.

  9. #9
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273
    Can Visual C++ do Fortran, or was that my imagination being fuelled by alcohol and a few other bad things (Again)?

  10. #10
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,212
    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!

  11. #11
    King of the Internet Fahrenheit's Avatar
    Join Date
    Oct 2001
    Posts
    128
    Hmm.. I never really see Fortran used much. Mostly C/Perl/PHP/Java/ASP. Maybe I don't look in the right places.

  12. #12
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743
    >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.
    My Website

    "Circular logic is good because it is."

  13. #13
    The Earth is not flat. Clyde's Avatar
    Join Date
    Mar 2002
    Posts
    1,403
    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 )

  14. #14
    Registered User axon's Avatar
    Join Date
    Feb 2003
    Posts
    2,572
    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.

    some entropy with that sink? entropysink.com

    there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka

  15. #15
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>> 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.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. real-world apps in C++ (preferably simple)?
    By Aisthesis in forum C++ Programming
    Replies: 13
    Last Post: 06-12-2009, 01:03 PM
  2. Its About Fortran
    By panfilero in forum Tech Board
    Replies: 2
    Last Post: 11-29-2005, 07:49 AM
  3. need some help with fortran
    By InvariantLoop in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 03-08-2005, 03:13 AM
  4. Linking Fortran procedures with C program
    By gest in forum C Programming
    Replies: 5
    Last Post: 07-14-2003, 12:35 PM
  5. any good fortran help sites
    By smd in forum C++ Programming
    Replies: 3
    Last Post: 07-02-2002, 06:10 AM