[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] F90 interface available?

From: Michael Hennebry
Subject: Re: [Help-glpk] F90 interface available?
Date: Mon, 28 Jun 2004 13:56:35 -0500 (CDT)

On Mon, 28 Jun 2004 address@hidden wrote:

> I would like to test GLPK for the minor iteration in an Outer Approximation
> MINLP scheme (as a replacement for LP_SOLVE). Is there a Fortran (or better
> Fortran 90) interface available? Has anybody experience in integrating GLPK
> in a F90 code?

So far as I know, GLPK has no FORTRAN interface.
You can still use it from FORTRAN.

Mixing C and FORTRAN can be done in non-GLPK-specific fashion.
I have called FORTRAN from C.
You want to call C from FORTRAN.

An important thing to remember is that from C's point of view,
FORTRAN passes pointers.
Another is that FORTRAN 77 doesn't have explicit pointers.
In all the systems that I've used a pointer will fit in an int or a long.
Returning function values is more variable than parameter passing.

Suppose you want to a C function with the signature  int glpk(Foo *fo, int bar);
write the following C function:
void glpk_f(Foo **pfo, int pbar, int *retval)
*retval=glpk(*pfo, *pbar);

Call glpk_f something like this:
INTEGER fooptr
C If you have big pointers, you might need DOUBLEPRECSION fooptr
INTEGER bar, retval
CALL somthing_f(..., fooptr, ...)
C fooptr must get its value somewhere.
C likewise bar
CALL glpk_f(fooptr, bar, retval)

My recollection is that when I compiled my C code,
I had to set a compiler option to require or prevent
the adding of an underscore to C's external names.

Also, it's probably best to arrange
for the main program to be a C program.
FORTRAN has less initialization to do at startup.
Probably you could call FORTRAN's main
program from a main program written in C.

Mike   address@hidden
"Nothing says it like words if you know how to use them."
                    --  the Professional Organization of English Majors

reply via email to

[Prev in Thread] Current Thread [Next in Thread]