<?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: Problem with COMMON in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842398#M60367</link>
    <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;FileNameLength isn't a variable - you have declared it as a PARAMETER value and are attempting to assign a value to it twice.&lt;/P&gt;
&lt;P&gt;Also make sure you aren't mixing up 250 and 255 for your name lengths&lt;/P&gt;</description>
    <pubDate>Wed, 19 Oct 2005 16:13:25 GMT</pubDate>
    <dc:creator>greldak</dc:creator>
    <dc:date>2005-10-19T16:13:25Z</dc:date>
    <item>
      <title>Problem with COMMON</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842394#M60363</link>
      <description>&lt;DIV&gt;My code is old and is using lots of variables in different places to holdfile names.&lt;/DIV&gt;
&lt;DIV&gt;At present all these variables are dimensioned to 80.&lt;/DIV&gt;
&lt;DIV&gt;I want to increase this to say 255.&lt;/DIV&gt;
&lt;DIV&gt;Therefore to make it supportable in the future I want to define one varialbe, say FileNameLength as 255.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;integer,parameter:: FileNameLength=250&lt;BR /&gt;character*(FileNameLength) cFileName&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;This works OK on its own, but I get problems with duplicate definitions with 'COMMON' satements which are used to dimension many of the variables.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;What is the solution to this?&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Thanks,&lt;/DIV&gt;
&lt;DIV&gt;David&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 18 Oct 2005 22:23:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842394#M60363</guid>
      <dc:creator>davidgraham</dc:creator>
      <dc:date>2005-10-18T22:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with COMMON</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842395#M60364</link>
      <description>I don't quite understand the nature of the problem.  There's nothing wrong with what you have shown so far.  Can you show a self-contained example that demonstrates the problem?</description>
      <pubDate>Tue, 18 Oct 2005 22:32:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842395#M60364</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2005-10-18T22:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with COMMON</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842396#M60365</link>
      <description>&lt;P&gt;Perhaps you are including several header files some of which may declare the same common block but with different/different allocations of variables?&lt;/P&gt;
&lt;P&gt;Also your given declaration for cFileName is not in a COMMON.&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 19 Oct 2005 05:40:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842396#M60365</guid>
      <dc:creator>jim_dempsey</dc:creator>
      <dc:date>2005-10-19T05:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with COMMON</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842397#M60366</link>
      <description>&lt;P&gt;The problem is that I have FileNameLength defined in a common block AND in the program.&lt;/P&gt;
&lt;P&gt;The program has&lt;/P&gt;
&lt;P&gt;include 'fnames.gcb'&lt;/P&gt;
&lt;P&gt;integer,parameter:: FileNameLength=250&lt;BR /&gt;character*(FileNameLength) cFileName&lt;/P&gt;
&lt;P&gt;etc...&lt;/P&gt;
&lt;P&gt;The common block is in file 'Fnames.gcb'&lt;/P&gt;
&lt;P&gt;integer,parameter:: FileNameLength=250&lt;BR /&gt;character*(FileNameLength) cgbf,CCOD&lt;BR /&gt;common/fnames/ cgbf,CCOD&lt;/P&gt;
&lt;P&gt;The error message is:&lt;/P&gt;
&lt;P&gt;This name has already been assigned a data type. [FILENAMELENGTH]&lt;/P&gt;
&lt;DIV&gt;as FileNameLength is defined both in the program &amp;amp; in the common block.&lt;/DIV&gt;
&lt;DIV&gt;I have triedFileNameLength in a Module and using USE.&lt;/DIV&gt;
&lt;DIV&gt;There must be a simple way of defining a variable that I can use in the program and in a common block.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Hope this helps,&lt;/DIV&gt;
&lt;DIV&gt;David&lt;/DIV&gt;</description>
      <pubDate>Wed, 19 Oct 2005 15:55:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842397#M60366</guid>
      <dc:creator>davidgraham</dc:creator>
      <dc:date>2005-10-19T15:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with COMMON</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842398#M60367</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;FileNameLength isn't a variable - you have declared it as a PARAMETER value and are attempting to assign a value to it twice.&lt;/P&gt;
&lt;P&gt;Also make sure you aren't mixing up 250 and 255 for your name lengths&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2005 16:13:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842398#M60367</guid>
      <dc:creator>greldak</dc:creator>
      <dc:date>2005-10-19T16:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with COMMON</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842399#M60368</link>
      <description>More simply, you are declaring the name FileNameLength twice, which is not allowed.  Remove one of the definitions.</description>
      <pubDate>Wed, 19 Oct 2005 20:09:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842399#M60368</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2005-10-19T20:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with COMMON</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842400#M60369</link>
      <description>&lt;P&gt;I want to use the variable 'FileNameLength' in several Common blocks.&lt;/P&gt;
&lt;P&gt;I have tried removing them, to leave only one, but get the error messages:&lt;/P&gt;
&lt;P&gt;'A COMMON block data object must not be an automatic object.'&lt;/P&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;P&gt;'This name has not been given an explicit type. [FILENAMELENGTH]'&lt;/P&gt;
&lt;P&gt;I'm getting confused,&lt;/P&gt;
&lt;P&gt;David&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2005 20:46:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842400#M60369</guid>
      <dc:creator>davidgraham</dc:creator>
      <dc:date>2005-10-19T20:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with COMMON</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842401#M60370</link>
      <description>The best way to do it is to have it in the include file (just as you have it now) and ONLY include the file wherever the symbols are needed. You appear to have a mixture of include and re-spelling of definitions.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.xeffort.com" target="_blank"&gt;Jugoslav&lt;/A&gt;</description>
      <pubDate>Wed, 19 Oct 2005 21:03:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842401#M60370</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2005-10-19T21:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with COMMON</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842402#M60371</link>
      <description>&lt;P&gt;I'm not sure if I follow you.&lt;/P&gt;
&lt;P&gt;I have made a new common block called fnl.gcb:&lt;/P&gt;
&lt;P&gt;integer:: FileNameLength=250&lt;BR /&gt;common/FNL/FileNameLength&lt;/P&gt;
&lt;P&gt;It wouldn't compile with 'Parameter'.&lt;/P&gt;
&lt;P&gt;Then in each program that needs this variable or has an include file that needs this variable I have added include 'fnl.gcb'.&lt;/P&gt;
&lt;P&gt;When I compile, I get an error on the first program which containsa common block.&lt;/P&gt;
&lt;P&gt;Error: A COMMON block data object must not be an automatic object.&lt;/P&gt;
&lt;P&gt;I don't know what that error messagemeans.&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;I don't think I have any spelling problems.&lt;/P&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;David&lt;/DIV&gt;</description>
      <pubDate>Wed, 19 Oct 2005 21:34:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842402#M60371</guid>
      <dc:creator>davidgraham</dc:creator>
      <dc:date>2005-10-19T21:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with COMMON</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842403#M60372</link>
      <description>Your first version of .gcb file was perfectly fine. This one won't work -- you need a PARAMETER to declare length of a character within the common block (that's what compiler tells you that "COMMON block data object must not be an automatic object"), and you can't put a parameter within a common block, because it's not a variable.&lt;BR /&gt;&lt;BR /&gt;Your original problem was that you defined FileNameLength twice, once in .gcb file and other time again in code (.for file) (that's what I meant by "spelled"). The solution was just to remove the re-declarations.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.xeffort.com" target="_blank"&gt;Jugoslav&lt;/A&gt;</description>
      <pubDate>Wed, 19 Oct 2005 21:51:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842403#M60372</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2005-10-19T21:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with COMMON</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842404#M60373</link>
      <description>&lt;P&gt;David,&lt;/P&gt;
&lt;P&gt;If you can, why not dispense with COMMON. You can do this by creating a module containing the arrays, variables and constant parameters. I've done this on a Solution with 11 project files and ~700 source modules. It is a bit of work but you can do it incrimentaly. You could start with&lt;/P&gt;
&lt;P&gt;-----------------------------&lt;/P&gt;
&lt;DIV&gt;! mod_common.f90&lt;/DIV&gt;
&lt;DIV&gt;module mod_common&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt; integer,parameter:: FileNameLength=250&lt;BR /&gt; character*(FileNameLength) cFileName&lt;/DIV&gt;
&lt;DIV&gt;end module mod_common&lt;/DIV&gt;
&lt;DIV&gt;-----------------------&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Then insert "use mod_common" at the top of the routines that use FileNameLength or cFileName.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Then as you find more items that you would like better control over you can place them in there too.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;You will find that this is a relatively easy way to convert a fixed dimension array in COMMON to an allocatable array. No source code changes other than for the COMMON/mod_common, the use mod_common, and the allocation in the init code. All array references remain untouched.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Jim Dempsey&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 19 Oct 2005 22:33:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842404#M60373</guid>
      <dc:creator>jim_dempsey</dc:creator>
      <dc:date>2005-10-19T22:33:11Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with COMMON</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842405#M60374</link>
      <description>&lt;DIV&gt;I have created the module fnl:&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Module fnl&lt;BR /&gt;! file name length&lt;BR /&gt;integer,parameter:: FileNameLength=250&lt;BR /&gt;end module&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Then added 'use fnl' to any procedures that require it.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;The common blocks defining the variable just then need:&lt;/DIV&gt;
&lt;DIV&gt;character*(FileNameLength) cgbf&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;I think that's it sorted, thanks.&lt;/DIV&gt;
&lt;DIV&gt;David&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 20 Oct 2005 17:54:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842405#M60374</guid>
      <dc:creator>davidgraham</dc:creator>
      <dc:date>2005-10-20T17:54:07Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with COMMON</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842406#M60375</link>
      <description>&lt;DIV&gt;Keep in mind that you can start placing more features into the module section. Converting an array from fixed size in common to allocatable in the module is relatively easy to do (once you insert the "use foo"). Also it makes for easier code maintenance. Especialy when you compile one set of subroutines with one set of includes with COMMONs and a different set of subroutimes with a different set of includes with COMMONs only to find during debugging that the common COMMONs aren't quite the same. Using modules forces a singular instance of a formerly named variable in COMMON.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;One of the steps along the learning curve to using modules is often the include files for COMMON use EQUIVELENCE.. To overcome this use UNION&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt; COMMON Array, Array1&lt;/DIV&gt;
&lt;DIV&gt; DIMENSION Array(10,10), Array1(100)&lt;/DIV&gt;
&lt;DIV&gt; EQUIVELENCE (Array(1,1) Array1(1))&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;becomes&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt; union&lt;/DIV&gt;
&lt;DIV&gt; map&lt;/DIV&gt;
&lt;DIV&gt; real :: Array(10,10)&lt;/DIV&gt;
&lt;DIV&gt; end map&lt;/DIV&gt;
&lt;DIV&gt; map&lt;/DIV&gt;
&lt;DIV&gt; real :: Array1(100)&lt;/DIV&gt;
&lt;DIV&gt; end map&lt;/DIV&gt;
&lt;DIV&gt; end union&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Then as you progress through your changes that some routines may have a common array(10,10) and others use the same name but different extents or rank. To easily overcome this use a derrived type and use the Fortran Preprocessor with #define.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;module foo&lt;/DIV&gt;
&lt;DIV&gt;...&lt;/DIV&gt;
&lt;DIV&gt;type badabing&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt; union&lt;/DIV&gt;
&lt;DIV&gt; map&lt;/DIV&gt;
&lt;DIV&gt; real :: Array(10,10)&lt;/DIV&gt;
&lt;DIV&gt; end map&lt;/DIV&gt;
&lt;DIV&gt; map&lt;/DIV&gt;
&lt;DIV&gt; real :: Array1(100)&lt;/DIV&gt;
&lt;DIV&gt; end map&lt;/DIV&gt;
&lt;DIV&gt; end union&lt;/DIV&gt;
&lt;DIV&gt;end type badabing&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;type badabang&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt; union&lt;/DIV&gt;
&lt;DIV&gt; map&lt;/DIV&gt;
&lt;DIV&gt; real :: Array(10,10)&lt;/DIV&gt;
&lt;DIV&gt; end map&lt;/DIV&gt;
&lt;DIV&gt; map&lt;/DIV&gt;
&lt;DIV&gt; real :: Array1(100)&lt;/DIV&gt;
&lt;DIV&gt; end map&lt;/DIV&gt;
&lt;DIV&gt; end union&lt;/DIV&gt;
&lt;DIV&gt;end type badabang&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;type(badabing) :: bing&lt;/DIV&gt;
&lt;DIV&gt;type(badabang) :: bang&lt;/DIV&gt;
&lt;DIV&gt;end module foo&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Then in the include files that are used in the souce files that require the badabing have&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;#define Array badabing.Array&lt;/DIV&gt;
&lt;DIV&gt;#define Array1 badaging.Array1&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;That is it. No souce code changes to differentiate the references. You do have to select the appropriate #define but that is easier and less error prone that search and replace.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Jim Dempsey&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 21 Oct 2005 00:21:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842406#M60375</guid>
      <dc:creator>jim_dempsey</dc:creator>
      <dc:date>2005-10-21T00:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with COMMON</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842407#M60376</link>
      <description>&lt;P&gt;oops us&lt;/P&gt;
&lt;P&gt;#define Array bing.Array&lt;/P&gt;
&lt;P&gt;#define Array1 bing.Array1&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 21 Oct 2005 00:23:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-COMMON/m-p/842407#M60376</guid>
      <dc:creator>jim_dempsey</dc:creator>
      <dc:date>2005-10-21T00:23:30Z</dc:date>
    </item>
  </channel>
</rss>

