next up previous contents
Next: What Appears in an Up: Program Units Previous: External Function Example

 

Procedure Interfaces

For EXTERNAL procedures it is possible to provide an explicit interface for a procedure. Consider:

    SUBROUTINE expsum( n, k, x, sum )! in interface
     USE KIND_VALS:ONLY long
     IMPLICIT NONE
     INTEGER, INTENT(IN) :: n        ! in interface
     REAL(long), INTENT(IN) :: k,x   ! in interface
     REAL(long), INTENT(OUT) :: sum  ! in interface
     REAL(long), SAVE :: cool_time
      sum = 0.0
      DO i = 1, n
       sum = sum + exp(-i*k*x)
      END DO
    END SUBROUTINE expsum            ! in interface

The explicit INTERFACE for this routine is given by the statements which appear in the declarations part of any program unit that calls expsum:

    INTERFACE           ! for EXTERNAL procedures
     SUBROUTINE expsum( n, k, x, sum )
      USE KIND_VALS:ONLY long
      INTEGER, INTENT(IN) :: n
      REAL(long), INTENT(IN) :: k,x
      REAL(long), INTENT(OUT)  :: sum
     END SUBROUTINE expsum
    END INTERFACE

Interfaces replace any EXTERNAL statements and are not needed for internal (or module) procedures.

For more information, click here gif

Now try this question gif


next up previous contents
Next: What Appears in an Up: Program Units Previous: External Function Example

©University of Liverpool, 1997
Wed May 28 23:37:18 BST 1997
Not for commercial use.