We can also encapsulate the stack program,
MODULE stack IMPLICIT NONE INTEGER, PARAMETER :: stack_size = 100 INTEGER, SAVE :: store(stack_size), pos=0 CONTAINS SUBROUTINE push(i) INTEGER, INTENT(IN) :: i ... END SUBROUTINE push SUBROUTINE pop(i) INTEGER, INTENT(OUT) :: i ... END SUBROUTINE pop END MODULE stack
Any program unit that includes the line:
USE stack CALL push(2); CALL push(6); .. CALL pop(i); ....can access pop and push therefore use the 100 element global integer stack.
For more information, click here