forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Passing complex numbers between C# and Fortran

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Anonymous
Guest





PostPosted: Sun Nov 06, 2005 1:32 pm    Post subject: Passing complex numbers between C# and Fortran Reply with quote

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: 7916
Location: Salford, UK

PostPosted: Mon Nov 07, 2005 12:56 am    Post subject: Passing complex numbers between C# and Fortran Reply with quote

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
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Mon Nov 07, 2005 1:48 am    Post subject: Passing complex numbers between C# and Fortran Reply with quote

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
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group