<?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 External Common Blocks problem with OS X in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/External-Common-Blocks-problem-with-OS-X/m-p/752587#M8561</link>
    <description>I'm in the process of porting our Intel Fortran code from Windows to OSX/Linux. I went through Visual Studio and figured out the equivalent compiler flags for OSX/Linux. I am using the evaluation ifort 11 (056). They are as follows:&lt;BR /&gt;&lt;BR /&gt;ifort -nologo -g -noaltparam -fpscomp nolibs -save -zero -align rec1byte -fpconstant -traceback -check bounds -threads&lt;BR /&gt;&lt;BR /&gt;What we have is a library and a few executables that link to the library. Our code uses External Common Blocks for global variables (it was written many years ago and rewriting the code isn't currently feasible.) On the Mac side, these External Common Blocks don't get populated when linked through the library but do when linked directly. However, on the Windows and Linux side, they work regardless.&lt;BR /&gt;&lt;BR /&gt;I've created a simple example to illustrate my problem.&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE&gt;[shell]!Test_External.for!&lt;BR /&gt;&lt;BR /&gt;      PROGRAM Test_External&lt;BR /&gt;&lt;BR /&gt;      IMPLICIT NONE&lt;BR /&gt;&lt;BR /&gt;      ! EXTERNAL declarations&lt;BR /&gt;      EXTERNAL datcom_tables  &lt;BR /&gt;&lt;BR /&gt;      CALL Test_Datcom&lt;BR /&gt;&lt;BR /&gt;      STOP&lt;BR /&gt;      END&lt;BR /&gt;[/shell]&lt;/PRE&gt;
&lt;PRE&gt;[shell]!Test_Datcom.for!   &lt;BR /&gt;&lt;BR /&gt;      SUBROUTINE Test_Datcom()&lt;BR /&gt;&lt;BR /&gt;      IMPLICIT NONE&lt;BR /&gt;      &lt;BR /&gt;      INCLUDE 'datcom.inc'&lt;BR /&gt;&lt;BR /&gt;      PRINT 1, npt3b(1), npt3b(2),npt3b(3), npt3b(4), npt3b(5)&lt;BR /&gt;   1   FORMAT ('(1)=',I3,' (2)=',I3,' (3)=',I3,' (4)=',I3,' (5)=',I3)&lt;BR /&gt;   &lt;BR /&gt;      PRINT 2, z3b(1), z3b(2),z3b(3)&lt;BR /&gt;   2   FORMAT ('(1)=',F4.1,' (2)=',F4.1,' (3)=',F4.1)&lt;BR /&gt;&lt;BR /&gt;      RETURN&lt;BR /&gt;      END&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;!datcom.inc!&lt;BR /&gt;&lt;BR /&gt;      INTEGER npt3b&lt;BR /&gt;      COMMON /datcom_a/ npt3b(5)&lt;BR /&gt;     &lt;BR /&gt;     &lt;BR /&gt;      REAL z3b&lt;BR /&gt;      COMMON /datcom_d/ z3b(5)&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;[/shell]&lt;/PRE&gt;
&lt;PRE&gt;[cpp]!datcom_tables.for!&lt;BR /&gt;&lt;BR /&gt;      BLOCK DATA datcom_tables&lt;BR /&gt;&lt;BR /&gt;      INCLUDE 'datcom.inc'&lt;BR /&gt;&lt;BR /&gt;      DATA z3b(1), npt3b(1) /1.0, 8/&lt;BR /&gt;      DATA z3b(2), npt3b(2) /2.0, 8/&lt;BR /&gt;      DATA z3b(3), npt3b(3) /4.0, 8/&lt;BR /&gt;      DATA z3b(4), npt3b(4) /6.0, 8/&lt;BR /&gt;      DATA z3b(5), npt3b(5) /8.0, 8/&lt;BR /&gt;      END[/cpp]&lt;/PRE&gt;
&lt;BR /&gt;When I compile this example using the following command:&lt;BR /&gt;&lt;BR /&gt;ifort $(FFLAGS) Test_External.for Test_Datcom.for datcom_tables.for -o Test&lt;BR /&gt;&lt;BR /&gt;I get&lt;BR /&gt;&lt;BR /&gt;./Test&lt;BR /&gt;(1)= 8 (2)= 8 (3)= 8 (4)= 8 (5)= 8&lt;BR /&gt;(1)= 1.0 (2)= 2.0 (3)= 4.0&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;However, when I compile using the library&lt;BR /&gt;&lt;BR /&gt;ifort $(FFLAGS) Test_External.for -ltestexternal -L. -o Test1&lt;BR /&gt;&lt;BR /&gt;I get&lt;BR /&gt;&lt;BR /&gt;./Test1&lt;BR /&gt;(1)= 0 (2)= 0 (3)= 0 (4)= 0 (5)= 0&lt;BR /&gt;(1)= 0.0 (2)= 0.0 (3)= 0.0&lt;BR /&gt;&lt;BR /&gt;The library is generated with&lt;BR /&gt;&lt;BR /&gt;ifort $(FLAGS) -fpic -c datcom_tables.for Test_Datcom.for&lt;BR /&gt;ar rc testexternal.a datcom_tables.o Test_Datcom.o&lt;BR /&gt;&lt;BR /&gt;Using the same Makefile, both tests compile and work as expected under Linux. I think the problem is a linking error but wanted to see what you guys thought.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance!&lt;BR /&gt;&lt;BR /&gt;Nate&lt;BR /&gt;</description>
    <pubDate>Wed, 28 Jan 2009 21:32:31 GMT</pubDate>
    <dc:creator>nknotts</dc:creator>
    <dc:date>2009-01-28T21:32:31Z</dc:date>
    <item>
      <title>External Common Blocks problem with OS X</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/External-Common-Blocks-problem-with-OS-X/m-p/752587#M8561</link>
      <description>I'm in the process of porting our Intel Fortran code from Windows to OSX/Linux. I went through Visual Studio and figured out the equivalent compiler flags for OSX/Linux. I am using the evaluation ifort 11 (056). They are as follows:&lt;BR /&gt;&lt;BR /&gt;ifort -nologo -g -noaltparam -fpscomp nolibs -save -zero -align rec1byte -fpconstant -traceback -check bounds -threads&lt;BR /&gt;&lt;BR /&gt;What we have is a library and a few executables that link to the library. Our code uses External Common Blocks for global variables (it was written many years ago and rewriting the code isn't currently feasible.) On the Mac side, these External Common Blocks don't get populated when linked through the library but do when linked directly. However, on the Windows and Linux side, they work regardless.&lt;BR /&gt;&lt;BR /&gt;I've created a simple example to illustrate my problem.&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE&gt;[shell]!Test_External.for!&lt;BR /&gt;&lt;BR /&gt;      PROGRAM Test_External&lt;BR /&gt;&lt;BR /&gt;      IMPLICIT NONE&lt;BR /&gt;&lt;BR /&gt;      ! EXTERNAL declarations&lt;BR /&gt;      EXTERNAL datcom_tables  &lt;BR /&gt;&lt;BR /&gt;      CALL Test_Datcom&lt;BR /&gt;&lt;BR /&gt;      STOP&lt;BR /&gt;      END&lt;BR /&gt;[/shell]&lt;/PRE&gt;
&lt;PRE&gt;[shell]!Test_Datcom.for!   &lt;BR /&gt;&lt;BR /&gt;      SUBROUTINE Test_Datcom()&lt;BR /&gt;&lt;BR /&gt;      IMPLICIT NONE&lt;BR /&gt;      &lt;BR /&gt;      INCLUDE 'datcom.inc'&lt;BR /&gt;&lt;BR /&gt;      PRINT 1, npt3b(1), npt3b(2),npt3b(3), npt3b(4), npt3b(5)&lt;BR /&gt;   1   FORMAT ('(1)=',I3,' (2)=',I3,' (3)=',I3,' (4)=',I3,' (5)=',I3)&lt;BR /&gt;   &lt;BR /&gt;      PRINT 2, z3b(1), z3b(2),z3b(3)&lt;BR /&gt;   2   FORMAT ('(1)=',F4.1,' (2)=',F4.1,' (3)=',F4.1)&lt;BR /&gt;&lt;BR /&gt;      RETURN&lt;BR /&gt;      END&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;!datcom.inc!&lt;BR /&gt;&lt;BR /&gt;      INTEGER npt3b&lt;BR /&gt;      COMMON /datcom_a/ npt3b(5)&lt;BR /&gt;     &lt;BR /&gt;     &lt;BR /&gt;      REAL z3b&lt;BR /&gt;      COMMON /datcom_d/ z3b(5)&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;[/shell]&lt;/PRE&gt;
&lt;PRE&gt;[cpp]!datcom_tables.for!&lt;BR /&gt;&lt;BR /&gt;      BLOCK DATA datcom_tables&lt;BR /&gt;&lt;BR /&gt;      INCLUDE 'datcom.inc'&lt;BR /&gt;&lt;BR /&gt;      DATA z3b(1), npt3b(1) /1.0, 8/&lt;BR /&gt;      DATA z3b(2), npt3b(2) /2.0, 8/&lt;BR /&gt;      DATA z3b(3), npt3b(3) /4.0, 8/&lt;BR /&gt;      DATA z3b(4), npt3b(4) /6.0, 8/&lt;BR /&gt;      DATA z3b(5), npt3b(5) /8.0, 8/&lt;BR /&gt;      END[/cpp]&lt;/PRE&gt;
&lt;BR /&gt;When I compile this example using the following command:&lt;BR /&gt;&lt;BR /&gt;ifort $(FFLAGS) Test_External.for Test_Datcom.for datcom_tables.for -o Test&lt;BR /&gt;&lt;BR /&gt;I get&lt;BR /&gt;&lt;BR /&gt;./Test&lt;BR /&gt;(1)= 8 (2)= 8 (3)= 8 (4)= 8 (5)= 8&lt;BR /&gt;(1)= 1.0 (2)= 2.0 (3)= 4.0&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;However, when I compile using the library&lt;BR /&gt;&lt;BR /&gt;ifort $(FFLAGS) Test_External.for -ltestexternal -L. -o Test1&lt;BR /&gt;&lt;BR /&gt;I get&lt;BR /&gt;&lt;BR /&gt;./Test1&lt;BR /&gt;(1)= 0 (2)= 0 (3)= 0 (4)= 0 (5)= 0&lt;BR /&gt;(1)= 0.0 (2)= 0.0 (3)= 0.0&lt;BR /&gt;&lt;BR /&gt;The library is generated with&lt;BR /&gt;&lt;BR /&gt;ifort $(FLAGS) -fpic -c datcom_tables.for Test_Datcom.for&lt;BR /&gt;ar rc testexternal.a datcom_tables.o Test_Datcom.o&lt;BR /&gt;&lt;BR /&gt;Using the same Makefile, both tests compile and work as expected under Linux. I think the problem is a linking error but wanted to see what you guys thought.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance!&lt;BR /&gt;&lt;BR /&gt;Nate&lt;BR /&gt;</description>
      <pubDate>Wed, 28 Jan 2009 21:32:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/External-Common-Blocks-problem-with-OS-X/m-p/752587#M8561</guid>
      <dc:creator>nknotts</dc:creator>
      <dc:date>2009-01-28T21:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: External Common Blocks problem with OS X</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/External-Common-Blocks-problem-with-OS-X/m-p/752588#M8562</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
Yes, I can reproduce what you are seeing. It doesn't seem to be tied to the compiler options either.&lt;BR /&gt;&lt;BR /&gt;I am investigating this further, but it looks like a bug.&lt;BR /&gt;&lt;BR /&gt;ron&lt;BR /&gt;</description>
      <pubDate>Fri, 30 Jan 2009 16:37:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/External-Common-Blocks-problem-with-OS-X/m-p/752588#M8562</guid>
      <dc:creator>Ron_Green</dc:creator>
      <dc:date>2009-01-30T16:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: External Common Blocks problem with OS X</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/External-Common-Blocks-problem-with-OS-X/m-p/752589#M8563</link>
      <description>&lt;P&gt;The BLOCK DATA in the static library is ignored because no external reference is created. We filed Radar Bug ID #: 5887862 against ld64. We can check on the status. There is a work-around.&lt;BR /&gt;&lt;BR /&gt;Your example works when linking as follows (add the &lt;STRONG&gt;-Xlinker&lt;/STRONG&gt; options) to force an external reference to the BLOCK DATA:&lt;/P&gt;
&lt;P&gt; ifort Test_External.for -ltestexternal -L. -o Test1 &lt;STRONG&gt;-Xlinker&lt;/STRONG&gt; -u &lt;STRONG&gt;-Xlinker&lt;/STRONG&gt; _datcom_tables_&lt;BR /&gt;&lt;BR /&gt;Just a note: The ifort syntax provided here assumes the static library is named: &lt;STRONG&gt;libtestexternal.a&lt;/STRONG&gt; (your earlier steps name it differently)&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jan 2009 17:41:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/External-Common-Blocks-problem-with-OS-X/m-p/752589#M8563</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2009-01-30T17:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: External Common Blocks problem with OS X</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/External-Common-Blocks-problem-with-OS-X/m-p/752590#M8564</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
I opened a bug report against the Mac OS X compiler. The ID is DPD200112075&lt;BR /&gt;&lt;BR /&gt;We saw a similar bug on the Linux compiler some 2-3 years ago. Hopefully this is similar and we can apply that same fix to the Mac OS X compiler.&lt;BR /&gt;&lt;BR /&gt;I used the simple reproducer from that older issue:&lt;BR /&gt;&lt;BR /&gt;lib.f90&lt;BR /&gt;BLOCK DATA FOOBAR&lt;BR /&gt;COMMON /MYCOMMON/ I&lt;BR /&gt;DATA I /3/&lt;BR /&gt;END BLOCK DATA FOOBAR&lt;BR /&gt;&lt;BR /&gt;prog.f90&lt;BR /&gt;PROGRAM MAIN&lt;BR /&gt;COMMON /MYCOMMON/ I&lt;BR /&gt;EXTERNAL FOOBAR&lt;BR /&gt;PRINT *, I&lt;BR /&gt;END&lt;BR /&gt;&lt;BR /&gt;ifort -c lib.f90&lt;BR /&gt;ar rc lib.a lib.o&lt;BR /&gt;ifort -o prog prog.f90 lib.a&lt;BR /&gt;./prog&lt;BR /&gt; 0&lt;BR /&gt;&lt;BR /&gt;answer should be 3. as seen by&lt;BR /&gt;&lt;BR /&gt;ifort -o prog prog.f90 lib.o&lt;BR /&gt;./prog&lt;BR /&gt; 3&lt;BR /&gt;&lt;BR /&gt;Thanks for sending this in. I will keep you posted on when a fix is available. For the time being, avoid the library on Mac OS X and link in the .o files.&lt;BR /&gt;&lt;BR /&gt;ron&lt;BR /&gt;</description>
      <pubDate>Fri, 30 Jan 2009 17:47:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/External-Common-Blocks-problem-with-OS-X/m-p/752590#M8564</guid>
      <dc:creator>Ron_Green</dc:creator>
      <dc:date>2009-01-30T17:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: External Common Blocks problem with OS X</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/External-Common-Blocks-problem-with-OS-X/m-p/752591#M8565</link>
      <description>Thanks for the help guys.&lt;BR /&gt;&lt;BR /&gt;Nate&lt;BR /&gt;</description>
      <pubDate>Fri, 30 Jan 2009 18:34:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/External-Common-Blocks-problem-with-OS-X/m-p/752591#M8565</guid>
      <dc:creator>nknotts</dc:creator>
      <dc:date>2009-01-30T18:34:58Z</dc:date>
    </item>
    <item>
      <title>Re: External Common Blocks problem with OS X</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/External-Common-Blocks-problem-with-OS-X/m-p/752592#M8566</link>
      <description>A less attractive alternative work-around to the earlier linker options is using DLLIMPORT in &lt;STRONG&gt;Test_Datcom.for&lt;/STRONG&gt; as shown:&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE&gt;[cpp]!Test_Datcom.for!

      SUBROUTINE Test_Datcom()
      IMPLICIT NONE

      INCLUDE 'datcom.inc'
!dec$ attributes dllimport :: datcom_a
!dec$ attributes dllimport :: datcom_b

      PRINT 1, npt3b(1), npt3b(2),npt3b(3), npt3b(4), npt3b(5)
  1   FORMAT ('(1)=',I3,' (2)=',I3,' (3)=',I3,' (4)=',I3,' (5)=',I3)

      PRINT 2, z3b(1), z3b(2),z3b(3)
  2   FORMAT ('(1)=',F4.1,' (2)=',F4.1,' (3)=',F4.1)

      RETURN
      END
[/cpp]&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Jan 2009 19:13:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/External-Common-Blocks-problem-with-OS-X/m-p/752592#M8566</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2009-01-30T19:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: External Common Blocks problem with OS X</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/External-Common-Blocks-problem-with-OS-X/m-p/752593#M8567</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;BR /&gt;Our developers confirmed that your case is the same as the case the Kevin Davis mentioned. &lt;BR /&gt;This is a bug with the Apple linker.&lt;BR /&gt;&lt;BR /&gt;We'll have to wait for that Radar issue to be fixed, we've closed our bug report.</description>
      <pubDate>Fri, 20 Feb 2009 22:59:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/External-Common-Blocks-problem-with-OS-X/m-p/752593#M8567</guid>
      <dc:creator>Ron_Green</dc:creator>
      <dc:date>2009-02-20T22:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: External Common Blocks problem with OS X</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/External-Common-Blocks-problem-with-OS-X/m-p/752594#M8568</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;BR /&gt;I confirmed this issue is fixed in Xcode 3.2 on Snow Leopard with our upcoming 11.1 compiler.</description>
      <pubDate>Wed, 25 Feb 2009 19:55:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/External-Common-Blocks-problem-with-OS-X/m-p/752594#M8568</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2009-02-25T19:55:03Z</dc:date>
    </item>
  </channel>
</rss>

