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

Using DLL from EXCEL

zohair
Beginner
814 Views
Hi

I created a DLL version of the NAG F90 library using the CVF version 6.6 (update B).

I can use the DLL with the CVF compiler however I needed to use the /I switch to access the modules created during the compilation of the library source files (the modules contain generic interfaces and derived types).

My question is:
Can this DLL be used from another system such as MS EXCEL
or VB?
To be more specific, when generic names are used the compiler uses the interface block information in the ".mod" files to determine the specific procedure to be used during lining. I wonder how VB or EXCEL will cope with this situation especially if the specific names are declared as PRIVATE.

Thanks

Zohair

0 Kudos
3 Replies
Jugoslav_Dujic
Valued Contributor II
814 Views
Generic names are Fortran-specific things, so, of course, you cannot access these from VB or Excel; generic names "exist" only during compilation stage -- once the dll is built, they're nowhere to be seen.

What you can do is to dllexport specific names and call these from VBA -- regardless of the fact that they are declared PRIVATE. These names do exist, and their exported form is _MODULENAME_mp_ROUTINENAME@n. Take a look at .EXP files, as the cleanest way to dllexport routines without changing the sources. Create a file with extension .exp and include it in your project:
EXPORTS
   FooRoutine=_NAG_mp_FOOROUTINE@4
   BarRoutine=...
The number following @ must be equal to number of arguments * 4. The dll will dllexport the FOOROUTINE under name "FooRoutine".

However, one thing bugs me: I think that it isn't possible to use a generic name from a DLL (from CVF .exe) unless appropriate specific name was dllexported as well -- otherwise you'd get a link error. However, your post suggests that it isn't the case? Are there DLLEXPORT directives or .exp file in NAG f90 library?

Jugoslav
0 Kudos
gfthomas8
Novice
814 Views
That's neat. Is is redistributable? Is it free?

I don't see why you can't use the DLL from Excel (VBA) or VB. From what I can gather private procedures in Fortran modules are public in _mixed_ language (C/C++)apps. How do you mix VB or VBA with Fortran?; can be done but I digress. He's a leg up. Download NAG's trial version of their CVF-generated DLL and look at the VB samples for insight as to how they do what you'd like to do with your version of the DLL.

HTH,
Gerry T.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
814 Views
Errata: replace ".exp" with ".def" above.
0 Kudos
Reply