Re: C++ wrapper for a fortran77 program??
From: Catherine Rees Lay (spamtrap_at_polyhedron.org.uk)
Date: 06/09/04
- Next message: Catherine Rees Lay: "Re: qsort and arbitrary types"
- Previous message: David Frank: "Re: qsort and arbitrary types"
- In reply to: hc2002: "Re: C++ wrapper for a fortran77 program??"
- Next in thread: Tom: "Re: C++ wrapper for a fortran77 program??"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 9 Jun 2004 09:49:15 +0100
In article <a71eefaa.0406081846.2a6821cf@posting.google.com>, hc2002
<c.hong@mailcity.com> writes
>beliavsky@aol.com wrote in message
>news:<3064b51d.0406080719.56adbda5@posting.google.com>...
>> c.hong@mailcity.com (hc2002) wrote in message
>>news:<a71eefaa.0406071540.750cdcfc@posting.google.com>...
>> > Hi everyone,
>> >
>> > I have a fortran77 program on unix (made up of 5 fortran program files
>> > and about 5k lines). I would like to make it work on windows. Besides
>> > completely rewriting the fortran program in c or c++, I was told that
>> > a C++ wrapper to call the functions inside of it may work as well. I
>> > am looking for the most practical way to do this project. And if C++
>> > wrapper is the best option, what steps should I take? Some examples
>> > will be appreciated. I know some of c and c++, but not an expert.
>> > Thanks for any of your advice on this...
>> >
>> > Hong
>>
>> If the Unix program is text-based and you want the same thing on
>> Windows, just get a Fortran 77 compiler for Windows (as others have
>> said), such as g77 or Open Watcom. If you want the Windows program to
>> have a GUI, then things are more complicated. Fortran compiler vendors
>> such as Absoft, Intel, Lahey, and Salford do provide facilities to
>> simplify GUI creation without becoming a full-fledged Windows
>> programmer. Other frequently-mentioned choices are Tcl/Tk (free, and
>> usable on Windows and Unix), Borland Delphi, Visual Basic, and Visual
>> C++. Other products to simplify GUI creation are Winteracter and
>> GINOMENU.
>
>Hi guys,
>
>Thanks a lot for all of your good comments. I slightly modified my
>fortran programs and compiled it on G77 compiler. It generated an .exe
>file, which works great! The reason why I was and still am thinking
>about a wrapper is that it might allow other software to call my
>fortran functions more easily. So it can become more portable. I am
>not sure if I am thinking correctly. Any further comments are highly
>appreciated.
>
>Hong
If you want other software to call your functions, possibly the easiest
way is just to take your main program out and compile everything else
into a DLL. Then you can give this to anyone, with details about what
calling convention you use, and they can call your routines.
Now this is where your C++ wrapper might come in useful. If your
routines accept character arguments, for instance, the other software
will have to pass them in the form which your Fortran compiler expects,
and this is unlikely to be the default form that their C++ compiler
uses. With a C++ wrapper which takes arguments the way that C++ passes
them and converts them to what your Fortran expects, you get to figure
out how to make this work properly and they don't have to.
Having said that, if the other software is written in, say, Delphi,
having a C++ wrapper isn't really much more use than the original
Fortran calling sequences. A Delphi wrapper, on the other hand, would
then be just what you want. So don't do a lot of work on this sort of
stuff unless it's actually going to be used. It doesn't make your code
any more portable, it just makes it easier to call from a different
single language.
HTH,
Catherine.
-- Catherine Rees Lay To email me, use my first name in front of the "at".
- Next message: Catherine Rees Lay: "Re: qsort and arbitrary types"
- Previous message: David Frank: "Re: qsort and arbitrary types"
- In reply to: hc2002: "Re: C++ wrapper for a fortran77 program??"
- Next in thread: Tom: "Re: C++ wrapper for a fortran77 program??"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|