- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page