HP Fortran Programmer's Reference (September 2007)

HP Fortran statements
ENTRY
Chapter 10 351
name actually referenced in the current call. The same restrictions apply when you use a
dummy argument in a specification expression to specify an array bound or character
length.
A procedure defined by an ENTRY statement may be given an explicit interface by use of an
INTERFACE block. The procedure header in the interface body must be a FUNCTION
statement for an entry to a function subprogram, and a SUBROUTINE statement for an
entry to a subroutine subprogram.
The ENTRY statement was often used in FORTRAN 77 programs in situations where a set of
subroutines or functions had slightly different dummy argument lists but entailed
computations involving identical data and code. In Fortran 90 the use of the ENTRY statement
in such situations can be replaced by the use of optional arguments.
Examples
The following example defines a subroutine subprogram with two dummy arguments. The
subprogram also contains an ENTRY statement that takes only the first dummy argument
specified in the SUBROUTINE statement.
SUBROUTINE Full_Name (first_name, surname)
CHARACTER(20) :: first_name, surname
...
ENTRY Part_Name (first_name)
The following example creates a stack. It shows the use of ENTRY to group the definition of a
data structure together with the code that accesses it, a technique known as encapsulation.
(This example could alternatively be programmed as a module, which would be preferable in
that it does not rely on storage association.)
SUBROUTINE manipulate_stack
IMPLICIT NONE
INTEGER size, top /0/, value
PARAMETER (size = 100)
INTEGER, DIMENSION(size) :: stack
SAVE stack, top
ENTRY push(value) ! Push value onto the stack
IF (top == size) STOP 'Stack Overflow'
top = top + 1
stack(top) = value
RETURN
ENTRY pop(value) ! Pop top of stack and place in value
IF (top == 0) STOP 'Stack Underflow'
value = stack(top)
top = top - 1
RETURN
END SUBROUTINE manipulate_stack