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

DLL's

JohnNichols
Valued Contributor III
760 Views
Dear Steve:

Building Executables that Use DLLs

The Fortran help includes the topic listed above.

I built the Adder example shown in the Fortran help and it compiles ok to a DLL and a LIB file.

I have tried to follow the method outlined in the the topic above to use the Adder Module, but I keep getting a 7002 error.

Error1 error #7002: Error in opening the compiled module file. Check INCLUDE paths. [ADDERMACHINE_USE]B:\\Users\\John\\Documents\\Visual Studio 2010\\Projects\\Adder++\\Adder++\\Adder++.f903

I am pretty sure I am calling the wrong Module in the Set of Adder Modules and I am creating the Project Solution incorrectly.

So my questions are:
1. What sort of Fortran program type can I use to callthe Adder Module Group?
2. Using the program from Question 1 am I using the ADDMachine_Types module:
[bash]module AddMachine_Types

    use AddMachine_USE
    use ifwinty

    !  Strings used in registering class
    character*17, parameter :: AddMachine_CLASS_NAME = ("AddMachine Class")
    character*16, parameter :: AddMachine_PROGID = ("Adder.AddMachine")
    character*3,  parameter :: AddMachine_VERSION = ("1.0")
    character*10, parameter :: AddMachine_THREADING_MODEL = ("APARTMENT")

    ! CLSIDs        
    type (guid), parameter :: CLSID_AddMachine = &
        GUID(#496d991e, #7bd7, #4131, &
        char('93'X)//char('5e'X)//char('24'X)//char('68'X)// &
        char('98'X)//char('63'X)//char('68'X)//char('49'X))
                                                [/bash]


or the AdddMachine_use module.
[bash]module AddMachine_USE

    type Adder_InstanceData
        sequence
        !  DO NOT REMOVE THIS LINE
        !  TODO:  Add fields and remove "dummy"
        real (4) CurrentValue
        !  DO NOT REMOVE THIS LINE
    end type

  contains
[/bash]

Queston 3: What does the mainapp.f90 as listed in the USING DLL routines look like?

As listed in:

Using the Intel Fortran COM Server




Thanks

JMN
0 Kudos
5 Replies
Steven_L_Intel1
Employee
760 Views
I guess you didn't notice that the error message references ADDERMACHINE_USE while the module is named ADDMACHINE_USE

You are creating a COM Server. This is typically "called" from a non-Fortran application, such as VB.NET or C#. You would not use this from a Fortran main program (although you could if you also used the Fortran Module Wizard, but that's just masochism.

I don't think you want to be using the COM Server Wizard. This is a specialized topic that requires some advanced knowledge of the Component Object Model in Windows.

For a Fortran program that uses a Fortran DLL, just think of the DLL as a collection of routines. You would call the routines exactly as if they were included in the project. For routines, you can add a
!DEC$ ATTRIBUTES DLLIMPORT :: routinename
directive, but that's optional. (It's not optional for variables imported from a DLL.)

What is it exactly you want to do?
0 Kudos
JohnNichols
Valued Contributor III
760 Views
Dear Steve:

I was looking to see what limits I had in developing Fortran code.

The CX1Reader program I have been playing with for the last few months has some very old components inside it. The program takes an acceleration trace (time, acceleration X, Y and Z point data) and performs a Fast Fourier Transform, among other things. I originally used a FFT program that was modified from an old FORTRAN textbook, but moved over in the mid 90's to the Numerical Recipes in FORTRAN modules, although in the current iteration I am still using F77 routines, as they are fast and easy to use. Why change your underpants type if you like them so to speak. I had looked at the NR F90 modules, but was wondering what else is available.

I am looking to how we actually implement the CX1 program as part of the measurement system for acceleration and hence damage on bridges. Akin to measuring the temperature on your Dell XPS 1430 computer, cause if the bastard gets too hot it croaks. (Aussie for - it gets upset and stops working).I have been tempted to get a frig just for my XPS but the water issue worries me. Apparently heating is due to the large graphics card and the small fan. I have acooling pad, but sometimes I just have to switch it off for a while. Unfortunately one cannot switch of bridges, and in the middle of the world going to the pot one wants the computer measuring the level of trouble in the pot to work properly. (Like SLim Pickens on the bomb)
So your COM stuff with the ADDER methods looked a neat way to implement some of the wavelet routines, which are really just a convolution algorithm, which is sophomore Fortran at its simplest.


As you noted "such as VB.NET or C#", but when Bill Gates or his many minions, (think of the little blue one eyed google wearingmen in the latest kids movie), chose Basic over Fortran development one has to ask what they were thinking. In the early 90's when they took this step I thought they were crazy, I also thought Lotus was insane to throw away the IMPROV program for 123. We now the crazy iteration of C# and F#. I have tried both programs and the only question I have is 'Why?". I know Why, but really why?



So humour an old gray haired bastard, and let us enjoy some machosim togethor, for the simple reason we can and in the long run we are trying to save lives.So how would I call my add program in Fortran?

For a Fortran program that uses a Fortran DLL, just think of the DLL as a collection of routines. ++ I used libraries a lot in the old days when time was precious and one could boil a kettle and make a cup of tea whilst one waited for the code to compile. If you want to teach someone how to be very careful writing code give them a slow compiler. I am still lost as to how I take one of my FORTRAN subroutine groups and make a LIB out of it. I used to have a large standard library. I can not find the old LIB routine from MICROSOFT. It is alluded to in the HELP files, but I am still lost with it.

Thanks.

JMN
0 Kudos
Steven_L_Intel1
Employee
760 Views
John,

Don't go there. COM is the wrong solution for you. What you want is a simple, native DLL. Write your "sophomore" Fortran code. You probably don't even want a DLL, just a static library. The compiler documentation has a section on creating libraries, and using the command line if you are so inclined. From the command line, you create a library with:

lib /out=mylib.lib object1.obj object2.obj object3.obj

etc.
0 Kudos
JohnNichols
Valued Contributor III
760 Views
The lib function does not work from the Windows CMD line.

I can create a LIB function as you suggest from within the MS Studio and that is probably best.

Thanks for the advice.

JMN
0 Kudos
Steven_L_Intel1
Employee
760 Views
Yes, lib works fine from the command line, but you have to establish the "Fortran build environment" for the command line session. We provide shortcuts in the Start menu for that. None of the build tools are available if you just open a plain command prompt.
0 Kudos
Reply