<?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: Modules &amp; multiple source files in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Modules-multiple-source-files/m-p/831770#M52848</link>
    <description>Don't worry, I don't intend to move back to the 70's. I totally agree with you regarding include statements and interface blocks. I will try to find a neater way of partitioning the code into modules.&lt;BR /&gt;&lt;BR /&gt;My code was originally contained in asingle file. These problems only arose when I split it into a number of separate files (the source code itself was identical). What does the compiler do differently when it uses multiple source files which would lead to this problem?&lt;BR /&gt;&lt;BR /&gt;Thanks !</description>
    <pubDate>Sat, 07 May 2005 17:50:56 GMT</pubDate>
    <dc:creator>andrew_line</dc:creator>
    <dc:date>2005-05-07T17:50:56Z</dc:date>
    <item>
      <title>Modules &amp; multiple source files</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Modules-multiple-source-files/m-p/831766#M52844</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have several modules, each of which is stored in a separate file. Each module contains a number of routines which 'use' data or routines from the other modules. I'm finding that regardless of how I include these files in my main source code, it can't compile. &lt;BR /&gt;&lt;BR /&gt;Consider this simple example. In 'fileA.f90' I have this,&lt;BR /&gt;&lt;BR /&gt;MODULE A&lt;BR /&gt;  REAL:: varA&lt;BR /&gt;CONTAINS&lt;BR /&gt;&lt;BR /&gt;  SUBROUTINE MULTIPLY(result)&lt;BR /&gt;  USE B&lt;BR /&gt;  REAL:: result&lt;BR /&gt;  result = varA * varB&lt;BR /&gt;  END SUBROUTINE&lt;BR /&gt;&lt;BR /&gt;END MODULE&lt;BR /&gt;&lt;BR /&gt;.... and in 'fileB.f90' I have this,&lt;BR /&gt;&lt;BR /&gt;MODULE B&lt;BR /&gt;  REAL:: varB&lt;BR /&gt;CONTAINS&lt;BR /&gt;&lt;BR /&gt;  SUBROUTINE ADD(result)&lt;BR /&gt;  USE A&lt;BR /&gt;  REAL:: result&lt;BR /&gt;  result = varA + varB&lt;BR /&gt;  END SUBROUTINE&lt;BR /&gt;&lt;BR /&gt;END MODULE&lt;BR /&gt;&lt;BR /&gt;and in my 'main.f90' file I might have&lt;BR /&gt;&lt;BR /&gt;PROGRAM MAIN&lt;BR /&gt;&lt;BR /&gt;INCLUDE 'fileA.f90'&lt;BR /&gt;INCLUDE 'fileB.f90'&lt;BR /&gt;REAL::  answer&lt;BR /&gt;&lt;BR /&gt;CALL ADD(answer)&lt;BR /&gt;CALL MULTIPLY(answer)&lt;BR /&gt;&lt;BR /&gt;END PROGRAM&lt;BR /&gt;&lt;BR /&gt;In order for the compiler to main.exe it first needs A.mod B.mod. Now, in order to compile module A into A.mod, the compiler must have access to B.mod. However, B.mod can't be created until A.mod exists! &lt;BR /&gt;&lt;BR /&gt;How do I resolve this problem ?</description>
      <pubDate>Sat, 07 May 2005 00:20:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Modules-multiple-source-files/m-p/831766#M52844</guid>
      <dc:creator>andrew_line</dc:creator>
      <dc:date>2005-05-07T00:20:42Z</dc:date>
    </item>
    <item>
      <title>Re: Modules &amp; multiple source files</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Modules-multiple-source-files/m-p/831767#M52845</link>
      <description>This sort of circular dependency will give dependency analyzers fits.  The most appropriate solution is to put variables varA and varB in a module C which is USEd from A and B.&lt;BR /&gt;&lt;BR /&gt;Also, you should not be using INCLUDE here.  Use the USE statement.</description>
      <pubDate>Sat, 07 May 2005 01:07:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Modules-multiple-source-files/m-p/831767#M52845</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2005-05-07T01:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: Modules &amp; multiple source files</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Modules-multiple-source-files/m-p/831768#M52846</link>
      <description>Thanks Steve,&lt;BR /&gt;&lt;BR /&gt;I see the sense in your solution, but surely this limits the benefits of using modules in the first place.&lt;BR /&gt;&lt;BR /&gt;If I were to create a large code which could logically be split up into a number of components, it would be sensible to separate them out into modules. Obviously these components will have to speak to each other at some point and hence it would make sense to create a number of interfacing routines to allow this to happen. In my model I 'contain' these routines within each module (which may be the source of the problem). However, if this model were to contain only a small number of components, surely it could contain many of these circular dependencies.&lt;BR /&gt;&lt;BR /&gt;Is there no way of predefining these troublesome function calls as one would in C/C++ headers?</description>
      <pubDate>Sat, 07 May 2005 01:38:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Modules-multiple-source-files/m-p/831768#M52846</guid>
      <dc:creator>andrew_line</dc:creator>
      <dc:date>2005-05-07T01:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: Modules &amp; multiple source files</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Modules-multiple-source-files/m-p/831769#M52847</link>
      <description>No, I don't see that it limits the benefits.  If you want the C way, then use INCLUDE and INTERFACE blocks, but that's a step back to the 1970s, in my view.&lt;BR /&gt;&lt;BR /&gt;There are a number of ways to organize things so that you don't have circular dependencies. In your case, it might make more sense to put the routines in the same module rather than separate modules, if they have to call each other.</description>
      <pubDate>Sat, 07 May 2005 02:00:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Modules-multiple-source-files/m-p/831769#M52847</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2005-05-07T02:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Modules &amp; multiple source files</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Modules-multiple-source-files/m-p/831770#M52848</link>
      <description>Don't worry, I don't intend to move back to the 70's. I totally agree with you regarding include statements and interface blocks. I will try to find a neater way of partitioning the code into modules.&lt;BR /&gt;&lt;BR /&gt;My code was originally contained in asingle file. These problems only arose when I split it into a number of separate files (the source code itself was identical). What does the compiler do differently when it uses multiple source files which would lead to this problem?&lt;BR /&gt;&lt;BR /&gt;Thanks !</description>
      <pubDate>Sat, 07 May 2005 17:50:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Modules-multiple-source-files/m-p/831770#M52848</guid>
      <dc:creator>andrew_line</dc:creator>
      <dc:date>2005-05-07T17:50:56Z</dc:date>
    </item>
    <item>
      <title>Re: Modules &amp; multiple source files</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Modules-multiple-source-files/m-p/831771#M52849</link>
      <description>The compiler itself doesn't care about anything except that the .mod file for any module referenced is already there when it compiles the USE.  But if compiling module A depends on module B having been compiled, and module B depends on module A, there's no way to satisfy the compiler on this.  It also will cause any build dependency analyzer to have fits.&lt;BR /&gt;&lt;BR /&gt;There are ways to "fake out" the compiler by declaring one of the variables with the EXTERN attribute and an ALIAS that has the properly decorated external name of the module variable.  I really, really don't recommend you go this route.</description>
      <pubDate>Sat, 07 May 2005 19:21:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Modules-multiple-source-files/m-p/831771#M52849</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2005-05-07T19:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: Modules &amp; multiple source files</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Modules-multiple-source-files/m-p/831772#M52850</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;I do not agree with the next statement:&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;"&lt;EM&gt;If I were to create a large code which could logically be split up into a number of components, it would be sensible to separate them out into modules."&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;I have seen before the idea to put all files into modules, but I think thatit is not sensible to use this method when you want to split up a large program.&lt;/DIV&gt;
&lt;DIV&gt;I think it is sensible to split up a large program in &lt;STRONG&gt;functional parts&lt;/STRONG&gt;. These functional parts should be programmed as &lt;STRONG&gt;routines&lt;/STRONG&gt; (subroutines or functions). It is an other point where you put thse routines. &lt;/DIV&gt;
&lt;DIV&gt;In my opinion, you could can do one of the following:&lt;/DIV&gt;
&lt;OL&gt;
&lt;LI&gt;Put each routine in a separate file of which the file name is directly related to the routine name (e.g. routine &lt;EM&gt;xxx&lt;/EM&gt; in file &lt;EM&gt;xxx.&lt;/EM&gt;90)&lt;/LI&gt;
&lt;LI&gt;Collect some functional relatedroutines (short one's) in one file with a name related to the function&lt;/LI&gt;
&lt;LI&gt;Put some functional related routines in a module after the CONTAINS-statement.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;I always use a mix of the three possibilities in one program.&lt;/P&gt;
&lt;P&gt;I don't prefer option 3, because all routines which use the module (by calling "use &lt;EM&gt;module-name") &lt;/EM&gt;will be re-compiled when you modify one of the routines in the module. Option 3 is needed when you use for example module procedures. Further I use module only for declarations of variables that are used in various routines.&lt;/P&gt;
&lt;P&gt;Guus&lt;/P&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 09 May 2005 15:56:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Modules-multiple-source-files/m-p/831772#M52850</guid>
      <dc:creator>nijhuis</dc:creator>
      <dc:date>2005-05-09T15:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: Modules &amp; multiple source files</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Modules-multiple-source-files/m-p/831773#M52851</link>
      <description>In my experience, I see two ways to solve this problem :&lt;BR /&gt;1 - Separate A and B modules into data and functions modules &lt;BR /&gt;   "file a_data.f90"&lt;BR /&gt;    MODULE A_DATA&lt;BR /&gt;    REAL:: varA&lt;BR /&gt;    END MODULE&lt;BR /&gt;&lt;BR /&gt;   "file a.f90"&lt;BR /&gt;    MODULE A&lt;BR /&gt;    USE A_DATA&lt;BR /&gt;    CONTAINS&lt;BR /&gt;&lt;BR /&gt;    SUBROUTINE MULTIPLY(result)&lt;BR /&gt;    USE B_DATA&lt;BR /&gt;    REAL:: result&lt;BR /&gt;    result = varA * varB&lt;BR /&gt;    END SUBROUTINE&lt;BR /&gt;&lt;BR /&gt;    and so on.&lt;BR /&gt;&lt;BR /&gt;2 - If A and B modules are cross dependent, think about merge them&lt;BR /&gt;    into one AB module</description>
      <pubDate>Mon, 09 May 2005 16:02:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Modules-multiple-source-files/m-p/831773#M52851</guid>
      <dc:creator>aliho</dc:creator>
      <dc:date>2005-05-09T16:02:20Z</dc:date>
    </item>
  </channel>
</rss>

