I was trying to use Fortran function in Mathematica. I was following mainly this answer . My Fortran code looks like this:
FUNCTION TESTFUNCTION(X,Y)
!DEC$ ATTRIBUTES DLLEXPORT::TESTFUNCTION
!DEC$ ATTRIBUTES REFERENCE :: X,Y
REAL(8), DIMENSION(2) :: X
REAL(8) :: Y, TESTFUNCTION
TESTFUNCTION = (X(1)+X(2)) * Y
END FUNCTION
To create .dll I have used Intel Fortran Compiler, while following this guide . My Mathematica input is:
Needs["NETLink`"]
ReinstallNET["Force32Bit" -> True]
SetDirectory[NotebookDirectory[]];
path = FileNameJoin[{Directory[], "testfunction.dll"}];
TestFunction = DefineDLLFunction["TESTFUNCTION_",path ,
"double", {"double[]", "double*"}]
This gives:
(*
Out[26]=Function[Null,
If[NETLink`DLL`Private`checkArgCount["TESTFUNCTION_", {##1}, 2],
Wolfram`NETLink`DynamicDLLNamespace`DLLWrapper1`TESTFUNCTIONU[##1], \
$Failed], {HoldAll}]
*)
After calling
TestFunction[{1.0, 2.0}, 3.0]
I've obtained
(*
Out[27]= NET::netexcptn:
A .NET exception occurred: System.EntryPointNotFoundException:
Unable to find an entry point named 'TESTFUNCTION_'
in DLL 'D:\Files\testfunction\testfunction.dll'.
at Wolfram.NETLink.DynamicDLLNamespace.DLLWrapper1.TESTFUNCTION_(Double[] ,Double& ).
*)
Can somebody please tell why I have this error message. Any suggestions are more than welcomed. Here is the source code and .dll file.
_
$\endgroup$