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 

FTN + C#

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



Joined: 25 Apr 2006
Posts: 41
Location: Wuerzburg, Germany

PostPosted: Fri Mar 09, 2007 2:06 pm    Post subject: FTN + C# Reply with quote

Is it possible to combine Fortran and C# (data exchange) in WIN32 environment , or only using .NET ?
Klaus
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


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

PostPosted: Fri Mar 09, 2007 4:56 pm    Post subject: Reply with quote

Only .NET.
Back to top
View user's profile Send private message AIM Address
MERO



Joined: 25 Apr 2006
Posts: 41
Location: Wuerzburg, Germany

PostPosted: Mon Mar 12, 2007 8:48 am    Post subject: Reply with quote

Is the same true for Fortran + C++ ?
Klaus
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


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

PostPosted: Mon Mar 12, 2007 9:46 am    Post subject: Reply with quote

FTN95 can be combined with ("unmanaged") C++ under Win32.

SLINK allows you to link object files created by either FTN95 or SCC.
A Plato project can contain both Fortran and C++ files.
Back to top
View user's profile Send private message AIM Address
DrTip



Joined: 01 Aug 2006
Posts: 74
Location: Manchester

PostPosted: Wed Mar 14, 2007 10:37 am    Post subject: Reply with quote

Further to Pauls answer

depending on you problem and the complexity required

you can make Mixed C++ code, ie unmanaged and managed projects.

the unmanaged methods can then made to interface with WIN32 ftn95 and managed objects are visible to the .NET environment and C#. This is the preferred method of doing complex interop tasks in the .NET environment.

This structure could be use the ADO.NET classes to get data from a database to be passed to FTN95 code.

I have used these methods in both directions ie calling Win32 FTN95 DLL's from .NET applications and also FTN95 WIN32 projects calling .NET classes.

I was driven to this because I needed to use some antique win32 libaries in my ftn95 projects.

if you are using a C# calling program you could also use

System.Runtime.InteropServices

to call native WIN32 FTN95 libraries from C#

I can post a simple example of this

here

C# calling program --

using System;
using System.Runtime.InteropServices;


class Program
{
[DllImport("nativeftn95.dll")]
static extern void TOBECALLED();

static void Main(string[] args)
{
TOBECALLED();
Console.WriteLine("This is a C# string...\nPress any key");
Console.ReadKey();
}
}


nativeftn95.dll --- code


subroutine tobecalled
write(*,*) 'this is a WIN32 fortran dll string'
end subroutine


obviously the C# code needs to be able to find the the library if this method is used - the dllimport label contains the path to the native dll.


this interop structure appears to be missing from FTN95.net, I personally feel this should be added for the next version of FTN95, ie being able to call native libraries from FTN95.net without going via another .NET language.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Wed Mar 14, 2007 1:19 pm    Post subject: Reply with quote

DrTip is right. You can access managed C++ from a Win32 C++ project.
You could then access the result from a Win32 FTN95 project.
Not easy but possible.
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 -> General 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