- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
I'm trying to send two arrays (a double and a long) from VB to a FORTRAN DLL. I don't understand why I can get (without problems) all variables but my array of longs?The DLL returns the same array; it accepts the call but doesn't perform any calculation with the array!!???
Here the short code:
Subroutine VB_FOR(x,n,m,r,xx,nn,mm,rr)
implicit none
!
!MS$ATTRIBUTES DLLEXPORT :: VB_FOR
!MS$ATTRIBUTES ALIAS : 'VB_FOR' :: VB_FOR
!
Real(8) , intent(inout) :: x
Integer(2) , intent(in) :: n
Integer(2) , intent(in) :: m
Real(8) , intent(inout) :: r
Integer(4) , intent(inout) :: xx
Integer(2) , intent(in):: nn
Integer(2) , intent(in):: mm
Integer(4) , intent(inout) :: rr
dimension x(n,m)! dimension of the array of doubles
dimension xx(nn,mm) ! ... array of longs
integer :: i
integer :: j
do i=1,n
do j=1,m
x(i,j)=x(i,j)*n/10! WORKS FINE
end do
end do
r=2.13*r*r! WORKS FINE
do i=1,nn
do j=1,mm
xx(i,j)=xx(i,j)*xx(i,j)! DO NOT WORK (?)
end do
end do
rr=rr*rr! WORKS FINE
end subroutine
The Visual Basic 6 side:
Private Declare Sub VB_FOR Lib "VB_FOR.dll" (ByRef Array_Dbl As Double, ByRef Linha_Dbl As Integer, ByRef Coluna_Dbl As Integer, ByRef Duplo_Dbl As Double, ByRef Array_Lng As Long, ByRef Linha_Lng As Integer, ByRef Coluna_Lng As Integer, ByRef Longo_Lng As Long)
Sub CallDLL_Click()
.
.
.
Call VB_FOR(MyDblArr(1, 1), n, m, My_Double, MyLngArr(1, 1), nn, mn, My_Long)
.
.
.
End Sub
ANY SUGGESTION ?
Here the short code:
Subroutine VB_FOR(x,n,m,r,xx,nn,mm,rr)
implicit none
!
!MS$ATTRIBUTES DLLEXPORT :: VB_FOR
!MS$ATTRIBUTES ALIAS : 'VB_FOR' :: VB_FOR
!
Real(8) , intent(inout) :: x
Integer(2) , intent(in) :: n
Integer(2) , intent(in) :: m
Real(8) , intent(inout) :: r
Integer(4) , intent(inout) :: xx
Integer(2) , intent(in):: nn
Integer(2) , intent(in):: mm
Integer(4) , intent(inout) :: rr
dimension x(n,m)! dimension of the array of doubles
dimension xx(nn,mm) ! ... array of longs
integer :: i
integer :: j
do i=1,n
do j=1,m
x(i,j)=x(i,j)*n/10! WORKS FINE
end do
end do
r=2.13*r*r! WORKS FINE
do i=1,nn
do j=1,mm
xx(i,j)=xx(i,j)*xx(i,j)! DO NOT WORK (?)
end do
end do
rr=rr*rr! WORKS FINE
end subroutine
The Visual Basic 6 side:
Private Declare Sub VB_FOR Lib "VB_FOR.dll" (ByRef Array_Dbl As Double, ByRef Linha_Dbl As Integer, ByRef Coluna_Dbl As Integer, ByRef Duplo_Dbl As Double, ByRef Array_Lng As Long, ByRef Linha_Lng As Integer, ByRef Coluna_Lng As Integer, ByRef Longo_Lng As Long)
Sub CallDLL_Click()
.
.
.
Call VB_FOR(MyDblArr(1, 1), n, m, My_Double, MyLngArr(1, 1), nn, mn, My_Long)
.
.
.
End Sub
ANY SUGGESTION ?
- Marcas:
- Intel® Fortran Compiler
Link copiado
2 Respostas
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Why are you using !MS$ATTRIBUTES instead of !DEC$ATTRIBUTES? What version of Fortran are you using?
Using the debuggers on the VB and Fortran sides, can you verify the contents of the integer array before the call from VB and after your Fortran subroutine begins execution?
Mike D.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
I think all you need to do is to chg your line:
Integer(4) , intent(inout) :: xx
to:
Integer(4) , intent(inout) :: xx(mm,nn)
+you might need to put the declarations for mm & nn before it.
I can't tell why it works with real(8) and not with int(4).
Also, your loop is row-major, it is much slower than col.major suitable for both VB and f90.
Finally, if you're still on cvf it is best to use com-servers instead of "naked" dlls.
Message Edited by Rahzan on 03-03-2005 01:09 PM
Responder
Opções do tópico
- Subscrever fonte RSS
- Marcar tópico como novo
- Marcar tópico como lido
- Flutuar este Tópico para o utilizador atual
- Marcador
- Subscrever
- Página amigável para impressora