Fortran程序错误

时间:2013-02-05 05:37:57

标签: fortran90

我希望你帮忙写一个程序来转换表格中的fortran数组(n,m)(p,3)。

我试过这个程序:

program Temp
implicit none
real,dimension (23250,27)::table
real::time
integer::i
integer::j
integer::wl
integer::al
  i=1,23250  
read(*,*) time(i),wl(i),(table(i,j),j=1,27)
 j=1,27 
alt(j)=j
write(*,*) time(i),alt(j),table(i,j)
continue
continue 

endprogram Temp 

但错误消息显示为:

 D:\Travaux de thèse\modeling\essay\essay.f90(9) : Error: Syntax error, found ',' when expecting one of: <END-OF-STATEMENT> ;
  i=1,23250  
-----^
D:\Travaux de thèse\modeling\essay\essay.f90(11) : Error: Syntax error, found ',' when expecting one of: <END-OF-STATEMENT> ;
 j=1,27 
----^
D:\Travaux de thèse\modeling\essay\essay.f90(10) : Error: Constants and expressions are invalid in read-only I/O lists.   [TIME]
read(*,*) time(i),wl(i),(table(i,j),j=1,27)
----------^
D:\Travaux de thèse\modeling\essay\essay.f90(10) : Error: Constants and expressions are invalid in read-only I/O lists.   [WL]
read(*,*) time(i),wl(i),(table(i,j),j=1,27)
------------------^
D:\Travaux de thèse\modeling\essay\essay.f90(12) : Error: This name has not been declared as an array.   [ALT]
alt(j)=j
^
Error executing df.exe.

essay.exe - 5 error(s), 0 warning(s)

任何人都可以帮助我吗? Ť 提前骚扰你。

1 个答案:

答案 0 :(得分:0)

仅从您的示例代码

来确定此代码的位置有点困难。您在定义的问题中提到的数组“数组”在哪里?如果你想循环某些东西,你需要使用'do'语句[1]。此外,我会尝试以编程方式访问该数组的维度,因此您不必对其进行硬编码。以下代码段不完整,但可能会让您前进。

program Temp
implicit none
real,dimension (23250,27)::table
integer, dimension(2) :: table_shape
real::time
integer::i
integer::j
integer::wl
integer::al

table_shape = shape(table)
do i=1, table_shape(1)
    read(*,*) time(i),wl(i),(table(i,j),j=1,27)
    do j=1, table_shape(2)
        alt(j)=j
        write(*,*) time(i),al(j),table(i,j)
        !continue
        !continue 
    enddo
enddo

endprogram Temp 

最佳, 最大

[1] http://en.wikibooks.org/wiki/Fortran/Fortran_control

相关问题