All entry names within a function subprogram are associated with the name of the function subprogram. Therefore, defining any entry name or the name of the function subprogram defines all the associated names with the same data type. All associated names with different data types become undefined.
The function and entry names do not need to have the same data type, but they all must be consistent within one of the following groups of data types:
Group 1: | BYTE, INTEGER*1, INTEGER*2, INTEGER*4, INTEGER*8 (Alpha only) , LOGICAL*1, LOGICAL*2, LOGICAL*4, LOGICAL*8 (Alpha only) , REAL*4, DOUBLE PRECISION (REAL*8), COMPLEX*8, DOUBLE COMPLEX (COMPLEX*16) (Alpha only) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Group 2: | REAL*16 (VMS, U*X), DOUBLE COMPLEX (COMPLEX*16) (VAX only) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Group 3: | CHARACTER |
When either a RETURN statement or an implied return at the end of a subprogram is executed, the symbolic name used to refer to the function subprogram must be defined.
If the function has a character data type, all entry names must have the same character data type and length specification as the function. The specified length must also agree with the length specified in the program unit referring to the entry name. If an asterisk enclosed in parentheses is used to specify the length of the entry name, the entry name has a passed length (see Section 6.1.1.4).
The following example illustrates a function subprogram that computes the hyperbolic functions sinh, cosh, and tanh:
REAL FUNCTION TANH(X) C Statement function to compute twice sinh TSINH(Y) = EXP(Y) - EXP(-Y) C Statement function to compute twice cosh TCOSH(Y) = EXP(Y) + EXP(-Y) C Compute tanh TANH = TSINH(X)/TCOSH(X) RETURN C Compute sinh ENTRY SINH(X) SINH = TSINH(X)/2.0 RETURN C Compute cosh ENTRY COSH(X) COSH = TCOSH(X)/2.0 RETURN END