HP 3000 Manuals

ENTRY Statement (Nonexecutable) [ HP FORTRAN 77/iX Reference ] MPE/iX 5.0 Documentation


HP FORTRAN 77/iX Reference

ENTRY Statement (Nonexecutable) 

The ENTRY statement provides an alternate name, argument list, and
starting point for a function or subroutine.  It can appear only in a
subroutine or function subprogram, not in a main program or block data
subprogram.

[]
----------------------------------------------------------------------------------------------- | | | | | Item | Description/Default | Restrictions | | | | | ----------------------------------------------------------------------------------------------- | | | | | name | Name for the alternate starting | None. | | | point. | | | | | | ----------------------------------------------------------------------------------------------- | | | | | * | Placeholder for alternate return | Asterisk is permitted only in a | | | points. | subroutine. | | | | | ----------------------------------------------------------------------------------------------- Semantics The formal arguments in an ENTRY statement can differ in order, number, type, and name from the formal arguments in the FUNCTION statement, SUBROUTINE statement, or other ENTRY statements. However, for each call to the subprogram through a given entry point, only the formal arguments of that entry point can be used. When records are passed as arguments to entry points, all the fields in the record must agree in type, order, and dimension with the declared formal arguments. If no formal arguments are listed after a particular ENTRY statement, no arguments are passed to the subprogram when a call to that ENTRY name is made. The ENTRY statement name cannot appear as a variable in any statement prior to the ENTRY statement, except in a type statement within a function subprogram. Within a subprogram, an entry name must not appear both as an entry name in an ENTRY statement and as a formal argument in a FUNCTION or SUBROUTINE statement, or another ENTRY statement. An entry name must not appear in an EXTERNAL statement. An ENTRY statement can appear anywhere in a subprogram after the FUNCTION or SUBROUTINE statement, with the exception that the ENTRY statement must not appear between a block IF statement and its corresponding END IF statement, or between a DO statement and the end of its DO loop. A subprogram can have zero or more ENTRY statements. An ENTRY statement is a nonexecutable statement. If control falls into an ENTRY statement, the statement is treated as an unlabeled CONTINUE statement; that is, control moves to the next statement. Within a function subprogram, all variables whose names are also the names of entries are associated with each other and with the variable, if any, whose name is also the name of the function subprogram. Therefore, any such variable that becomes defined causes all associated variables of the same type to become defined, and all those of a different type to become undefined. Such variables are not required to be of the same type unless the type is character, but the variable whose name references the function must be in a defined state when a RETURN or END statement is executed in the subprogram. An associated variable of a different type must not become defined during execution of the function reference. The asterisks in an ENTRY statement are similar to those of the SUBROUTINE statement. Example (User input is underlined.) PROGRAM sum INTEGER i,j WRITE (6,*) 'Enter two numbers: ' READ (5,*) i,n IF (i .EQ. 0) THEN CALL sum1(j) ELSE IF (j .EQ. 0) THEN CALL sum1(i) ELSE CALL sum2(i,j) ENDIF END SUBROUTINE sum2(i,j) WRITE (6,*) 'Neither number equals 0.' i = i + j ENTRY sum1(i) WRITE (6,*) 'The sum of the numbers is', i, '.' RETURN END Enter two numbers: 9 0 The sum of the numbers is 9. Enter two numbers: 1 2 Neither number equals 0. The sum of the numbers is 3.


MPE/iX 5.0 Documentation