Intel fortran-80 manual External Procedures, FUNCTION Statement, Referencing External Functions

Models: fortran-80

1 130
Download 130 pages 742 b
Page 52
Image 52
5.2 External Procedures

Functions And Subroutines

FORTRAN-80

A statement function may be referenced only in the program unit where it is defined. The statement function may not reference another statement function if that other function is defined later in the program unit. Furthermore, a statement function in a FUNCTION subprogram must not reference the name of the subprogram. A reference to an external function in the expression of a statement function must not cause a dummy argument of the statement function to become undefined or redefin- ed.

5.2 External Procedures

This section desi:ribes external procedures, specifically procedures defined by FUNCTION and SUBROUTINE subprograms. It also describes statements related to external procedures: RETURN, SAVE, EXTERNAL, and the subroutine CALL.

5.2.1 FUNCTION Statement

The FUNCTION statement introduces a FUNCTION subprogram. The FUNC- TION statement must always be the first statement of the subprogram and the sub- program must be terminated with an END statement.

The format of the FUNCTION statement is

[typ] FUNCTION tunc ([dum [,dum] ...])

where

typ is either INTEGER [*Ien], REAL, or LOGICAL [*lenJ, len being

1,2, or 4.

June is the symbolic name of the subprogram and is an external function name.

dum is a dummy argument and is either a variable, array, or dummy procedure name.

The FUNCTION subprogram name, appearing as a variable within the subprogram, must become defined or redefined each time the subprogram is executed. The value of this variable when a RETURN or END is executed is the value of the function. An external function in a subprogram may use dummy arguments to return values in addition to the function value returned.

If 'typ' is not specified, the type and length of 'func' are determined by the default conventions described in sections 2.2.2.1 and 2.2.2.2.

5.2.1.1 Referencing External Functions.

An external function is referenced by specifying its name in an expression (along with all necessary actual arguments).

The actual arguments in the reference must agree in order, number, type, and length with their corresponding dummy arguments. One exception is the use of a subroutine name as an actual argument; subroutine names do not have an associated type. Actual arguments must also be one of the following:

An expression

An array name

An intrinsic function name

An external procedure name

A dummy procedure name

5-4

Page 52
Image 52
Intel fortran-80 manual External Procedures, FUNCTION Statement, Referencing External Functions, typ FUNCTION tunc dum ,dum