主题:小弟再次求助vb调用Fortran问题
!*****************************************************
! subroutine for probability density distrubition
!*****************************************************
subroutine prod(n,x,nd,ramp,prop,av,sd)
$ATTRIBUTES DLLEXPORT :: prod
!DEC$ ATTRIBUTES REFERENCE::n,,nd,x,ramp,prop,av,sd !规定参数为引用传递
INTEGER,intent(in)::n,nd
REAL*8 x(nd),ramp(21),prop(21),av,sd
dimension bound(21)
! intialization
do 110 i=1,21
ramp(i)=1.-real(i-1)/10
bound(i)=ramp(i)-0.05
prop(i)=0.
110 continue
xmax=0.
do 120 m=1,n
xmax=amax1(xmax,abs(x(m)))
120 continue
do 130 m=1,n
x(m)=x(m)/xmax
130 continue
av=0.
sd=0.
! probability density
do 150 m=1,n
av=av+x(m)
sd=sd+x(m)**2
do 140 i=1,21
if(x(m).lt.bound(i))goto 140
prop(i)=prop(i)+1
goto 150
140 continue
150 continue
do 160 i=1,21
prop(i)=prop(i)/real(n)*100
160 continue
av=av/real(n)
sd=sqrt(sd/real(n)-av**2)
return
endsubroutine
[b]vb代码如下[/b]
Private Declare Sub prod Lib "E:\prod.dll" Alias "_prod@28" (ByRef a As Long, ByRef b As Double, ByRef c As Long, ByRef d As Double, ByRef e As Double, ByRef f As Double, ByRef g As Double)
Private Sub Form_Click()
Dim a As Long
Dim x(1 To 109445), y(1 To 109445), ramp, prop, av, sd As Double
Open "e:\N.dat" For Input As #1
Input #1, a
Print a
For i = 1 To a
Input #1, x(i), y(i)
Next i
Call prod(a, y(1), a, ramp, prop, av, sd)
Print av, sd
End Sub
结果是找不到dll入口点
! subroutine for probability density distrubition
!*****************************************************
subroutine prod(n,x,nd,ramp,prop,av,sd)
$ATTRIBUTES DLLEXPORT :: prod
!DEC$ ATTRIBUTES REFERENCE::n,,nd,x,ramp,prop,av,sd !规定参数为引用传递
INTEGER,intent(in)::n,nd
REAL*8 x(nd),ramp(21),prop(21),av,sd
dimension bound(21)
! intialization
do 110 i=1,21
ramp(i)=1.-real(i-1)/10
bound(i)=ramp(i)-0.05
prop(i)=0.
110 continue
xmax=0.
do 120 m=1,n
xmax=amax1(xmax,abs(x(m)))
120 continue
do 130 m=1,n
x(m)=x(m)/xmax
130 continue
av=0.
sd=0.
! probability density
do 150 m=1,n
av=av+x(m)
sd=sd+x(m)**2
do 140 i=1,21
if(x(m).lt.bound(i))goto 140
prop(i)=prop(i)+1
goto 150
140 continue
150 continue
do 160 i=1,21
prop(i)=prop(i)/real(n)*100
160 continue
av=av/real(n)
sd=sqrt(sd/real(n)-av**2)
return
endsubroutine
[b]vb代码如下[/b]
Private Declare Sub prod Lib "E:\prod.dll" Alias "_prod@28" (ByRef a As Long, ByRef b As Double, ByRef c As Long, ByRef d As Double, ByRef e As Double, ByRef f As Double, ByRef g As Double)
Private Sub Form_Click()
Dim a As Long
Dim x(1 To 109445), y(1 To 109445), ramp, prop, av, sd As Double
Open "e:\N.dat" For Input As #1
Input #1, a
Print a
For i = 1 To a
Input #1, x(i), y(i)
Next i
Call prod(a, y(1), a, ramp, prop, av, sd)
Print av, sd
End Sub
结果是找不到dll入口点