home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 349_01 / sss.arc / EX_0401.FOR < prev    next >
Text File  |  1991-04-09  |  3KB  |  109 lines

  1. C     Program EX_0401.FOR
  2. C     Listing 6F - see documentation in TUTOR.SSS
  3.  
  4. $include:'SSSF1.H'
  5.  
  6.       subroutine prime
  7. $include:'SSSF2.H'
  8.       integer ARRIVL, TRYBUY, REPLNS, CUSTMR, GOODS
  9.       real*8 c, mean, min, mode, max, limit
  10.       common ARRIVL, TRYBUY, REPLNS, CUSTMR, GOODS,
  11.      +  c, mean, min, mode, max, limit
  12.       real*8 endt
  13.       data endt /40.0/
  14.  
  15.       ARRIVL = 1
  16.       TRYBUY = 2
  17.       REPLNS = 3
  18.       CUSTMR = 0
  19.       GOODS  = 1
  20.       mean   = 2.0
  21.       c      = 15.0
  22.       min    = 5.0
  23.       mode   = 7.0
  24.       max    = 9.0
  25.       limit  = 4.0
  26.  
  27.       call INIQUE(0, 0, 2)
  28.       call inista(1,'Outof stock          ',0, 0, 0, 0)
  29.       call inista(2,'Avestock             ',1, 0, 0, 0)
  30.       call SIMEND(endt)
  31.       call CREATE(EX(mean), CUSTMR)
  32.       call TALLY(2, c)
  33.       return
  34.       end
  35.  
  36.       subroutine buying
  37. $include:'SSSF2.H'
  38.       integer ARRIVL, TRYBUY, REPLNS, CUSTMR, GOODS
  39.       real*8 c, mean, min, mode, max, limit
  40.       common ARRIVL, TRYBUY, REPLNS, CUSTMR, GOODS,
  41.      +  c, mean, min, mode, max, limit
  42.  
  43.       if (c.eq.limit)
  44.      +  call CREATE(TR(min, mode, max), GOODS)
  45.       if (c.gt.0) then
  46.         c = c - 1
  47.       else
  48.         call TALLY(1, 1)
  49.       endif
  50.       call TALLY(2, c)
  51.       call DISPOS
  52.       return
  53.       end
  54.  
  55.       subroutine order
  56. $include:'SSSF2.H'
  57.       integer ARRIVL, TRYBUY, REPLNS, CUSTMR, GOODS
  58.       real*8 c, mean, min, mode, max, limit
  59.       common ARRIVL, TRYBUY, REPLNS, CUSTMR, GOODS,
  60.      +  c, mean, min, mode, max, limit
  61.  
  62.       c = c + 12
  63.       call TALLY(2, c)
  64.       call DISPOS
  65.       return
  66.       end
  67.  
  68.       Program EX_0401
  69. $include:'SSSF2.H'
  70.       integer ARRIVL, TRYBUY, REPLNS, CUSTMR, GOODS
  71.       real*8 c, mean, min, mode, max, limit
  72.       common ARRIVL, TRYBUY, REPLNS, CUSTMR, GOODS,
  73.      +  c, mean, min, mode, max, limit
  74.       integer ecode
  75.  
  76.       call prime
  77.  
  78.   99  ecode = NEXTEV()
  79.       if (ecode.gt.0) then
  80.         goto (101, 102, 103) ecode
  81.  
  82. C ARRIVL
  83.   101   continue
  84.         if (IDE().eq.CUSTMR) then
  85.           call CREATE(EX(2.0), CUSTMR)
  86.           call SCHED(0.0, TRYBUY, IDE())
  87.         else
  88.           call SCHED(0.0, REPLNS, IDE())
  89.         endif
  90.         goto 99
  91.  
  92. C TRYBUY
  93.   102   continue
  94.         call buying
  95.         goto 99
  96.  
  97. C REPLNS
  98.   103   continue
  99.         call order
  100.         goto 99
  101.  
  102.       else
  103.  
  104.         call SUMRY(' ')
  105.         stop 'End of simulation'
  106.  
  107.       endif
  108.       end
  109.