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

Fortran 90 to c++ converter

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

Reply
 
LinkBack Thread Tools Display Modes
Old   July 28, 2000, 00:00
Default Fortran 90 to c++ converter
  #1
Guoping Xia
Guest
 
Posts: n/a
Is there a converter from Fortran 90 to c++? Could anybody tell me please?

Thanks!
  Reply With Quote

Old   July 28, 2000, 04:32
Default Re: Fortran 90 to c++ converter
  #2
andy
Guest
 
Posts: n/a
There is the old f2c (Fortran 77 to C). This might give you a start depending on what it does with the Fortran 90 constructs.

Can I ask why you want to convert the code?
  Reply With Quote

Old   July 28, 2000, 12:55
Default Re: Fortran 90 to c++ converter
  #3
Guoping Xia
Guest
 
Posts: n/a
The fortran 90 code I wrote is for mesh adaptation. I use the dynamic data structures of the new generation of Fortran. However, I find it is not so fast as I expected,so I want to try c++. That is the reason.
  Reply With Quote

Old   July 28, 2000, 13:34
Default Re: Fortran 90 to c++ converter
  #4
andy
Guest
 
Posts: n/a
I have little direct experience of Fortran 90 but I do know you have to be careful passing your dynamic arrays around. It may be worth having a quick chat with someone (or some reference) which will give you some guidance. Many years ago someone from NAG was explaining the pitfalls of Fortran 90 to me but none of it has stuck unfortunately. It may be a place to start.

C++ is slow. Even the most optimistic will only claim it might approach the speed of Fortran (e.g. Blitz) and this is only after extraodinary efforts to emulate in C/C++ code the optimisation operations performed by a normal Fortran compiler (carefully avoiding reference to the very useful but... g77). You will not believe how long even simple code takes to compile and the bloat of the resulting binary.

Even Bjarne Stroustrup (C++ ARM) cheerfully admits that the C array is irrepairable (I may be misquoting a bit here because I cannot find the reference - anyone?).

If you want speed then stick to Fortran 77 and a decent compiler. Writing one or two extra routines to compact your fixed size arrays when they have hit their maximum size is not much of a chore. Certainly when compared to the efforts of getting to grips with templating in C++ (assuming your C++ compiler has implemented enough template features to use them effectively!).

  Reply With Quote

Old   July 28, 2000, 21:32
Default Re: Fortran 90 to c++ converter
  #5
Jongtae Kim
Guest
 
Posts: n/a
Hi Gouping, How are you?

It is said that Fortran77 is the fastest language. C and Fortran90 are faster than C++. OOP is slower than structured programming. Dynamic memory allocation makes your code slow-down. But if you use more arrays to save mesh connectivities for the adaptation, you can get the speed-up. So I recommand you to save all the informations for mesh connectivities.

Sincerely yours,

Jongtae Kim

  Reply With Quote

Old   July 28, 2000, 22:59
Default Re: Fortran 90 to c++ converter
  #6
John C. Chien
Guest
 
Posts: n/a
(1). C++ is equal to c plus object-oriented programming using class and object. (2). You don't have to use oop when writing code in C++ language. The conventional c-language, structured procedural programming still works. (3). The reason going into oop is not for speed but for ease of program maintenance and program resue. (4). I would say that program written in oop style in C++ (class and object) tends to simulate the real world objects and activities more closely. This is especially true for the data hiding inside the class and object. It is always protected from unauthorized access. In the non-oop world, data are not associated with any object and are not protected. (5). Since the new data type such as the user-defined class type, needs to be declared first and then defined later, it always take time to create (constructor) and clean-up (destructor) the object. (6). Just like renting an apartment, the apartment needs to be cleaned, painted, range and oven checked out,etc.. before one can move in. On the other hand, the non-oop approach will simply put you in a big shelter as long as there is a bed available. But then you don't have the privacy at all in the big shelter, not to mention about the security of the personal things. So, the extra security will require extra time and resources. (7). So, C++ with oop is not created for speed. Like graphic programming in computer games, you will have to go a step further to use either DirectX or assembly language in order to really get the speed gain.
  Reply With Quote

Old   July 31, 2000, 05:29
Default Re: Fortran 90 to c++ converter
  #7
Oliver Gloth
Guest
 
Posts: n/a
I don't think that you can put it that simple (i.e. F77 is faster than C and F90, which are faster than C++ and so on). The big problem about dynamic arrays is aliasing. That means the compiler can not know if two arrays overlap in the memory. This can just not happen in F77, right? Another point is making use of object-oriented features, without thinking about performance. There are, however, many nice approaches to be efficient and object-oriented. If you are interested in OOP+numerics you should check out <a href=http://oonumerics.org/oon/>The Object-Oriented Numerics Page</a>, which is maintained by T.Veldhuizen (the author of Blitz++). I personally recommend his text about 'Techniques for scientific C++' which can be found on that page as well. To my opinion the benefits from OOP (reusability, mainatinability) are worth the effort, although it can still be a bit painful right now.
  Reply With Quote

Old   August 9, 2000, 06:57
Default Re: Fortran 90 to c++ converter
  #8
andy
Guest
 
Posts: n/a
While looking for something else I came across this link to a F90 to C++ converter.

http://www.cross.ru/kcc/

Could you post back to let us know if it works? Or is partially useful?

  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 23:13
visual fortran Monica Main CFD Forum 1 August 28, 2004 21: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 10:34


All times are GMT -4. The time now is 09:48.