Problems with modules when dynamically loading libraries

Problems with modules when dynamically loading libraries

renee.nutter@lmco.com's picture


I am dynamically loading several shared libraries from a main program. Each library contains fortran subroutines. One of the libraries links in a module that contains data that should be shared by all of the other libraries that will be dynamically loaded. The problem is that after I load the libraries, each subroutine seems to be looking at a separate copy of the module data. If I change the value in one subroutine, the value is not reflected in the data when viewed from a subroutine that resides in a separate shared library. This result is also dependent on the order that I load in the libraries.

For compiling, I am using ifortwith the following options:
-shared -extend_source -save -fpic -c

For linking, I am using icc.

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Steve Lionel (Intel)'s picture

Typically the way you would do this is have one .so that contains just the shared storage and all the other libraries link against that, so when any of them is loaded, they pull in the same common shared data. I don't know how you do this in detail on Linux - I have done it on other platforms.


If you don't do it that way, each library thinks it is its own definition of the storage.

Steve

Login to leave a comment.