fortran - 错误: unclassifiable statement in fortran

标签 fortran

当我运行以下简单程序时

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

这显示了

Error: Unclassifiable statement

最佳答案

您尚未声明子例程中的xyz。 Fortran不知道这些变量是函数(尚未定义)还是数组。解决方法很简单:在子例程中显式声明数组:

    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

关于fortran - 错误: unclassifiable statement in fortran,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16930096/

相关文章:

c++ - C/FORTRAN 将双下溢设置为零

C/Fortran 混合代码以一种奇怪的方式使用 MPI/ScaLAPACK 段错误

fortran - 在Fortran中将逻辑类型转换为 double

python - 用 Python 编写 Fortran 无格式文件

从 c 调用 fortran 77 进行 arpack

c++ - Eigen 在使用显式循环的矩阵乘法中比 Fortran 慢得多

c++ - 混合 C++ 和 Fortran 代码的问题

fortran - 澄清一个 fortran 隐含循环

dynamic - Fortran:命名输出文件时出现 "output statement overflows record"错误

string - 使用 Fortran 读取整数列表文件