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

Exposing a Fortran dll to both COM and Fortran?

mbrengartner
Beginner
6,061 Views

Hello, I've been tasked with coming up with a way to expose some Fortran subroutines in a dll to both other Fortran projects and COM.

First of all: I do not know Fortran. You may wonder about the wisdom of choosing me to accomplish this task - I know I do ;) It is what it is!

I've spent considerable time researching this and I think it's time to ask for some direct help. Thesubroutines are:

sub1(real8a, real8b, char256c, char80d)

sub2 has 19 real(8) parameters

sub3 has 22 real(8) parameters

Here's what I've tried so far:

Put DLLExport statements in the dllto expose the subroutines, and DLLIMPORT statements in the project.

Created a generic console app that calls into the dll, using the .lib file. Result: Unresolved external.

I've used the /gen-interfaces switch to get a whole mess o' .mod and f90 files. I've linked to those individual mod files. Result: corrupt file or can't open file.

It would seem that I just don't get what needs to be done. It seems so simple...

I'm sure that I've left out crucial bits of information - I'm sorry, I just don't know what to provide. I'm happy to add anything that you need!

Thanks in advance,

Mike

0 Kudos
23 Replies
DavidWhite
Valued Contributor II
412 Views
Mike,

My most recent experience in this was calling Fortran from Excel VBA, where there is a function for filling a string with multiple characters. Don't know what language your COM routine is in, so can't advise you on that.

For the Fortran call, you should not need to fill the string before the call, but if you did, you could use a FORALL statement or DO Loop.

Regards, David
0 Kudos
mbrengartner
Beginner
412 Views

Unfortunately, it's the Fortran stuff we're having the issue with. It seems to already be padded.

Thanks,
Mike

0 Kudos
DavidWhite
Valued Contributor II
412 Views
Mike,

Are the strings declared as fixed length and 256 chars long on both sides of the call? Variable length strings seem to cause the most problems.

Can you get the DLL to work with a direct call from Fortran?

If you want me to look at your code (or a demo version of it), can you email it to roonwhit tigris org.

Regards, David White
0 Kudos
Reply