Error: unclassifiable statement in fortran

63,942

Solution 1

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

Solution 2

Just as ifort prompts that (variable z)This name has not been declared as an array or a function.u need to declare variable x,y,z to be arrays in subroutine polymul.

Share:
63,942
Admin
Author by

Admin

Updated on July 09, 2022

Comments

  • Admin
    Admin 6 months

    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