Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
公告
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

VS2005 C#.Net Calling Fortran 9.1 dll

jeltz
初学者
1,089 次查看
Going in circles on this stupid test program. I create a fortran dll with subroutine called test, and use .NET interop services in C# to [DllImport("fortrandll.dll")], but when calling the fortran subroutine from C#, get the runtime debug exception "unable to find entry point for test". This is supposed to be the way to call unmanaged dll functions from managed C#.Net is it not?
Is this just thatI have not got calling conventions right? (default optionsused at either end, but setting numerous permutations of calling options does not work either. Any thoughts?
Jeltz

Message Edited by jeltz on 05-19-200606:09 AM

0 项奖励
5 回复数
Steven_L_Intel1
1,089 次查看
We'd need to see more of the code. Keep in mind that C# is case-sensitive and Fortran, by default, upcases all of the routine names. Also, I'm uncertain if C# requires the stdcall calling mechanism for dllimport routines.
0 项奖励
jeltz
初学者
1,089 次查看

Doh...forgot to add !DEC$ ATTRIBUTES DLLEXPORTto fortran function so little wonderC# could not find it....Sorry, I will crawl back under my rock now. Just goes to show that error messages sometimes say what they mean...Jeltz

0 项奖励
jeltz
初学者
1,089 次查看
OK Steve now explain this one!
the following code fails in the C# call with:
Unable to load DLL 'testit.DLL': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
subroutine testit()
integer*4 NY
!DEC$ ATTRIBUTES DLLEXPORT::testit
integer*4 i
real*8 ma(55)
ma(1)=1
ma(55)=1
do i=1,54
ma(i)=1
end do
end subroutine testit
BUT with one minor change, the followingexecutes just fine:
subroutine testit()
integer*4 NY
!DEC$ ATTRIBUTES DLLEXPORT::testit
integer*4 i
real*8 ma(55)
ma(1)=1
ma(55)=1
do i=1,54
ma(10)=1
end do
end subroutine testit
This is the managed C# code doing the calling
[DllImport("testit.dll")]
private extern static void TESTIT();

public static void test()
{
TESTIT( );
}
0 项奖励
jeltz
初学者
1,089 次查看

OK found the answer; The one change to the code made it go look for a fortran support dll which it could not find. had to find the right fortran dll in the 9.1 lib directory and put it in the right place.

Why are these ancilliary fortran dlls not in the interopdll hunt path for .Net 2.0 ? and since the fortan compiler knows it need them (eventually at runtime) why can it not make them a project dependency?

Jeltz

0 项奖励
Steven_L_Intel1
1,089 次查看
When you installed the compiler, you were asked if you wanted to modify the system environment variables and warned that if you didn't, programs that depend on the Fortran DLLs won't run. You can manually add the path to the Fortran BIN folder to PATH.

I'm not familiar with DLLs as project dependencies or "interop dll paths". I'll look those up.
0 项奖励
回复