我正在阅读矩阵的行数和列数' A'来自档案 - ' var_and_runs.txt' 但它显示了编译错误 - '意外的数据声明声明'
implicit none
integer i, var, runs
integer rows, cols
open(unit = 30, file = 'var_and_runs.txt')
read(30,*) cols,rows
INTEGER, DIMENSION(:, :), ALLOCATABLE :: A
ALLOCATE (A(rows, cols))
open (unit = 40, file = 'read_this.txt')
read(40,*) A
A = transpose(A)
do 80 i = 1,3
print*, A(i,:)
80 continue
print*, A
end
请帮忙!
答案 0 :(得分:2)
在可执行语句之后,您不能拥有任何变量声明。在您的情况下,您应该替换
open(unit = 30, file = 'var_and_runs.txt')
read(30,*) cols,rows
INTEGER, DIMENSION(:, :), ALLOCATABLE :: A
与
INTEGER, DIMENSION(:, :), ALLOCATABLE :: A
open(unit = 30, file = 'var_and_runs.txt')
read(30,*) cols,rows
希望一切都能正常运作。