- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have a simple VB code that loads an IVF dll. If I call the Fortran routine in that dll from VB without passing any data, it works fine. If I pass an array of doubles (but don't do anything with them on the Fortran side), everything works fine so long as the length of the double array is less than ~100. If the array length is greater than 100, the Fortran seems to execute just fine but everything crashes upon return to VB. This is very reproducible. Is there a workaround or should I pass multiple vectors, each of relatively short length?
TIA,
Jeff
I have a simple VB code that loads an IVF dll. If I call the Fortran routine in that dll from VB without passing any data, it works fine. If I pass an array of doubles (but don't do anything with them on the Fortran side), everything works fine so long as the length of the double array is less than ~100. If the array length is greater than 100, the Fortran seems to execute just fine but everything crashes upon return to VB. This is very reproducible. Is there a workaround or should I pass multiple vectors, each of relatively short length?
TIA,
Jeff
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - zalcjm
Hi,
I have a simple VB code that loads an IVF dll. If I call the Fortran routine in that dll from VB without passing any data, it works fine. If I pass an array of doubles (but don't do anything with them on the Fortran side), everything works fine so long as the length of the double array is less than ~100. If the array length is greater than 100, the Fortran seems to execute just fine but everything crashes upon return to VB. This is very reproducible. Is there a workaround or should I pass multiple vectors, each of relatively short length?
TIA,
Jeff
I have a simple VB code that loads an IVF dll. If I call the Fortran routine in that dll from VB without passing any data, it works fine. If I pass an array of doubles (but don't do anything with them on the Fortran side), everything works fine so long as the length of the double array is less than ~100. If the array length is greater than 100, the Fortran seems to execute just fine but everything crashes upon return to VB. This is very reproducible. Is there a workaround or should I pass multiple vectors, each of relatively short length?
TIA,
Jeff
This is frequently posted problem. If you do a forum search using 'Visual Basic' you should find some useful help.
A summary of the precautions you should take first is as follows:
on VB side
1. Declare numerical variables as usual as either scalars or arrays as required; these are passed ByRef
2. Declare string variables as usual (possibly pad with blanks to required length); these are passed ByVal
on Fortran side
1. Declare dummy arguments (including scalar real arguments) as arrays of dimension (1) or actual dimension if larger
2. Use !DEC$ ATTRIBUTES REFERENCE :: for string arguments only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - anthonyrichards
This is frequently posted problem. If you do a forum search using 'Visual Basic' you should find some useful help.
A summary of the precautions you should take first is as follows:
on VB side
1. Declare numerical variables as usual as either scalars or arrays as required; these are passed ByRef
2. Declare string variables as usual (possibly pad with blanks to required length); these are passed ByVal
on Fortran side
1. Declare dummy arguments (including scalar real arguments) as arrays of dimension (1) or actual dimension if larger
2. Use !DEC$ ATTRIBUTES REFERENCE :: for string arguments only
If the passing is the same as from VBA, in the caller, define the arrays as needed, but use actual arguments like ARRAY1(1), ARRAY2(1), etc.
On the Fortran side, you need to use e,e
!DEC$ ATTRIBUTES REFERENCE :: RealIn,NRealIn,NIntIn,IntIn,NRealOut,RealOut,NCharOut,Str
For ALL arguments (not just strings)
As you can see, I have passed the array sizes as well, so these are declared like
Real(KIND=8), INtent(IN) :: RealIn(NRealIn)
Hope this helps.
David
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