
	MODULE DYNA
	IMPLICIT NONE
	REAL, DIMENSION(:), ALLOCATABLE, SAVE :: WORK
	END MODULE DYNA

	PROGRAM TEST_OF_DYNA
	USE DYNA
	IMPLICIT NONE
	PRINT *, 'MAIN'
	CALL SUB1
	CALL SUB2
	PRINT *, 'MAIN'
	END PROGRAM TEST_OF_DYNA
	
	SUBROUTINE SUB1
	USE DYNA
	IMPLICIT NONE
!	The size of WORK is determined here
	INTEGER :: I
	REAL, DIMENSION(5) :: A, B
	PRINT *, 'SUB1'
        A = 1.0
	B = (/ (3.0, I = 1, 5) /)
	ALLOCATE ( WORK(SIZE(B)) )
	WORK = A
        WRITE(*,*) A
        WRITE(*,*) B
        WRITE(*,*) WORK
	END SUBROUTINE SUB1
	
	SUBROUTINE SUB2
	USE DYNA
	IMPLICIT NONE
!	The array WORK is used here
	REAL :: B
	REAL, DIMENSION(:), ALLOCATABLE :: A
	PRINT *, 'SUB2'
	ALLOCATE ( A(SIZE(WORK)) )
        A = 2.*WORK
	B = SUM(WORK)
	WORK = A
        WRITE(*,*) A
        WRITE(*,*) B
        WRITE(*,*) WORK
	END SUBROUTINE SUB2
