Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29277 Discussions

C to Fortran translators: do they exist?

forall
Beginner
1,128 Views
Are there any scripts/utilities (free or commercial) that can translate code written in C (or C+ or C++) into Fortran? I have found some stuff that converts Fortran into C but nothing that goes the opposite way... thanks in advance.
0 Kudos
4 Replies
ingo_berg
Beginner
1,128 Views
They don't exist as far as I know.

One could implement a translator from C to Fortran for the common subset of features. The problem is no real world C program uses only those features. You wouldnt be able to translate much more than a "hello world" sucessfully.

For instance even Fortran 95 does not support allocation or derived type arrays (although intel implemented it as an extension) This is done all over the place in C programms. Linked lists commonly used in C are impossible to translate in a generic way to Fortran without support for pointers. Translating i/o function with a variable number of parameters like printf would be very difficult.

Regards,
Ingo
0 Kudos
Steven_L_Intel1
Employee
1,128 Views
Allocation of derived type arrays is standard F95. Do you mean a derived type component that is ALLOCATABLE? That indeed is an extension to F95, standard in F03. But standard F95 has POINTER components, which comes much closer to C semantics than does ALLOCATABLE.
0 Kudos
ingo_berg
Beginner
1,127 Views
Yes that is what i meant. By the way this is a crucial feature for me. I hope i'm gonna see more F2003 features in intel fortran in the near future.
0 Kudos
emc-nyc
Beginner
1,127 Views
There was a C2F translator listed at the Fortran Company, however the link ( http://home.cfl.rr.com/davegemini/C2F.ZIP ) appears to be dead. You could try googling for it, but it's probably easier to get a C compiler.
0 Kudos
Reply