HP Fortran Programmer's Reference (September 2007)

Program units and procedures
Internal procedures
Chapter 7168
END PROGRAM main
! print_avg is an external subprogram
SUBROUTINE print_avg(x)
REAL :: x(:) ! an assumed-shape array
! reference the internal function get_avg
PRINT *, get_avg(x)
CONTAINS ! start of internal procedure part
REAL FUNCTION get_avg(a) ! get_avg is an internal procedure
! The interface of an internal procedure is explicit within
! the hosting unit, so this function may declare a as an
! assumed-shape array.
REAL a(:) ! an assumed-shape array
! references to the SUM and SIZE intrinsics
get_avg = SUM(a) / SIZE(a)
END FUNCTION get_avg
END SUBROUTINE print_avg
Here are the command lines to compile and execute the program, along with the output from
a sample run:
$ f90 int_func.f90
$ a.out
4.66667