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

C++ Vs Fortran

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 6, 2009, 14:53
Default Re: C++ Vs Fortran
  #41
kenn k.q. zhang
Guest
 
Posts: n/a
c++ is analogous to "english"

fortran is analogous to the local dielect languange in my hometown in china

so,

which one to choose for scientific computing???
  Reply With Quote

Old   March 6, 2009, 18:57
Default Re: C++ Vs Fortran
  #42
ag
Guest
 
Posts: n/a
These last two comments are absolutely asinine. Who cares if IEEE "discriminates" against us "poor CFD people"? I've got a job to do (as I assume the original poster does) and my self-esteem doesn't hang on what others say about FORTRAN. I use it because I know it better, so I can get my job done faster - which is the most important metric for the original poster.
  Reply With Quote

Old   March 7, 2009, 06:23
Default Re: C++ Vs Fortran
  #43
ztdep
Guest
 
Posts: n/a
since you have a large project to do, and you have many years experience , fortran is the first choise.

since your code is for the computation, both language will do the same thing.

you can find a lot of code written in fortran to do the cfd
  Reply With Quote

Old   March 21, 2009, 08:57
Default
  #44
Member
 
Join Date: Mar 2009
Posts: 62
Rep Power: 17
RenardP is on a distinguished road
Both Fortran and C++ are suitable for developing a large CFD code.
Besides today you can call Fotran from a C++ function or vice versa in a straightforward manner.
In the end all it matters is how familiar are you with one of this languages.
RenardP is offline   Reply With Quote

Old   March 24, 2009, 17:02
Default
  #45
New Member
 
samaneh
Join Date: Mar 2009
Location: Iran
Posts: 1
Rep Power: 0
saha is on a distinguished road
i dont have so experience in CFD ! but my well educated proff perefer Fortran!
saha is offline   Reply With Quote

Old   March 24, 2009, 20:18
Default
  #46
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,151
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
I think that some statements about the Fortan are really unfair.

Actually, all the old bad things about the Fortran (which also promoted the bad, and very illogical indeed, programming style) have been, more or less, removed while keeping the language almost the same.

It's probably not suited for graphics (not at all) but, all you need in CFD is an input file and, even for the more advanced codes on the programming side (unstructured mesh commercial solvers), it is a simple text file and there is no way in which any different compiled language can be better than the Fortran in simply treating the numerical data as it happens in CFD codes.
sbaffini is offline   Reply With Quote

Old   March 24, 2009, 20:55
Default
  #47
Member
 
Join Date: Mar 2009
Posts: 62
Rep Power: 17
RenardP is on a distinguished road
Fortran is fine for basic CFD, I did my fair share of coding in Fortran 77 and Fortran 90.

But when you need more complicated data structures like a linked list or advanced string operation facility, C++ with STL is far more easy to use. In Fortran you will need to build from scratch a lot data structures.

I'm sure you can develop a CFD code using only good old arrays but when you need to interpret/read an unstructured mesh you will really appreciate a linked list.

I know you can implement any "modern" data structures in Fortran 90 - 95 - 2003 but I bet nobody is happy when he must implement this.

The other face of the coin is that in Fortran you already have implemented a lot of good mathematical routines and in C/C++ aparently not. Well nowdays you have a lot Open Source mathematical subroutines in C/C++ like GSL, FFTW ....

From a modern perspective I will always recomand to simply use C++ for new codes and if you already have good, tested, old Fortran routines simply link these with your C++ code.
RenardP is offline   Reply With Quote

Old   March 25, 2009, 04:58
Default
  #48
New Member
 
Join Date: Mar 2009
Posts: 27
Rep Power: 17
jugghead is on a distinguished road
I would like to see object-oriented CFD codes and application of rigorous unit testing and version control.
jugghead is offline   Reply With Quote

Old   March 27, 2009, 13:09
Default Matlab
  #49
jwm
New Member
 
john mckelliget
Join Date: Mar 2009
Posts: 7
Rep Power: 17
jwm is on a distinguished road
Folks,

I know that interpreted MATLAB is about a thousand times slower than a compiled C or FORTRAN program.

How does a compiled MATLAB program stack up, speedwise?
jwm is offline   Reply With Quote

Old   April 1, 2009, 08:26
Default
  #50
New Member
 
Join Date: Mar 2009
Posts: 4
Rep Power: 17
Marcus is on a distinguished road
Quote:
Originally Posted by RenardP View Post
Both Fortran and C++ are suitable for developing a large CFD code.
Besides today you can call Fotran from a C++ function or vice versa in a straightforward manner.
In the end all it matters is how familiar are you with one of this languages.
I wish it were that simple. I consistently run into the "legacy code" argument, saying I shouldn't bother to write any CFD apps in anything but Fortran because all the old dinosaur titans of industry are stuck with it. As for cross-compiling, something just seems wrong about calling C/C++ from an existing Fortran numerical code, instead of vice versa

Quote:
Originally Posted by jwm View Post
Folks,

I know that interpreted MATLAB is about a thousand times slower than a compiled C or FORTRAN program.

How does a compiled MATLAB program stack up, speedwise?
I personally can't give you any hard numbers, but there is a Matlab webinar this Friday, April 3 on "strategies and techniques for speeding up your MATLAB applications." Info available here if you're interested: https://mathworksevents.webex.com/ma...=a&d=667286592
Marcus is offline   Reply With Quote

Old   April 1, 2009, 14:26
Default
  #51
Member
 
Join Date: Mar 2009
Posts: 62
Rep Power: 17
RenardP is on a distinguished road
I've used gfortran (for compiling Fortran code),gcc (for C code and g++(for C++) and I've called Fortran from C/C++ and vice-versa without a problem.

You have to be sure that you use compatible compilers (GNU in my case or you can always use the Intel Fortran and C++ compilers for the same job).

I never said these is simple, you have to do a lot of checking because Fortran and C "thinks" differently (e.g. array storing order) but in the end it will work if you are determined to do that.

If you develop a new code from scratch and you know both C/C++ and Fortran I will advise you to use C++.

Matlab - is simply not well suited for serious CFD (it will work well for simple proof of concept 1D applications). If you will have a large code think only at the bunch of m code you will have for each function. Other thing - how much memory uses your Matlab only for running his interpretor (start Matlab and check how much RAM he uses) ? How long will take you to load into Matlab a 50MB file with numbers ? .

Paul
RenardP is offline   Reply With Quote

Old   April 1, 2009, 14:28
Default
  #52
Member
 
Join Date: Mar 2009
Posts: 62
Rep Power: 17
RenardP is on a distinguished road
And in the end a small question - how much are you willing to pay for a Matlab parallel edition (I suppose you will have to buy a license for each computer node you intend to use)?
RenardP is offline   Reply With Quote

Old   April 4, 2009, 04:26
Default We checked it befor ! speed of Fortran and C++
  #53
New Member
 
Asghar
Join Date: Apr 2009
Posts: 16
Rep Power: 17
bohluly is on a distinguished road
There are several major problems with using C, for numerical programming. Mainly, the languages were designed for systems programming, not high precision, efficient number crunching and mathematical calculations.
in our search, we have not found any reason why FORTRAN should not be used for numeric programming. In contrast we have find that in some issues FORTRAN is more powerful than C in scientific and numerical programming specially in computational

FORTRAN and C have been compared, and their strengths and weaknesses with respect to scientific programming have been identified, the languages are evaluated on their performance.

for example

in + & - & * & / fortran is faster
in integer power computation fortran is faster A^2
in non-integer power C is faster A^2.33
in if endif control C is faster
in do for loop C is faster
in reading of data fortran is faster

in writing of data C is faster
bohluly is offline   Reply With Quote

Old   June 26, 2009, 07:47
Default
  #54
New Member
 
Join Date: Mar 2009
Posts: 27
Rep Power: 17
jugghead is on a distinguished road
See this answer:

Basically C/C++ can be as fast as Fortran as long as you carefully use the restrict keyword when defining pointers to arrays.

http://stackoverflow.com/questions/1...-than-c/499392
jugghead is offline   Reply With Quote

Old   February 10, 2012, 16:33
Default plzz help me.
  #55
New Member
 
crane
Join Date: Jul 2011
Posts: 7
Rep Power: 14
doorna is on a distinguished road
Dear all;
I am a super beginner in programming but i am super enthusiastic to know how to write codes.I know fundamental concepts of CFD.I wonder if any one knows of some books or sites which includes writing codes with c++ using CFD concepts.The only experience I had was writing code for lid driven cavity and it hasn't converge.It is like a dream for me write codes different problems!!!!!!!!!I am ready to do whatever it costs!
your answers are immensely appreciated in advance
best,
Doorna
doorna is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fortran Compiler-CFX12.1 Araz CFX 13 March 27, 2017 05:37
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 15: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 14:10.