      subroutine DATAIN
      include 'SIZE.INC'
      include 'GLOBAL.INC'
      include 'LOCAL.INC'
      include 'UNITS.INC'
      double precision Y(NPX,NCHEM)
      integer I,J,K,RECDAT(FILDAT),HRECS
      integer DPRECS,RRECS,IRECS,CRECS,TRECS
      integer NDBLPR, NREALS, NINTS, NCHARS
      integer IBUFF(VARIEC)
      integer M,L,IENV,ICOM
      character*3 CHEM1(NCHEM), ECO1
      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
      open (unit=KINLUN(MACHNO),FILE='SPECS.DAT',status='OLD')
      if (.not.(TOPOPN(MACHNO))) rewind KINLUN(MACHNO)
      read (KINLUN(MACHNO),5000) RECDAT(17),RECDAT(23),RECDAT(35),
     &RECDAT(41)
5000  format (4(1X,I2))
      NDBLPR = 0
      NREALS = 789
      NINTS = 7
      NCHARS = 62
      DPRECS = NDBLPR/VARDEC
      if (NDBLPR-VARDEC*DPRECS.ne.0) DPRECS = DPRECS+1
      RRECS = NREALS/VARREC
      if (NREALS-VARREC*RRECS.ne.0) RRECS = RRECS+1
      IRECS = NINTS/VARIEC
      if (NINTS-VARIEC*IRECS.ne.0) IRECS = IRECS+1
      CRECS = NCHARS/VARCEC
      if (NCHARS-VARCEC*CRECS.ne.0) CRECS = CRECS+1
      TRECS = DPRECS+RRECS+IRECS+CRECS
      RECDAT(15) = RRECS
      RECDAT(16) = IRECS
      RECDAT(54) = CRECS
      RECDAT(18) = 0
      RECDAT(19) = NREALS
      RECDAT(20) = NINTS
      RECDAT(50) = NCHARS
      RECDAT(09) = RECDAT(7)+RECDAT(8)
      RECDAT(10) = TRECS*RECDAT(17)
      NDBLPR = 0
      NREALS = (MAXDAT+3)*NCON+MAXDAT*(NPX*26+6)+6*NPX+3
      NINTS = 4*NCON+1
      NCHARS = 62+NPX+MAXDAT
      DPRECS = NDBLPR/VARDEC
      if (NDBLPR-VARDEC*DPRECS.ne.0) DPRECS = DPRECS+1
      RRECS = NREALS/VARREC
      if (NREALS-VARREC*RRECS.ne.0) RRECS = RRECS+1
      IRECS = NINTS/VARIEC
      if (NINTS-VARIEC*IRECS.ne.0) IRECS = IRECS+1
      CRECS = NCHARS/VARCEC
      if (NCHARS-VARCEC*CRECS.ne.0) CRECS = CRECS+1
      TRECS = DPRECS+RRECS+IRECS+CRECS
      RECDAT(21) = RRECS
      RECDAT(22) = IRECS
      RECDAT(55) = CRECS
      RECDAT(24) = 0
      RECDAT(25) = NREALS
      RECDAT(26) = NINTS
      RECDAT(51) = NCHARS
      RECDAT(11) = RECDAT(9)+RECDAT(10)
      RECDAT(12) = RECDAT(23)*TRECS
      NDBLPR = 0
      NREALS = 5*NPX*NCHEM*MAXDAT+MAXMAS
      NINTS = 5*MAXMAS
      NCHARS = 62
      DPRECS = NDBLPR/VARDEC
      if (NDBLPR-VARDEC*DPRECS.ne.0) DPRECS = DPRECS+1
      RRECS = NREALS/VARREC
      if (NREALS-VARREC*RRECS.ne.0) RRECS = RRECS+1
      IRECS = NINTS/VARIEC
      if (NINTS-VARIEC*IRECS.ne.0) IRECS = IRECS+1
      CRECS = NCHARS/VARCEC
      if (NCHARS-VARCEC*CRECS.ne.0) CRECS = CRECS+1
      TRECS = DPRECS+RRECS+IRECS+CRECS
      RECDAT(33) = RRECS
      RECDAT(34) = IRECS
      RECDAT(56) = CRECS
      RECDAT(36) = 0
      RECDAT(37) = NREALS
      RECDAT(38) = NINTS
      RECDAT(52) = NCHARS
      RECDAT(45) = RECDAT(11)+RECDAT(12)
      RECDAT(46) = RECDAT(35)*TRECS
      NDBLPR = 0
      NREALS = 2*NTRAN
      NINTS = 4*NTRAN
      NCHARS = 62
      DPRECS = NDBLPR/VARDEC
      if (NDBLPR-VARDEC*DPRECS.ne.0) DPRECS = DPRECS+1
      RRECS = NREALS/VARREC
      if (NREALS-VARREC*RRECS.ne.0) RRECS = RRECS+1
      IRECS = NINTS/VARIEC
      if (NINTS-VARIEC*IRECS.ne.0) IRECS = IRECS+1
      CRECS = NCHARS/VARCEC
      if (NCHARS-VARCEC*CRECS.ne.0) CRECS = CRECS+1
      TRECS = DPRECS+RRECS+IRECS+CRECS
      RECDAT(39) = RRECS
      RECDAT(40) = IRECS
      RECDAT(57) = CRECS
      RECDAT(42) = 0
      RECDAT(43) = NREALS
      RECDAT(44) = NINTS
      RECDAT(53) = NCHARS
      RECDAT(47) = RECDAT(45)+RECDAT(46)
      RECDAT(48) = RECDAT(41)*TRECS
      do 150 I = 1, HRECS
         J = (I-1)*VARIEC
         K = J+VARIEC
         J = J+1
         M = 0
         do 130 L = J, K
            M = M+1
            if (L.gt.FILDAT) go to 140
            IBUFF(M) = RECDAT(L)
130      continue
140      continue
         write (RANUNT(MACHNO),rec=I) IBUFF
150   continue
      write (PRINTR(MACHNO),5010)
5010  format ('1')
      call BLNKCO
      call BLNKEN
      call BLNKLO
      call BLNKPR
      write (PRINTR(MACHNO),5020)
5020  format (/' Database      Record      Description'/' ========      
     &======      ==========='/)
      IENV = 0
      ICOM = 0
160   continue
      KCHEM = 1
      call INITL (Y,1)
      read (KINLUN(MACHNO),5030,end=180) ECO1,PRSWG,MODEG,MONTHG
      read (KINLUN(MACHNO),5030,end=180) CHEM1(1)
5030  format (A3,5(1X,I2))
      if (CHEM1(1).eq.'END') go to 180
      if (CHEM1(1).eq.'NON') go to 170
      IFLAG = 0
      call CHEMIN (CHEM1)
      if (IFLAG.eq.8) then
         write (PRINTR(MACHNO),5040) (CHEMNA(K,1),K=1,50)
5040     format (/1X,'Chemical error, not stored: ',50A1)
         go to 170
      endif
      ICOM = ICOM+1
      call PAK (ICOM,1)
      write (PRINTR(MACHNO),5050) ICOM,(CHEMNA(K,1),K=1,50)
5050  format (' Chemical:',6X,I3,3X,50A1)
170   continue
      if (ECO1.eq.'END') go to 180
      if (ECO1.eq.'NON') go to 160
      IFLAG = 0
      call ENVIN (ECO1)
      if (IFLAG.eq.8) then
         write (PRINTR(MACHNO),5060) ECONAM
5060     format (/1X,'Environment error, not stored: ',50A1)
         go to 160
      endif
      IENV = IENV+1
      call PAKENV (IENV)
      write (PRINTR(MACHNO),5070) IENV,ECONAM
5070  format (' Environment:',3X,I3,3X,50A1)
      go to 160
180   continue
      return
      end
