View previous topic :: View next topic |
Author |
Message |
Anonymous Guest
|
Posted: Sun Nov 06, 2005 1:32 pm Post subject: Passing complex numbers between C# and Fortran |
|
|
I am trying to mix Fortran code and C# code. A Fortran subroutine should call a C# static method.
On the Fortran side I have this code:
subroutine testf(c)
ASSEMBLY_EXTERNAL(NAME="Test.Class1.testc") testc
complex c
call testc(c)
return
end
In C# I wrote this:
namespace Test
{
unsafe public sealed class Class1
{
static public void testc(Complex8* px)
{
Complex8 x = *px;
Console.WriteLine("Number = {0} + {1}i", x.Real, x.Imaginary);
}
}
}
I always get this error:
error 1119 - No .NET method matches this call
It works well when I use float instead of complex, no matter whether I use float or float* in the declaration. But not for complex. How can I pass complex numbers and arrays of complex numbers to C#? And is there a way I could map the Fortran Complex8 to another complex type that I would prefer to use in C# (with the same layout, of course)?
Thanks in advance,
Andreas Hofer
|
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Mon Nov 07, 2005 12:56 am Post subject: Passing complex numbers between C# and Fortran |
|
|
Andreas
One way to do this is to create a C# object of the appropriate class using OBJECT and NEW@ in your FTN95 code. The help file FTN95.chm gives further details. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Mon Nov 07, 2005 1:48 am Post subject: Passing complex numbers between C# and Fortran |
|
|
Andreas
You can also use FTN95 complex numbers in C# and Visual Basic .NET as follows
Salford.Fortran.Complex16 x = new Salford.Fortran.Complex16(1.0,1.0);
Similarly for Complex8. See "Calling Fortran from other .NET languages" in the help file. |
|
Back to top |
|
|
|