从 Fortran IV 更新到 Fortran 77

发布于 2024-10-16 08:00:47 字数 424 浏览 4 评论 0原文

我收到了一项咨询任务,我将把 Fortran IV 程序更新到 Fortran 77。问题是我从来没有用 Fortran 编写过代码。您能给我一些关于在哪里可以学习 Fortran 的建议吗?Fortran IV 和 77 之间有什么区别?

编辑

要更新的程序正在MODCOMP 9250上运行(请参阅图片此处)该程序是在原始编译器上开发的。编译器在 1990 年左右更新到 Fortran 77。我的客户想要对应用程序做一些修改,并希望借此机会将代码更新到最新的编译器

I have received an consulting assignment where I will update a Fortran IV program to Fortran 77. The problem is that I never coded in Fortran. Can you give me tips on where I can learn Fortran and what is the difference between the Fortran IV and 77?

Edit

The program to be updated is running on a MODCOMP 9250 (See pictures here) The program was developed on the original compiler. The compiler was updated to Fortran 77 around 1990. My clients want to do some modifications to the application and want to take this opportunity to update the code to the latest compiler

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

疾风者 2024-10-23 08:00:47

这似乎是一个非常奇怪的作业……目的是为了教导编程语言在过去几十年里已经得到了改进吗?如果是这样,为什么不翻译成现代语言,例如 Fortran 95?

虽然我偶尔会遇到遗留的 FORTRAN 77 代码,但自从我使用真正的 FORTRAN IV 以来已经很长时间了——很难记住其中的差异。我认为最大的改进是 IF 语句的改进,这使得编写更清晰的代码变得更容易。更改列表显示在 http://en.wikipedia.org/wiki/Fortran

如果如果您使用的是 gfortran,则以下选项应编译 FORTRAN 77 程序:

gfortran -ffixed-form  -ffixed-line-length-none  -W  -Wall -pedantic -o my_prog.exe   my_prog.for

This seems a really bizarre assignment ... is the purpose to teach that programming languages have improved over the decades? If so, why not translate into a modern language, such as Fortran 95?

While I occasionally encounter legacy FORTRAN 77 code, it has been a very long time since I worked with true FORTRAN IV -- it is hard to remember the differences. I think that the biggest was improved IF statements, that made it easier to write clearer code. A list of the changes appears at http://en.wikipedia.org/wiki/Fortran

If you are using gfortran, the following options should compile a FORTRAN 77 program:

gfortran -ffixed-form  -ffixed-line-length-none  -W  -Wall -pedantic -o my_prog.exe   my_prog.for
奶茶白久 2024-10-23 08:00:47

检查两者之间差异的最佳位置是 Fortran 标准草案(最新草案实际上与已发布的标准相同;只是它们可以免费下载)。

例如,f77 标准

然而问题是,在 fIV 标准时代并没有如此遵循,几乎所有(我什至可以肯定地说所有)编译器都包含各种供应商扩展,其中一些肯定可以在您的应用程序中找到。程序也是如此。因此,如果您也有编译器手册,请拿一本。

“更新到 f77”的过程(天啊,我从没想过我会这么说 - “更新到 f77”)对你来说,最好以某种方式进行。
a) 在某处学习 Fortran 简短教程(很多都在互联网上);只是为了看看 fortran 是什么样子
b) 一旦您开始识别程序元素和结构,您就可以开始翻译它。很可能你将不得不将很多 TYPE (取决于)转换为 WRITE 或 PRINT,修改一些 IF 语句,修改一些文件输入/输出操作,你可能还会遇到一些 COMMON,通过它们你可以有或多或少的问题,......无论如何,尝试一下,当遇到困难时,在这里发帖。

你的任务有多大?

ps 正如我在上面的一些评论中所说,您正在翻译的程序很可能并不是真正的 fIV,而是 fIV、f66/77 的混合体,甚至可能是 f90 的某些元素 - 但您的教授/布置作业的人不是意识到其中的差异。除非您只是从旧数据磁带上复制它。我以前经常看到这样的例子。

The best place for checking the differences between the two is the fortran standards drafts (latest drafts are practically identical to the published standards; only they're free for download).

For example, f77 standard.

The problem however is that in the time of fIV standards were not so followed, and almost all (I can even safely say all) compilers included a variety of vendor extensions, of which some are surely found in your program as well. So, take a compiler manual, if you have one, as well.

The process of "updating to f77" (Gawd, I never thought I would say that - "updating to f77") would for you, be best to go in a way.
a) take a fortran short tutorial somewhere (a lot of them on the internet); just to see what fortran looks like
b) once you start recognizing program elements and structures, you can start translating it. Probability is that you will have to translate a lot of TYPE (depends) to WRITE or PRINT, modify some IF statements, modify some file input/output operations, you'll probably also encounter some COMMONs, with which you can have more or less problems, ... in any case, try, and when get stuck, post here.

How big is your assignment?

p.s. As I said in some comment above, chances are the program you're translating isn't really fIV but a mixture of fIV, f66/77, maybe even some elements of f90 - but your professor/person giving the assignment isn't aware of the difference. Unless you just copied it from an old data tape. I used to see such examples all the time.

北陌 2024-10-23 08:00:47

Fortran IV 的大部分内容都是有效的 Fortran 77。如果您可以找到安装了 g77(旧的 GNU Fortran 77 编译器)的平台,打开标准合规模式,并且编译时没有警告或错误,那么您就完成了。如果教授们说这还不够,他需要更具体地说明他想要什么。

我不知道 Fortran 95 编译器是否有一个选项可以让您检查 Fortran 77 合规性。

Most of Fortran IV is valid Fortran 77. If you can find a platform with g77 (the old GNU Fortran 77 compiler) installed, turn on standards-compliance-mode, and compile without warnings or errors, you are done. If the professors says that is not enough, he needs to be more specific about what he wants.

I don't know if any Fortran 95 compilers have an option that lets you check for Fortran 77 compliance.

笑红尘 2024-10-23 08:00:47

谷歌搜索“fortran 77 教程”会出现相当多的结果,看起来像是对 Fortran 77 程序的结构和语法的合理介绍(我不能推荐任何个人经验,因为我早在大学就学过) -对我来说最热门的内容看起来就像一个很好的介绍:

http ://www-teaching.physicals.ox.ac.uk/Unix+Prog/hargrove/tutorial_77/

您可能还需要查找有关您将使用的编译器的具体细节(gfortran 似乎当今 Linux 的标准命令行),如果只是为了找出如何编译代码的正确命令行。

如果您来自更现代语言的背景,那么需要了解的关键点是:

  • 标准 Fortran 77 不是一种自由格式语言
  • 它是过程性的并且不支持面向对象(尽管这在以后的版本中可用)语言)

但是它确实支持通常的基本编程结构,即 if/else、循环等。

希望这会有所帮助 - 祝你好运!

Googling "fortran 77 tutorial" throws up quite a few hits which look like reasonable introductions to the structure and syntax of Fortran 77 programs (I can't recommend anything from personal experience as I learnt it at university way back in the day) - the top hit for me looks like as good an intro as any:

http://www-teaching.physics.ox.ac.uk/Unix+Prog/hargrove/tutorial_77/

You'll probably also need to look up specific details on the compiler you'll be using (gfortran seems to the standard one for Linux these days), if only to find out the correct command line how for compiling your code.

If you're coming form the background of more modern languages then the key points to know are:

  • Standard Fortran 77 is not a free-format language
  • It is procedural and doesn't support object-orientation (though this is available in later revisions of the language)

However it does support the usual basic programming structures i.e. if/else, loops etc.

Hope this helps - good luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文