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

 

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.)

Now try this question gif


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

Adam Marshall ©University of Liverpool, 1996
Fri Dec 6 15:03:35 GMT 1996
Not for commercial use.