Fortran77基础
Fortran77的程序就是一系列文本的文件。一个简单的Fortran程序如下:其中c开头的代表的是注释行。
c23456789 (this line demonstrates the column rules)
program circle
real r, area
c This program reads a real number r and prints
c the area of a circle with radius r.
write (*,*) 'Give radius r:'
read (*,*) r
area = 3.14159*r*r
write (*,*) 'Area = ', area
stop
end
一个Fortran程序通常由一个主程序组成。也有可能有subprograms。主程序的结构是:主程序名,变量声明,语句。这里需要注意变量的名字不能跟主程序的名字一样。另外Fortran是不区分大小写的。name declaration statements等斜体加粗表示是非Fortran语句。 program name declarations statements stop end 列位置规则 每一列都是一个空格。第7-72空格位置处才是写命令语句的位置。
Col1Col2-5Col 6Col 7-72Col 73-80空格,c,*,!语句标签(一般都是空格)上下行语句连接符+,&,或者2,3,4这样的第几行语句列序列号(今天基本不用了
添加注释在开头输入c,*,!均可以把当前行编程注释行。 链接上下两行
c23456789
c the next statements goes over two physical lines
area = 3.1415926
+ *r*r
空格是无效的在Fortran77中空格是忽略的,如果你想要你可以除掉所有的空格
|