前言
Fortran77没有全局变量这一说,也就是几个subroutines之间都用的变量。Fortran77都是使用subroutine parameter list 或者叫做common block,但是我们应该减少使用全局变量的定义。
一、例子。定义两个全局变量alpha, beta
c2345678
program main
some declarations
real alpha, beta
common /coeff/ alpha, beta
statements
stop
end
subroutine sub1 (some arguments)
declarations of arguments
real alpha, beta
common /coeff/ alpha, beta
statements
return
end
subroutine sub2 (some arguments)
declarations of arguments
real alpha, beta
common /coeff/ alpha, beta
statements
return
end
这里我们定义一个公共区域coeff(coeff是这个公共区域的名字). 上述程序在common blocks中定义了两个变量一个叫做alpha,另一个叫beta。common block中可以定义很多的全局变量。这些变量在common block定义时,不必所有的变量类型都一样。每一个想要使用全局变量的su