Calling a Fortran Program from VB .NET

I have a Fortran code (sample.f90) that opens a dat file and returns a number of things.  Most importantly, are two arrays, ARRAY1 (an array of 8 integer values) & ARRAY2 (double-dimensioned array containing a whole lot of data).  Sample code:

SUBROUTINE READDATA (ARRAY1, ARRAY2)
  INTEGER ARRAY1(8)
  REAL ARRAY2(400,1016)
  .
  .
  .
  RETURN
END

Running the code in Fortran, returns the proper arrays.  To call this from VB .NET I built the sample.f90 code as a .dll (sample.dll) and called it using the following VB code:

Declare Sub READDATA Lib "c:\....\sample.dll" (ByVal ARRAY1() As Integer, ByVal ARRAY2(,) As Single)

Private Sub ...
Dim ARRAY1(8) As Integer
Dim ARRAY2(400,1016) As Single
   Call READDATA(ARRAY1, ARRAY2)
End Sub

All values in ARRAY1 come back as they should when displayed in a text box, but ARRAY2 is all messed up.  ARRAY2(0,0) has one value that doesn't mean much, but then is repeated along the first row for however many rows were in the array on the Fortran side.  For example, if there were 10 rows and 254 columns of data in the array as it existed in Fortran, then in VB .NET it would appear as ARRAY2(0,0) = ARRAY2(0,1) = .. = ARRAY2(0,9) = an unintelligible value depending on how it's declared on the VB side (single/double/integer/etc.)  The rest of ARRAY2 is equal to 0.  

I'm almost certain that this is a case of a mis-match between variable types from one language to the other, but is there a way to get VB .NET to understand the REAL variable type from Fortran and thus make the array legible?
BuckeyeZAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

davideconsonniCommented:
you can see a tecnology called Xml-Rpc
is like soap.

http://www.xml-rpc.org

see implementations sections

0
tsuganiCommented:
This happens because vb reads entire rows and not separate numbers since vb does not have a format command similar with fortran.
The best way i can think to solve the problem is to alter your fortran code to separate the outputs with commas.
For example if u have a 3x3 array output (fortran side) it should be in the form

1, 2, 3
4, 5, 6
7, 8, 9
0
tsuganiCommented:
....If that doesnt solve the problem post your readdata subroutine because there might be something wrong with that.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

BuckeyeZAuthor Commented:
Thanks for the tips, but actually, in the time it took for a response, I figured out most of my problem.  When I was compiling the .dll, I didn't have the /convert:vaxd qualifier in the line.  Once I did that, I could pass the real numbers (sort of).  My other problem had to do with having the indexing reversed.  On the Fortran side, if the array was ARRAY2(400,1016), it had to be dimensioned in VB as ARRAY2(1016,400).  Once I made this two changes, I started to get somewhere.

Now, the only problem is the accuracy of the values that are passed.  If I pass a single value (one that is also contained in the array) from the Fortran side to the VB, I get a very accurate value.  But if that value is compared to the same one that was contained in the array, it's way off.  Is there a way to overcome this problem?
0
BuckeyeZAuthor Commented:
Thanks for the tips, but actually, in the time it took for a response, I figured out most of my problem.  When I was compiling the .dll, I didn't have the /convert:vaxd qualifier in the line.  Once I did that, I could pass the real numbers (sort of).  My other problem had to do with having the indexing reversed.  On the Fortran side, if the array was ARRAY2(400,1016), it had to be dimensioned in VB as ARRAY2(1016,400).  Once I made this two changes, I started to get somewhere.

Now, the only problem is the accuracy of the values that are passed.  If I pass a single value (one that is also contained in the array) from the Fortran side to the VB, I get a very accurate value.  But if that value is compared to the same one that was contained in the array, it's way off.  Is there a way to overcome this problem?
0
CleanupPingCommented:
BuckeyeZ:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.