next up previous contents
Next: External Function Syntax Up: External Subroutine Syntax Previous: External Subroutine Syntax

 

External Subroutine Example

An external procedure may invoke a further external procedure,

  SUBROUTINE sub1(a,b,c)
   IMPLICIT NONE
   EXTERNAL sum_sq
   REAL :: a, b, c, s
     ...
    CALL sum_sq(a,b,c,s)
    ...
  END SUBROUTINE sub1

calls,

  SUBROUTINE sum_sq(aa,bb,cc,ss)
   IMPLICIT NONE
    REAL, INTENT(IN) :: aa, bb, cc
    REAL, INTENT(OUT) :: ss
    ss = aa*aa + bb*bb + cc*cc
  END SUBROUTINE sum_sq

The principle is the same as for calling an internal procedure except that:

  1. whereas an internal procedure has access to the host's declarations (and so inherits, amongst other things, the IMPLICIT NONE) external procedures do not. An IMPLICIT NONE is needed in every external procedure.
  2. the external procedure should be declared in an EXTERNAL statement. (This is optional but is good practise.)

Return to corresponding overview page gif


next up previous contents
Next: External Function Syntax Up: External Subroutine Syntax Previous: External Subroutine Syntax

©University of Liverpool, 1997
Wed May 28 20:20:27 BST 1997
Not for commercial use.