SuivantPrec.Bas prec.BasNiv. sup.

4.3 Program Units 

A complete executable program consists of one or more program units. There is always one (and only one) main program unit: this starts with a PROGRAM statement. There may also be any number of subprogram units of any of the three varieties: Subroutines and external functions are known collectively as external procedures; block data subprograms are not procedures and are used only for the special purpose of initialising the contents of named common blocks.

Every program unit must end with an END statement.

Procedures 

Subroutines and external functions are collectively known as external procedures: they are described in full in section 9. A procedure is a self-contained sequence of operations which can be called into action on demand from elsewhere in the program. Fortran supplies a number of intrinsic functions such as SIN, COS, TAN, MIN, MAX, etc. These are procedures which are automatically available when you need to use them in expressions. External functions can be used in similar ways: there may be any number of arguments but only one value is returned via the function name.

The subroutine is a procedure of more general form: it can have any number of input and output arguments but it is executed only in response to an explicit CALL statement.

Procedures may call other procedures and so on, but a procedure may not call itself directly or indirectly; Fortran does not support recursive procedure calls.

Most Fortran systems allow procedures to be written in other languages and linked with Fortran modules into an executable program. If the procedure interface is similar to that of a Fortran subroutine or function this presents no problem.

The normal way to transfer information from one program unit to another is to use the argument list of the procedure as described in section 9, but it is also possible to use a common block: a shared area of memory. This facility, which is less modular, is described in section 12.

SuivantPrec.Bas prec.HautNiv. sup.