Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Passing Arrays FROM fortran TO VB.NET

Rudy__Delcroit
Beginner
583 Views

Dear All,

I tryied to pass array FROM fortran to VB.net but cannot manage it (the problem is not calling from Vb.NET to Fortran but FROM fortran TO Vb. Net). The VB.NET subroutine doesn't fire. I have used a code similare to the one posted here : http://software.intel.com/en-us/forums/topic/292132

I googled this problem and it seems that several people have the same issue. I read all the following post :

http://software.intel.com/en-us/forums/topic/285760

http://origin-software.intel.com/en-us/forums/topic/297256

http://software.intel.com/en-us/forums/topic/272924

I also tried to get inspiration from the 'MixedLanguage' sample code provided with the compiler but I couldn't break it.

Has someone already crack this problem ?

Additionnally, what about including a code sample in 'Mixed Language' as the question seems to be raised every year (but still not answered) ?

Thank you very much,

Vincent

0 Kudos
8 Replies
Steven_L_Intel1
Employee
583 Views

How about you attach a ZIP of the VS solution of what you tried and I'll take a look. I'm not a VB expert so constructing a test case would be time-consuming.

0 Kudos
Anthony_Richards
New Contributor I
583 Views

Just to be clear about what you want to be able to do:

Do you

A) want to access an array of some sort that exists in a Fortran DLL FROM VB.NET executable or DLL via a call to a routine/function in a Fortran DLL so that the Fotran code can then return control to the VB.NET code whence the VB.NET code can then access and process the array contents?

Or

B) Do you want to call, FROM WITHIN a Fortran executable or DLL, a function in a VB.NET DLL and give it the address/contents of an array located within the Fortran executable or DLL so that the VB.NET code can access the array contents and then return control to the Fortran code?

Which of these applies?

0 Kudos
Rudy__Delcroit
Beginner
583 Views

Dear Steve, Anthony,

To the question of Anthony, I'm trying B) :FROM WITHIN a Fortran executable call a function in a VB.NET DLL and give it the address/contents of an array located within the Fortran executable so that the VB.NET code can access the array contents and then return control to the Fortran code.

Please find hereafter a code sample. There are two projects :

- VbDLL is the Vb.NET project that creates the COM DLL to be called by fortran. (compiling it on your computer should register the DLL).

-Fortran is the executable that would call the VbDLL. I used module wizard with automation to create the interface code.

The sample works great for a integer, a real and a string but not for an array of integer ... Simply nothing happens ... No error message Nothing.

The final goal is passing a two dimension string array ...

Thank for any help.

 

Regards,

Vincent

0 Kudos
Anthony_Richards
New Contributor I
583 Views

It does not look like it is possible for arrays.

Everything I try results in the $status flag returning -2147024809 (80070057) which translates as "One or more arguments are invalid".

(For alist of Automation errors, see http://support.microsoft.com/kb/186063)

0 Kudos
Rudy__Delcroit
Beginner
583 Views

Anthony,

Impossible is not a fortran instruction, therefore it must be possible. Lets say that it is just undocumented :)

It must be possible because the samples provided with the compiler (mixed language - Safe Array) present the transfer of array from VB .NET to Fortran. The other way arround should be a piece of cake ...

What I suspect is that Module Wizard doesn't generate the right code when the DLL has an array as argument.

Mr Lionel, can you have a look at it ?

Regards,

Vincent

0 Kudos
Steven_L_Intel1
Employee
583 Views

I will try, but it may be a while before I can get to it.

0 Kudos
Rudy__Delcroit
Beginner
583 Views

Hi Mr Lionel,

Have you been able to have a look at the above message ?

I'm about to rework on the subject. Your help would be very much appreciated.

Regards,

Vincent

0 Kudos
Steven_L_Intel1
Employee
583 Views

I did not look at this, sorry, but I would expect that a two-dimension string array is just not something Fortran and VB have the same view of. You could probably do it with a SAFEARRAY as shown in the safearray sample, but it will be complex.

0 Kudos
Reply