Lahey/Fujitsu Fortran

Scope

Names of program units, common blocks, and external procedures have global scope. That is, they may be referenced from anywhere in the program. A global name must not identify more than one global entity in a program.

Names of statement function dummy arguments have statement scope. The same name may be used for a different entity outside the statement, and the name must not identify more than one entity within the statement.

Names of implied-do variables in DATA statements and array constructors have a scope of the implied-do list. The same name may be used for a different entity outside the implied-DO list, and the name must not identify more than one entity within the implied-DO list.

Other names have local scope. The local scope, called a scoping unit, is one of the following:

Names in a scoping unit may be referenced from a scoping unit contained within it, except when the same name is declared in the inner, contained scoping unit. This is known as host association. For example,

 
subroutine external () implicit none integer :: a, b ... contains subroutine internal () implicit none integer :: a ... a=b ! a is the local a; ! b is available by host association ... end subroutine internal ... end subroutine external

In the statement a=b, above, a is the a declared in subroutine internal, not the a declared in subroutine external. b is available from external by host association.

Data Sharing

To make an entity available to more than one program unit, pass it as an argument, place it in a common block (see See COMMON Statement), or declare it in a module and use the module (see See Module Program Units).