24.11.2014 Views

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Functions and Subroutines<br />

12.6.1 ENTRY Statements in External Functions<br />

Entry names may also appear in type statements. Their type may or may not be the same type as other<br />

entry names or the actual name of the external function unless the function is of type CHARACTER. If the<br />

function is of type CHARACTER then the type of all the entry names must be of type CHARACTER.<br />

Conversely, if an entry name is of type CHARACTER, then all other entry names and the function name<br />

must be of type CHARACTER. An entry name, like external function names, is treated as a variable within<br />

the subprogram it appears. Within a function subprogram, there is an association between variables whose<br />

name is an entry name and the variable whose name corresponds to the external function. When such a<br />

variable becomes defined, all other such variables of the same type also become defined and other such<br />

variables not of the same type become undefined. This can be best illustrated by an example.<br />

Example:<br />

PRINT *, EVAL(2), EVAL3(4.0)<br />

END<br />

INTEGER FUNCTION EVAL( X )<br />

INTEGER EVAL2, X<br />

REAL EVAL3, Y<br />

C = 1<br />

GOTO 10<br />

ENTRY EVAL2( X )<br />

C = 2<br />

GOTO 10<br />

ENTRY EVAL3( Y )<br />

C = 3<br />

10 EVAL2 = C * X<br />

END<br />

In the previous example, invoking EVAL would cause the result of 2 to be returned even though EVAL was<br />

never assigned to in the function EVAL but since EVAL2 and EVAL are of the same type they are associated<br />

and hence defining EVAL2 causes EVAL to be defined. However, invoking EVAL3 would cause an<br />

undefined result to be returned since EVAL3 is of type REAL and EVAL2 is of type INTEGER and hence<br />

are not associated. EVAL3 does not become defined.<br />

12.6.2 ENTRY Statement Restrictions<br />

1. An entry name may not appear in any statement previous to the ENTRY statement containing the<br />

entry name except in a type statement.<br />

2. If an entry name in a function is of type CHARACTER, each entry name and the name of the<br />

function must also be of type CHARACTER. If the name of the function or the name of any<br />

entry point has a length specification of (*), then all such entities must have a length<br />

specification of (*) otherwise they must all have a length specification of the same integer<br />

value.<br />

3. If a dummy argument appears in an executable statement, then that statement can be executed<br />

provided that the dummy argument is in the dummy argument list of the procedure name<br />

referenced.<br />

4. A name that appears as a dummy argument in an ENTRY statement must not appear in the<br />

expression of a statement function unless it is a dummy argument of the statement function, it<br />

has appeared in the dummy argument list of a FUNCTION or SUBROUTINE statement, or the<br />

ENTRY statement appears before the statement function statement.<br />

The ENTRY Statement 275

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!