<?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 DLLs and Common block in Intel® Moderncode for Parallel Architectures</title>
    <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/DLLs-and-Common-block/m-p/867316#M2740</link>
    <description>&lt;P&gt;I used Help files in IVF, "Coding Requirements for Sharing Data in DLLs", "Exporting and Importing Common Block Data", where example of appropriate DLLEXPORT directive is included and described. When I create a dll and I put common blocks that I want to be linked to the same common block in my exe program, the common block information does not pass from the exe to the dll.&lt;/P&gt;
&lt;P&gt;How can I declare common block in both the main exe and any dll and having the information passing?&lt;/P&gt;
&lt;P&gt;The code source of the DLL is:&lt;BR /&gt;&lt;STRONG&gt;subroutine&lt;/STRONG&gt; Seta &lt;BR /&gt;&lt;STRONG&gt; use&lt;/STRONG&gt; user32&lt;BR /&gt; &lt;STRONG&gt;use &lt;/STRONG&gt;kernel32&lt;BR /&gt; !DEC$ ATTRIBUTES STDCALL, REFERENCE,ALIAS :"Seta":: Seta&lt;BR /&gt; &lt;STRONG&gt;!DEC$ ATTRIBUTES DLLEXPORT:: Seta, /X/ &lt;BR /&gt;&lt;/STRONG&gt; &lt;STRONG&gt;implicit none&lt;/STRONG&gt; &lt;BR /&gt; &lt;STRONG&gt;common&lt;/STRONG&gt; /X/C,B,A&lt;BR /&gt; &lt;STRONG&gt;real&lt;/STRONG&gt; C,B,A&lt;BR /&gt; A=A+1&lt;BR /&gt; B=B+1&lt;BR /&gt; &lt;STRONG&gt;return&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;end subroutine&lt;/STRONG&gt; Seta&lt;/P&gt;
&lt;P&gt;The subroutine in the main program that uses the DLL is:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;subroutine test&lt;/STRONG&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;use&lt;/STRONG&gt; user32&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;use&lt;/STRONG&gt; kernel32&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;implicit none&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;pointer&lt;/STRONG&gt; (p_seta, seta)&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;integer&lt;/STRONG&gt;(HANDLE) :: dll_handle&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;integer&lt;/STRONG&gt;(BOOL) :: free_status&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;integer&lt;/STRONG&gt; i&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;real&lt;/STRONG&gt; AP&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;common&lt;/STRONG&gt; /X/C,B,A&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;real&lt;/STRONG&gt; C,B,A&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;Interface&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;subroutine&lt;/STRONG&gt; Seta&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;!DEC$ ATTRIBUTES DLLIMPORT:: Seta, /X/ &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;implicit none&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;common&lt;/STRONG&gt; /X/C,B,A&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;real&lt;/STRONG&gt; C,B,A&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;end subroutine&lt;/STRONG&gt; Seta&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;end interface&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; !==========================================!&lt;/P&gt;
&lt;P&gt; dll_handle = LoadLibrary ("DLL_a.dll"C)&lt;/P&gt;
&lt;P&gt; ! Check for errors&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;if&lt;/STRONG&gt; (dll_handle == NULL) &lt;STRONG&gt;then&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; ! Failure&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;stop&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;end if&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; p_seta = GetProcAddress (dll_handle, "Seta"C)&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;if&lt;/STRONG&gt; (p_Seta == NULL) &lt;STRONG&gt;then&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; ! Failure&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;stop&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;end if&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; ! Now call the function&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;call&lt;/STRONG&gt; seta ! the value of A in the DLL is 1&lt;/P&gt;
&lt;P&gt; Ap=A ! the value of A in the subroutine test is 0 so Ap=0&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;free_status = freelibrary(p_seta)&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;end subroutine Test &lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;If you have a solution, pelase send me a simple example.&lt;BR /&gt;thanks in advance&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 13 Jan 2009 08:59:39 GMT</pubDate>
    <dc:creator>moncef</dc:creator>
    <dc:date>2009-01-13T08:59:39Z</dc:date>
    <item>
      <title>DLLs and Common block</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/DLLs-and-Common-block/m-p/867316#M2740</link>
      <description>&lt;P&gt;I used Help files in IVF, "Coding Requirements for Sharing Data in DLLs", "Exporting and Importing Common Block Data", where example of appropriate DLLEXPORT directive is included and described. When I create a dll and I put common blocks that I want to be linked to the same common block in my exe program, the common block information does not pass from the exe to the dll.&lt;/P&gt;
&lt;P&gt;How can I declare common block in both the main exe and any dll and having the information passing?&lt;/P&gt;
&lt;P&gt;The code source of the DLL is:&lt;BR /&gt;&lt;STRONG&gt;subroutine&lt;/STRONG&gt; Seta &lt;BR /&gt;&lt;STRONG&gt; use&lt;/STRONG&gt; user32&lt;BR /&gt; &lt;STRONG&gt;use &lt;/STRONG&gt;kernel32&lt;BR /&gt; !DEC$ ATTRIBUTES STDCALL, REFERENCE,ALIAS :"Seta":: Seta&lt;BR /&gt; &lt;STRONG&gt;!DEC$ ATTRIBUTES DLLEXPORT:: Seta, /X/ &lt;BR /&gt;&lt;/STRONG&gt; &lt;STRONG&gt;implicit none&lt;/STRONG&gt; &lt;BR /&gt; &lt;STRONG&gt;common&lt;/STRONG&gt; /X/C,B,A&lt;BR /&gt; &lt;STRONG&gt;real&lt;/STRONG&gt; C,B,A&lt;BR /&gt; A=A+1&lt;BR /&gt; B=B+1&lt;BR /&gt; &lt;STRONG&gt;return&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;end subroutine&lt;/STRONG&gt; Seta&lt;/P&gt;
&lt;P&gt;The subroutine in the main program that uses the DLL is:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;subroutine test&lt;/STRONG&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;use&lt;/STRONG&gt; user32&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;use&lt;/STRONG&gt; kernel32&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;implicit none&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;pointer&lt;/STRONG&gt; (p_seta, seta)&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;integer&lt;/STRONG&gt;(HANDLE) :: dll_handle&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;integer&lt;/STRONG&gt;(BOOL) :: free_status&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;integer&lt;/STRONG&gt; i&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;real&lt;/STRONG&gt; AP&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;common&lt;/STRONG&gt; /X/C,B,A&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;real&lt;/STRONG&gt; C,B,A&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;Interface&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;subroutine&lt;/STRONG&gt; Seta&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;!DEC$ ATTRIBUTES DLLIMPORT:: Seta, /X/ &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;implicit none&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;common&lt;/STRONG&gt; /X/C,B,A&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;real&lt;/STRONG&gt; C,B,A&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;end subroutine&lt;/STRONG&gt; Seta&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;end interface&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; !==========================================!&lt;/P&gt;
&lt;P&gt; dll_handle = LoadLibrary ("DLL_a.dll"C)&lt;/P&gt;
&lt;P&gt; ! Check for errors&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;if&lt;/STRONG&gt; (dll_handle == NULL) &lt;STRONG&gt;then&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; ! Failure&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;stop&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;end if&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; p_seta = GetProcAddress (dll_handle, "Seta"C)&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;if&lt;/STRONG&gt; (p_Seta == NULL) &lt;STRONG&gt;then&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; ! Failure&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;stop&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;end if&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; ! Now call the function&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;call&lt;/STRONG&gt; seta ! the value of A in the DLL is 1&lt;/P&gt;
&lt;P&gt; Ap=A ! the value of A in the subroutine test is 0 so Ap=0&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;free_status = freelibrary(p_seta)&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;end subroutine Test &lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;If you have a solution, pelase send me a simple example.&lt;BR /&gt;thanks in advance&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jan 2009 08:59:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/DLLs-and-Common-block/m-p/867316#M2740</guid>
      <dc:creator>moncef</dc:creator>
      <dc:date>2009-01-13T08:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: DLLs and Common block</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/DLLs-and-Common-block/m-p/867317#M2741</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
Check the examples which come with your compiler. Don't try to mix conventions from different eras. Look up examples discussed on the Windows Fortran forum, and ask questions there.&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Jan 2009 12:41:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/DLLs-and-Common-block/m-p/867317#M2741</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2009-01-13T12:41:49Z</dc:date>
    </item>
  </channel>
</rss>

