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 

Visual Basic calling a Fortran dll

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



Joined: 21 Jan 2011
Posts: 65
Location: Leimen, Germany

PostPosted: Tue Nov 22, 2011 5:46 pm    Post subject: Visual Basic calling a Fortran dll Reply with quote

Hello forum,
my colleague is producing a User Interface with Visual Basic in a .NET environment (win 7) and, sofar, I suplied Fortran exes, which he called (I'm using Plato). On the long run it is impeding to use exe, dlls would be more elegant.

I saw many threads about this topic and searched the FTN95 help pages, but we did not come to a good solution. Finally VB always complains about a "missing entry point".

Who can give some cookbook how to compile and link a simple f(x,y) for a VB application. Should I use DBK_LINK2? What about F_STDCALL? What about ASSEMBLY_INTERFACE (name="Process")? All this together or 'depends on'?

Who has a simple ready-to-go f95 and VB piece of code, together with a .bat compile and link sequence?

Thanks in advance!
Back to top
View user's profile Send private message
johannes



Joined: 21 Jan 2011
Posts: 65
Location: Leimen, Germany

PostPosted: Tue Nov 22, 2011 5:51 pm    Post subject: Reply with quote

have to add: I'm using FTN 5.50.0
Must I upgrade?
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Wed Nov 23, 2011 9:35 am    Post subject: Reply with quote

For .NET you will need to create a DLL using /CLR on the FTN95 command line.

Visual Studio is preferred to Plato for .NET otherwise you don't have access to a debugger.

You will need to use one of the versions of DBK_LINK (DBK_LINK, DBK_LINK2, or DBK_LINK4) depending on which .NET version you are building for.

F_STDCALL is not relevant but ASSEMBLY_INTERFACE is.

You may find some examples in My Documents\FTN95 Examples\NET but I can only see ones with an FTN95 frontend whilst you want to have a VB frontend.

An upgrade should not be necessary unless you begin to encounter problems arising out of using Windows 7, Visual Studio 2010 or .NET 4.
Back to top
View user's profile Send private message AIM Address
johannes



Joined: 21 Jan 2011
Posts: 65
Location: Leimen, Germany

PostPosted: Wed Nov 23, 2011 6:19 pm    Post subject: Reply with quote

Hi Paul,
thanks, that helped. The reason why my stuff didn't work, was because I got FTN95 5.50.0, and DBK_LINK4 ist available not before FTN95 6.x. I think I'd have to upgrade.

For the visitors. This was working in collaboration with VB in Netframe4:

File F.f95:
integer function F(x,y)
ASSEMBLY_INTERFACE(NAME="MyCalc")
integer*4 :: x, y
F=x+y
end

file F.f95
subroutine F(x,y)
ASSEMBLY_INTERFACE(NAME="MyCalc")
integer , INTENT(INOUT) :: x ! INTENT(INOUT) seems necessary!
integer , INTENT(INOUT) :: y
y=x*10
x=x+y
end


batch file:
ftn95 F.F95 /CLR /CLR_VER 4
dbk_link4 F.dll F.DBK
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