首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Fortran程序错误

Fortran程序错误
EN

Stack Overflow用户
提问于 2013-02-05 13:37:57
回答 1查看 792关注 0票数 0

我希望您能帮助我编写一个程序,将fortran数组(n,m)转换为表(p,3)。

我试着用这个程序:

代码语言:javascript
复制
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 

但错误消息显示为:

代码语言:javascript
复制
 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)

有人能帮我吗?我会提前通知你的。

EN

回答 1

Stack Overflow用户

发布于 2013-02-06 16:46:13

仅从您的示例代码来看,要弄清楚这段代码的用处有点困难。您在定义的问题中提到的数组“array”在哪里?如果你想循环遍历一些东西,你需要使用'do‘statement1。此外,我会尝试以编程方式访问该数组的维数,因此您不必对其进行硬编码。下面的代码片段并不完整,但也许它能让您上手。

代码语言:javascript
复制
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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14700855

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档