next up previous contents
Next: Visualisation of Global Storage Up: Modules Previous: Implementation of a Stack

 

Module Global Data Example

For example, the following defines a very simple 100 element integer stack

   MODULE stack
    INTEGER, PARAMETER :: stack_size = 100
    INTEGER, SAVE :: store(stack_size), pos=0
   END MODULE stack

and two access functions,

    SUBROUTINE push(i)
     USE stack
     IMPLICIT NONE
      ...
    END SUBROUTINE push
    SUBROUTINE pop(i)
     USE stack
     IMPLICIT NONE
      ...
    END SUBROUTINE pop

A main program can now call push and pop which simulate a 100 element INTEGER stack -- this is much neater than using COMMON block.

For more information, click here gif


next up previous contents
Next: Visualisation of Global Storage Up: Modules Previous: Implementation of a Stack

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