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

C++ or Fortran for CFD solvers

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 13, 1998, 17:52
Default C++ or Fortran for CFD solvers
  #1
andy
Guest
 
Posts: n/a
What are peoples experiences of coding CFD solvers in C++? Do they run at something approaching the speed of Fortran? Does the added abstraction really help in writing code faster and/or developing it once the code is written?
  Reply With Quote

Old   August 14, 1998, 11:58
Default Re: C++ or Fortran for CFD solvers
  #2
Andrzej Matuszkiewicz
Guest
 
Posts: n/a
Hi Andy,

There is at least one systematic study of C++ versus Fortran in CFD: H. Jiang & P.A. Forsyth, "Robust Linear and Nonlinear Strategies for Solution of the Transonic Euler Equations" Computers & Fluids Vol. 24, No. 7, pp. 753-770, 1995. It seems to me that it has been done before the Blitz library was available.

I think there is one major point for C++. The market for C++ compilers is much bigger that for Fortran, so C++ compilers improve their efficency very fast. It seems to me that makers of Fortran compilers cannot afford such an effort.

Andrzej
  Reply With Quote

Old   August 14, 1998, 15:39
Default Re: C++ or Fortran for CFD solvers
  #3
Igor Antropov
Guest
 
Posts: n/a
Well, yes, C compilers are getting better. However, most FORTRAN compilers are products of long evolution, and I do not think that C compiler developers will be able to catch up overnight. In addition, whenever you need some nontrivial mathematical routine to append to your CFD program, the chances are that it was written in FORTRAN rather than in C. So, the choice between FORTRAN and C for CFD, or another activity related to mathematics is like a choice between English and Esperanto. Surely Esperanto is better, but because of some strange reason everybody speaks English.
  Reply With Quote

Old   August 14, 1998, 16:49
Default Re: C++ or Fortran for CFD solvers
  #4
Anthony Iannetti
Guest
 
Posts: n/a
Andy,

Fortran is still the standard for CFD codes, or technical computing for a long time. As far as ease of use, whe programming in atechincal code, all anguages are about the same. Fortran 90 is able to address arrays much easier than Fortran 77 or the C languages. Fortran 90 is almost ojext oriented (it uses 'modules' instead of classes). The guys at Los Alamos told me in a seminar that it is very easy to work with. But for technical computing, speed is essential. Fortran is typically 5 times + faster than C++. This figure comes directly from NASA. It is also, from independant benhmarking, 1.5 to 2.0 times faster than C. Why, simply put frotran is designed to do one thing well - number crunching. C and C ++ are general languages. While fortran can do graphics (vis OpenGL). Must GUI's are written in C++. In this area, pheomenal speed is not important. This is when classes really help. Maybe C++ might improve, but I doubt it high performance fortran is becoming the defacto standard for CFD (it is based on F90). Also, F90 codes, becasuse of there implicit array operations, are able to be automatically parallelized much more effeciently than C++. Remember parallel programming is not a CFD standard.

Tony
  Reply With Quote

Old   August 14, 1998, 18:45
Default Nothing lasts forever
  #5
Andrzej Matuszkiewicz
Guest
 
Posts: n/a
"Everyone" spoke Latin in the Middle Ages, French in 19th century, English in 20th century... Nothing lasts forever.

Andrzej
  Reply With Quote

Old   August 14, 1998, 20:07
Default Re: C++ or Fortran for CFD solvers
  #6
Jonas Larsson
Guest
 
Posts: n/a
C++ is just as fast as F77 provided you write the code efficiently. The problem is that it is very easy to write inefficient code in C++ and you have to be very experienced to avoid pitfalls that will slow down your code considerably.

As I see it F77 (and also to some extent F90) helps the code developer to write efficient code, but doesn't give enough support to structure the code and make it easily maintainable.

C++ is the opposite, it helps the code developer to write well structured and easily maintainable code, but it doesn't help you to write efficient code.

Don't ask me what is best - depends on code complexity and how critical speed is I guess.
  Reply With Quote

Old   August 15, 1998, 06:54
Default Re: Nothing lasts forever
  #7
D.C
Guest
 
Posts: n/a
"Nothing, excepting Fortran and Unix!", will say "the Unix peoples". They do not remember perhaps, that 70 % of them Unix system is written in … Yes,in C language.

Dear Andrzej,

That was a good answer. Of course it is possible to write high performance codes in C of C++. Most of companies producing CAD-CAM, or CFD programs, have written or started to write these programs in C, or C++. At NASA there is an "important push" to move some of them old, good, reliable codes from Fortran to C. Why? Why, the CFD world moves from structured (or block structured) grid, finite differences (and I would say, Fortran) codes, toward the unstructured, flow-adaptive, finite volumes, large parallel (and here I would say C++, dynamic allocation and memory management) codes?

And, I would like to say a bit more (to put some gas on fire!) and I am sure that there will be a lot of peoples, "screaming" that it is impossible. Unfortunately for them, the future will be:

C++ language (and Java++ for Internet programming),

And …

Yes, Windows NT (here the Unix peoples will be very angry).

But, look who leads the software market! Fortunately, or not, in the next 10 years, everything will speak… windows. The new Windows NT 5.0 is coming! How the "Old, good Unix" can survive! I think he cannot!

Hey, Unix peoples don't take these words personally! This is the way it happens in history. That it is! This is the way these things move!

We already told them! And we tell them everyday!

Best regards. D.C.

I expect a lot of reactions! OK! This is good!

  Reply With Quote

Old   August 15, 1998, 07:13
Default Re: Nothing lasts forever
  #8
Stephane BARALON
Guest
 
Posts: n/a
Hi,

As you expected, you'll get some reaction.

I would like to emphasize that windows NT, OK, but Windows NT SERVERS: NO! The unix-based servers are still the best for large networks.

I must admit that I am not favorable to the idea of a Microsoft planet !

SINCERELY,

  Reply With Quote

Old   August 15, 1998, 13:40
Default Re: C++ or Fortran for CFD solvers
  #9
Stephane Baralon
Guest
 
Posts: n/a
Hi,

I also think that the C compilers still have some way to go before they catch up the performance of Fortran77 compilers ( F90 compilers are today not efficient enough: dixit a reknown workstation manufacturer: "There is no reason for a strictly f77 code to execute slower when compiled with an f90 compiler than with an f77 compiler. However, at this time(1/97), f90 generated code is often 2x (and sometimes worse) slower than f77 code".)

However, we should keep in mind that computer, as well as language performance are still strongly hardware dependent.

Another comment is that most of the CFD GURUS of today are from the fortran years. So wait for the next generation to hear gurus who would advise their colleagues to write their codes in C++ !!
  Reply With Quote

Old   August 18, 1998, 11:21
Default Re: Nothing lasts forever
  #10
David Hargreaves
Guest
 
Posts: n/a
Just one (major) point to make. Until NT becomes a multi-user operating system, every CFD user in a company will (potentially) require an expensive computational/graphics server on their desk. There is no such thing as job submission, CPU sharing or multiple logins on NT. Oh and 64-bit would be nice....
  Reply With Quote

Old   August 19, 1998, 13:21
Default Re: C++ or Fortran for CFD solvers
  #11
John C. Chien
Guest
 
Posts: n/a
Based on my personal experience, integrated CFD codes will be the only way to help the designer and spread the use of the CFD technology. In other word, the interactive, graphic interface should be part of the CFD code. In 80's, I have developed integrated CFD codes on mini-computer. I run the code interactively, with mesh display, solution display as part of CFD run. This was in a very big company environment. In late 80's, I was able to do the same on PC/486, using MS Fortran with color graphics. When you run the code, you don't have to worry about the graphic output. You can grap the frame and use the Windows paint program to do the editing, and send it to the printer right away. You don't have to worry about the pre- and post-processing at all. For me , the next step is to write the integrated CFD code in Windows , this can be done in either C or C++. With C++, you can re-use the codes. It is just like the animation world, you build the geometry, model, mesh, textures, lighting, animation sequence, in C or C++. In research environment, Fortran is straightforward. But, the number of people using Fortran will decrease in time. I have not written an integrated CFD code in C++ yet, but I have studied the Windows programming, C and C++ for eight years. My feeling is " a user-friendly CFD code should look like a Windows-based 3-D animation, or paint , or word processing program." ( if you can make it user-friendly using Fortran and OpenGl , I think, it will also serve the purpose.) Thank you for your time.
  Reply With Quote

Old   September 3, 1998, 18:56
Default Re: C++ or Fortran for CFD solvers
  #12
Clifford Arnold
Guest
 
Posts: n/a
This is a trick question. There are many issues. Several have been mentioned by others (e.g. ease of parallelization, maintenance costs of less structured code, speed of execution). Unfortunately the little actual data to substantiate any particular opinion is often out of date quickly.

I have heard from two different sources that major CFD solvers written in C or C++ are just as fast as FORTRAN due to huge improvements in the compilers' backend code generators (e.g. DEC compilers (FORTRAN, C and C++) for Windows95 and Windows/NT!!). I found this to be an amazing statement due to my strong bias towards FORTRAN for speed reasons.

And for those of you who think that may be true on PCs but not on UNIX boxes, recheck the performance numbers comparing these two platforms. Again it is shocking how fast those cheap little things are.

Depending on your compiler you may have a different experience, but I suspect any current advantage *you* see in FORTRAN in speed is only temporary. The fellow who said the money isn't being spent on FORTRAN is right. It hasn't been there for years. And there is data that other languages' compilers have already caught up.

From a code maintenance point of view and leveraging new programming resources, I believe the answer is C or C++ today and other languages in the future.
  Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 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 06:37
FORTRAN vs. C/C++ in CFD Solvers Carlos Manglano Main CFD Forum 8 December 16, 2008 12:56
Fortran solvers Mike Main CFD Forum 4 January 17, 2007 17:01
visual fortran Monica Main CFD Forum 1 August 28, 2004 21:45
Fortran77 or Fortran 90 Swapnil CFX 2 November 26, 2002 16:16


All times are GMT -4. The time now is 12:34.