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

C++ fortran confusion

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 25, 2008, 13:51
Default C++ fortran confusion
  #1
prapanj
Guest
 
Posts: n/a
Hi

I currently use fortran 90 for all my codes. But these days I see that opens source CFD libraries like open FOAM are written in c++. I dont find any open source stuff like that for a fortran user. Do you think a CFD-ian these days should be good in both fortran and C++/C ? Please guide me.

thank you

Prapanj
  Reply With Quote

Old   February 25, 2008, 21:41
Default Re: C++ fortran confusion
  #2
Quarkz
Guest
 
Posts: n/a
Hi,

I'm also using fortran 90. I've learnt C in sch too but I prefer fortran 90. I feel more comfortable with it. I wonder if there's a real advantage to using C++...

Anyway, I found that most new linear eqn solvers seem to be written in C, although a fortran interface is still present. These include PETSc, hypre, just to name a few.

It seems that most sch don't teach fortran nowadays, which is quite a pity. Moreover, most ppl I talk to feel that fortran's an outdated ancient language. Of cos, they're not in the CFD field.

Anyway, to answer your qn, I think knowing C should help. Not sure abt C++
  Reply With Quote

Old   February 25, 2008, 23:03
Default Re: C++ fortran confusion
  #3
rt
Guest
 
Posts: n/a
c++ is recently prefarable mainly due to OOP capability, when u develop ur code in ur short period research, Fortran could be quit sufficient (+ wrapping third party tools), but when u should think to reusability, future extension, having multiple developers, having a clean modular code, ease of use (data & functionality encapsulation), ... using OOP programming is unavoidable.

for OOP c++ could be the best choice. Note that C is not OOP language but it is possible to use its for this purpose (there are some text on OOC), e.g. GLib is wrriten in this way.

some peoples have used mixed programming to relax from performance drop of c++ (e.g. Chombo code), but experts use additional power of c++ to do this job e.g. expression templete programming (e.g. BLITZ++)
  Reply With Quote

Old   February 26, 2008, 00:24
Default Re: C++ fortran confusion
  #4
hadian
Guest
 
Posts: n/a
Fortran is much easier for CFD and numerical purposes and there are some notes on the internet for OOP by fortran. the main week point is that there is not any powerful graphical library for fortran while you can find plenty of those libraries for C and C++ (and many of theme are free). It seems Mixed Language programming can overcome these problems but it is not easy and maybe your code will not be portable. Hadian
  Reply With Quote

Old   February 26, 2008, 09:30
Default Re: C++ fortran confusion
  #5
rt
Guest
 
Posts: n/a
>... there is not any powerful graphical library for fortran while you can find plenty of those libraries for C and C++

This is not important, we rarely like to visualize results on-the-fly and usually CFD post-processors (Paraveiw, Ensight, Tecplot, ...) works on exported data (also for moderate size problems generation of results are very slow)

> but it is not easy and maybe your code will not be portable

recently the portability issue of mixed language programming is just due to posrability of Fortran code or C++ code itself, and so it is not issue too (several opensources use this with autoconfig which is fairly portable).

Regarding to OOP programming i should add this that, OOP programming needs knowledge in this regard and its design is very very important, usually design of OOP code (design of classes, their import/export, hierarch, ..) take more time than programming (e.g. for early stage of VTK lib. development, this phase takes 6 fold more time than programming).

  Reply With Quote

Old   February 26, 2008, 09:48
Default Re: C++ fortran confusion
  #6
jinwon park
Guest
 
Posts: n/a
It is very questionable whether C++ can replace scientific fortran codes since one has different preferences in terms of OOP, efficiency and reusuability. I have learnt c++, fortran, java and matlab for my researches so far. Before starting ph.d, I had preferred c++ since it provides efficient framework for OOP. However, in doing Ph.D work, these were not major portions. Anyway, for better research, I do not want to study programming more since most CFD peoples are not computer engineer.

Good luck!
  Reply With Quote

Old   February 26, 2008, 10:05
Default Re: C++ fortran confusion
  #7
cfd_newbie
Guest
 
Posts: n/a
My advice is to use FORTRAN 95/2003 for number crunching programs and, if you need a decent GUI, you could always use Python for that.

By the way Python could glue Fortran and C/C++ application very easy. In that way you could use an open source library written in C++ and your one Fortran code.

A very good book for mixing Python, Fortran and C++ is:

Python Scripting for Computational Science.
  Reply With Quote

Old   February 26, 2008, 23:12
Default Re: C++ fortran confusion
  #8
hadian
Guest
 
Posts: n/a
As i experienced during my pdh, having a graphical library for limited visualization in a CFD code can save time during the development. For example, graphical monitoring of the residuals in an implicit solver, make the debugging much easier than monitoring the numbers.

about Python, it seems that python is going to be very popular. But it is an interpreter. IS it as fast as fortran or c++ which are compilers? does anybody have experience working with python in CFD? Hadian
  Reply With Quote

Old   February 27, 2008, 05:05
Default Re: C++ fortran confusion
  #9
Rami
Guest
 
Posts: n/a
There are some F90 open source codes, e.g., Elmer (http://www.csc.fi/elmer/) and Dolfyn (sorry, I don't have a link, but it is a dutch software).
  Reply With Quote

Old   February 27, 2008, 09:45
Default Re: C++ fortran confusion
  #10
cfd_newbie
Guest
 
Posts: n/a
About Python ...

Python is an interpreted language and in Python you could not achieve the speed of a Fortran or C++ code, but:

1. A professional CFD code is made of many parts and except the solver everything could be developed in Python.

2. You could have only the IDE written in Python, your solver could be a Fortran or a C++ code. This will ensure the portability of your code between Linux and Windows for example.

3. You could have the pre-processing and post-processing part in Python.

....

  Reply With Quote

Old   February 29, 2008, 03:10
Default Re: C++ fortran confusion
  #11
J
Guest
 
Posts: n/a
Hi,

What are the graphical engines you know of for Fortran? (free preferably!)

  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 12:31.