next up previous contents
Next: Encapsulation - Stack example Up: Modules Previous: Modules - Procedure Declaration

 

Modules - Procedure Encapsulation

Module procedures are specified after the CONTAINS separator,

    MODULE related_procedures
     IMPLICIT NONE
     ! INTERFACEs of MODULE PROCEDURES do 
     ! not need to be specified they are 
     ! 'already present'
    CONTAINS
     SUBROUTINE sub1(A,B,C)
      ! Can see Sub2's INTERFACE
      ...
     END SUBROUTINE sub1
     SUBROUTINE sub2(time,dist)
      ! Can see Sub1's INTERFACE
      ...
     END SUBROUTINE sub2
    END MODULE related_procedures

The main program attaches the procedures by
use-association

    PROGRAM use_of_module
     USE related_procedures ! includes INTERFACES
     CALL sub1((/1.0,3.14,0.57/),2,'Yobot')
     CALL sub2(t,d)
    END PROGRAM use_of_module
sub1 can call sub2 or vice versa.

For more information, click here gif

Now try this question gif

Now try this question gif

Now try this question gif


next up previous contents
Next: Encapsulation - Stack example Up: Modules Previous: Modules - Procedure Declaration

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