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

Calling C# from Fortran

fbalderasintel
501 Views
Has anyone called a C# function, in a dll, from Fortran ? If so, does it work the same a calling a C function with regards to linking and setting up the interface? I can call Fortran from C# but have not had luck going from the other direction.
I'm now thinking about using a callback mechanism because I'll have a lot of back and forth. Does anyone have a callback example whereFortran callsback to C# with a function pointer?
0 Kudos
3 Replies
Steven_L_Intel1
Employee
501 Views

The C# code is in .NET managed code - you could use the "Fortran Module Wizard" to generate Fortran interfaces to the C# code's methods. This is under Tools.
0 Kudos
fbalderasintel
501 Views

The C# code is in .NET managed code - you could use the "Fortran Module Wizard" to generate Fortran interfaces to the C# code's methods. This is under Tools.

I am going to use CALL SYSTEM("csharp_program.exe") to launch a console program to do its deed and then close and return to Fortran. This should work for my immediate needs.
0 Kudos
Steven_L_Intel1
Employee
501 Views

Ok. If you'd like to do it without a console window opening up, try the Win32 API ShellExecute.
0 Kudos
Reply