<?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: forrtl: warning (402): an array temporary was created  why? in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/forrtl-warning-402-an-array-temporary-was-created-why/m-p/757359#M12846</link>
    <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
I confirmed this was the case. The standard says that your routine is called "as if" the right side were enclosed in parentheses, making it an expression. In such cases, we pass a copy. You can't disable this.&lt;BR /&gt;</description>
    <pubDate>Thu, 23 Jul 2009 20:50:15 GMT</pubDate>
    <dc:creator>Steven_L_Intel1</dc:creator>
    <dc:date>2009-07-23T20:50:15Z</dc:date>
    <item>
      <title>forrtl: warning (402): an array temporary was created  why?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/forrtl-warning-402-an-array-temporary-was-created-why/m-p/757354#M12841</link>
      <description>Hello all,&lt;BR /&gt;I'm creating a simple 'vector' type with overloaded basic operations like adding, assignment and so on. I'm hiding the implementation into a module. As a bare minimum I have to provide a facility to assign a 'usual' array to a 'vector'. When compiled with Intel Fortran 10.1 compiler under Ubuntu, I am receiving a warning that an array temporary is created. Googling tells me that this warning is usually associated with mixing fortran 77 arrays (contiguous in memory) and fortran 90 arrays (not necessarily contiguous).&lt;BR /&gt;&lt;BR /&gt;What I'm confused about is that in the code below I don't seem to be ever using fortran 77 style arrays. It seems that I'm missing something kindergarten-ish, but I can't figure what is the issue. Can anybody clarify it?&lt;BR /&gt;&lt;BR /&gt;Here's the offending code:&lt;BR /&gt;&lt;BR /&gt;!-----------------------------&lt;BR /&gt;module blah&lt;BR /&gt;implicit none&lt;BR /&gt;&lt;BR /&gt;integer,parameter :: d=3           ! dimension&lt;BR /&gt;&lt;BR /&gt;public  assignment(=), momentum,d,dump&lt;BR /&gt;&lt;BR /&gt;private&lt;BR /&gt;&lt;BR /&gt;! basic type itself&lt;BR /&gt;type momentum&lt;BR /&gt;private&lt;BR /&gt;integer, dimension(d) :: elem&lt;BR /&gt;end type momentum&lt;BR /&gt;&lt;BR /&gt;interface assignment(=)         &lt;BR /&gt;module procedure arr        ! assign arr to vector&lt;BR /&gt;end interface&lt;BR /&gt;&lt;BR /&gt;contains&lt;BR /&gt;&lt;BR /&gt;! assign array to vector --- the offending procedure&lt;BR /&gt;subroutine arr(ve,ar)&lt;BR /&gt;implicit none&lt;BR /&gt;type(momentum), intent(out) :: ve&lt;BR /&gt;integer, intent(in)  :: ar(d)&lt;BR /&gt;ve%elem=ar&lt;BR /&gt;end subroutine arr&lt;BR /&gt;&lt;BR /&gt;end module blah&lt;BR /&gt;&lt;BR /&gt;!+++++++++++++++++++++++++++++++++++&lt;BR /&gt;program trrry&lt;BR /&gt;use blah&lt;BR /&gt;implicit none&lt;BR /&gt;type(momentum) :: ve&lt;BR /&gt;integer :: a(d)&lt;BR /&gt;&lt;BR /&gt;a=1;&lt;BR /&gt;ve=a;            ! this call generates the warning&lt;BR /&gt;&lt;BR /&gt;end program trrry&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 23 Jul 2009 15:31:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/forrtl-warning-402-an-array-temporary-was-created-why/m-p/757354#M12841</guid>
      <dc:creator>burovski</dc:creator>
      <dc:date>2009-07-23T15:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: forrtl: warning (402): an array temporary was created  why?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/forrtl-warning-402-an-array-temporary-was-created-why/m-p/757355#M12842</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
I think the issue is that the semantics of defined assignment are that the right side is completely evaluated before any stores to the left side are done. The compiler is not recognizing that there is no overlap and, conservatively, creates a temporary copy of the right side before calling the assignment routine. To the part of the compiler that processes this, it looks like a normal call to a subroutine and hence you get the warning (which is optional and comes from -check arg_temp_created).&lt;BR /&gt;</description>
      <pubDate>Thu, 23 Jul 2009 15:58:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/forrtl-warning-402-an-array-temporary-was-created-why/m-p/757355#M12842</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2009-07-23T15:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: forrtl: warning (402): an array temporary was created  why?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/forrtl-warning-402-an-array-temporary-was-created-why/m-p/757356#M12843</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Dear Mr. Lionel,&lt;BR /&gt;&lt;BR /&gt;Thank you very much for the answer!&lt;BR /&gt;Is there a way to avoid creating such temporary?&lt;BR /&gt;It's a minor issue of course; my main reasons for wanting it is that it's a routine which is called repeatedly in my code --- hence I'd really prefer getting maximum performance for it. &lt;BR /&gt;&lt;BR /&gt;Thanks again,&lt;BR /&gt; Zhenya&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;</description>
      <pubDate>Thu, 23 Jul 2009 19:54:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/forrtl-warning-402-an-array-temporary-was-created-why/m-p/757356#M12843</guid>
      <dc:creator>burovski</dc:creator>
      <dc:date>2009-07-23T19:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: forrtl: warning (402): an array temporary was created  why?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/forrtl-warning-402-an-array-temporary-was-created-why/m-p/757357#M12844</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
Not that I can think of. To be honest, I'm a bit surprised that the temp is there because we have an open issue where such assignments where overlap is possible gives bad results. Perhaps the temp was the initial fix for this. I'll have to ask about this. but there is no control that I am aware of.&lt;BR /&gt;</description>
      <pubDate>Thu, 23 Jul 2009 20:00:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/forrtl-warning-402-an-array-temporary-was-created-why/m-p/757357#M12844</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2009-07-23T20:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: forrtl: warning (402): an array temporary was created  why?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/forrtl-warning-402-an-array-temporary-was-created-why/m-p/757358#M12845</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;OK, no way it is then. Thanks a lot!&lt;BR /&gt;&lt;BR /&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/336209"&gt;Steve Lionel (Intel)&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt; Not that I can think of. To be honest, I'm a bit surprised that the temp is there because we have an open issue where such assignments where overlap is possible gives bad results. Perhaps the temp was the initial fix for this. I'll have to ask about this. but there is no control that I am aware of.&lt;BR /&gt;&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;</description>
      <pubDate>Thu, 23 Jul 2009 20:03:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/forrtl-warning-402-an-array-temporary-was-created-why/m-p/757358#M12845</guid>
      <dc:creator>burovski</dc:creator>
      <dc:date>2009-07-23T20:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: forrtl: warning (402): an array temporary was created  why?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/forrtl-warning-402-an-array-temporary-was-created-why/m-p/757359#M12846</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
I confirmed this was the case. The standard says that your routine is called "as if" the right side were enclosed in parentheses, making it an expression. In such cases, we pass a copy. You can't disable this.&lt;BR /&gt;</description>
      <pubDate>Thu, 23 Jul 2009 20:50:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/forrtl-warning-402-an-array-temporary-was-created-why/m-p/757359#M12846</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2009-07-23T20:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: forrtl: warning (402): an array temporary was created  why?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/forrtl-warning-402-an-array-temporary-was-created-why/m-p/757360#M12847</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/336209"&gt;Steve Lionel (Intel)&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt; I confirmed this was the case. The standard says that your routine is called "as if" the right side were enclosed in parentheses, making it an expression. In such cases, we pass a copy. You can't disable this.&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
I think the purpose of this warning is that such temps can create overhead, but the overhead for a size 3 vector is not very significant. It would be useful to print the size of the temp so that messages could be sorted or filtered, and maybe have a built-in size threshold for printing.&lt;BR /&gt;&lt;BR /&gt;Actually, this example produces a temporary known at compile time. Why not print a warning at compile time? Even when tempraries are conditional (i.e. due to strided array refs), the compiler could print a conditional-temp warning. Compile-time messages would make it easier to avoid temp-generating constructs.&lt;BR /&gt;</description>
      <pubDate>Fri, 24 Jul 2009 15:32:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/forrtl-warning-402-an-array-temporary-was-created-why/m-p/757360#M12847</guid>
      <dc:creator>joseph-krahn</dc:creator>
      <dc:date>2009-07-24T15:32:18Z</dc:date>
    </item>
  </channel>
</rss>

