<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: sharing module between dll and main program in fortran in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901991#M80965</link>
    <description>&lt;P&gt;i can not find the sample code &lt;/P&gt;
&lt;P&gt;can you send it again&lt;/P&gt;
&lt;P&gt;thanks&lt;/P&gt;</description>
    <pubDate>Thu, 21 Aug 2008 15:34:03 GMT</pubDate>
    <dc:creator>Pam_R_</dc:creator>
    <dc:date>2008-08-21T15:34:03Z</dc:date>
    <item>
      <title>sharing module between dll and main program in fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901987#M80961</link>
      <description>&lt;P&gt;i have a problem sharing module between dll and main program&lt;/P&gt;
&lt;P&gt;there are 2 sub programs in dll &lt;/P&gt;
&lt;P&gt;1) chf_cor&lt;/P&gt;
&lt;P&gt;2) module main_data&lt;/P&gt;
&lt;P&gt;subroutine chf_cor (i, chf, correlation) &lt;BR /&gt;!&lt;BR /&gt;! Subroutine to evaluate chf using 1 of 9 different correlations&lt;BR /&gt;!&lt;BR /&gt; use main_data&lt;BR /&gt;! &lt;BR /&gt; implicit none&lt;BR /&gt;!&lt;BR /&gt;!dec$ attributes dllexport :: chf_cor&lt;BR /&gt;!&lt;BR /&gt; character(*) correlation&lt;BR /&gt; integer(4) i&lt;BR /&gt; real(8) chf&lt;BR /&gt;!&lt;BR /&gt; character(50) correlation_name(10)&lt;BR /&gt;!&lt;BR /&gt; real(8) constants(10)&lt;BR /&gt;! &lt;BR /&gt; data correlation_name(1) / 'chf correlation 0 - bur &amp;amp; wub ' /&lt;BR /&gt;!&lt;BR /&gt; data constants / 1.0d0, 2.0d0, 3.0d0, 4.0d0, 5.0d0, 6.0d0, 7.0d0, 8.0d0, 9.0d0, 10.0d0 / &lt;BR /&gt;! &lt;BR /&gt; num_cor = 10 &lt;BR /&gt; write(6,*) 'num_cor = ', num_cor &lt;BR /&gt; chf = constants(i)*prop(i)&lt;BR /&gt; correlation = correlation_name(i)&lt;BR /&gt;!&lt;BR /&gt; end subroutine chf_cor&lt;/P&gt;
&lt;P&gt;module&lt;/P&gt;
&lt;P&gt; module main_data&lt;BR /&gt;!&lt;BR /&gt;!dec$ attributes dllexport :: num_cor&lt;BR /&gt;!&lt;BR /&gt; integer(4), save :: num_cor &lt;BR /&gt;! &lt;BR /&gt;!&lt;BR /&gt; real(8), save :: prop(10)&lt;BR /&gt;! &lt;BR /&gt; end module main_data&lt;/P&gt;
&lt;P&gt;i did compile and created dll with following command&lt;/P&gt;
&lt;P&gt;ifort /dll chf_cor.f90 main_data.f90&lt;/P&gt;
&lt;P&gt;this created chf_cor.lib&lt;/P&gt;
&lt;P&gt;the main program using dll looks like this&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#ff0000" size="4"&gt;program main&lt;BR /&gt; use main_data&lt;BR /&gt;! &lt;BR /&gt; implicit none&lt;BR /&gt;!&lt;BR /&gt; integer(4) i&lt;BR /&gt; real(8) chf&lt;BR /&gt; character(50) correlation&lt;BR /&gt;!&lt;BR /&gt; i = 1&lt;BR /&gt;! num_cor = 10&lt;BR /&gt; call chf_cor (i, chf, correlation) ! this call initializes num_cor&lt;BR /&gt;!&lt;BR /&gt; write(6,*) 'num_cor = ', num_cor&lt;BR /&gt; do i = 1,10&lt;BR /&gt; prop(i) = i*1.0d0&lt;BR /&gt; end do&lt;BR /&gt;! &lt;BR /&gt; do i = 1, num_cor&lt;BR /&gt;!&lt;BR /&gt; call chf_cor (i, chf, correlation) &lt;BR /&gt;!&lt;BR /&gt; write (6,9000) i, chf, correlation&lt;BR /&gt; end do &lt;BR /&gt;!&lt;BR /&gt;9000 format ('numb = ',i2,' chf = ',1p,
e13.5,3x,a50)&lt;BR /&gt; end program main &lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000000" size="4"&gt;the problem starts now&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="4"&gt;when i try to link .lib with main.f90&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="4"&gt;ifort /libs:dll main.f90 chf_cor.lib&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="4"&gt;i get an error saying liking error - unresolved external symbol referenced in program main&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="4"&gt;how do i resolve this ?&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="4"&gt;the only i way i can link if i use modules main_data.f90 again in main program&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="4"&gt;ifort /libs:dll main.f90 main_data.f90 chf_cor.lib&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="4"&gt;the only problem with this is the data in module is not sharable and does not reflect changes made by dll program in main program&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="4"&gt;help needed&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Aug 2008 05:32:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901987#M80961</guid>
      <dc:creator>Pam_R_</dc:creator>
      <dc:date>2008-08-20T05:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: sharing module between dll and main program in fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901988#M80962</link>
      <description>&lt;P&gt;You should include INTERFACE blocks for all routines imported from your DLL (chf_cor being the only one visible in your code). These blocks should contain DLLIMPORT attributes for the symbols imported from the DLL so that thelinker knows where to find them.&lt;/P&gt;
&lt;P&gt;If you have created CHF_COR.DLL and its accompanying export library CHF_COR.LIB, then add CHF_COR.LIB to your MAIN program solution. This should ensure the DLL is found and included when external references are satisfied. You still need to specify DLLIMPORT for the CHF_COR subprogram. Also, make sure that CHF_COR.DLL is copied to a location where the MAIN program can find it (into the same directory as the MAIN.EXE for example)&lt;/P&gt;</description>
      <pubDate>Wed, 20 Aug 2008 08:32:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901988#M80962</guid>
      <dc:creator>anthonyrichards</dc:creator>
      <dc:date>2008-08-20T08:32:06Z</dc:date>
    </item>
    <item>
      <title>Re: sharing module between dll and main program in fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901989#M80963</link>
      <description>&lt;P&gt;thanks for the prompt reply&lt;/P&gt;
&lt;P&gt;this works ok, i have another problem with the same program&lt;/P&gt;
&lt;P&gt;i am trying to share character data of module between dll and main program&lt;/P&gt;
&lt;P&gt;as i understand it creates two copies of data objects.&lt;/P&gt;
&lt;P&gt;i declared !DEC$ ATTRIBUTES DLLEXPORT :: ibaw2 in one of the modules shared by dll and main program&lt;/P&gt;
&lt;P&gt;when main program starts evene before initializing ibaw2 - it gets some garbage values XD00, also it does not allow it to be over written by any subroutine.&lt;/P&gt;
&lt;P&gt;when try to access ibaw2 in dll subroutine it still has the same garbage value.&lt;/P&gt;
&lt;P&gt;without import/export the value is blank&lt;/P&gt;
&lt;P&gt;help needed &lt;/P&gt;
&lt;P&gt;thanks in advance&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Aug 2008 21:30:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901989#M80963</guid>
      <dc:creator>Pam_R_</dc:creator>
      <dc:date>2008-08-20T21:30:19Z</dc:date>
    </item>
    <item>
      <title>Re: sharing module between dll and main program in fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901990#M80964</link>
      <description>A sample DLL_Shared_Data is provided that illustrates how to share data using a DLL.&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Aug 2008 23:55:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901990#M80964</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-08-20T23:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: sharing module between dll and main program in fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901991#M80965</link>
      <description>&lt;P&gt;i can not find the sample code &lt;/P&gt;
&lt;P&gt;can you send it again&lt;/P&gt;
&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Thu, 21 Aug 2008 15:34:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901991#M80965</guid>
      <dc:creator>Pam_R_</dc:creator>
      <dc:date>2008-08-21T15:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: sharing module between dll and main program in fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901992#M80966</link>
      <description>It's part of the installed Intel Visual Fortran product, for example,&lt;BR /&gt;&lt;BR /&gt;C:Program FilesIntelCompilerFortran10.1.024samplesDLLDLL_Shared_Data&lt;BR /&gt;&lt;BR /&gt;This particular sample uses a single DLL whose variables are write-shared among two separate executables. This may be a bit more complex than you need, but the basic principles are similar as to how you declare things. If you're not sharing data among programs, just within a single program, then you don't need the linker option for read-write sharing.&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Aug 2008 17:38:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901992#M80966</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-08-21T17:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: sharing module between dll and main program in fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901993#M80967</link>
      <description>&lt;P&gt;Steve,&lt;/P&gt;
&lt;P&gt;The example you reference indicates that the variables in the module to be shared must be initialized:&lt;/P&gt;&lt;B&gt;&lt;FONT color="#0000ff" size="2"&gt;
&lt;P&gt;real&lt;/P&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt; :: shared_variable = 999.0 &lt;/FONT&gt;&lt;FONT color="#008000" size="2"&gt;! Must initialize to non-zero value&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color="#008000" size="2"&gt;! in order to be placed in .data section&lt;/FONT&gt;&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;I am trying to share an allocatable array,which is in a module, between a main program and a DLL. For instance:&lt;/FONT&gt;&lt;/P&gt;&lt;FONT size="2"&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT color="#0000ff" size="2"&gt;MODULE&lt;/FONT&gt;&lt;/B&gt;&lt;FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt; KMODELT&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT color="#0000ff" size="2"&gt;INTEGER&lt;/FONT&gt;&lt;/B&gt;&lt;FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;, &lt;/FONT&gt;&lt;B&gt;&lt;FONT color="#0000ff" size="2"&gt;ALLOCATABLE&lt;/FONT&gt;&lt;/B&gt;&lt;FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt; :: MODID(:)&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT color="#008000" size="2"&gt;!DEC$ ATTRIBUTES DLLEXPORT :: MODID&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT color="#0000ff" size="2"&gt;ENDMODULE&lt;/FONT&gt;&lt;/B&gt;&lt;FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt; KMODELT&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;I cannot initialize MODID as it is allocatable. So, is there a way to share a allocatable array in a modulein a DLL?&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#008000" size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Aug 2008 18:51:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901993#M80967</guid>
      <dc:creator>Brett_B_</dc:creator>
      <dc:date>2008-08-25T18:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: sharing module between dll and main program in fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901994#M80968</link>
      <description>The comment in the example applies only when you are sharing data in a DLL between two or more separately running executables. Are you doing this? &lt;BR /&gt;&lt;BR /&gt;An ALLOCATABLE array does not require anything special to be shared across EXEs in a DLL. A POINTER should be initialized to NULL() if shared.&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Aug 2008 19:22:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901994#M80968</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-08-25T19:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: sharing module between dll and main program in fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901995#M80969</link>
      <description>&lt;P&gt;Hi Steve,&lt;/P&gt;
&lt;P&gt;No, I am just running one executable. I am trying to be able to access the MODID(:) array in the DLL via a USE statement.MODID has been allocated and assigned values in the the main program. When I call the subroutine that is part of the DLL, it seems not to know that the array has been allocated, and I get the error:&lt;/P&gt;
&lt;P&gt;forrtl: severe (408): fort: (2): Subscript #1 of the array MODID has value 1 which is greater than the upper bound of -1&lt;/P&gt;
&lt;P&gt;So, in my case, with just one executable, do I not need the /section:data,RWS liner command line directive?&lt;/P&gt;
&lt;P&gt;Is there something else I need to do to be able to access the array in the DLL? Maybe a DLLIMPORT directive in the subroutine within the DLL?&lt;/P&gt;
&lt;P&gt;Thanks for your help.&lt;/P&gt;
&lt;P&gt;Brett Bednarcyk&lt;/P&gt;</description>
      <pubDate>Mon, 25 Aug 2008 19:45:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901995#M80969</guid>
      <dc:creator>Brett_B_</dc:creator>
      <dc:date>2008-08-25T19:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: sharing module between dll and main program in fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901996#M80970</link>
      <description>&lt;P&gt;&amp;gt;&amp;gt;An ALLOCATABLE array does not require anything special to be shared across EXEs in a DLL.&lt;/P&gt;
&lt;P&gt;!!???!!&lt;/P&gt;
&lt;P&gt;Explain please why if the array descriptor "lives" in the DLL address space .AND. if one EXE of potentially several EXE's issues an allocate then how does the descriptor point globally (to all DLL users) allocated memory as opposed to memory within the EXE that performed the allocation?&lt;/P&gt;
&lt;P&gt;It would seem like you would want to export the array descriptor in the EXE and import it (in EXE context) into the DLL. The the allocations are local to the EXE by visible to the DLL on an EXE by EXE basis. (each EXE has seperate area of memory with same name in DLL)&lt;/P&gt;
&lt;P&gt;Alternately, with descriptor inside DLL you could perform a call from the EXE to the DLL with instructions to allocate memory from a pool mapable inside the DLL while addressable from EXE's using the DLL copy of the descriptor. This would not be a standard allocate as it would require specifying a seperate heap (one that grows in the DLL). (shared memory)&lt;/P&gt;
&lt;P&gt;If you want shared memory amongst several processes consider using a memory mapped file from within the EXE and building descriptors to the memory mapped file. The function to perform this would be in the DLL. In this manner, each application gets its own array descriptor pointing at the same memory mapped file but which may reside at different virtual addresses within each process. If the process dies the processes handle(s) to the memory mapped file are closed and things are cleaned up. If you hack something into a common array descriptor inside the DLL you would not get this cleanup capability.&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Aug 2008 20:08:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901996#M80970</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2008-08-25T20:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: sharing module between dll and main program in fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901997#M80971</link>
      <description>&lt;P&gt;Steve,&lt;/P&gt;
&lt;P&gt;Apparently I do not know how to make any data in a module accessible in a DLL as I just changed things to try to access a REAL rather than the allocatable array and it did not work either - the value is wrong inside the DLL. Perhaps you could just outline how to access data in a module through the USE statement in a DLL, or point me to where I can find this.&lt;/P&gt;
&lt;P&gt;One note - I have the module code in both the main program and the DLL projects - is this wrong? I needed to do this in order to get the DLL to link.&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Brett&lt;/P&gt;</description>
      <pubDate>Mon, 25 Aug 2008 20:14:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901997#M80971</guid>
      <dc:creator>Brett_B_</dc:creator>
      <dc:date>2008-08-25T20:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: sharing module between dll and main program in fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901998#M80972</link>
      <description>Yes, it is wrong to have the module code in both projects. Here is what to do.&lt;BR /&gt;&lt;BR /&gt;The module source belongs in the DLL project. Add ATTRIBUTES DLLEXPORT directives for any items you want exported.&lt;BR /&gt;&lt;BR /&gt;For the executable project, add the "output" folder of the DLL project (the Debug or Release) folder to the list of INCLUDE folders. Add a USE of the module to the executable project sources. It will pick up the .mod file from the DLL project.&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Aug 2008 20:45:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901998#M80972</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-08-25T20:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: sharing module between dll and main program in fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901999#M80973</link>
      <description>&lt;P&gt;Steve:&lt;/P&gt;
&lt;P&gt;I have a similar problem, and I try to do what you suggest. However, still I am doing something wrong.&lt;/P&gt;
&lt;P&gt;I have a Fortran EXE and a Fortran DLL. I need to access allocatable arrays from both. I wrote this module:&lt;/P&gt;
&lt;P&gt;MODULE MODFLOW_GLOBAL&lt;BR /&gt; INTEGER, ALLOCATABLE, DIMENSION(:) :: MFL_COL &lt;BR /&gt; INTEGER, ALLOCATABLE, DIMENSION(:) :: MFL_ROW &lt;BR /&gt; CHARACTER(200) :: MFL_FILENAME&lt;BR /&gt;!DEC$ ATTRIBUTES DLLEXPORT :: MFL_COL, MFL_ROW&lt;BR /&gt; !DEC$ ATTRIBUTES DLLEXPORT :: MFL_FILENAME&lt;/P&gt;
&lt;P&gt;END MODULE MODFLOW_GLOBAL&lt;/P&gt;
&lt;P&gt;That I added as part of the DLL project. I then have the include directory where the correspoding MOD is in the EXE file.&lt;/P&gt;
&lt;P&gt;I read the character variable in the EXE and allocate the arrays, butitis notright. THe values are not correct.&lt;/P&gt;
&lt;P&gt;Couldyou help?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Reinaldo&lt;/P&gt;</description>
      <pubDate>Mon, 25 Aug 2008 22:36:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/901999#M80973</guid>
      <dc:creator>Reinaldo</dc:creator>
      <dc:date>2008-08-25T22:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: sharing module between dll and main program in fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/902000#M80974</link>
      <description>Reinaldo, I responded in &lt;A href="https://community.intel.com/isn/Community/en-US/forums/permalink/30262106/30262106/ShowThread.aspx#30262106"&gt;your separate thread&lt;/A&gt;.&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Aug 2008 15:11:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/902000#M80974</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-08-26T15:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: sharing module between dll and main program in fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/902001#M80975</link>
      <description>&lt;P&gt;Steve,&lt;/P&gt;
&lt;P&gt;Thank you for your excellent help - things seem to be working for me now.&lt;/P&gt;
&lt;P&gt;I have a couple more quick questions that I hope you can answer:&lt;/P&gt;
&lt;P&gt;1) Do the modules have to be in the DLL project? Is it not possible to put them in the EXE project and, within the DLL project,get the .mod files through the INCLUDE directory specification?&lt;/P&gt;
&lt;P&gt;2) Is there a way to make all variables in a file or a module default to ATTRIBUTES DLLEXPORT without having to explicitly type the directive for each variable? I have hundreds of modules with thousands of variables, and it would help a lot to have short cut like this.&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;-----Brett&lt;/P&gt;</description>
      <pubDate>Tue, 26 Aug 2008 16:13:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/902001#M80975</guid>
      <dc:creator>Brett_B_</dc:creator>
      <dc:date>2008-08-26T16:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: sharing module between dll and main program in fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/902002#M80976</link>
      <description>1) No - the modules have to be in the DLL project as that is where the variables and routines from the module are defined. The EXE is referencing them.&lt;BR /&gt;&lt;BR /&gt;2) No. We have a wish-list item for this and I will add your request to it.&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Aug 2008 16:53:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/902002#M80976</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-08-26T16:53:28Z</dc:date>
    </item>
    <item>
      <title>Re: sharing module between dll and main program in fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/902003#M80977</link>
      <description>&lt;P&gt;Brett,&lt;/P&gt;
&lt;P&gt;&amp;lt;&lt;IS there="" a="" way="" to="" make="" all="" variables="" in="" a="" file="" or="" a="" module="" default="" to="" attributes="" dllexport="" without="" having="" to="" explicitly="" type="" the="" directive="" for="" each="" variable=""&gt;&amp;gt;&lt;/IS&gt;&lt;/P&gt;
&lt;P&gt;You could encapsulate the variables in a moduleinto a user declared type and create one instance of that type which is exported. &lt;/P&gt;
&lt;P&gt;module mod_foo&lt;BR /&gt;type Type_mod_foo&lt;BR /&gt;real :: A,B,C&lt;BR /&gt;...&lt;BR /&gt;end Type_mod_foo&lt;BR /&gt;&lt;FONT color="#008080"&gt;&lt;EM&gt;c&lt;/EM&gt;DEC$ ATTRIBUTES DLLEXPORT :: FOO&lt;/FONT&gt;&lt;BR /&gt;type(Type_mod_foo) :: FOO&lt;/P&gt;
&lt;P&gt;However, this will require you to specify the container when referencing the variables&lt;/P&gt;
&lt;P&gt;FOO%A&lt;/P&gt;
&lt;P&gt;This can be hidden using the preprocessor FPP&lt;/P&gt;
&lt;P&gt;#define A FOO%a&lt;BR /&gt;#defineB FOO%b&lt;/P&gt;
&lt;P&gt;place the above in an include file that is not part of the module and is included in your source files.&lt;/P&gt;
&lt;P&gt;But then debugging is a bit awkward (intellipoint won't work and you have to watch FOO%A instead of A)&lt;/P&gt;
&lt;P&gt;Steve,&lt;/P&gt;
&lt;P&gt;Can you look at extending the USE mapping capability to map fields of declared defined types to local variables&lt;/P&gt;
&lt;P&gt;use mod_foo, FOO%A =&amp;gt; A&lt;/P&gt;
&lt;P&gt;Then a user such as Brett could accomplish the mapping with an ugly Fortran include file.&lt;/P&gt;
&lt;P&gt;Alternately, extend EQUIVALENCE to accept a similar syntax (take plenty of barf bags to the next committee meeting when you suggest this).&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Tue, 26 Aug 2008 17:55:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/902003#M80977</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2008-08-26T17:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: sharing module between dll and main program in fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/902004#M80978</link>
      <description>Jim,&lt;BR /&gt;&lt;BR /&gt;What you're asking for is sort of like the ASSOCIATE construct in F2003. The syntax looks like this:&lt;BR /&gt;&lt;BR /&gt;ASSOCIATE (A =&amp;gt; FOO%A)&lt;BR /&gt; ... do things with A that are really FOO%A&lt;BR /&gt;END ASSOCIATE&lt;BR /&gt;&lt;BR /&gt;Intel Fortran 10.1 does not support this, but it will come in the next major release, whenever that is....&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Aug 2008 20:03:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/902004#M80978</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-08-26T20:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: sharing module between dll and main program in fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/902005#M80979</link>
      <description>&lt;P&gt;I tried building the DLL in CVF rather than ifort, and it compiled and linked, but it is not running correctly when calling it from the ifort EXE project - I am getting an error about allocating an array that has already been allocated. This is with everything the same, only now building the DLL with CVF. I am using the CVF calling convention in the ifort projects. Also, because the subroutine in the DLL calls subroutines in the EXE, I had exposed these subroutines in the EXE with DLLEXPORT and included the resulting .LIB in the DLL project. As I said,this worked for the ifort DLL.Could this .LIB be the problem, or maybe the .MODS now being generated by the CVF DLL project? Or should this work and maybe I have an alignment issue or something screwing up the memory?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;----Brett&lt;/P&gt;</description>
      <pubDate>Tue, 26 Aug 2008 20:51:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/902005#M80979</guid>
      <dc:creator>Brett_B_</dc:creator>
      <dc:date>2008-08-26T20:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: sharing module between dll and main program in fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/902006#M80980</link>
      <description>Did you set the "use runtime libraries" setting in the EXE project to the DLL libraries? It should work if you recompiled everything.&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Aug 2008 21:02:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/sharing-module-between-dll-and-main-program-in-fortran/m-p/902006#M80980</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-08-26T21:02:22Z</dc:date>
    </item>
  </channel>
</rss>

