- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Steve,
Im about to begin a mixed language project, where in C# is I/O andan IVF dll is the mathematical kernel.
In my projects was an older example you posted here some time ago, I couldnt findthat thread any more, it is called csharpsample. There is an c# console application and a fortran dll, where c# calls a fortran subroutine and it passes the results.
I have one general question: Why do you use in c# System.Single and not floatfor fortran real?
Is this equivalence "chart" correct or do I miss something?
fortranc#
real(kind=4) System.Single (why not float?)
real(kind=8) double
real(kind=16) decimal
integer(kind=2) short
integer(kind=4) int
integer(kind=8) long
character*(*) System.Text.StringBuilder
logical bool (or somekind of int?)
Thanks in advance,
Markus
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Fortran LOGICAL has no equivalent in C/C++/C#. It is emphatically NOT bool.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If someone can give an example on handling different data types, arrays or module data that would be great. I am sure we can all benefit from a sample program.
Thanks.
- 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
Yes, this is the example I have on my disk.
Logical is not bool, I know that. So you have to create a workaround, passing an int = 0 as .false. and != 0 as .true. or something like that.
Iknow why the author uses System.Single instead of float. Its the same :-) float isthe C# keyword for the .NET Class System.Single, so it doesnt matter.
The good thing in this example is, that the array size is unknown to the Fortran DLL (nArry(*)). The bad thing is, it only works with 1 dimensional arrays. Does anybody knows how to change this into 2 or 3 dimensional arrays?
I try to avoid allocatable arrays, but sometimes you dont have the choice :-)
When you work with more dimensional arrays you have to consider that C# and Fortran arrays have a different way how the data isstored in memory. A C# Array[x,y,z] is the Fortran Array(z,y,x).
Markus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When I call the subroutine, the Exception System.BadImageFormatException appears.
I know that this has something to do with x86 and x64 settings in Visual Studio. I changed the C# project to x86, the IVF project is Win32. But it still wont work.
This happens with newly created C#.GUI and IVF.dll too
Does anybody has similar problems andmaybe a solution?
Markus
- 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
Now Im stuck to let this C# program communicate through this DLL with a Fortran program as shared memory (http://software.intel.com/en-us/forums/showpost.php?p=169028).
Ive found some posts and I think there are 2 problems: First, Windows7 (and Vista too) uses Shared Memory differently than WindowsXP. Furthermore, .NET programs run in seperate "application domains".
Im on it :-)
Markus

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