next up previous contents index
Next: Statement Types and Order Up: Program Units Previous: Program Units

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.


next up previous contents index
Next: Statement Types and Order Up: Program Units Previous: Program Units
Helen Rowlands
8/27/1998