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

Export Module to dll file

Chris_Ower
Beginner
410 Views

We have a main dll with  calculations and in this dll there are  have many modules.

We want to add a post-processor but this will be placed in a separate dll  In this separate dll the idea is to use modules with results from the main dll.

I have tested with a small post processor dll  and now it is working (with some problems on the way) so variables from modules in the main dll are available in the post Proc. dll.

My test example:

In main dll I have this module:

module test

real a

!dec$ attributes dllexport :: a

real b

!dec$ attributes dllexport :: b

end module

 

I set a b to some variables and then I export the module:

!dec$ attributes dllexport :: test

When this is done I  use a and b in  the separate post-proc. dll and they are correct

This is fine but for the real case I have many hundreds/thousands of results in many modules.

I have tested to comment out dllexport for a and b but then it did not work.

My question: Is there a command or trick to avoid adding dllexport for all variables in my modules?

BR

Christer

 

 

 

 

 

 

 

 

0 Kudos
5 Replies
Steven_L_Intel1
Employee
410 Views

Sorry, no. All variables must be explicitly exported. At least when you USE the module, the DLLEXPORTs are converted to DLLIMPORTs automatically.

Do you really have that many separate variables to share from the DLL? Maybe you need to take another look at program structure.

0 Kudos
Chris_Ower
Beginner
410 Views

Steve,

Thanks for information !

 

After I wrote my question I looked around and found another thread ( 301019 from 2008)  and the same request was in the wish-list. Maybe next version?

0 Kudos
jimdempseyatthecove
Honored Contributor III
410 Views

Why not use:

! In main dll I have this module:
module test
  type test_t
    real a
    real b
  end type test_t

  type(test_t) :: test_data
  !dec$ attributes dllexport :: test_data
end module

Jim Dempsey

0 Kudos
Steven_L_Intel1
Employee
410 Views

I'll be honest and say that I don't think an "export everything" option is a good idea. While it's on our list of requests, it's not something we're considering at this time.

In addition to Jim's suggestion, if you put the shared variables in a COMMON and DLLEXPORT the COMMON, that would be a way of getting the variables shared without having to name them individually. I'm a bit hesitant to suggest this as COMMON is considered obsolescent, but you can put COMMON in a module.

Here's a short example demonstrating this.

module mymod
common /foo/ a,b,c
!DEC$ ATTRIBUTES DLLEXPORT :: /foo/
contains
subroutine init
!DEC$ ATTRIBUTES DLLEXPORT :: init
a = 42.
b = 23.
c = 19.
end subroutine init
end module mymod
program test
use mymod
implicit none
call init
print *, a,b,c
end

 

0 Kudos
Chris_Ower
Beginner
410 Views

Jim and Steve,

Many thanks for good suggestions!

I will test.

 

Chris

0 Kudos
Reply