View previous topic :: View next topic |
Author |
Message |
john62
Joined: 20 Feb 2007 Posts: 10
|
Posted: Wed Apr 18, 2007 9:31 am Post subject: VB-6 Array call a FTN95 Fortran.dll |
|
|
Hallo all
We trey to make a fortran.dll and called from VB-6
Since we are not a very experienced fortran-programmer,i need some help
This example program as test program for a bigger array routine with two arguments ,but i callecd a runtime Error all ready Error'453'
Can't find dll entry point on subarray on C:\john........\subarray2.dll
I think that the problem are the lenght of the array and how to pass it to the fortran.dll ,it's make no difference of we pass this lenghts also as a argument to the fortran.dll
We do some think wrong .
The vb-6 code are
Private sub Command1_click()
Dim X( 1 to 10 ) as integer
Dim N as Integer
Dim R as Integer
N = 10
For I =1 to 10
X(I) =I
next I
Call Subarray2 (X(1) , R )
text1.text = str$ (R)
end sub
On a module
Declare sub SUBARRAY lib"C:\jan.......subarray2.dll\X as Integer,R as Integer
On Fortran FTN95 with the F_ STDCALL as extra compiler options
Subroutine SUBARRAY(Arr,R)
Integer(kind=3):: Arr(
Integer(kind=3)::R
Integer(kind=3)::J
R=0.0
j=10
Do j= I
R=R+ Arr( J )
End do
End subroutine
I would be very pleased for any help
john |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7934 Location: Salford, UK
|
Posted: Wed Apr 18, 2007 1:12 pm Post subject: |
|
|
Initially I would recommend using F_STDCALL in the code as in the KBase of this forum under "Calling a Salford FTN95 DLL from Microsoft Visual Basic". See also in the help file under Win32 platform->Mixed language programming->Calling an FTN95 DLL from Visual Basic.
Your initial tests should use a simple scalar variable passed ByRef.
When moving to arrays, make sure the elements of the same size in VB and FTN95.
FTN95 arrays are stored contiguously in "column major" ordering.
I do not remember if VB 6 arrays are contiguous. They could be "safe arrays" with a header as in .NET. If the arrays have more than one dimension then the ordering could be wrong. |
|
Back to top |
|
|
DrTip
Joined: 01 Aug 2006 Posts: 74 Location: Manchester
|
Posted: Wed Apr 18, 2007 5:46 pm Post subject: |
|
|
FYI
VB 6 arrays unlike VB.NET array are native and have no header.
Carl |
|
Back to top |
|
|
john62
Joined: 20 Feb 2007 Posts: 10
|
Posted: Thu Apr 19, 2007 9:53 am Post subject: |
|
|
OK paul
it's works so far ,i change the integer(kind=3) to integer(kind=2)
and so far so good,but found a new problem
Can I debug a FTN95.dll within a vb-6 project??
Or is it only possible on dot.net configuration ??
greatings john |
|
Back to top |
|
|
Robert
Joined: 29 Nov 2006 Posts: 448 Location: Manchester
|
Posted: Thu Apr 19, 2007 5:40 pm Post subject: |
|
|
VB arrays are safe arrays. They run contiguous in memory. You can find information about them here: http://msdn2.microsoft.com/en-us/library/ms221145.aspx
Whether you can debug your Fortran DLL with SDBG depends on what your VB6 program does. In general if you make a .exe with VB and then do
sdbg vbprog.exe
You should be able to debug your DLLs. |
|
Back to top |
|
|
DeltaWilko
Joined: 25 Feb 2009 Posts: 1
|
Posted: Sat Feb 28, 2009 3:16 am Post subject: Re: VB-6 Array call a FTN95 Fortran.dll |
|
|
Hi
Re calling a fortran dll from VB6.
I would like to know the final outcome of this post. I get exactly the same error 453 message.
I am new to FORTRAN and so not sure what it means by 'cant find entry point'
Have worked for some time on this now and working through the previous posts does not sort the problem out.
Does some one have an example of a fully working portion of code that I can try out to see where I am going wrong.
many thanks
David
john62 wrote: | Hallo all
We trey to make a fortran.dll and called from VB-6
Since we are not a very experienced fortran-programmer,i need some help
This example program as test program for a bigger array routine with two arguments ,but i callecd a runtime Error all ready Error'453'
Can't find dll entry point on subarray on C:\john........\subarray2.dll
I think that the problem are the lenght of the array and how to pass it to the fortran.dll ,it's make no difference of we pass this lenghts also as a argument to the fortran.dll
We do some think wrong .
The vb-6 code are
Private sub Command1_click()
Dim X( 1 to 10 ) as integer
Dim N as Integer
Dim R as Integer
N = 10
For I =1 to 10
X(I) =I
next I
Call Subarray2 (X(1) , R )
text1.text = str$ (R)
end sub
On a module
Declare sub SUBARRAY lib"C:\jan.......subarray2.dll\X as Integer,R as Integer
On Fortran FTN95 with the F_ STDCALL as extra compiler options
Subroutine SUBARRAY(Arr,R)
Integer(kind=3):: Arr(
Integer(kind=3)::R
Integer(kind=3)::J
R=0.0
j=10
Do j= I
R=R+ Arr( J )
End do
End subroutine
I would be very pleased for any help
john |
|
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7934 Location: Salford, UK
|
Posted: Sat Feb 28, 2009 12:53 pm Post subject: |
|
|
There is some information in the KBase article in this forum under the heading "Calling a Salford FTN95 DLL from Microsoft Visual Basic
". This information is also in the help file FTN95.chm. You can probably ignore the bit about LibMain. |
|
Back to top |
|
|
|