forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

VB-6 Array call a FTN95 Fortran.dll

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
john62



Joined: 20 Feb 2007
Posts: 10

PostPosted: Wed Apr 18, 2007 9:31 am    Post subject: VB-6 Array call a FTN95 Fortran.dll Reply with quote

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(Smile
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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7926
Location: Salford, UK

PostPosted: Wed Apr 18, 2007 1:12 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
DrTip



Joined: 01 Aug 2006
Posts: 74
Location: Manchester

PostPosted: Wed Apr 18, 2007 5:46 pm    Post subject: Reply with quote

FYI

VB 6 arrays unlike VB.NET array are native and have no header.

Carl
Back to top
View user's profile Send private message
john62



Joined: 20 Feb 2007
Posts: 10

PostPosted: Thu Apr 19, 2007 9:53 am    Post subject: Reply with quote

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
View user's profile Send private message
Robert



Joined: 29 Nov 2006
Posts: 445
Location: Manchester

PostPosted: Thu Apr 19, 2007 5:40 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
DeltaWilko



Joined: 25 Feb 2009
Posts: 1

PostPosted: Sat Feb 28, 2009 3:16 am    Post subject: Re: VB-6 Array call a FTN95 Fortran.dll Reply with quote

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(Smile
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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7926
Location: Salford, UK

PostPosted: Sat Feb 28, 2009 12:53 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group