【发布时间】:2011-03-22 01:41:10
【问题描述】:
每当我编译以下 fortran 代码时:
program test
implicit none
integer :: temp(1),i
integer :: z(1:10) = [(i,i=1,10)]
temp(1) = 10
z(2) = temp
end program test
我收到错误:错误 #6366:数组表达式的形状不符合 如果我换行:
z(2) = temp
到
z(2) = temp(1)
它编译并运行良好。为什么不能将单个元素数组分配给另一个数组的元素而不必显式列出该元素。我问这个是因为一些内在函数,如 minloc 和 pack 返回排名 1 的值。例如: z(i) = minloc(z) 产生同样的错误。
【问题讨论】:
标签: arrays fortran variable-assignment