Error: unclassified statement in fortran

When I ran the next 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 

he showed

Error: Unclassified Statement

+6
source share
2 answers

You have not declared that x , y and z are in a subroutine. Fortran does not know whether these variables are functions (which are not defined) or an array. The fix is ​​simple: declare arrays explicitly in a 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 
+9
source

Just as ifort requests (variable z) This name has not been declared as an array or function. It is necessary to declare the variables x, y, z arrays in the polymul subroutine.

+2
source

Source: https://habr.com/ru/post/946556/


All Articles