Error: DATA statement at (1) has more values than variables
我刚学fortran,下面这段代码总编译不成功,总提示 Error: DATA statement at (1) has more values than variablesprogram ex0707
implicit none
integer, parameter :: row = 3
integer, parameter :: col = 2
integer :: m(row, col)
integer r
integer c
data((m(r, c),r=1,2,3),c=1,2)/10,20,30,40,50,60/
write(*, "(i3, i3, /,i3, i3, /, i3, i3)")((m(r, c), c=1,2),r=1,2,3)
stop
end
编译信息如下(警告我都删掉了):
ex0707.f95:9:5:
data((m(r, c),r=1,2,3),c=1,2)/10,20,30,40,50,60/
1
Error: DATA statement at (1) has more values than variables
编译失败。
我没有多赋值啊?请各位指教。
data((m(r, c),r=1,3),c=1,2)/10,20,30,40,50,60/ 既然是刚学,就要学新的,你这个代码风格有点老了。推荐彭国伦的书。另外,使用二维数组,可以看看这个http://fcode.cn/guide-45-1.html
program ex0707
implicit none
integer, parameter :: row = 3, col = 2
integer :: m(row, col)
integer r, c
m = reshape(,)
write(*, "(2i3)") ((m(r, c), c=1,2),r=1,3)
read(*,*)
end 谢谢 我刚发现是这里的错,谢谢,以后多指教。我项用fortran作概率统计分析用
我正在读他的fortran95程序设计, m = reshape(,)这种格式的输入还没看到:-) 恭喜你,学到新东西了 fcode 发表于 2018-6-6 08:31
恭喜你,学到新东西了
谢谢,多指教
页:
[1]