简体   繁体   English

Fortran语法(子例程的声明)

[英]Fortran syntax (declaration of subroutine)

I try to read fortran (i think so) program and can`t understand beginning of subroutine. 我尝试阅读fortran程序(我认为是这样),但无法理解子程序的开头。 Its look like: 它看起来像: fortran1 I cant understand second block (red) - what is this? 我无法理解第二个方块(红色),这是什么? Parameters/arguments, global variable or something like that? 参数/参数,全局变量还是类似的东西?

And yellow is looks like constant array, but language declaration is different in my manual. 黄色看起来像常量数组,但是语言声明在我的手册中有所不同。

Also i cant find declaration of IF like this: 我也找不到这样的IF声明:

在此处输入图片说明

Its a IF (condition) then goto less,eq,greater or something other? 它的IF(条件)然后变小,变大,变大还是其他?

You're looking at rather old fixed source form FORTRAN in which the position of characters on lines is significant. 您正在查看的是旧的固定源格式FORTRAN,其中字符在行上的位置很重要。 In particular any character (other than a 0 or a blank) in column 6 indicates that the line is a continuation of the previous line. 特别是,第6列中的任何字符(非0或空格)都表示该行是前一行的延续。 A C in column 1 indicates a comment. 第1列中的C表示注释。

Strange IF statement first 首先出现奇怪的IF语句

IF( HP(IM) - 70. ) 105,105,110

is an arithmetic if statement. 是算术if语句。 If HP(IM)-70 is negative, go to line labelled 105 , if zero go to line labelled 105 , if positive to line labelled 110 . 如果HP(IM)-70为负,则转到标记为105行,如果为零,则转到标记为105行,如果为正,则转到标记为110行。 Your posting doesn't show those lines, the labels are in columns 1-5 of a line. 您的发布未显示这些行,标签在一行的1-5列中。

Now red 现在红色

COMMON

introduces a common block whose name, if any, then follows enclosed in / / . 引入一个公共块,其名称(如果有的话)紧跟在/ / There then follows a list of the variables in the common block. 然后是公共块中的变量列表。 In your code the declarations of common blocks CONTRL , ALPHA and DON are spread across lines. 在您的代码中,公共块CONTRLALPHADON的声明CONTRL分布。

Your code suggests that the common blocks are being used to pass variables to/from the subroutine without using its argument list. 您的代码建议使用公共块将变量传递到子例程/从子例程传递变量,而不使用其参数列表。 There is probably a program scope with the same common blocks declared, the same common blocks may appear in other subroutines too. 程序范围中可能声明了相同的公共块,相同的公共块也可能出现在其他子例程中。 Don't be surprised if the other scopes have common blocks with the same names but apparently different contents, one of the nefarious uses of common blocks was to fiddle around with variable names. 如果其他作用域具有名称相同但内容显然不同的通用块,请不要感到惊讶,通用块的一种有害用法是摆弄变量名。 Even more fun, a variable which is a 4-byte integer in one scope can be treated as a 4-byte real in another scope. 更有趣的是,在一个作用域中为4字节整数的变量可以在另一作用域中被视为4字节实数。

Now green 现在绿色

DATA TME / ... /

initialises the array TME with the values between / and / . 使用//之间的值初始化数组TME

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

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