      subroutine DECOD2(IREC,CC,WHICH,II,CBUFF)
      include 'SIZE.INC'
      include 'UNITS.INC'
      integer CC,IBUFF(VARIEC),HRECS,IREC,OFF(5,4),RECDAT(FILDAT),WHICH
      integer M,I,L,IO1,IO2,IO3,IO4,IO5,ISET,I1,I2,MAXREC,II,J
      character CBUFF(VARCEC)
        data OFF / 9, 15, 16, 54, 17, 11, 21, 22, 55, 23,
     &            45, 33, 34, 56, 35, 47, 39, 40, 57, 41/
      CC = 1
      if (IREC.lt.1) go to 160
      HRECS = FILDAT/VARIEC
      if (FILDAT-VARIEC*HRECS.ne.0) HRECS = HRECS+1
      M = 0
      do 110 I = 1, HRECS
         read (RANUNT(MACHNO),rec=I) IBUFF
         do 100 L = 1, VARIEC
            M = M+1
            if (M.gt.FILDAT) go to 120
            RECDAT(M) = IBUFF(L)
100      continue
110   continue
120   continue
      IO1 = OFF(1,WHICH)
      IO2 = OFF(2,WHICH)
      IO3 = OFF(3,WHICH)
      IO4 = OFF(4,WHICH)
      IO5 = OFF(5,WHICH)
      ISET = RECDAT(IO1)
      I2 = RECDAT(IO2)+RECDAT(IO3)
      I1 = I2+RECDAT(IO4)
      MAXREC = RECDAT(IO5)
      if (IREC.gt.MAXREC) go to 160
      II = ISET+(IREC-1)*I1+I2
      read (RANUNT(MACHNO),rec=II) CBUFF
      do 130 J = 1, 50
         if (CBUFF(J).ne.' ') go to 140
130   continue
      CC = 2
140   continue
150   continue
      return
160   continue
      if (WHICH.eq.1) write (TTYOUT(MACHNO),5000) IREC
5000  format (/' Chemical record No. is out-of-range:',I11)
      if (WHICH.eq.2) write (TTYOUT(MACHNO),5010) IREC
5010  format (/' Environment record No. is out-of-range:',I11)
      if (WHICH.eq.3) write (TTYOUT(MACHNO),5020) IREC
5020  format (/' Load record No. is out-of-range:',I11)
      if (WHICH.eq.4) write (TTYOUT(MACHNO),5030) IREC
5030  format (/' Product record No. is out-of-range:',I11)
      CC = 3
      go to 150
      end
