2013-02-05 68 views
0

我想要你的幫助,編寫一個程序來轉換表(p,3)中的fortran數組(n,m)。Fortran程序錯誤

我試着用此程序:

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) 

誰能幫幫我? T 需要提前。

+0

S'il VOUS褶,voyez:http://blog.stackoverflow.com/2009/07/non-english-question-政策/ –

+0

Je voudrais une kilo de pomme de terre,s'il vous plais。對不起,這就是我所記得的:-) – paxdiablo

回答

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

+0

感謝您的幫助 – user2041932