Silverfrost Forums

Welcome to our forums

Visual Basic calling a Fortran dll

22 Nov 2011 4:46 #9262

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!

22 Nov 2011 4:51 #9263

have to add: I'm using FTN 5.50.0 Must I upgrade?

23 Nov 2011 8:35 #9268

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.

23 Nov 2011 5:19 #9279

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

Please login to reply.