0

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)

誰でも私を助けることができますか?よろしくお願いします。

4

1 に答える 1

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

于 2013-02-06T08:46:13.433 に答える