简体   繁体   English

使用寓言从Fortran 77转换为C ++

[英]Using Fable to convert from Fortran 77 to C++

I'm just trying to convert a basic helloworld.f program into C++ using fable (in preparation for a bigger program later). 我只是想使用寓言将基本的helloworld.f程序转换为C ++(以备将来使用更大的程序)。 I'm getting an error though that says: 我收到一个错误,虽然说:

fable.read.Error: Missing END for PROGRAM:
  at hello.f(1):
  |      program HelloWorld|

Which I don't understand as it compiles and runs properly otherwise. 我不了解,因为它可以编译并正常运行。 The program is just: 该程序只是:

  program HelloWorld
  implicit none
     write (*,*) 'Hello, world!'   ! This is an inline comment
  end program HelloWorld 

Does anyone see the issue that fable is finding? 有人看到寓言找到的问题吗? I've never used it before so I'm just trying to see how it works. 我以前从未使用过它,所以我只是想看看它是如何工作的。 Thanks in advance for any help! 在此先感谢您的帮助!

I think it can't parse end program HelloWorld . 我认为它无法解析end program HelloWorld Try changing it to end program or just to end . 尝试将其更改为end program或仅end

UPDATE: Indeed, in Fortran 77 everything must end with just END : 更新:确实,在Fortran 77中,所有内容都必须END结尾:

The END statement indicates the end of the sequence of statements and comment lines of a program unit ( 3.5). END语句指示程序单元(3.5)的语句和注释行序列的结尾。 If executed in a function or subroutine subprogram, it has the effect of a RETURN statement ( 15.8). 如果在函数或子例程子程序中执行,则具有RETURN语句(15.8)的作用。 If executed in a main program, it terminates the execution of the executable program. 如果在主程序中执行,它将终止可执行程序的执行。

The form of an END statement is: END语句的形式为:

END 结束

An END statement is written only in columns 7 through 72 of an initial line. END语句仅写在初始行的第7至72列中。 An END statement must not be continued . END语句不能继续 No other statement in a program unit may have an initial line that appears to be an END statement. 程序单元中的其他任何语句都不能具有看起来像END语句的首行。 The last line of every program unit must be an END statement . 每个程序单元的最后一行必须是END语句

Testing with fable on python 2.7.7, you can end your program with either end or end program , but not with end program XXXXX . 在python 2.7.7上使用寓言进行测试,您可以使用endend program ,但不能使用end program XXXXX This is from what I can tell is due to the way this programs parser works and interprets a match against program <something> as a starting program block, even if preceded by end . 据我所知,这是由于此程序解析器的工作方式以及将与program <something>的匹配项解释为起始程序块(即使在end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM