Question calling fortran dll

akmitra

New member
Joined
Dec 6, 2008
Messages
2
Programming Experience
Beginner
I am trying to learn how to add fortran references to a vb.net project.

I have written a simple fortran code:
VB.NET:
SUBROUTINE TEST(A,B,C)
REAL:: A,B,C
C=A+B
END TEST
Made a dll by using the SilverFrost compiler.

Added this dll into my vb.net project as reference.

Calling the FORTRAN subroutine in the program
VB.NET:
Dim a, b, c As Single
    Private Declare Ansi Sub TEST Lib "FortranApplication1.dll" (ByRef a As Single, ByRef b As Single, ByRef c As Single)

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        a = TextBox1.Text
        b = TextBox2.Text
        Call TEST(a, b, c)
        TextBox3.Text = c
    End Sub

I am getting an execution error,
"No entry point found for TEST"

Any help will be greatly appreciated.

Best of regards
 
This article is for VB6: How To Create a FORTRAN DLL and Call It from Visual Basic
Didn't find VB.Net version, but it should be similar with the Declare and call, but it explains lots for Fortran setup. I don't think you can "add reference" to Fortran dlls, they are not COM, are they?
 
That's a nice bit of info John. Just for interests sake, Fortran was the first language I ever learned, back in my second year of university in 1993 as a Chemical engineering student. It was the most enjoyable subject in the whole course so when I finished I went back for two years and studied Computer Science and became a programmer instead.
 
solved the fortran dll issue

Thanks to those who responded.

I made the dll with G95 (which is a freebie, whereas SilverFrost was not).

I had to resove 3 issues:

#1: There are some tricks due to the addition of an underscore to the subroutine name in the fortran dll.

#2: The dll should not be included as a reference in the VB project. Instead, it must reside in the bin folder of the VB project.

#3: Some tricks in passing the array from VB to fortran and back. As VB starts numbering rows and columns from zero, whereas fortran does it from one.

Finally, one comment: Writing big-crunch procedures in fortran is a good idea, because fortran runs 20 times faster than VB.

Best of regards to all
 
Back
Top