On Sun, 11 Mar 2018, Andrew Makhorin wrote:

-------- Forwarded Message --------
From: Antonio Carlos Moretti <moretti+dated
+1521124706.e2c...@ime.unicamp.br>
To: help-glpk@gnu.org
Subject:
Date: Sat, 10 Mar 2018 11:38:24 -0300

Hello,
Is there any way to call glpk from a fortran program?

Probably.
I called FORTRAN 77 from C when doing my thesis in the 1980's.
According to Wikipedia, Fortran 2003 included C interoperability.
Fortran 2018, whenever it arrives,
is supposed to be even more interoperable.

I have no subsequence experience.

Getting the external names compatible
might require compiler or linker options.
For some reason, underscores_ are often involved.
I never understood why.

C does call by value.
At the time, my FORTRAN did call by reference, i.e. pointer.
My recollection is the the standard at the time
allowed either call by reference or by value-result.
The program was ill-formed if the difference mattered.
My guess is that this was handled in Fortran 2003.
If not handled by Fortran, a C wrapper function will work.

C array indices are most significant index first.
Fortran array indices are most significant index last.

I think that Fortran now has the equivalent of C structs.
If not, passing the appropriate member of a common block
woud be equivalent to passing a pointer to a struct.

If all else fails, my guess is that C++ wrapper functions would work.

extern "C" int fredC(....);

extern "FORTRAN"
int fredF(....)
{
    return fredC(....);
}

--
Michael   henne...@web.cs.ndsu.nodak.edu
"Sorry but your password must contain an uppercase letter, a number,
a haiku, a gang sign, a heiroglyph, and the blood of a virgin."
                                                             --  someeecards

_______________________________________________
Help-glpk mailing list
Help-glpk@gnu.org
https://lists.gnu.org/mailman/listinfo/help-glpk

Reply via email to