# To subscribers of the xforms list from Steve Lamont <spl@ncmir.ucsd.edu> :
> I have some very old (but useful) FORTRAN code (mid 60's)! I've been
> working with it on two fronts : 1) f2c-ing the fortran code, and 2)
> developing front-ends using xforms. I've been successful on both
> fronts, independently, but I can't merge the two (2-mains I believe). I
> read Bob's comment suggesting the use of a "c" wrapper, but I don't have
> a clue what a wrapper is. Can someone help me.
Loosely, a wrapper is basically just some "glue" code that hides the
ugly details of an interface or provides some interface between two
disparate APIs. I'm not sure if there's a real formal definition
beyond that.
A wrapper in this case could be an interface between the FORTRAN
function/subroutine calling convention and the C calling convention to
allow a FORTRAN program to call the XForms C language library.
There are several ways of going about the task, depending upon what
your needs are.
If all you need to do is basically call the FORTRAN program from a C
program, this might be pretty easy. Just change your FORTRAN main to
a subroutine or function, link the two in the standard manner, and
call it from the C program.
If you need to call XForms functions from within the FORTRAN program,
that can be a little more complicated, though perhaps not much. There
is a FORTRAN binding for XForms that provides that glue to which I
referred earlier. I don't know how up-to-date it is or how good it
is, but one does exist. Check the XForms web site (see below for
URL).
If the FORTRAN program wants to do simple interaction with the user
through, say PRINT and READ statements, and you want to provide a GUI
to do this, you could set up pipes in your C program to read and write
standard input/output and do a fork() and exec(), then feed the
exec()ed FORTRAN program whatever input it needs and read whatever it
spits out, processing appropriately. If you're not familiar with the
technique, just about any good Unix programming reference (such as
Stevens, _UNIX Network Programming_) should give you all the
instruction you need.
spl
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuhs.mil or see
http://bob.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://world.std.com/~xforms
List Archive: http://bob.usuhs.mil/mailserv/list-archives/
This archive was generated by hypermail 2b29 : Thu Nov 30 2000 - 20:47:58 EST