Link to home
Start Free TrialLog in
Avatar of lili6420
lili6420

asked on

Convert Fortran to C++

I have a very big software written in Digital Fortran.  I want to convert it to Microsoft Visual C++ format.  It is OK if converted codes are not object oriented.

Please recommend a good tool to automate the convertion, and if possible please advise in what circumstances that tool will fail.

Thanks,
Audrey
ASKER CERTIFIED SOLUTION
Avatar of TheLord
TheLord

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DanRollins
Hi TheLord,
The experts in this Topic Area have agreed not to post Answers, rather to post only Comments.  That tends to  provide more, and more varied, input for the Asker and enables more Experts to collaborate to solve the problem.

In this case, that is particularly a good idea, since the link that you posted does not answer the question.  In fact, it describes something quite different from what lili6420 requested.  That makes it less than the 'perfect and only' answer that would qualify as an exception to the 'Comments Only' agreement.  So, in the future, please post comments, like everybody else.  Thanks!

-- Dan
Avatar of yonat
yonat

you can try f2c - I think it comes with GNU. If not, you can get it at http://www.netlib.org/f2c/ .
You can also check out http://mywebpages.comcast.net/iliareznik/fpc.htm
Avatar of lili6420

ASKER

I have looked at the web proposed by the Lord, and as well as the f2c program.  It seems to me it doesn't support digital Fortan.  With simple fortran code, the program generated warning without converting to the desired C/C++ codes.

My desired tool is a fully functional tool, probably a commercial tool, which supports digital Fortran.

Thanks.
Audrey
lili6420,

There is, and could be, no tool that will convert your FTN code into perfect C++ code.  If there was, there would be no need for humans in the coding process (discuss... :-)

I don't think the route you're suggesting is the best one - why rip apart a (presumably) fully functional, tested set of code simply because it isn't in the same language as the rest of your program?

Buy an up to date FORTRAN compiler, such as http://www.compaq.com/fortran/ which integrates nicely into the VC++ dev environment.  Then compile the code as FORTRAN, and call the functions from your C++ code.

If this is not acceptable, then think about what you're asking - you want to convert all of this code automagically into C++ (or C, in which case f2c is the preferred solution, as mentioned above).  If anything fails, you will still want to go back to the original FTN code to work out what it was supposed to be doing.  There is no shame in maintaining some FORTRAN in your project - I even write new FORTRAN code for very specific tasks, where calculation speed is very important.

Of course, this question would very quickly degenerate into a FTN vs C++ thread, which would be fruitless - decide whether it really is essential that you have all of your code in one language.  If it is, use f2c and change the bits you want to (on the whole it does a very good job).  You will now have lots of C in your C++ program, which you call using a slightly different calling convention from the original FORTRAN.  If your objective is to avoid knowing/ hiring anyone who knows FORTRAN, I doubt that you can meet it.

Cheers, and best of luck.
Hi lili6420,
I think you forgot this question.
Can you please remove it from the LOCK Question list by either awarding the points to deserving expert, or rejecting the posted answer.

Thank you