Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tool for C++ 2 FORTRAN?

361 views
Skip to first unread message

Arjan

unread,
May 27, 2022, 2:02:31 AM5/27/22
to
Hi, is there a good tool to convert a C++ project to FORTRAN?

Sjouke Burry

unread,
May 27, 2022, 2:43:26 AM5/27/22
to
On 27.05.22 8:02, Arjan wrote:
> Hi, is there a good tool to convert a C++ project to FORTRAN?
>
Try a human brain.
Those things can be very useful.

Arjan

unread,
May 27, 2022, 3:45:38 AM5/27/22
to
Op vrijdag 27 mei 2022 om 08:43:26 UTC+2 schreef Sjouke Burry:
Of course.
But:
1: My brain does not have the knowledge yet and I miss the time to learn C++.
2: My project does not have the means to hire a person with a qualified brain.

A.

Thomas Koenig

unread,
May 27, 2022, 5:52:20 AM5/27/22
to
Arjan <arjan.v...@rivm.nl> schrieb:
> Hi, is there a good tool to convert a C++ project to FORTRAN?

My guess would be that it is almost impossible to do in a way
that is possible except at a very low level that it would be almost
iimpossible to maintain.

Consider one C++ feature, multiple inheritance - Fortran does
not have it (which is good), and there is no really clear way to
model it, unless you construct your vtabs by hand.

FortranFan

unread,
May 27, 2022, 1:10:27 PM5/27/22
to
@Arjan,

First, a question: why "2 FORTRAN"?! Staring with ISO IEC standard document for this programming revision published in 1991, it has been "Fortran" e.g., the so-called "Fortran 90" revision to refer to that 1991 publication.

`FORTRAN` might come across as implying your interest in working with a prior version, say FORTRAN 77 and its nonstandard extensions. In year 2022, those who wish to work with such `FORTRAN` will be fewer in numbers!!

Secondly, you may want to consider "crowdsourcing" such an effort instead of seeking a tool.

For example, you can start a project on GitHub where you post the C++ code in question. Then you can request for help on this forum and also at the Fortran Discourse site (https://fortran-lang.discourse.group/) with translations to modern Fortran and chances are high several of the eager Fortran enthusiasts will chip away at the C++ code and assist with authoring modern Fortran incarnation of what this C++ code does.

I suggest you give that a try, if you can.

Beliavsky

unread,
May 27, 2022, 1:26:01 PM5/27/22
to
On Friday, May 27, 2022 at 2:02:31 AM UTC-4, Arjan wrote:
> Hi, is there a good tool to convert a C++ project to FORTRAN?

No, but you can create C interfaces to your code and call them from Fortran.
There are also tools such as SWIG https://github.com/swig-fortran and
shroud https://github.com/LLNL/shroud to make it easier to call C++
from Fortran.

David Duffy

unread,
May 27, 2022, 9:36:26 PM5/27/22
to
Beliavsky <beli...@aol.com> wrote:
> Hi, is there a good tool to convert a C++ project to FORTRAN?

The Rose Compiler knows Fortran and C++ and can translate backwards and
forwards between languages. They don't give any examples specifically
for C++ to Fortran, as it seems to be more a toolkit or framework
for rolling your own:

https://github.com/rose-compiler/rose/wiki/How-to-create-a-translator

0 new messages