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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With