- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi!
Ich try to write a dll in Fortran that exports function having strings as parameters to be used in a Fortran program. But I doesn't work!!! Can somebody give me an example of this? Thank you!
Below are parts of my Fortran code. Where is the error?
Ich try to write a dll in Fortran that exports function having strings as parameters to be used in a Fortran program. But I doesn't work!!! Can somebody give me an example of this? Thank you!
Below are parts of my Fortran code. Where is the error?
interface logical function LoadInterActionParameter(Anco, Ansteu, & & AMixRule, Atblock, k, la, l, s, kkap, kep, Aexdataname) !DEC$ IF DEFINED(_X86_) !DEC$ ATTRIBUTES STDCALL, ALIAS : '_LOADINTERACTIONPARAMETER@48' :: LOADINTERACTIONPARAMETER !DEC$ ELSE !DEC$ ATTRIBUTES STDCALL, ALIAS : 'LOADINTERACTIONPARAMETER' :: LOADINTERACTIONPARAMETER !DEC$ ENDIF !DEC$ ATTRIBUTES REFERENCE::Aexdataname, Anco, ansteu DEC$ ATTRIBUTES REFERENCE::AMixRule, Atblock !DEC$ ATTRIBUTES REFERENCE::k, la, l, s, kkap, kep character*(*) AExdataName integer Ansteu, AMixRule, Atblock, Anco double precision k(10,10), la(10,10), l(10,10) double precision s(10,10), kkap(10,10), kep(10,10) end function end interface ---------------------------- logical function LoadInterActionParameter(Anco, Ansteu, AMixRule, Atblock, & & k, la, l, s, kkap, kep, Aexdataname) !DEC$ ATTRIBUTES DLLEXPORT::LOADINTERACTIONPARAMETER !DEC$ ATTRIBUTES REFERENCE::Aexdataname, Anco, ansteu, AMixRule, Atblock !DEC$ ATTRIBUTES REFERENCE::k, la, l, s, kkap, kep implicit none integer Ansteu, AMixRule, Atblock integer xnsteu, xmixrule, xkt, Anco double precision k(10,10), la(10,10), l(10,10) double precision s(10,10), kkap(10,10), kep(10,10) character*(*) Aexdataname LoadInterActionParameter = .false. ! Body end function
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please never use the term "doesn't work" (especially not followed by !!!). Doesn't compile? Doesn't link? Causes your application to crash? Causes your computer to burn?.
With combination STDCALL+REFERENCE on string arguments, length of
the string is not passed. Thus, you have to "hard-code" string length in the callee, i.e. CHARACTER(LEN=50).
If you intend to use it only from Fortran caller, STDCALL, REFERENCE and ALIAS are not necessary (but do no harm as long as they're consistent). In the actual case, if you omit STDCALL, your declaration of character variable could retain standard (LEN=*).
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your answer, Jugoslav!
I could solve my problem with giving the length explicitly (Len = 50 etc.). Can I find somewhere a WORKING example of how to use functions with strings from a DLL in Fortran?
Thank you!
Stan
I could solve my problem with giving the length explicitly (Len = 50 etc.). Can I find somewhere a WORKING example of how to use functions with strings from a DLL in Fortran?
Thank you!
Stan
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page