Re: VB .Net and Intel Visual Fortran 9
- From: "Kevin" <kevin.dressel@xxxxxxxxxxx>
- Date: Mon, 28 Aug 2006 17:46:18 GMT
OK, I discovered that some of the IVF libraries were improperly installed
causing the program to fail. All seems to be working now.
Regards,
Kevin
"Kevin" <kevin.dressel@xxxxxxxxxxx> wrote in message
news:J4Kn3v.M0o@xxxxxxxxxxxxxxxxxx
Hey guys!
I've been trying to get these to programs to play nicely for the last few
days or so but am having a heck of a time getting Visual Basic 2005 (or VB
2003 for that matter) to load a DLL created with IVF 9. The problem I'm
having is that the VB program cannot load the DLL (DLL not found error).
Specifically, the problem crops up when I write code in the DLL (a
subroutine) to accept an array from VB - in my case a 2D array. You can
write the entire subroutine, but as soon as you include any operations
dealing with the array, I get an error at runtime that it cannot find the
DLL, even if the path is hard-coded in the declaration statement. Strip
out the array stuff and the DLL functions great. I've been testing with a
simple program. As a side note, I don't actually try using the subroutine
in the VB code, although I did try the VB with the declaration statement
there (it's a no go).
The VB interface is a simple form with three text boxes, a button, and a
checkbox, all of which make use of the first Fortran sub and function
which work perfectly fine when the array stuff is left out of the DLL. So
I'm not really concerned about that. Where my problem comes in getting
the array stuff to work. Does anybody here have any ideas at all how to
fix this? I'm new to both VB .Net 03 or 05 and the Intel Fortran compiler.
I've had success in the past using VB6 and Compaq Fortran, the latter of
which I cannot get to work on my PC.
If anyone has some simple examples of passing multi-dimension arrays (or
even single dim) from VB 03 or 05 to a DLL created with IVF, I'd love to
see them.
I appreciate any assistance here!
Cheers,
Kevin
P.S. Although I have had no problems with it, is INTEGER(8) the same as a
VB Long? They're both 8-byte, correct?
VB CODE (created in VB 2005, but probably would work in 2003 as well):
Public Class Form1
Declare Sub stest Lib "test.dll" (ByVal i As Integer, ByVal j As
Integer, ByRef k As Long)
Declare Function ftest Lib "test.dll" (ByRef i As Long, ByRef j As
Long) As Integer
Declare Sub mmult Lib "test.dll" (ByRef i As Double, ByRef j As Double,
ByRef k As Double, ByVal l As Long, ByVal m As Long, ByVal n As Long)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If CheckBox1.Checked = True Then
TextBox1.Text = Str(ftest(CInt(Val(TextBox2.Text)),
CInt(Val(TextBox3.Text))))
Else
Dim a As Long
Call stest(CInt(Val(TextBox2.Text)), CInt(Val(TextBox3.Text)),
a)
TextBox1.Text = Str(a)
End If
End Sub
End Class
FORTRAN CODE:
SUBROUTINE stest(i,j,k)
!DEC$ ATTRIBUTES STDCALL :: stest
!DEC$ ATTRIBUTES DLLEXPORT :: stest
!DEC$ ATTRIBUTES ALIAS:'stest' :: stest
!DEC$ ATTRIBUTES VALUE :: i,j
!DEC$ ATTRIBUTES REFERENCE :: k
IMPLICIT NONE
INTEGER, INTENT(IN) :: i, j
INTEGER(8), INTENT(OUT) :: k
k = i - j
END SUBROUTINE stest
INTEGER(8) FUNCTION ftest(i,j)
!DEC$ ATTRIBUTES STDCALL :: ftest
!DEC$ ATTRIBUTES DLLEXPORT :: ftest
!DEC$ ATTRIBUTES ALIAS:'ftest' :: ftest
!DEC$ ATTRIBUTES REFERENCE :: i,j
IMPLICIT NONE
INTEGER(8), INTENT(IN) :: i, j
ftest = i - j
END FUNCTION FTEST
!SUBROUTINE mtrans(nrow, mcol
! Subroutine mmult uses the Fortran function "MATMUL" to perform matrix
multiplication of two arrays. It
! accepts three arrays, "arrayA" and "arrayB" for input and "answer" for
output (all by reference), as well
! as three integers that define the array shapes.
!
! Define "arrayA" as (n,m) & "arrayB" as (m,k) -> "answer" will be
(n,k)
SUBROUTINE mmult(arrayA, arrayB, answer, n, m, k)
!DEC$ ATTRIBUTES STDCALL :: mmult
!DEC$ ATTRIBUTES DLLEXPORT :: mmult
!DEC$ ATTRIBUTES ALIAS:'mmult' :: mmult
!DEC$ ATTRIBUTES REFERENCE :: arrayA, arrayB, answer
!DEC$ ATTRIBUTES VALUE :: n, m, k
IMPLICIT NONE
INTEGER(8), INTENT (IN) :: n, m, k
REAL(8), DIMENSION(n,m), INTENT(IN) :: arrayA
REAL(8), DIMENSION(m,k), INTENT(IN) :: arrayB
REAL(8), DIMENSION(n,k), INTENT(INOUT) :: answer
answer = MATMUL(arrayA, arrayB)
END SUBROUTINE mmult
.
- References:
- VB .Net and Intel Visual Fortran 9
- From: Kevin
- VB .Net and Intel Visual Fortran 9
- Prev by Date: Re: CRC32 using VB.net
- Next by Date: Re: Help With Adding Controls At Runtime
- Previous by thread: VB .Net and Intel Visual Fortran 9
- Next by thread: Please Help Me Understand Cdec
- Index(es):