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

Fortran dll

KeesRoos
初学者
733 次查看

Hi all.

I am new to Frotran, need some precise calculations, writing a fortran dll, to be called from C#. Following Fortran function compiles (Intel Fortran compiler, Microsoft Visual studio 2022) without error or warning:

function getSin( instance ) result(output)
! Dec$ ATTRIBUTES DLLEXPORT, C :: getSin
 
!Dec$ ATTRIBUTES REFERENCE :: instance
 
type(struct_angle), intent(in) :: instance
real*16 :: output
 
real*16 :: angle16
real*16 :: sine16
 
angle16 = instance%value_
sine16 = QSIN(angle16)
 
output = angle16
end function getSin
 
However, C# reports an error: cannot find the module or dependencies.
 
When I comment out the line: sine16 = QSIN(angle16)
and let the function return a fictive value, the problem does not occur.
Can anyone tell what causes this error and what I can do to solve it? 

 

标签 (1)
0 项奖励
5 回复数
Steve_Lionel
名誉分销商 III
694 次查看
0 项奖励
JohnNichols
重要分销商 III
666 次查看
function getSin( instance ) result(output)
! Dec$ ATTRIBUTES DLLEXPORT, C :: getSin
 
!Dec$ ATTRIBUTES REFERENCE :: instance
 
type(struct_angle), intent(in) :: instance
real*16 :: output
 
real*16 :: angle16
real*16 :: sine16
 
angle16 = instance%value_
sine16 = QSIN(angle16)
 
output = angle16
end function getSin

It helps make it easy to read if you use the formatting tool on the tool bar it looks like </>.

In reality, there is almost a one to one correspondence between Fortran and C# in terms of functionality, so making a DLL in Fortran unless you are doing heavy duty calculations is a waste of time, unless it is a learning exercise.  

0 项奖励
JohnNichols
重要分销商 III
665 次查看

As an example the Numerical Analysis in Fortran FFT translated into C# yields the same loop time on 16384 data points as Fortran version,  and the version on RPi runs in 7 seconds.  

Of course one can use the MKL version, which is faster. 

Mixing languages is painful.  I was running some numerically intensive Fortran stuff the other day, the loop time for each set was about 1.5 seconds on a core I7, the machine started some services and the loop time went to 5 seconds, it took me a while to find the blasted services and turn them off.  

 

0 项奖励
KeesRoos
初学者
509 次查看

Hi Steve,

thanks for your prompt reaction. I have been out this week, just home again.

Adding oneAPI\2025.0\bin to the Path variable does not solve my problem.

Any idea what more I can try? 

0 项奖励
Steve_Lionel
名誉分销商 III
467 次查看

If you open an Intel oneAPI command prompt window (from the Start menu) and run your application from there, does it work? Did you build your DLL as a Release configuration?

0 项奖励
回复