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