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

Including fortran and C programs in a visual C# program

imeca
Beginner
1,507 Views
Hello,
I am a new user of intel fortran compilers as well as visual studio 2005, this is my first post here.
i have fortran77 source codes. these codes call some C functions. until now, i am able to compile the all in an ".exe" and lunch it through the windows prompt.
now, i want to make all these fortran and C functions being lunched through a user interface made with visual C# 2005. the problem is that i didn't found the ideal method that allows me to do that.
i thought about a DLL compilation but i failed. i think there is a method that includes directly the intel formtran compiler in C# project. that will, normally, allow me to exchange structures and data between the different languages without any problem.
can anybody help me about this topic.

thanks.
0 Kudos
19 Replies
imeca
Beginner
1,507 Views
Hello,
is there any one who can help me. two days since i sent my request, 62 read it and no one answered it.
please help me, it becomes urgent!

thanks again
0 Kudos
klaus_knebel
Beginner
1,507 Views
Hello
I think this is not possible.
I had this question before too. I wanted to call C# DLL from IVFortran.
C# is 'doing' .NET Code only , and IVF is not doing .NET Code.
We have tried it, but it does not work.
Too bad, but thats the way it is (at the moment)
Klaus
http://software.intel.com/en-us/forums//topic/58378
0 Kudos
Rob4
Beginner
1,507 Views

Hello All,

I'm also looking for robust ways to develop VS2005 C# GUI interfaces which call Intel Fortran for the number crunching. I believeSteve suggested that this could be accomplished via the COM interface restored in version 10+. Do any of the experts have an example of this approach that they would share with the novices? What are the pros/cons vs a Fortran DLL approach?

Cheers,

Rob

0 Kudos
g_f_thomas
Beginner
1,507 Views

This was discussed as late as Feb 2008, IIRC. Do a search on the forum (IMO, the first thing to do before posting here or anywhere else). Briefly C# can call IVF and conversely.

Gerry

0 Kudos
imeca
Beginner
1,507 Views
thank you thomas,
in fact, there is an example posted by steve in which there is a call of fortran routines in a c# projet within visual studio. that helped me a lot, but there are still some things not clear in the method (properties , etc.).
i ll be very thankful if you or any of the experts explains to us the details through a little example such as the one of steve :
the properties of each part of the project;
the properties of the entire project;
the output folders;
the order of generation;
how to make automatically the fortran dll being build directly into the C# project debug folder;
etc.

thank you again.
0 Kudos
g_f_thomas
Beginner
1,507 Views

Go to the thread

create a fortran dll to make a call from C# code (AIS, Feb 2008)

and look at the last post. Download the attachment.

BTW, doing what you want to do (GUI in C# and IVF dll) is easier said than done, especially if you are new to this sort of thing. Why not use a dialog or QuickWin app from IVF?

Gerry

0 Kudos
klaus_knebel
Beginner
1,507 Views
Hello

As I wrote above, to my knowledge it is not possible to combine IVF and C# in an easy way.
We tried it, but without success (calling a C# DLL from IVF).
The workaround using COM is (imo) complicated.
If you want to do GUI, I recommend QuickWin or a third party tool like Winteracter, which is quite easy to handle.
Klaus

0 Kudos
Steven_L_Intel1
Employee
1,507 Views
It is as easy as it is from VB.NET using DLLs. Using COM is harder (though has other benefits.)
0 Kudos
Rob4
Beginner
1,507 Views

Hi,

I am using managed C# to call an IVF dll and encounter the following message when I try to start debugging in the VS 2008 IDE: "The debugger does not support managed and native code at the same time on this platform." My platform is Intel64 with XP64. This is a serious pain, IMHO. Can anyone tell me if the debugger does support managed and native code at the same time on IA32, or indeed any platform? Is there a work around, or am I missing some simple way of working with mananged and native code? Would calling the native IVF code througha COM interface rather than as adll make any difference to way the debugger would work?

Thanks,

Rob

0 Kudos
Steven_L_Intel1
Employee
1,507 Views
Hmm - first time I've heard of that one. Mixed managed-native code debugging works on IA-32 and XP/Vista. Be sure to check the "Enable unmanaged code debugging" in the managed project's Debug property page. Using COM would likely not make a difference.

XP 64-bit is an unusual platform - not a lot of users on that.
0 Kudos
onkelhotte
New Contributor II
1,507 Views
klaus.knebel@mero.de:
Hello

As I wrote above, to my knowledge it is not possible to combine IVF and C# in an easy way.
We tried it, but without success (calling a C# DLL from IVF).
The workaround using COM is (imo) complicated.
If you want to do GUI, I recommend QuickWin or a third party tool like Winteracter, which is quite easy to handle.
Klaus

Calling a fortran dll from c# is easy. Passing arrays and strings is a little bit tricky, but not impossible. So you can do your input in Windows Forms and output via GDI, DirectX or OpenGL, manipulationdatabases...and your fortran dll does the calculation.

But why want you call a c# dll from fortran? QuickWin as a GUI is circuitous when you want to do more than edit boxes. Graphical output is very slow and heavily uses cpu time.

Markus

0 Kudos
klaus_knebel
Beginner
1,507 Views
Hello
I do my GUI using Winteracter.
Very good, no problem.
I do not want to use C# for GUI, this is not the issue.

We have some numerical subroutines which we would like to
use in a C# programm.
(==> calling a IVF DLL from C#)
On the other side we would like to use some C# code within a Fortran program
(==> calling a C# DLL from IVF)
I know it is 'easy' and possible using C++ , but C# ??

Maybe is somebody has a small example code
Klaus
0 Kudos
Steven_L_Intel1
Employee
1,507 Views
I have attached a small example.
0 Kudos
onkelhotte
New Contributor II
1,507 Views

Steve, Klaus wants to call a c# dll from a fortran program, not vice versa...

Markus

0 Kudos
klaus_knebel
Beginner
1,507 Views
Well
both ways would be usefull.
We will look at the sample program from Steve.
Klaus
0 Kudos
g_f_thomas
Beginner
1,507 Views

The attached sample does it all!

Gerry

0 Kudos
onkelhotte
New Contributor II
1,507 Views
g.f.thomas:

The attached sample does it all!

Gerry

I dont see how fortran calls a c# method in your project...

Markus

0 Kudos
Steven_L_Intel1
Employee
1,507 Views
There are two distinct solutions in that ZIP.
0 Kudos
g_f_thomas
Beginner
1,507 Views

Essentially, Get2DMatrix is a 'method' that is common to both the c#server and the ivf client so that invoking one indirectly invokes the other pretty much the way ivf can access VB6 via the AddressOf operator. To directly invoke a method of c# you have to know more about c#, in particular how to manipulate its IL bytecode, something I posted about here on this forum a while back.

BTW, this forum's focusis Fortran via IVF not C# which has any number of forums elsewhere.

HTH,

Gerry

0 Kudos
Reply