<?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: passing rank2 array into rank1 dummy in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-rank2-array-into-rank1-dummy/m-p/815875#M45210</link>
    <description>&lt;P&gt;Hmm - doesn't work the way I had envisioned. Perhaps my idea of passing a(1,1) doesn't work for generics - probable. I suppose the alternative is to have two versions of each i and r routine, one for 1D arrays, one for 2D arrays.&lt;/P&gt;
&lt;P&gt;Using an adjustable array, a(n), is better than assumed-size, a(*), as you give the optimizer more information about the array bounds, and you can then do whole-array operations with the bound specified where you can't with *, but otherwise they're the same.&lt;/P&gt;</description>
    <pubDate>Sun, 10 Dec 2006 01:11:15 GMT</pubDate>
    <dc:creator>Steven_L_Intel1</dc:creator>
    <dc:date>2006-12-10T01:11:15Z</dc:date>
    <item>
      <title>passing rank2 array into rank1 dummy</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-rank2-array-into-rank1-dummy/m-p/815870#M45205</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
the following code accomplishes exactly what I need (dynamic
equivalence, with array sizes determined at runtime), with no warnings
(on CVF), but I am unsure it is 100% legal, since it involves passing a
rank2 array into a dummy argument that is rank1.&lt;BR /&gt;
&lt;BR /&gt;
!===============&lt;BR /&gt;
module m&lt;BR /&gt;
implicit none&lt;BR /&gt;
contains&lt;BR /&gt; subroutine associate1D(a1,np,p1)&lt;BR /&gt; implicit none&lt;BR /&gt; integer,intent(in)::np&lt;BR /&gt; integer,intent(in),target::a1(np)&lt;BR /&gt; integer,pointer::p1(:)&lt;BR /&gt; p1=&amp;gt;a1(1:np)&lt;BR /&gt; endsubroutine associate1D&lt;BR /&gt;
endmodule m&lt;BR /&gt;
!-------------&lt;BR /&gt;
program main&lt;BR /&gt;
use m&lt;BR /&gt;
implicit none&lt;BR /&gt;
integer,parameter::n1=2,n2=3&lt;BR /&gt;
integer::a2D(n1,n2)&lt;BR /&gt;
integer,pointer::a1Dp(:)=&amp;gt;null()&lt;BR /&gt;
! ... various code&lt;BR /&gt;
call associate1D(a2D,n1*n2,a1Dp)&lt;BR /&gt;
! ... can now address a2D using single subscript via a1Dp (similar to equivalence,&lt;BR /&gt;
! but dynamic, with runtime array sizes, eg, if a2D is allocated or automatic or itself&lt;BR /&gt;
! a dummy explicit-size-array dummy argument)&lt;BR /&gt;
endprogram main&lt;BR /&gt;
!===============&lt;BR /&gt;
&lt;BR /&gt;
I was a bit surprised (and happy) that CVF doesnt complain, although from my
understanding of the Fortran argument association mechanism, explicit-shape (and assumed-size)
arrays are passed-in using the address of the first element, which
would explain why the example works. So is this construction legal? and
is there a better way to accomplish this result? thanks in advance as
usual.&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Dec 2006 13:23:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-rank2-array-into-rank1-dummy/m-p/815870#M45205</guid>
      <dc:creator>forall</dc:creator>
      <dc:date>2006-12-07T13:23:05Z</dc:date>
    </item>
    <item>
      <title>Re: passing rank2 array into rank1 dummy</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-rank2-array-into-rank1-dummy/m-p/815871#M45206</link>
      <description>&lt;P&gt;The code is legal-if you are passing an array to an explicit-shape array, the ranks need not match as long as the number of elements in the dummy don't exceed the number of elements in the actual.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2006 02:05:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-rank2-array-into-rank1-dummy/m-p/815871#M45206</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2006-12-08T02:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: passing rank2 array into rank1 dummy</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-rank2-array-into-rank1-dummy/m-p/815872#M45207</link>
      <description>good. However, it seems it is not possible to overload multiple
versions (eg, for real and integer arrays "a") of 'associate1D' using
generic interfaces, since the compiler cannot resolve the reference to
the specific routine (since none of them, by construction, expect a
rank2 array). I guess overloading them is not essential.&lt;BR /&gt;</description>
      <pubDate>Fri, 08 Dec 2006 02:45:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-rank2-array-into-rank1-dummy/m-p/815872#M45207</guid>
      <dc:creator>forall</dc:creator>
      <dc:date>2006-12-08T02:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: passing rank2 array into rank1 dummy</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-rank2-array-into-rank1-dummy/m-p/815873#M45208</link>
      <description>You could always call the "associate" routine with the first element of the array in question - that will match an array of any rank through "sequence association".</description>
      <pubDate>Fri, 08 Dec 2006 03:28:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-rank2-array-into-rank1-dummy/m-p/815873#M45208</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2006-12-08T03:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: passing rank2 array into rank1 dummy</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-rank2-array-into-rank1-dummy/m-p/815874#M45209</link>
      <description>Steve,&lt;BR /&gt;
&lt;BR /&gt;
any chance you could give an illustration of this? I have tried several ways to overload&lt;BR /&gt;
&lt;BR /&gt;
 subroutine associate1D_i(a1,np,p1)&lt;BR /&gt;
 implicit none&lt;BR /&gt;
 integer,intent(in)::np&lt;BR /&gt;
 integer,intent(in),target::a1(np)&lt;BR /&gt;
 integer,pointer::p1(:)&lt;BR /&gt;
 p1=&amp;gt;a1(1:np)&lt;BR /&gt;
 endsubroutine associate1D_i&lt;BR /&gt;
&lt;BR /&gt;
and&lt;BR /&gt;
&lt;BR /&gt;
 subroutine associate1D_r(a1,np,p1)&lt;BR /&gt;
 implicit none&lt;BR /&gt;
 integer,intent(in)::np&lt;BR /&gt;
 real,intent(in),target::a1(np)&lt;BR /&gt;
 real,pointer::p1(:)&lt;BR /&gt;
 p1=&amp;gt;a1(1:np)&lt;BR /&gt;
 endsubroutine associate1D_r&lt;BR /&gt;
&lt;BR /&gt;
onto the same generic name associate1D, but the calls to the generic
name are not resolved and I get the compiler message - "there is no
matching specific subroutine".&lt;BR /&gt;
&lt;BR /&gt;
While on this topic, is there any difference at all if I use an
assumed-size instead of explicit-size dummy array a1? ie, declare
a1(*). I tested it and it works identically, but are there any
advantages to doing it? thanks!&lt;BR /&gt;
&lt;BR /&gt;
dmitri&lt;BR /&gt;
&lt;BR /&gt;</description>
      <pubDate>Sun, 10 Dec 2006 00:17:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-rank2-array-into-rank1-dummy/m-p/815874#M45209</guid>
      <dc:creator>forall</dc:creator>
      <dc:date>2006-12-10T00:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: passing rank2 array into rank1 dummy</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-rank2-array-into-rank1-dummy/m-p/815875#M45210</link>
      <description>&lt;P&gt;Hmm - doesn't work the way I had envisioned. Perhaps my idea of passing a(1,1) doesn't work for generics - probable. I suppose the alternative is to have two versions of each i and r routine, one for 1D arrays, one for 2D arrays.&lt;/P&gt;
&lt;P&gt;Using an adjustable array, a(n), is better than assumed-size, a(*), as you give the optimizer more information about the array bounds, and you can then do whole-array operations with the bound specified where you can't with *, but otherwise they're the same.&lt;/P&gt;</description>
      <pubDate>Sun, 10 Dec 2006 01:11:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-rank2-array-into-rank1-dummy/m-p/815875#M45210</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2006-12-10T01:11:15Z</dc:date>
    </item>
    <item>
      <title>Re: passing rank2 array into rank1 dummy</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-rank2-array-into-rank1-dummy/m-p/815876#M45211</link>
      <description>Associate1D is legal, but using a1Dp afterwards is illegal, as a2D does not have the TARGET attribute. And even if it had, the functionality is compiler-dependent (it is granted for assumed shape and scalars, but not for explicit shape or assumed size)&lt;BR /&gt;&lt;BR /&gt;sec. 12.4.1.2 of the standard says that&lt;BR /&gt;&lt;BR /&gt;If the dummy argument has the TARGET attribute and is an explicit-shape array or is an assumed-size array, and the corresponding actual argument has the TARGET attribute but is not an array section with a vector subscript then&lt;BR /&gt;(1) On invocation of the procedure, whether any pointers associated with the actual argument become associated with the corresponding dummy argument is processor dependent and&lt;BR /&gt;(2) When execution of the procedure completes, the pointer association status of any pointer that is pointer associated with the dummy argument is processor dependent.&lt;BR /&gt;&lt;BR /&gt;I have recently needed the same (aliasing with different rank) and came to the conclusion that there is no F95-standard way to mimic the reshaping ability of F2003 pointers&lt;BR /&gt;(there is a trick to do bounds-remapping, however), save for the EQUIVALENCE statement on static arrays.&lt;BR /&gt;However, your code is likely to work with most compilers on machines with linear memory, unless the compiler does a temporary copy on the call of Associate2D &lt;BR /&gt;(which it is allowed to). &lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Jaroslav&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Dec 2006 15:12:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-rank2-array-into-rank1-dummy/m-p/815876#M45211</guid>
      <dc:creator>hajek</dc:creator>
      <dc:date>2006-12-12T15:12:05Z</dc:date>
    </item>
  </channel>
</rss>

