      subroutine GHOST(Y,IT)
      include 'SIZE.INC'
      include 'GLOBAL.INC'
      include 'LOCAL.INC'
      include 'UNITS.INC'
      include 'INPAR.INC'
      include 'LOCAL1.INC'
      include 'LOCAL2.INC'
      double precision Y(KOUNT,KCHEM)
      integer IBUFF(VARIEC), IT
      integer I, J, K, K2, NFIRST, NLAST, ISAVE
      if (BATCH.gt.0) go to 170
      call STARTG
      if (IFLAG.eq.8) go to 260
      call PRCHEM
      if (IFLAG.eq.8) go to 260
      call PRPROD
      call CKPULS
      call PRENV
      if (IFLAG.eq.8) go to 260
      if (PRSWG.eq.0.or.MODEG.eq.3) then
         NFIRST = 1
         NLAST = 12
      else
         NFIRST = MONTHG
         NLAST = MONTHG
      endif
      do 100 I = 1, 52
         ACCUM1(I) = 0.0
100   continue
      do 110 J = 1, KOUNT
         ACCUM3(7,J) = 0.0
         do 110 I = 1, 6
            ACCUM3(I,J) = 0.0
            ACCUM4(I,J) = 0.0
            do 110 K = 1, KCHEM
               ACCUM2(I,J,K) = 0.0
110   continue
      do 130 NDAT = NFIRST, NLAST
         call DISTRB
         call FLOWS
         if (IFLAG.eq.8) go to 260
         call CKLOAD
         if (IFLAG.ne.8) go to 120
         if (MODEG.eq.1) go to 260
120      continue
         call SOLAR
         call FIRORD
         if (MODEG.lt.3.and.PRSWG.gt.0) go to 130
         call PACSCR (IBUFF)
130   continue
      if (MODEG.lt.3.and.PRSWG.eq.0) call M12BAR
      if (MODEG.eq.2) call CKICM2 (Y)
      if (IFLAG.eq.8) go to 260
      if (MODEG.ne.1) go to 140
      call STEADY (Y)
      if (IFLAG.ge.8) go to 260
140   continue
      if (MODEG.gt.2) go to 160
      call PRICL (1)
      if (MODEG.ne.1) go to 160
      call AVEOUT (Y)
      call FLXOUT (Y)
      do 150 K2 = 1, KCHEM
         QWSAV(K2) = Z(5,K2)
         QSSAV(K2) = Z(6,K2)
         QTSAV(K2) = Z(5,K2)+Z(6,K2)
150   continue
160   continue
      if (KOUNTW.eq.0.0) KOUNTW = 1.0
      if (KOUNTS.eq.0.0) KOUNTS = 1.0
      go to 260
170   continue
      ISAVE = RPTLUN(MACHNO)
      RPTLUN(MACHNO) = TTYOUT(MACHNO)
      go to (180,190,200,210,220,230,240), IT
180   continue
      BATCH = 1
      call TABC
      go to 250
190   continue
      BATCH = 1
      call TABD
      go to 250
200   continue
      BATCH = 1
      call SOLAR
      go to 250
210   continue
      BATCH = 1
      call CKPULS
      go to 250
220   continue
      BATCH = 1
      call PRPROD
      go to 250
230   continue
      BATCH = 1
      call PRCHEM
      go to 250
240   continue
      BATCH = 1
      call PRICL (YEAR1G)
250   continue
      BATCH = 0
      RPTLUN(MACHNO) = ISAVE
260   continue
      return
      end
