Using FORTRAN in Visual Basic 2k5

I'm kind of new to programming, so if anyone can help me out I'd appreciate it.

I'm writing a program that has the majority of its computational work written in FORTRAN. The FORTRAN program takes a file input which I have create successfully, but I don't know how to declare and call the FORTRAN library from VB. Can anyone help me out

JE



Answer this question

Using FORTRAN in Visual Basic 2k5

  • JohnPrem

    Yeah I got to that point, now whenever I run my program I get an Unable to find entry point exception... any ideas


  • Dmitry Shaporenkov

    If you can create a COM Class Library (or a .NET class library is even better) in Fortran. (An I dont know what version of Fortran your using). Using a COM or .NET class library make the methods language agnostic - meaning you can call them from any other language that supports COM or .NET class Libraries.

    Then to call them in a VB Application.

    You will create a windows or console application.

    Add a reference to you Fortran created Dll file.

    Then you should be able to call the methods from this DLL. You should be able to see the methods in the Object Browsers and then can call them using the method signatures shown

    Once they are in a COM Class Library - the language that the DLL was written in is irrelevent as this is what COM is all about - allowing you to write stuff in different languages and allow you to consume them in other languages.


  • Toolmaker

    You simply add the reference to the fortran dll. If its a COM or .NET dll then you should just be able to use the classes, methods in this dll.

    If it is not a COM or .NET DLL but an unmanaged API, then will need to use the declare statement or dllimports statement (they both equate to pretty well the same thing) to call the unmanaged API.


  • Marcos B

    First, is your Fortran DLL managed or not   I'll bet my whole paycheck 95% of the time it's unmanaged.  And if it is managed, it's going to be slower than molasses in my grandma's deep freezer.

    Make sure you compiled your Fortran DLL as a DLL:
    Your fortran compiler produces a DLL file and this goes in the same directory like your VB executable.  Both RELEASE and DEBUG configurations.

    Make sure your managed code is loading the DLL
    After you call LoadLibraryA, this returns an actual number.

    Make sure your interfacing functions match exactly the exported ones in the DLL.
    After you loaded the library, and loaded a specific function, the pointer to it is not a NULL object.  errr, NOTHING object.  Also, when declaring your interface, make sure you use  <Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType.WhatEver)> as needed.

  • Laughing John

    Ok, I've got a dll that I compiled from FORTRAN code, now how do I create a .NET or COM Class Library
  • Using FORTRAN in Visual Basic 2k5