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

C# and Fortran

JohnNichols
Valued Contributor III
653 Views
Dear Steve and Jim:

It can be done, and it is an interesting time while you get a Fortran Module talking to a C# Class Module.

I started with the Microsoft MSDN article on "How to call a managed DLL." This is the only way to do it that I couldfind that had any chance of success as onefinal program unit.

I got a C++ program, C++ 2010 Flavour working with C# - fairly straightforward with the article.

The device I want to use has a C# Developer Program with several C# DLL units. It took all of Saturday to get a method to have the C++ program talking to the C# Dll units. The developer did not sign the DLL units, so I had to create a stong named DLL and include the Developer's DLL units into the Strong Named unit using ILMERGE from Microsoft Research. This was a a challenge as I had not used managed code before.

ILMERGE and a few other programsdiassemble and reassembles the DLL's into one. Then I wrote a BATCH file to register the DLL. Took me back to 1984. Pun intended.

It took several hours on Sunday to get the C++ code to control the device so I could get data back. C# is not a nicely behaved language and the programmer used some unusual constructs.

Then I took the C calls Fortran Sample from Intel and fixed it so it worked as a 2010 C++ program. (Hint Intel)

Can I suggest that

1. Intel hire a bright young intern from any good CS program
2. Get the intern to update the Intel Fortran Samples to a modern world
3. Post the updates.

Just a thought.

Then I fixed the C Calls Fortran program so it called the C# Registered DLL.

I do not think that you can assemble one VS Solution to do all of the above steps. Pity.

So Steve it is possible, about 30 hours of work to get the unit data available to Fortran.

As far as Jim's suggestion on Memory Mapping that is the next step. A good one to.

LISP is so much easier.

I suspect the C# developer had a class in LISP as several of the methods are familiar.

Thanks for the help.

JMN


0 Kudos
0 Replies
Reply