- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
A Visual Fortran friend and I (VB6) are trying to collaborate on a mixed language project and we have hit a wall. He has written a dll to which I am calling, and passing 4 arguments, they are as follows:
arr1(0 to 2) as double
lng1
arr2(0 to 2, 31) as double
lng2
For some reason, the double values that he recieves are entirely different from those that I am passing him. Here is what we have checked / tried:
1.) Passing first value along with the array to indicate 0 or 1 base to Fortran:
eg:
FortProc arr1 (0)
2.) We attempted passing the arguments both as zero, and one base arrays
3.) I attempted to pass the array with all values set to zero - still got wild numbers in his debug file (which merely reported what he recieved.)
I apologize for not having code to post, but he has gone home for the night, and I thought I'd see if anyone has had a similar experience. I will post a sample project and the corresponding code from both languages this weekend. Any help would be greatly appreciated.
Best regards,
Danny
A Visual Fortran friend and I (VB6) are trying to collaborate on a mixed language project and we have hit a wall. He has written a dll to which I am calling, and passing 4 arguments, they are as follows:
arr1(0 to 2) as double
lng1
arr2(0 to 2, 31) as double
lng2
For some reason, the double values that he recieves are entirely different from those that I am passing him. Here is what we have checked / tried:
1.) Passing first value along with the array to indicate 0 or 1 base to Fortran:
eg:
FortProc arr1 (0)
2.) We attempted passing the arguments both as zero, and one base arrays
3.) I attempted to pass the array with all values set to zero - still got wild numbers in his debug file (which merely reported what he recieved.)
I apologize for not having code to post, but he has gone home for the night, and I thought I'd see if anyone has had a similar experience. I will post a sample project and the corresponding code from both languages this weekend. Any help would be greatly appreciated.
Best regards,
Danny
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Array base doesn't matter in the exchange -- it's a red herring. As long as you correctly pass the starting address, the indices will be correct within each respective language.
I suspect that you have a ByVal/ByRef mismatch. The normal way to exchange the arrays is to declare the argument ByRef and pass only the first (i.e. zeroth) element. I'm not sure if it works with 2-D arrays as well, though, as they could easily be differently stored in VB and Fortran; I'll let others comment on this aspect.
I suspect that you have a ByVal/ByRef mismatch. The normal way to exchange the arrays is to declare the argument ByRef and pass only the first (i.e. zeroth) element. I'm not sure if it works with 2-D arrays as well, though, as they could easily be differently stored in VB and Fortran; I'll let others comment on this aspect.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the reply JugoslavDujic. We were able to figure out the problem on Saturday, and I'm just getting around to post my results. It was a simple syntactical error on my part in the declaration for the fortran routine. It read like this:
Declare Sub FortProc Lib "D:FortdllMyFort.dll" (Long1 As Long, ArrayArg () As Double, Long2 As Long)
... and should have read:
Declare Sub FortProc Lib "D:FortdllMyFort.dll" (Long1 As Long, ArrayArg As Double, Long2 As Long)
In my little experience, (I'm green!) I have written one declare to pass an array before, and since then, I've gotten into the habit of putting parentheses "()" after them. I now know this is not the case with declare statements! It was particularly difficult, because VB did not throw an error. It merely returned very wrong values!
Thank you for your input though!
Danny
Declare Sub FortProc Lib "D:FortdllMyFort.dll" (Long1 As Long, ArrayArg () As Double, Long2 As Long)
... and should have read:
Declare Sub FortProc Lib "D:FortdllMyFort.dll" (Long1 As Long, ArrayArg As Double, Long2 As Long)
In my little experience, (I'm green!) I have written one declare to pass an array before, and since then, I've gotten into the habit of putting parentheses "()" after them. I now know this is not the case with declare statements! It was particularly difficult, because VB did not throw an error. It merely returned very wrong values!
Thank you for your input though!
Danny
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page