F2C converter 
Author Message
 F2C converter

What is a good fortran to C converter?

Thanx
NSP



Mon, 24 Nov 2008 17:38:01 GMT  
 F2C converter

Quote:
> What is a good Fortran to C converter?

> Thanx
> NSP

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.



Mon, 24 Nov 2008 18:05:45 GMT  
 F2C converter

Quote:

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

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



Mon, 24 Nov 2008 19:36:28 GMT  
 F2C converter

Quote:
> * 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



Mon, 24 Nov 2008 19:52:18 GMT  
 F2C converter

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

Quote:

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

> 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.

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



Mon, 24 Nov 2008 19:57:21 GMT  
 F2C converter

Quote:
> What is a good Fortran to C converter?

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

Lynn



Mon, 24 Nov 2008 23:42:17 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Commercial F2C converter

2. AT&T F2C converter

3. Looking for a Fortran to C converter (eg f2c)

4. f2c (Fortran to C) converter

5. Where find f2c, and is there a f2c++?

6. iand, ior for f2c (was:iand for f2c?)

7. f2c and structures, commercial f2c

8. Looking for a fortran to c converter (other than f2c).

9. ANNOUNCE: f2c-stabs - eases debugging of f2c compiled Fortran.

10. f2c problem. f2c Doesn't understand preprocessor directives.

11. f2c experiences

12. f2c experience

 

 
Powered by phpBB® Forum Software