<?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  calling the subroutine expecting multi-dimension array with the address of one-dimension array in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-the-subroutine-expecting-multi-dimension-array-with-the/m-p/968244#M96334</link>
    <description>&lt;P&gt;Hello!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I write a subroutine setrx and setix expecting a multi-dimensional array.&lt;BR /&gt;When they are called in main code, an address of a location in a one dimensional array&lt;BR /&gt;can be passed to them.&amp;nbsp; It works well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; But After I put the setrx and setix in a interface, calling the setx with the address&lt;BR /&gt;of one-dimension array will lead compile errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I&amp;nbsp;&amp;nbsp;need the help. Thanks in advance.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;!#########################################################&lt;BR /&gt;program main&lt;BR /&gt;!#########################################################&lt;BR /&gt;implicit none&lt;/P&gt;
&lt;P&gt;interface setx&lt;BR /&gt;&amp;nbsp; subroutine setrx(m,n,x)&lt;BR /&gt;&amp;nbsp; integer,intent(in) :: m&lt;BR /&gt;&amp;nbsp; integer,intent(in) :: n&lt;BR /&gt;&amp;nbsp; real,intent(out)&amp;nbsp;&amp;nbsp; :: x(m,*)&lt;BR /&gt;&amp;nbsp; end subroutine setrx&lt;/P&gt;
&lt;P&gt;&amp;nbsp; subroutine setix(m,n,x)&lt;BR /&gt;&amp;nbsp; integer,intent(in) :: m&lt;BR /&gt;&amp;nbsp; integer,intent(in) :: n&lt;BR /&gt;&amp;nbsp; integer,intent(out):: x(m,*)&lt;BR /&gt;&amp;nbsp; end subroutine setix&lt;BR /&gt;end interface setx&lt;/P&gt;
&lt;P&gt;real&amp;nbsp;&amp;nbsp;&amp;nbsp; :: rx(10),rxx(3,10)&lt;BR /&gt;integer :: ix(10),ixx(4,10)&lt;/P&gt;
&lt;P&gt;call setrx(1,10,rx)&lt;BR /&gt;call setix(1,10,ix)&lt;BR /&gt;call setrx(3,10,rxx)&lt;BR /&gt;call setix(4,10,ixx)&lt;BR /&gt;!&lt;BR /&gt;!&amp;nbsp; the following calls will lead two errors&lt;BR /&gt;!&lt;BR /&gt;! error #6285: There is no matching specific subroutine for this generic subroutine call.&amp;nbsp;&amp;nbsp; [SETX]&lt;BR /&gt;! ===================================================&lt;BR /&gt;call setx(1,10,rx)&amp;nbsp;&lt;BR /&gt;call setx(1,10,ix)&lt;BR /&gt;! ===================================================&lt;BR /&gt;!&lt;BR /&gt;!&amp;nbsp; the following calls are ok&lt;BR /&gt;!&lt;BR /&gt;call setx(3,10,rxx)&lt;BR /&gt;call setx(4,10,ixx)&lt;BR /&gt;!&lt;BR /&gt;end&lt;BR /&gt;end program main&lt;/P&gt;
&lt;P&gt;!=====================================================&lt;BR /&gt;subroutine setrx(m,n,x)&lt;BR /&gt;!=====================================================&lt;BR /&gt;implicit none&lt;BR /&gt;integer,intent(in) :: m&lt;BR /&gt;integer,intent(in) :: n&lt;BR /&gt;real,intent(out)&amp;nbsp;&amp;nbsp; :: x(m,*)&lt;/P&gt;
&lt;P&gt;integer :: i,j&lt;/P&gt;
&lt;P&gt;do j=1,n&lt;BR /&gt;&amp;nbsp; do i=1,m&lt;BR /&gt;&amp;nbsp;&amp;nbsp; x(i,j) = 1.0*i*j&lt;BR /&gt;&amp;nbsp; end do&lt;BR /&gt;end do&lt;BR /&gt;end subroutine setrx&lt;/P&gt;
&lt;P&gt;!=====================================================&lt;BR /&gt;subroutine setix(m,n,x)&lt;BR /&gt;!=====================================================&lt;BR /&gt;implicit none&lt;BR /&gt;integer,intent(in) :: m&lt;BR /&gt;integer,intent(in) :: n&lt;BR /&gt;integer,intent(out):: x(m,*)&lt;/P&gt;
&lt;P&gt;integer :: i,j&lt;/P&gt;
&lt;P&gt;do j=1,n&lt;BR /&gt;&amp;nbsp; do i=1,m&lt;BR /&gt;&amp;nbsp;&amp;nbsp; x(i,j) = i*j&lt;BR /&gt;&amp;nbsp; end do&lt;BR /&gt;end do&lt;BR /&gt;end subroutine setix&lt;/P&gt;</description>
    <pubDate>Wed, 02 Apr 2014 04:42:55 GMT</pubDate>
    <dc:creator>liuhuafei</dc:creator>
    <dc:date>2014-04-02T04:42:55Z</dc:date>
    <item>
      <title>calling the subroutine expecting multi-dimension array with the address of one-dimension array</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-the-subroutine-expecting-multi-dimension-array-with-the/m-p/968244#M96334</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I write a subroutine setrx and setix expecting a multi-dimensional array.&lt;BR /&gt;When they are called in main code, an address of a location in a one dimensional array&lt;BR /&gt;can be passed to them.&amp;nbsp; It works well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; But After I put the setrx and setix in a interface, calling the setx with the address&lt;BR /&gt;of one-dimension array will lead compile errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I&amp;nbsp;&amp;nbsp;need the help. Thanks in advance.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;!#########################################################&lt;BR /&gt;program main&lt;BR /&gt;!#########################################################&lt;BR /&gt;implicit none&lt;/P&gt;
&lt;P&gt;interface setx&lt;BR /&gt;&amp;nbsp; subroutine setrx(m,n,x)&lt;BR /&gt;&amp;nbsp; integer,intent(in) :: m&lt;BR /&gt;&amp;nbsp; integer,intent(in) :: n&lt;BR /&gt;&amp;nbsp; real,intent(out)&amp;nbsp;&amp;nbsp; :: x(m,*)&lt;BR /&gt;&amp;nbsp; end subroutine setrx&lt;/P&gt;
&lt;P&gt;&amp;nbsp; subroutine setix(m,n,x)&lt;BR /&gt;&amp;nbsp; integer,intent(in) :: m&lt;BR /&gt;&amp;nbsp; integer,intent(in) :: n&lt;BR /&gt;&amp;nbsp; integer,intent(out):: x(m,*)&lt;BR /&gt;&amp;nbsp; end subroutine setix&lt;BR /&gt;end interface setx&lt;/P&gt;
&lt;P&gt;real&amp;nbsp;&amp;nbsp;&amp;nbsp; :: rx(10),rxx(3,10)&lt;BR /&gt;integer :: ix(10),ixx(4,10)&lt;/P&gt;
&lt;P&gt;call setrx(1,10,rx)&lt;BR /&gt;call setix(1,10,ix)&lt;BR /&gt;call setrx(3,10,rxx)&lt;BR /&gt;call setix(4,10,ixx)&lt;BR /&gt;!&lt;BR /&gt;!&amp;nbsp; the following calls will lead two errors&lt;BR /&gt;!&lt;BR /&gt;! error #6285: There is no matching specific subroutine for this generic subroutine call.&amp;nbsp;&amp;nbsp; [SETX]&lt;BR /&gt;! ===================================================&lt;BR /&gt;call setx(1,10,rx)&amp;nbsp;&lt;BR /&gt;call setx(1,10,ix)&lt;BR /&gt;! ===================================================&lt;BR /&gt;!&lt;BR /&gt;!&amp;nbsp; the following calls are ok&lt;BR /&gt;!&lt;BR /&gt;call setx(3,10,rxx)&lt;BR /&gt;call setx(4,10,ixx)&lt;BR /&gt;!&lt;BR /&gt;end&lt;BR /&gt;end program main&lt;/P&gt;
&lt;P&gt;!=====================================================&lt;BR /&gt;subroutine setrx(m,n,x)&lt;BR /&gt;!=====================================================&lt;BR /&gt;implicit none&lt;BR /&gt;integer,intent(in) :: m&lt;BR /&gt;integer,intent(in) :: n&lt;BR /&gt;real,intent(out)&amp;nbsp;&amp;nbsp; :: x(m,*)&lt;/P&gt;
&lt;P&gt;integer :: i,j&lt;/P&gt;
&lt;P&gt;do j=1,n&lt;BR /&gt;&amp;nbsp; do i=1,m&lt;BR /&gt;&amp;nbsp;&amp;nbsp; x(i,j) = 1.0*i*j&lt;BR /&gt;&amp;nbsp; end do&lt;BR /&gt;end do&lt;BR /&gt;end subroutine setrx&lt;/P&gt;
&lt;P&gt;!=====================================================&lt;BR /&gt;subroutine setix(m,n,x)&lt;BR /&gt;!=====================================================&lt;BR /&gt;implicit none&lt;BR /&gt;integer,intent(in) :: m&lt;BR /&gt;integer,intent(in) :: n&lt;BR /&gt;integer,intent(out):: x(m,*)&lt;/P&gt;
&lt;P&gt;integer :: i,j&lt;/P&gt;
&lt;P&gt;do j=1,n&lt;BR /&gt;&amp;nbsp; do i=1,m&lt;BR /&gt;&amp;nbsp;&amp;nbsp; x(i,j) = i*j&lt;BR /&gt;&amp;nbsp; end do&lt;BR /&gt;end do&lt;BR /&gt;end subroutine setix&lt;/P&gt;</description>
      <pubDate>Wed, 02 Apr 2014 04:42:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-the-subroutine-expecting-multi-dimension-array-with-the/m-p/968244#M96334</guid>
      <dc:creator>liuhuafei</dc:creator>
      <dc:date>2014-04-02T04:42:55Z</dc:date>
    </item>
    <item>
      <title>There is another important</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-the-subroutine-expecting-multi-dimension-array-with-the/m-p/968245#M96335</link>
      <description>&lt;P&gt;There is another important point at play here than passing a 1-D array or scalar in place of a 2-D dummy argument: overlaid module procedures are called using their generic name. For this reason, the compiler must find a specific subroutine by matching arguments, and it finds none that takes a 1-D array argument.&lt;/P&gt;

&lt;P&gt;One way of making the code acceptable to the compiler is to add specific subroutines, say &lt;STRONG&gt;setix1d&lt;/STRONG&gt; and &lt;STRONG&gt;setrx1d&lt;/STRONG&gt;, that take a 1-D array, of the appropriate type, as the first argument.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Apr 2014 12:11:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-the-subroutine-expecting-multi-dimension-array-with-the/m-p/968245#M96335</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2014-04-02T12:11:15Z</dc:date>
    </item>
    <item>
      <title>The point of interfaces is to</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-the-subroutine-expecting-multi-dimension-array-with-the/m-p/968246#M96336</link>
      <description>&lt;P&gt;The point of interfaces is to detect such a situation so you can be happy in the knowledge that the compiler is doing the right thing.&lt;/P&gt;

&lt;P&gt;If you put your 'set' subroutines in a module you could create specific versions for 1 and 2 d arrays and use module procedure to define a generic interface (as suggested above).&lt;/P&gt;

&lt;P&gt;In this particular case you might want to consider doing the array initialization directly:&lt;/P&gt;

&lt;P&gt;[fortran]&lt;/P&gt;

&lt;P&gt;x = reshape([((i*j,i=1,m),j=1,n)],[m,n])&lt;/P&gt;

&lt;P&gt;[/fortran]&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Apr 2014 14:34:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-the-subroutine-expecting-multi-dimension-array-with-the/m-p/968246#M96336</guid>
      <dc:creator>Simon_Geard</dc:creator>
      <dc:date>2014-04-02T14:34:59Z</dc:date>
    </item>
    <item>
      <title>The purpose of code is cast a</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-the-subroutine-expecting-multi-dimension-array-with-the/m-p/968247#M96337</link>
      <description>&lt;P&gt;The purpose of code is cast a address of one-dimension array into multi-dimension array in subroutine.&lt;/P&gt;
&lt;P&gt;In subroutines the multi-dimension array will be readable and easy to be manipulated.&lt;/P&gt;
&lt;P&gt;For example;&lt;/P&gt;
&lt;P&gt;I define a large one-dimension array, F(1000).&amp;nbsp; I wan to use F(200:499) as a three-dimension coordinates array.&lt;/P&gt;
&lt;P&gt;So I'd like to cast the F(200) into&amp;nbsp;a multi-dimension array of &amp;nbsp;x[3,100] when subroutines&amp;nbsp;setx is called.&lt;/P&gt;
&lt;P&gt;call setx(3,100,F(200))&lt;/P&gt;
&lt;P&gt;In subroutines setx, the X(3,100) will be readable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Apr 2014 02:41:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/calling-the-subroutine-expecting-multi-dimension-array-with-the/m-p/968247#M96337</guid>
      <dc:creator>liuhuafei</dc:creator>
      <dc:date>2014-04-03T02:41:02Z</dc:date>
    </item>
  </channel>
</rss>

