Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

DLL doesn't work?

deeptii
Beginner
521 Views
hi! i am compiling this fortran dll and to be called from VB. after compiling, etc. the dll doesn't seem to do its job in VB. here is the fortran source code:

==========================================================
subroutine ccopy(n,cx,incx,cy,incy)
c
c copies a vector, x, to a vector, y.
c jack dongarra, linpack, 3/11/78.
c modified 12/3/93, array(1) declarations changed to array(*)
c
complex cx(*),cy(*)
integer i,incx,incy,ix,iy,n
c
if(n.le.0)return
if(incx.eq.1.and.incy.eq.1)go to 20
c
c code for unequal increments or equal increments
c not equal to 1
c
ix = 1
iy = 1
if(incx.lt.0)ix = (-n+1)*incx + 1
if(incy.lt.0)iy = (-n+1)*incy + 1
do 10 i = 1,n
cy(iy) = cx(ix)
ix = ix + incx
iy = iy + incy
10 continue
return
c
c code for both increments equal to 1
c
20 do 30 i = 1,n
cy(i) = cx(i)
30 continue
return
end
==========================================================

then i wrote a gateway subroutine which basically converts complex into 2 real numbers, here it is:

==========================================================
!DEC$ ATTRIBUTES DLLEXPORT :: gccopy
!DEC$ ATTRIBUTES ALIAS:'gccopy' :: gccopy

subroutine gccopy(n,rcx,icx,incx,rcy,icy,incy,cx,cy)

IMPLICIT NONE

EXTERNAL ccopy

complex cx(*),cy(*)
real rcx(*),icx(*),rcy(*),icy(*)
integer i,n,incx,incy

do 10 i = 1,n
cx(i) = CMPLX(rcx(i),icx(i))
cy(i) = CMPLX(rcy(i),icy(i))
10 continue

CALL ccopy(n,cx,incx,cy,incy)

do 20 i = 1,n
rcx(i) = REAL(cx(i))
icx(i) = AIMAG(cx(i))
rcy(i) = REAL(cy(i))
icy(i) = AIMAG(cy(i))
20 continue

return
end
==========================================================

the program is supposed to copy vector x to y. i tested the program in fortran alone and it works... after it's compiled to dll and be called from VB like this...

==========================================================
Option Explicit
Private Declare Sub gccopy Lib "d:downloadsschoolee496ccopydebugccopy.dll" _
(n As Integer, rcx As Single, icx As Single, incx As Integer _
, rcy As Single, icy As Single, incy As Integer, cx As Single, cy As Single)


Private Sub Command1_Click()

Dim n As Integer
Dim rcx As Single
Dim icx As Single
Dim rcy As Single
Dim icy As Single
Dim incx As Integer
Dim incy As Integer
Dim cx As Single
Dim cy As Single

n = 1
rcx = 5
icx = 1
incx = 1

Call gccopy(n, rcx, icx, incx, rcy, icy, incy, cx, cy)

Text1.Text = rcx
Text2.Text = icx
Text3.Text = rcy
Text4.Text = icy

End Sub
==========================================================

result is Text1 and Text2 displays 5,1, and Text3 and Text4 displays 0,0. so it means that the dll did not copy vector x to y :(

can someone give me some tips here... thanks a bundle~
0 Kudos
1 Reply
leoprex
Beginner
521 Views
I think your code cannot work: you define rcx (for instance) as a single in VB and as an array of single in Fortran: why?
0 Kudos
Reply