<?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 Quote:ianh wrote: in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Submodules-generate-LNK2005-error/m-p/1105777#M127889</link>
    <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;ianh wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Which version of the compiler are you using?&lt;/P&gt;

&lt;P&gt;How are you compiling and linking?&lt;/P&gt;

&lt;P&gt;It "works for me" with the current release (16.0.3.207) at the command line.&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;@IanH: I am using 2016.3.207&amp;nbsp;through MS&amp;nbsp;Visual&amp;nbsp;Studio Community Edition 2015.&amp;nbsp;I have had success with submodules as long as there is one level of dependency i.e. in my example, only submodule A is present. I did some experimenting with the settings and I found that I was using a calling convention of /iface:cvf. Changing the calling convention to default for this example eliminates the link error and the program runs fine. The problem is that my main project for which the submodule is being developed only works with the /iface:cvf calling convention.&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jun 2016 16:56:22 GMT</pubDate>
    <dc:creator>avinashs</dc:creator>
    <dc:date>2016-06-23T16:56:22Z</dc:date>
    <item>
      <title>Submodules generate LNK2005 error</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Submodules-generate-LNK2005-error/m-p/1105774#M127886</link>
      <description>&lt;P&gt;I have a parent module M that is extended in two submodules A and B. However, compilation generates the error: &lt;FONT size="1"&gt;error LNK2005: _M already defined in submodule_B.obj. Please &lt;/FONT&gt;advise as the documentation on submodules is very limited.&lt;/P&gt;

&lt;P&gt;The full code is as below and organized in three files.&lt;/P&gt;

&lt;P&gt;FILE 1&lt;/P&gt;

&lt;P&gt;module M&lt;/P&gt;

&lt;P&gt;&amp;nbsp; interface&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; module subroutine A1()&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end subroutine A1&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; module subroutine A2()&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end subroutine A2&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; module subroutine B1()&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end subroutine B1&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; module subroutine B2()&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end subroutine B2&lt;/P&gt;

&lt;P&gt;&amp;nbsp; end interface&lt;/P&gt;

&lt;P&gt;contains&lt;/P&gt;

&lt;P&gt;&amp;nbsp; subroutine C()&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; call A1()&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; call A2()&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; call B1()&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; call B2()&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; read *&lt;BR /&gt;
	&amp;nbsp; end subroutine C&lt;/P&gt;

&lt;P&gt;end module M&lt;/P&gt;

&lt;P&gt;FILE 2&lt;/P&gt;

&lt;P&gt;submodule (M) A&lt;/P&gt;

&lt;P&gt;contains&lt;/P&gt;

&lt;P&gt;&amp;nbsp; module subroutine A1()&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; print *, 'In A1'&lt;BR /&gt;
	&amp;nbsp; end subroutine A1&lt;/P&gt;

&lt;P&gt;&amp;nbsp; module subroutine A2()&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; print *, 'In A2'&lt;BR /&gt;
	&amp;nbsp; end subroutine A2&lt;BR /&gt;
	&amp;nbsp;&lt;BR /&gt;
	end submodule A&lt;/P&gt;

&lt;P&gt;FILE 3&lt;/P&gt;

&lt;P&gt;submodule (M) B&lt;/P&gt;

&lt;P&gt;contains&lt;/P&gt;

&lt;P&gt;&amp;nbsp; module subroutine B1()&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; print *, 'In B1'&lt;BR /&gt;
	&amp;nbsp; end subroutine B1&lt;/P&gt;

&lt;P&gt;&amp;nbsp; module subroutine B2()&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; print *, 'In B2'&lt;BR /&gt;
	&amp;nbsp; end subroutine B2&lt;BR /&gt;
	&amp;nbsp;&lt;BR /&gt;
	end submodule B&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 00:48:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Submodules-generate-LNK2005-error/m-p/1105774#M127886</guid>
      <dc:creator>avinashs</dc:creator>
      <dc:date>2016-06-23T00:48:54Z</dc:date>
    </item>
    <item>
      <title>Which version of the compiler</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Submodules-generate-LNK2005-error/m-p/1105775#M127887</link>
      <description>&lt;P&gt;Which version of the compiler are you using?&lt;/P&gt;

&lt;P&gt;How are you compiling and linking?&lt;/P&gt;

&lt;P&gt;It "works for me" with the current release (16.0.3.207) at the command line.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 01:37:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Submodules-generate-LNK2005-error/m-p/1105775#M127887</guid>
      <dc:creator>IanH</dc:creator>
      <dc:date>2016-06-23T01:37:52Z</dc:date>
    </item>
    <item>
      <title>I wouldn't recommend trying</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Submodules-generate-LNK2005-error/m-p/1105776#M127888</link>
      <description>&lt;P&gt;I wouldn't recommend trying to use Submodules with anything other than the latest compiler. (16 update 3) as it is a new feature and there have been a number of problems.&lt;/P&gt;

&lt;P&gt;On a separate note I can't see any advantage/point in having a contains section in the parent module. Any thoughts?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 09:34:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Submodules-generate-LNK2005-error/m-p/1105776#M127888</guid>
      <dc:creator>andrew_4619</dc:creator>
      <dc:date>2016-06-23T09:34:56Z</dc:date>
    </item>
    <item>
      <title>Quote:ianh wrote:</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Submodules-generate-LNK2005-error/m-p/1105777#M127889</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;ianh wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Which version of the compiler are you using?&lt;/P&gt;

&lt;P&gt;How are you compiling and linking?&lt;/P&gt;

&lt;P&gt;It "works for me" with the current release (16.0.3.207) at the command line.&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;@IanH: I am using 2016.3.207&amp;nbsp;through MS&amp;nbsp;Visual&amp;nbsp;Studio Community Edition 2015.&amp;nbsp;I have had success with submodules as long as there is one level of dependency i.e. in my example, only submodule A is present. I did some experimenting with the settings and I found that I was using a calling convention of /iface:cvf. Changing the calling convention to default for this example eliminates the link error and the program runs fine. The problem is that my main project for which the submodule is being developed only works with the /iface:cvf calling convention.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 16:56:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Submodules-generate-LNK2005-error/m-p/1105777#M127889</guid>
      <dc:creator>avinashs</dc:creator>
      <dc:date>2016-06-23T16:56:22Z</dc:date>
    </item>
    <item>
      <title>I suspect this maybe related</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Submodules-generate-LNK2005-error/m-p/1105778#M127890</link>
      <description>&lt;P&gt;I suspect this maybe related to&amp;nbsp;https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/610575 which at the end of the day is a name decoration calling convention issue.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 17:05:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Submodules-generate-LNK2005-error/m-p/1105778#M127890</guid>
      <dc:creator>andrew_4619</dc:creator>
      <dc:date>2016-06-23T17:05:08Z</dc:date>
    </item>
    <item>
      <title>No, this is a different</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Submodules-generate-LNK2005-error/m-p/1105779#M127891</link>
      <description>&lt;P&gt;No, this is a different problem peculiar to using STDCALL. I have a pretty good idea why this happens, but it's a bug. I will report it to the developers.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 17:59:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Submodules-generate-LNK2005-error/m-p/1105779#M127891</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2016-06-23T17:59:16Z</dc:date>
    </item>
    <item>
      <title>Escalated as issue</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Submodules-generate-LNK2005-error/m-p/1105780#M127892</link>
      <description>&lt;P&gt;Escalated as issue&amp;nbsp;DPD200412052. I was hoping this could be worked around by adding !DEC$ ATTRIBUTES CVF to each of the procedures (has to be done in the module and the submodule) but that triggers a different bug that I will report separately.&lt;/P&gt;

&lt;P&gt;For now you will have to avoid submodules when using CVF interfaces.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 18:27:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Submodules-generate-LNK2005-error/m-p/1105780#M127892</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2016-06-23T18:27:24Z</dc:date>
    </item>
    <item>
      <title>Andrew was in fact right -</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Submodules-generate-LNK2005-error/m-p/1105781#M127893</link>
      <description>&lt;P&gt;Andrew was in fact right - this is related to one of the issues in that other thread. But unlike there, MODULE PROCEDURE is not a workaround using ATTRIBUTES CVF. However, the following DOES work:&lt;/P&gt;

&lt;P&gt;In the parent module interfaces, use:&lt;/P&gt;

&lt;P&gt;!DEC$ ATTRIBUTES STDCALL,REFERENCE,DECORATE,ALIAS:"A1" :: A1&lt;/P&gt;

&lt;P&gt;Where A1 is replaced with the actual routine name.&lt;/P&gt;

&lt;P&gt;Then in the submodules, don't repeat the subroutine or function but use MODULE PROCEDURE instead. For example:&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;submodule (M) A

contains

  module procedure A1
    print *, 'In A1'
  end procedure A1

  module procedure A2
    print *, 'In A2'
  end procedure A2
 
end submodule A&lt;/PRE&gt;

&lt;P&gt;This works.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 18:56:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Submodules-generate-LNK2005-error/m-p/1105781#M127893</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2016-06-23T18:56:09Z</dc:date>
    </item>
    <item>
      <title>Thank-you everyone for your</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Submodules-generate-LNK2005-error/m-p/1105782#M127894</link>
      <description>&lt;P&gt;Thank-you everyone for your insight and help. I have had success with submodules with the /iface:cvf option. However, in all those cases there was only level of dependency. To be clear, the code above would have module M and submodule A with M as its ancestor but no submodule B. I checked this variant of the test example and it works with both the default and /iface:cvf options. It is only when a second submodule B also with M as its ancestor is added that the error occurs with /iface:cvf option. The default option works well in both cases.&lt;/P&gt;

&lt;P&gt;Just a side-note for all those who use Emacs 24.4.1 as an editor ... The automatic indenting option in Emacs does not work correctly&amp;nbsp;with submodules and associate constructs. It adds/changes the "end" constructs&amp;nbsp;in a manner that&amp;nbsp;generates other compiler errors so please watch out for that when using submodules.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 18:57:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Submodules-generate-LNK2005-error/m-p/1105782#M127894</guid>
      <dc:creator>avinashs</dc:creator>
      <dc:date>2016-06-23T18:57:04Z</dc:date>
    </item>
  </channel>
</rss>

