Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: unclassifiable statement in fortran

Tags:

fortran

When I ran the following simple program

program test
! integer m,n,r,i
double precision x(2),y(3),z(4)
x=(/2.0,1.0/)
y=(/1.0,2.0,1.0/)
call polymul(x,2,y,3,z,4)
print *,z
 end

subroutine polymul(x,m,y,n,z,r)
! polynominal multipy
integer i,j,k
do i=1,r
z(i)=0.0
end do
do i=1,m
  do j=1,n
    k=i+j-1
    z(k)=z(k)+x(i)*y(j)
  end do
end do
end

it showed

Error: Unclassifiable statement

like image 746
user2453893 Avatar asked Jun 05 '13 01:06

user2453893


Video Answer


1 Answers

You have not declared what x, y, and z are in the subroutine. Fortran does not know if these variables are functions (that have not been defined) or an array. The fix is simple: declare the arrays explicitly in the subroutine:

    subroutine polymul(x, m, y, n, z, r)
       implicit none
       integer m, n, r
       double precision x(m), y(n), z(r)
       integer i, j, k
       do i=1,r
          z(i)=0.0
       enddo
       do i=1,m
          do j=1,n
             k=i+j-1
             z(k)=z(k)+x(i)*y(j)
          enddo
       enddo
    end subroutine
like image 171
Kyle Kanos Avatar answered Oct 17 '22 05:10

Kyle Kanos