replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - C# and FTN95
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 

C# and FTN95

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



Joined: 17 Dec 2008
Posts: 13

PostPosted: Fri Dec 19, 2008 3:45 pm    Post subject: C# and FTN95 Reply with quote

Can you explain why this doesn't work?

DLL ft95test.dll:

subroutine greeter(num)
integer(kind=3), intent(in) :: num
assembly_interface (name="greeter")
print *, "Hello ", num
end subroutine

subroutine greeter2(greetee)
character(len=*), intent(in) :: greetee
assembly_interface (name="greeter2")
print *, "Hello ", greetee
end subroutine

(compiles without problems)

C# Program (Console application):
(references the dll)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Salford.Fortran;


namespace TestFortran
{
class Program
{
static void Main(string[] args)
{

int number = 99;
string programmer = "Thomas";
ft95test.GREETER(number);
ft95test.GREETER2(programmer, programmer.Length);
Console.ReadLine();
}
}
}


Error 3 The best overloaded method match for 'ft95test.GREETER(int*)' has some invalid arguments D:\Visual Studio 2008\Projects\F95Projects\Ft95Test\TestFortran\Program.cs 17 13 TestFortran
Error 4 Argument '1': cannot convert from 'int' to 'int*' D:\Visual Studio 2008\Projects\F95Projects\Ft95Test\TestFortran\Program.cs 17 30 TestFortran
Error 5 The best overloaded method match for 'ft95test.GREETER2(Salford.Fortran.Character*, int)' has some invalid arguments D:\Visual Studio 2008\Projects\F95Projects\Ft95Test\TestFortran\Program.cs 18 13 TestFortran
Error 6 Argument '1': cannot convert from 'string' to 'Salford.Fortran.Character*' D:\Visual Studio 2008\Projects\F95Projects\Ft95Test\TestFortran\Program.cs 18 31 TestFortran

If I'm not passing the Length argument, I get the message that there is no version of Greeter2 with only one argument.

Why does Fortran want pointers? I think the conversion is done through the Assembly_interface? If I try to pass arguments by reference it doesn't help.

Surprised
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Fri Dec 19, 2008 5:36 pm    Post subject: Reply with quote

I am a little rusty on this subject but I think that you should be using the lower case "greeter" etc. in your C# code otherwise you will not get the expected binding. The upper case form requires you to pass a reference.

See the help file under "Calling Fortran from other .NET languages".
Back to top
View user's profile Send private message AIM Address
Astelix



Joined: 17 Dec 2008
Posts: 13

PostPosted: Sat Dec 20, 2008 12:32 am    Post subject: Reply with quote

Thank you Paul, that helped.
Back to top
View user's profile Send private message
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