Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

calling the subroutine expecting multi-dimension array with the address of one-dimension array

$
0
0

Hello!


    I write a subroutine setrx and setix expecting a multi-dimensional array.
When they are called in main code, an address of a location in a one dimensional array
can be passed to them.  It works well.


   But After I put the setrx and setix in a interface, calling the setx with the address
of one-dimension array will lead compile errors.


  I  need the help. Thanks in advance.



!#########################################################
program main
!#########################################################
implicit none


interface setx
  subroutine setrx(m,n,x)
  integer,intent(in) :: m
  integer,intent(in) :: n
  real,intent(out)   :: x(m,*)
  end subroutine setrx


  subroutine setix(m,n,x)
  integer,intent(in) :: m
  integer,intent(in) :: n
  integer,intent(out):: x(m,*)
  end subroutine setix
end interface setx


real    :: rx(10),rxx(3,10)
integer :: ix(10),ixx(4,10)


call setrx(1,10,rx)
call setix(1,10,ix)
call setrx(3,10,rxx)
call setix(4,10,ixx)
!
!  the following calls will lead two errors
!
! error #6285: There is no matching specific subroutine for this generic subroutine call.   [SETX]
! ===================================================
call setx(1,10,rx) 
call setx(1,10,ix)
! ===================================================
!
!  the following calls are ok
!
call setx(3,10,rxx)
call setx(4,10,ixx)
!
end
end program main


!=====================================================
subroutine setrx(m,n,x)
!=====================================================
implicit none
integer,intent(in) :: m
integer,intent(in) :: n
real,intent(out)   :: x(m,*)


integer :: i,j


do j=1,n
  do i=1,m
   x(i,j) = 1.0*i*j
  end do
end do
end subroutine setrx


!=====================================================
subroutine setix(m,n,x)
!=====================================================
implicit none
integer,intent(in) :: m
integer,intent(in) :: n
integer,intent(out):: x(m,*)


integer :: i,j


do j=1,n
  do i=1,m
   x(i,j) = i*j
  end do
end do
end subroutine setix


Viewing all articles
Browse latest Browse all 5691

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>