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

How to export generic name for procedure (Interface)

fdc_dhi
Beginner
340 Views
Export of generic functions

I have a module (se below) and I want to export the geniric function/ Interface "GetCurrentTime": How can I do that?

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! MY DLL ENGINE !!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Module MEngine
implicit none
save
PRIVATE
....
Interface GetCurrentTime
module procedure dblGetCurrentTime
module procedure sglGetCurrentTime
end interface
....
....
PUBLIC::
GetCurrentTime

Contains:
! GetCurrentTime
subroutine dblGetCurrentTime (dout)
real*8 ,intent(out):: dout
dout = uznow
return
end subroutine dblGetCurrentTime

subroutine sglGetCurrentTime (fout)
real*4 ,intent(out):: fout
fout = uznow
return
end subroutine sglGetCurrentTime
....
End Module MEngine
0 Kudos
3 Replies
Jugoslav_Dujic
Valued Contributor II
340 Views
What do you mean "export"? Dllexport? No, you can't "export" it in the usual sense -- that info is available only during compile-time, and compiler actually always produces code which calls one of specific function when it resolves which one. I didn't look at .obj files of routines which call generic functions, but I'd bet you'll find only the specific names imported. In other words, GetCurrentTime ends up only in .mod files, but not in .obj files.

What you can do is to add the MEngine.mod to your .exe project -- I think that will work (provided that the .exe is in Fortran).

Jugoslav
0 Kudos
fdc_dhi
Beginner
340 Views
By export I mean dllexport and my .exe project is not a fortran program, but a C# program.
Could I instead dllexport each module procedure ??
0 Kudos
Jugoslav_Dujic
Valued Contributor II
340 Views
Yes, you can -- I recommend using ALIAS attribute (or a .def file) as well, because otherwise you'll get ugly name mapping, like _MENGINE_mp_SGLGETCURRENTTIME:

subroutine sglGetCurrentTime (fout)
!dec$attributes dllexport, decorate, alias: "sglGetCurrentTime":: sglGetCurrentTime

will export "_sglGetCurrentTime@4" and you will call it from C# as "sglGetCurrentTime".

Jugoslav

0 Kudos
Reply