PROGRAM finiteMM1 IMPLICIT NONE INTEGER, DIMENSION(:), ALLOCATABLE :: seed INTEGER, PARAMETER :: DP=SELECTED_REAL_KIND(14) INTEGER :: I,K,N,queuelength,maxarrivals,numarrivals REAL(KIND=DP) :: Rand,lambda,mu CALL RANDOM_SEED(size=K) ALLOCATE (seed(K)) WRITE(*, '(1x, a, i4, a)',ADVANCE="NO")'Enter ', K,& ' integers as random number seeds: ' READ(*, *) seed CALL RANDOM_SEED(put=seed) PRINT *, "Input lambda: " READ *, lambda PRINT *, "Input mu: " READ*, mu PRINT *, "Input queue capacity N: " READ *, N maxarrivals = 500 ! will use PASTA and look at queuelength just before this DO I = 1,100000 numarrivals = 0 queuelength = 0 ! arbitrary starting point A_Loop : DO CALL RANDOM_NUMBER(Rand) IF(Rand <= lambda/(lambda+mu))THEN !next event is arrival numarrivals = numarrivals + 1 queuelength = queuelength + 1 queuelength = min(queuelength,N) ELSE !next event is a departure queuelength = queuelength-1 queuelength = max(queuelength,0) END IF IF(numarrivals == maxarrivals) THEN queuelength = queuelength -1 !take away last arrival to look just before EXIT A_Loop END IF END DO A_Loop PRINT *, queuelength END DO END PROGRAM finiteMM1