Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
18 Views

Export Module to dll file

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
Highlighted
18 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
Highlighted
Beginner
18 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
Highlighted
18 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
Highlighted
18 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
Highlighted
Beginner
18 Views

Jim and Steve,

Many thanks for good suggestions!

I will test.

 

Chris

0 Kudos