Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29487 Discussions

Passing Fortran Procedures to C for Subsequent Callback

bgpalmer
Beginner
640 Views

Could someone please give me an example of how to pass the address of a FORTRAN subroutine to a C program so that the C program can call the subroutine at a later time (e.g. a callback)? The C code is in a DLL that is linked into the FORTRAN model. The FORTRAN model calls the C code most of the time, but sometimes during a call to the C code, the C code will need to call one of the FORTRAN subroutines.

Thanks,

Brian

0 Kudos
1 Reply
TimP
Honored Contributor III
640 Views

Here's an example of how it should work on the Fortran side:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35971

and here's a discussion of some false starts and corrections:

http://objectmix.com/fortran/353727-passing-pointer-function-using-iso_c_binding.html

and an actual example on the Fortran side

http://cims.nyu.edu/~donev/Fortran/F03GL/OpenGL_glut.f90

and a discussion on this forum including Windows issues

http://software.intel.com/en-us/forums/showthread.php?t=70235
0 Kudos
Reply