- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I know its possible to call C# from Fortran via C++. but was wondering do we some direct way to do it with the new intel compiler 2015?
Thanks
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
there are lots of threads on this subject in the forum if you do a search.....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The most straightforward way is to have C# build a regular (not COM or Automation) DLL. You'll then need to figure out what the C# code is looking for in its arguments. Not all C# argument types can be passed from Fortran.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A sketch of Steve's advice is as follows:
// C# .dll using System; using System.Collections.Generic; using System.Linq; using System.Text; //using YourOtherStufv; namespace YourDLL { public class YourDLLAsApp { public static void lauchYourApp(IntPtr ptr) // you figure out args you want { Console.WriteLine("We are now inside YourDLLAsApp (C# managed)"); ... } } } ! your interfaces module mod_Interfaces ... interface ! void lauchYourApp(void* ptr1) SUBROUTINE lauchYourApp(ptr) BIND(C, name="lauchYourApp") use, intrinsic :: ISO_C_BINDING use mod_Interfaces procedure(YourProcedure), pointer :: ptr end SUBROUTINE lauchYourApp end interface ... end module mod_Interfaces ! your program PROGRAM YourProgram use mod_Interfaces ... call lauchYourApp(SomeFortranRoutineOrType) ... end program YourProgram
The code is untested, merely a sketch.
Jim Dempsey

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page