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

Adam Marshall ©University of Liverpool, 1996
Fri Dec 6 18:56:08 GMT 1996
Not for commercial use.