F2C converter

F2C converter

Post by n o s p a » Fri, 09 Jun 2006 18:38:01


What is a good Fortran to C converter?

Thanx
NSP
 
 
 

F2C converter

Post by Catherine » Fri, 09 Jun 2006 19:05:45


There isn't one.

Well, to be fair, there are some (possibly the most widely used is, in
fact, called F2C). But if what you have is well written Fortran, there
is no way to get the same standard of C code from a mechanical converter.

There are, however, lots of ways to use Fortran code in a C project.
What do you actually need to do?

Catherine.

 
 
 

F2C converter

Post by n o s p a » Fri, 09 Jun 2006 20:36:28


I have interface a model written in Fortran to a simulation that
understands models in C++ only. I am told it is possible in one of the
following two ways:

* The model written in Fortran can be directly linked to a C interface,
or
* The model written in Fortran can be converted to C++ using a f2c
converter and then be interfaced.

Which is the easiest, reliable and computationally efficient? I guess
the second option. Any suggestions how it can be done.

Thanx
NSP
 
 
 

F2C converter

Post by Jan Vorbrg » Fri, 09 Jun 2006 20:52:18

> * The model written in Fortran can be directly linked to a C interface,

As every (?) C++ compiler also provides a C interface, you can easily go
this route. Just don't forget to turn off name-mangling by using extern "C".

Jan
 
 
 

F2C converter

Post by Arjen Mark » Fri, 09 Jun 2006 20:57:21


n o s p a m p l e a s e schreef:



No, definitely the first!
It is much easier and more reliable to create a thin layer of C to call
your
well-developed and well-tested Fortran routines than to have them
converted
by an automatic tool. I know f2c is well up to the task of converting
FORTRAN 77
code, but I doubt it is able to do Fortran 90/95 in the same way.

As for computationally efficient: a well-tuned C program is probably
just
as efficient as a well-tuned Fortran program (all reports about one
being
faster than the other are anecdotal at best and almost certainly
biased,
in the sense that for a particular small class of programs you may get
these
results and you may also get them by not tuning either language well
enough). However, my own experiments with Fortran 90/95 constructs
like array operations indicate that in general these are faster than
explicit loops. C does not have the comfort of array operations.

So, there is my conclusion: option 1 is the best choice.

Regards,

Arjen
 
 
 

F2C converter

Post by Lynn McGui » Sat, 10 Jun 2006 00:42:17

> What is a good Fortran to C converter?

Cobalt Blue's FOR_C converter http://www.yqcomputer.com/
has a very good reputation. I do know people who have used it in the
past for good results.

Lynn