View previous topic :: View next topic |
Author |
Message |
MERO
Joined: 25 Apr 2006 Posts: 41 Location: Wuerzburg, Germany
|
Posted: Fri Mar 09, 2007 2:06 pm Post subject: FTN + C# |
|
|
Is it possible to combine Fortran and C# (data exchange) in WIN32 environment , or only using .NET ?
Klaus |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Fri Mar 09, 2007 4:56 pm Post subject: |
|
|
Only .NET. |
|
Back to top |
|
|
MERO
Joined: 25 Apr 2006 Posts: 41 Location: Wuerzburg, Germany
|
Posted: Mon Mar 12, 2007 8:48 am Post subject: |
|
|
Is the same true for Fortran + C++ ?
Klaus |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Mon Mar 12, 2007 9:46 am Post subject: |
|
|
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 |
|
|
DrTip
Joined: 01 Aug 2006 Posts: 74 Location: Manchester
|
Posted: Wed Mar 14, 2007 10:37 am Post subject: |
|
|
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 |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Wed Mar 14, 2007 1:19 pm Post subject: |
|
|
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 |
|
|
|