- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was thinking if there is a way to create fortran dll and make call to it from C# code.
An example will be of great help if possible.
Thanks
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You asked in the other thread how to build DLL from the command line. You do it with:
ifort /dll sourcename.f90
You will want to add !DEC ATTRIBUTES DLLEXPORT lines as appropriate.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve - good to see that you are still Fortraning it!! I've been looking for exactly what you attached in this thread for quite some time now - thanks for the post. I did a quick review of the code and I have a couple of questions:
1 - since there are 8 parameters defined/passed in the C# and 6 parameters in the Fortran, I assume something is going on with either the characters (StringBuilder) data types, is this correct?
2 - Is there a "complete" list of how to marahall C# data types (including scalars, single and multidimensional arrays) down to fortran?
3 - Finally, do you see any problem building a C# wrapper around my good old fortran and using the resulting fortran DLL/C# wrapper .NET assembly in an ASP.NET v2.0 application? I want to start putting some of my useful engineering fortran into web applications and I see this a very viable solution.
Thanks.
Jon Lea
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2) I have no such list. I will comment that multidimensional arrays are likely to be problematic - C/C++ at least does not represent these as anything close to Fortran, and that probably goes for C# as well. I don't know if C# can use "SafeArrays" that VB.NET does - you can manipulate these with Fortran (see the VB.NET-SafeArray sample).
Most of the mixed-language things, especially with the .NET languages, we pick up as we go along. This particular example is based on code from a customer - I did not write it from scratch.
3) You could do that., but also look at the reintroduced COM Server capability in IVF 10.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've attached such a sample 'as is'. It works for me. YMMV.
C# has an Array class. What its relation is to a SafeArray I can't tell. It looks like its pretty close to a Fortran matrix. The demo illustrates the provision of a rank 2 real(8) matrix to C#by a VF Dll, the use of a Console in what is essentially a Windows Forms application, and the simulation of a lengthy operation in a (unsafe) thread. Enjoy.
Gerry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When I click the reposted zip it opens and the archive is intact.
Gerry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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