<?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 Yes, it is similar. in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153302#M140785</link>
    <description>&lt;P&gt;Yes, it is similar.&lt;/P&gt;</description>
    <pubDate>Wed, 14 Mar 2018 20:37:24 GMT</pubDate>
    <dc:creator>Steve_Lionel</dc:creator>
    <dc:date>2018-03-14T20:37:24Z</dc:date>
    <item>
      <title>ASSOCIATE vs Setting Local Variables Which Is Best?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153294#M140777</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Just wanted to get peoples opinions to using the ASSOCIATE command compared to setting a local variable within a Fortran Subroutine.&lt;/P&gt;

&lt;P&gt;Bellow would be an example code where I either use associate to use the shorter symbols A and B&lt;/P&gt;

&lt;P&gt;and the other option of just having a local variable (say double precision) set to the values stored and then use them.&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;  ! 
  ASSOCIATE ( A=&amp;gt;TYP%SUBTYP(I)%SUBTYP(J)%PROP1, B=&amp;gt;TYP%SUBTYP(I)%SUBTYP(J)%PROP2 )
         !
         !Do stuff with A and B
         !
  END ASSOCIATE
  !
  ! OR
  A = TYP%SUBTYP(I)%SUBTYP(J)%PROP1
  B = TYP%SUBTYP(I)%SUBTYP(J)%PROP2
  !
  !Do stuff with A and B
  !&lt;/PRE&gt;

&lt;P&gt;The main question is which would would be more beneficial to use, at what point does it become too many variables to reassign values (say if I had variables A-Z that were set). It seems like there would be a hit for copying the memory over to the local variables, but I am unsure how much of a speed hit there would be with initiating an ASSOCIATE local environment.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thanks for your inputs!&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 19:33:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153294#M140777</guid>
      <dc:creator>ScottBoyce</dc:creator>
      <dc:date>2018-03-13T19:33:20Z</dc:date>
    </item>
    <item>
      <title>ASSOCIATE is just for visual</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153295#M140778</link>
      <description>&lt;P&gt;ASSOCIATE is just for visual clarity - it shouldn't have any noticeable effect on performance. You'll have to decide for yourself whether use of ASSOCIATE is reasonable.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 20:27:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153295#M140778</guid>
      <dc:creator>Steve_Lionel</dc:creator>
      <dc:date>2018-03-13T20:27:38Z</dc:date>
    </item>
    <item>
      <title>I believe that the associate</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153296#M140779</link>
      <description>&lt;P&gt;I believe that the associate should be quicker than copying for anything bigger than a scalar integer or scalar real variable, ie. an array larger of either than one element. You did not show a declaration for A or B so dont know for your example.&lt;/P&gt;

&lt;P&gt;Steve, is my belief correct?&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 12:22:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153296#M140779</guid>
      <dc:creator>Andrew_Smith</dc:creator>
      <dc:date>2018-03-14T12:22:43Z</dc:date>
    </item>
    <item>
      <title>I would expect ASSOCIATE to</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153297#M140780</link>
      <description>&lt;P&gt;I would expect ASSOCIATE to be syntactical sugar rather than a run-time construct. That is: it guides the compiler to transform the code instead of introducing new variables that act as a sort of pointers.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 12:26:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153297#M140780</guid>
      <dc:creator>Arjen_Markus</dc:creator>
      <dc:date>2018-03-14T12:26:36Z</dc:date>
    </item>
    <item>
      <title>Is it possible that</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153298#M140781</link>
      <description>&lt;DIV&gt;
	&lt;P&gt;Is it possible that optimisation will overcome speed issues and end up with similar run-times for both?&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 14 Mar 2018 12:27:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153298#M140781</guid>
      <dc:creator>Andrew_Smith</dc:creator>
      <dc:date>2018-03-14T12:27:21Z</dc:date>
    </item>
    <item>
      <title>Compiler optimizations</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153299#M140782</link>
      <description>&lt;P&gt;Compiler optimizations typically perform common sub-expression substitution. IOW it may effectively perform the local variable scheme (as well as for associate form). Use of your own local variables can extend the scope of the life of the local copies. Local variables are not suitable for variables that are updated whereas associate can be used for both read and write.&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 12:56:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153299#M140782</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2018-03-14T12:56:04Z</dc:date>
    </item>
    <item>
      <title>Faster than copying? Yes. You</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153300#M140783</link>
      <description>&lt;P&gt;Faster than copying? Yes. You can think of ASSOCIATE as, in a vague way, like EQUIVALENCE. It creates a new variable that represents some part of a variable or variable-part. You can get into performance issues if the selector is noncontiguous, but otherwise it is in most cases, as Arjen suggests, "syntactic sugar".&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 16:37:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153300#M140783</guid>
      <dc:creator>Steve_Lionel</dc:creator>
      <dc:date>2018-03-14T16:37:43Z</dc:date>
    </item>
    <item>
      <title>I do not know if many current</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153301#M140784</link>
      <description>&lt;P&gt;I do not know if many current users of Fortran have used Pascal, but to me ASSOCIATE appears quite similar to Pascal's WITH; see&amp;nbsp;&lt;SPAN style="font-size: 13.008px;"&gt;&lt;A href="http://lazarus-ccr.sourceforge.net/fpcdoc/ref/refsu45.html" target="_blank"&gt;http://lazarus-ccr.sourceforge.net/fpcdoc/ref/refsu45.html&lt;/A&gt; .&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 17:04:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153301#M140784</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2018-03-14T17:04:10Z</dc:date>
    </item>
    <item>
      <title>Yes, it is similar.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153302#M140785</link>
      <description>&lt;P&gt;Yes, it is similar.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 20:37:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153302#M140785</guid>
      <dc:creator>Steve_Lionel</dc:creator>
      <dc:date>2018-03-14T20:37:24Z</dc:date>
    </item>
    <item>
      <title>Thanks, that is what I was</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153303#M140786</link>
      <description>&lt;P&gt;Thanks, that is what I was thinking. I just have a lot of local double precision variables that are set within a loop at runtime and I am transitioning them to ASSOCIATE blocks instead to reduce the amount of locals in the subroutine. I just was worried there would be a hit on the runtime (to me it would seem like ASSOCIATE would be faster since its not copying over a memory location vs just setting some form for of pointer).&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 20:43:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153303#M140786</guid>
      <dc:creator>ScottBoyce</dc:creator>
      <dc:date>2018-03-23T20:43:50Z</dc:date>
    </item>
    <item>
      <title>Bare in mind that the target</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153304#M140787</link>
      <description>&lt;P&gt;Bare in mind that the target of an ASSOCIATE is not the same as a temporary. IOW you modify the associate variable - you also modify the associated variable.&lt;/P&gt;

&lt;P&gt;Note, you can also use BLOCK/END BLOCK where immediately following BLOCK you can declare local variables (with names that can conflict with names used in other blocks as well as within an outer scope.&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 20:50:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153304#M140787</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2018-03-23T20:50:03Z</dc:date>
    </item>
    <item>
      <title>This is an implementation</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153305#M140788</link>
      <description>&lt;P&gt;This is an implementation detail, but a Fortran compiler would regard the associate name and the associated name as two names for one and the same variable, as in EQUIVALENCEd variables. No temporary is needed.&lt;/P&gt;

&lt;P&gt;Take the subroutine&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;subroutine sub(a,b)
implicit none
integer :: a,b
!
b=2*a
associate(la=&amp;gt;a, lb=&amp;gt;b)
   lb=2*la
end associate
return
end subroutine
&lt;/PRE&gt;

&lt;P&gt;Compile this to assembly, with and without optimization. You will find two identical store instructions to b and lb with /Od. If you allow optimization, all you see is single store instruction to the single stack location that can be accessed by the names b and lb.&lt;/P&gt;</description>
      <pubDate>Sat, 24 Mar 2018 12:56:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153305#M140788</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2018-03-24T12:56:00Z</dc:date>
    </item>
    <item>
      <title>That really good to know that</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153306#M140789</link>
      <description>&lt;P&gt;That really good to know that the behavior is different under optimization. I noticed that it created a shadow variable in the debugger, which is what prompted this discussion.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Mar 2018 15:56:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/ASSOCIATE-vs-Setting-Local-Variables-Which-Is-Best/m-p/1153306#M140789</guid>
      <dc:creator>ScottBoyce</dc:creator>
      <dc:date>2018-03-24T15:56:37Z</dc:date>
    </item>
  </channel>
</rss>

