CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Main CFD Forum

C++ Vs Fortran

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   February 26, 2009, 08:19
Default C++ Vs Fortran
  #1
Dave
Guest
 
Posts: n/a
Hi Guys, I'm about to start writing a pretty big CFD code to solve transonic flow about a moving airfoil. I have lots of experience in Fortran 90 and have dabbled a little in C++.

Which language would you suggest I use for a computationally expensive process? I have been told that Fortran usually leads to faster executables (i.e. less computation time for a given system) but some colleagues dislike Fortran and opt for C++.

I have no feelings either way - I would like to choose whichever program will give the fastest executable.

Could someone please offer some advice?
  Reply With Quote

Old   February 26, 2009, 08:51
Default Re: C++ Vs Fortran
  #2
mecpp
Guest
 
Posts: n/a
my PERSONAL choice is c++. If you ask me why, my answer would be felxibility.

  Reply With Quote

Old   February 26, 2009, 09:44
Default Re: C++ Vs Fortran
  #3
pc
Guest
 
Posts: n/a
Fortran = FORmula TRANslation

It was designed for, and continues to be optimized for, computationally intensive algorithms.
  Reply With Quote

Old   February 26, 2009, 09:45
Default Re: C++ Vs Fortran
  #4
ag
Guest
 
Posts: n/a
Go with what you know - use the FORTRAN.
  Reply With Quote

Old   February 26, 2009, 10:02
Default Re: C++ Vs Fortran
  #5
Steve
Guest
 
Posts: n/a
This is an entirely religious debate, fought over many years with no hint of logic or evidence.

For ultimate speed, forget high level languages and use assembly.
  Reply With Quote

Old   February 26, 2009, 11:23
Default Re: C++ Vs Fortran
  #6
pc
Guest
 
Posts: n/a
Steve has put it rather well. Which is the "best" programming language for CFD has been argued ad nauseum on this forum. You can search the forum for many past discussions on this matter.

You'll be spending a lot of time coding and debugging - use the language in which you are most proficient.
  Reply With Quote

Old   February 26, 2009, 11:26
Default Re: C++ Vs Fortran
  #7
Balduin Bankerotti
Guest
 
Posts: n/a
... or look if it is possible to use an existing library like OpenFOAM to solve your problem much faster.

  Reply With Quote

Old   February 26, 2009, 14:39
Default Re: C++ Vs Fortran
  #8
Bill
Guest
 
Posts: n/a
as others, use what is comfortable for you, for a good programmer, OOP etc (which are sound after cpp) are more concept, such that for an expert it's possible to implement it within fortran as well,

  Reply With Quote

Old   February 28, 2009, 02:22
Default Re: C++ Vs Fortran
  #9
Hadian
Guest
 
Posts: n/a
If the execution time is the only matter you concern, there is no difference between Fortran,C and C++. the difference of cpu time in different compilers of fortran (or c or c++) is much more that difference between c++ and fortran compiler of the same company. you can find many benchmarks on the internet. Hadian
  Reply With Quote

Old   February 28, 2009, 06:17
Default Re: C++ Vs Fortran
  #10
Tom
Guest
 
Posts: n/a
This depends on what features you use. A straight fortran code compared to a C++ code exploiting OOP (i.e. when the code is really C++ and not C) then the speed difference can be considerable (fortran can be > 2 times faster).

You can do the same thing to fortran (using the same compiler); e.g. compare two codes that do exactly the samething but write one in straight fortran and the other using derived types and operator overloading. Another way of putting this is that the choice of programming method is more significant than the choice of compiler; eg. g77 can actually be faster than intel ifort if you exploit derived types and operator overloading in ifort (however on the same fortran code ifort will be faster).
  Reply With Quote

Old   March 1, 2009, 16:02
Default Re: C++ Vs Fortran
  #11
kenn k.q. zhang
Guest
 
Posts: n/a
Fortran is faster than c++???

hoho,

how do you know???

from words of mouth???

how did they know???

did they show you solid comparison of speed??

or they also learned this from word of mouth???

come on,

how can c++, invented 1970 by the brilliant computerist, be a lot slower than fortran, which was invented in 1950s

and, just use your common sense --since you have lots of programming experience, how can a computer code which largely formed by loops be slower than the same code which have the same loops but differ in a couple of time-negligible operations???

100 times more importantly,

fortran promotes ugly programming style;

in contrast, c++ promotes beautiful programming;

anyone, if she/he tells me she/he is using fortran and knows little c++, my first response is this is a poor person in scientific computing or this person was ill-educated or ill-informed by some old researchers who know nothing about CFD and programming.

  Reply With Quote

Old   March 1, 2009, 16:02
Default Re: C++ Vs Fortran
  #12
kenn k.q. zhang
Guest
 
Posts: n/a
Fortran is faster than c++???

hoho,

how do you know???

from words of mouth???

how did they know???

did they show you solid comparison of speed??

or they also learned this from word of mouth???

come on,

how can c++, invented 1970 by the brilliant computerist, be a lot slower than fortran, which was invented in 1950s

and, just use your common sense --since you have lots of programming experience, how can a computer code which largely formed by loops be slower than the same code which have the same loops but differ in a couple of time-negligible operations???

100 times more importantly,

fortran promotes ugly programming style;

in contrast, c++ promotes beautiful programming;

anyone, if she/he tells me she/he is using fortran and knows little c++, my first response is this is a poor person in scientific computing or this person was ill-educated or ill-informed by some old researchers who know nothing about CFD and programming.

--------------------------------------------------------------------------------

  Reply With Quote

Old   March 1, 2009, 18:45
Default Re: C++ Vs Fortran
  #13
Andrew
Guest
 
Posts: n/a
What utter nonsense.
  Reply With Quote

Old   March 2, 2009, 02:55
Default Re: C++ Vs Fortran
  #14
Bill
Guest
 
Posts: n/a
kenn k.q. zhang:

sorry but i mean your reply speech without idea!

for one that know programming language is almost no matter

In generl Fortran is always faster than C/C++ (because several think like array bound check, .. in c++), *but* it is possible to improve C/C++ speed by changing some compiler swtich, *but* steel Fortran will be a bit faster

Well, if you do not think so, just provide a sample to prove your claim (a short Fortran & C++ programm plus required command for compile, ...), then we can accept that you have idea about what you said!!! (else i mean verbosity)
  Reply With Quote

Old   March 2, 2009, 06:14
Default Re: C++ Vs Fortran
  #15
Tom
Guest
 
Posts: n/a
Well considering he can't get his facts right (C++ in 1970? 1979 would be more accurate) I think it's best to ignore him.
  Reply With Quote

Old   March 2, 2009, 11:16
Default Re: C++ Vs Fortran
  #16
jughead
Guest
 
Posts: n/a
He is right about Fortran promoting ugly programming.

C++ is more modular and scalable. Fortran tends to be a mess. It is not OO and therefore has several limitations.

However, I think we have yet to see a state-of-the-art CFD C++ code implementation because there is a lack of people who are experts in both.

  Reply With Quote

Old   March 2, 2009, 11:40
Default Re: C++ Vs Fortran
  #17
Tom
Guest
 
Posts: n/a
You've obviously never done any supercomputer optimization or you wouldn't think that - OOP is a big no-no on these types of machines since it is very difficult for the compiler to optimize such code (read my first post and try a few examples yourself). Even in computer science there's been a bit of a backlash against OOP (as implemented in C++ particularly) for the last few years.

Anyway, cleanly written FORTRAN 90/95 is relatively easy to read and is well suited to programming numerical analysis problems.
  Reply With Quote

Old   March 2, 2009, 12:18
Default Re: C++ Vs Fortran
  #18
Bill
Guest
 
Posts: n/a
jughead and others:

lets to repeat what i have implied in the previous posts, OOP is a *concept* not a programming language, this concept can be implemented into any moderin language like Fortran, C, CPP

however, CPP provide some instructions that make it more easy (and more readable) but maybe in expense of cost

you can read about OOP in C to get what i imply (e.g. GLIB is somewho OOP in C, note: C is not known as OOP language for some peoples)

by above argument: it's obvious that programming syle is different from language and you can write an slow programm to both of Fortran & CPP

successful programmer is who that know how data and instruction is manipolated by CPU, e.g. cache coherency, parallel operation etc.

considering all things, a plane Fortran code usually perform a bit faster than a palne CPP code under the same condition
  Reply With Quote

Old   March 2, 2009, 12:33
Default Re: C++ Vs Fortran
  #19
a
Guest
 
Posts: n/a
I tend to use both. C++ at the design step and Fortran at the production step.

- I disagree on the fact that Fortran provides an ugly code with poor modularity (have a look on the Fortran 2003 features that are marvelous and appear now progressively in compilers). However it tends to make you lazy (at least me). This is why doing serious C++ as a first draft pushes me a little bit in terms of imagination. The double work overhead is not so much given the final quality that increases the long term productivity.

- I also disagree on the fact that C++ codes are slower. This is no more true. However, doing C++ is slower on the programming side: learning curve, potentiality of the language turned towards software engineering that is for me another field than strict scientific programming (unless your code is not your tool but the final product you wish to sell as a software) such that you expose yourself to traps uselessly.

- Thirdly and lastly, it is known that the C++ commitee is (apparently) not receptive to the requests made specifically for/by people wanting to use it for scientific computing. It invokes the same reason as me: C++ is for software engineering and must keep its goals clear. It says that something has been designed and is continually updated by paying attention to scientific programmer needs and that this thing is... Fortran (I remember having read something on informit.com). In other words, Fortran works specifically for us.
  Reply With Quote

Old   March 2, 2009, 13:51
Default Re: C++ Vs Fortran
  #20
Steve
Guest
 
Posts: n/a
Another consideration is the operating system where you will be running. Programming for Linux (and other *nix) is naturally easiest in C, because you have access to all the same functions that the OS does.

But anyway, not many people ever use rational decision making when choosing a language. It's normally a hunt for supporting evidence for an a priori decision.
  Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fortran Compiler-CFX12.1 Araz CFX 12 November 2, 2014 13:46
Intrinsic Procedure 'ISNAN' in GNU FORTRAN 77 hawk Main CFD Forum 1 April 12, 2005 22:13
visual fortran Monica Main CFD Forum 1 August 28, 2004 20:45
Fortran77 or Fortran 90 Swapnil CFX 2 November 26, 2002 16:16
Why Favoring Fortran over C/C++? Zi-Wei Chiou Main CFD Forum 35 September 26, 2001 09:34


All times are GMT -4. The time now is 18:00.