        subroutine PACSCR(IBUFF)
      include 'SIZE.INC'
      include 'GLOBAL.INC'
      include 'LOCAL.INC'
      include 'UNITS.INC'
      include 'INPAR.INC'
      include 'LOCAL1.INC'
      include 'LOCAL2.INC'
        real BUFF1 ( NPX * (4+47*NCHEM) )
        double precision BUFF2 ( NPX * NCHEM * (2+NPX+NCHEM))
        equivalence (BUFF1(1), ALPHA(1,1,1)), (BUFF2(1), CONLDL(1,1))
        integer IBUFF(VARIEC)
        integer I, J, K, NSP, NSTART, NEND
        integer OFFSET, NVAR, NRECS, FIRREC, LASTRC, ITRAIL, IALPHA(7)
        data IALPHA/1,5,9,13,17,21,25/
      OFFSET = 1
      if (NDAT.gt.1) OFFSET = 1+(NDAT-1)*(IBUFF(1)+IBUFF(3))
      NVAR = 1
      do 140 K = 1, KCHEM
         do 130 J = 1, KOUNT
            do 110 NSP = 1, 7
               if (SPFLGG(NSP,K).eq.0) go to 110
               do 100 I = IALPHA(NSP), IALPHA(NSP)+3
                  BUFF1(NVAR) = ALPHA(I,J,K)
                  NVAR = NVAR+1
100            continue
110         continue
            do 120 I = 29, 32
               BUFF1(NVAR) = ALPHA(I,J,K)
               NVAR = NVAR+1
120         continue
130      continue
140   continue
      do 160 K = 1, KCHEM
         do 150 J = 1, KOUNT
            BUFF1(NVAR) = BIOLKL(J,K)
            NVAR = NVAR+1
150      continue
160   continue
      do 170 J = 1, KOUNT
         BUFF1(NVAR) = BIOTOL(J)
         NVAR = NVAR+1
170   continue
      do 190 K = 1, KCHEM
         do 180 J = 1, KOUNT
            BUFF1(NVAR) = EXPOKL(J,K)
            NVAR = NVAR+1
180      continue
190   continue
      do 210 K = 1, KCHEM
         do 200 J = 1, KOUNT
            BUFF1(NVAR) = HYDRKL(J,K)
            NVAR = NVAR+1
200      continue
210   continue
      do 230 K = 1, KCHEM
         do 220 J = 1, KOUNT
            BUFF1(NVAR) = OXIDKL(J,K)
            NVAR = NVAR+1
220      continue
230   continue
      do 250 K = 1, KCHEM
         do 240 J = 1, KOUNT
            BUFF1(NVAR) = PHOTKL(J,K)
            NVAR = NVAR+1
240      continue
250   continue
      do 270 K = 1, KCHEM
         do 260 J = 1, KOUNT
            BUFF1(NVAR) = REDKL(J,K)
            NVAR = NVAR+1
260      continue
270   continue
      do 290 K = 1, KCHEM
         do 280 J = 1, KOUNT
            BUFF1(NVAR) = S1O2KL(J,K)
            NVAR = NVAR+1
280      continue
290   continue
      do 300 J = 1, KOUNT
         BUFF1(NVAR) = SEDCOL(J)
         NVAR = NVAR+1
300   continue
      do 310 J = 1, KOUNT
         BUFF1(NVAR) = SEDMSL(J)
         NVAR = NVAR+1
310   continue
      do 330 K = 1, KCHEM
         do 320 J = 1, KOUNT
            BUFF1(NVAR) = VOLKL(J,K)
            NVAR = NVAR+1
320      continue
330   continue
      do 340 J = 1, KOUNT
         BUFF1(NVAR) = WATVOL(J)
         NVAR = NVAR+1
340   continue
      do 370 K = 1, KCHEM
         do 360 J = 1, KOUNT
            do 350 NSP = 1, 7
               if (SPFLGG(NSP,K).eq.0) go to 350
               BUFF1(NVAR) = YSATL(NSP,J,K)
               NVAR = NVAR+1
350         continue
360      continue
370   continue
      if (NDAT.gt.1) go to 380
      NVAR = NVAR-1
      ITRAIL = mod(NVAR,VARREC)
      NRECS = NVAR/VARREC
      if (ITRAIL.ne.0) NRECS = NRECS+1
      IBUFF(1) = NRECS
      IBUFF(2) = ITRAIL
      if (ITRAIL.eq.0) IBUFF(2) = VARREC
380   continue
      NRECS = IBUFF(1)
      ITRAIL = IBUFF(2)
      FIRREC = OFFSET+1
      LASTRC = FIRREC+NRECS-1
      NSTART = 1
      if (NRECS.eq.1) go to 400
      NEND = VARREC
      do 390 K = FIRREC, LASTRC-1
         write (WRKLUN(MACHNO),rec=K) (BUFF1(I),I=NSTART,NEND)
         NSTART = NEND+1
         NEND = NEND+VARREC
390   continue
400   continue
      NEND = (NRECS-1)*VARREC+ITRAIL
      write (WRKLUN(MACHNO),rec=LASTRC) (BUFF1(I),I=NSTART,NEND)
      OFFSET = LASTRC
      NVAR = 1
      do 420 K = 1, KCHEM
         do 410 J = 1, KOUNT
            BUFF2(NVAR) = CONLDL(J,K)
            NVAR = NVAR+1
410      continue
420   continue
      do 450 K = 1, KCHEM
         do 440 J = 1, KOUNT
            do 430 I = 1, KOUNT
               BUFF2(NVAR) = INTINL(I,J,K)
               NVAR = NVAR+1
430         continue
440      continue
450   continue
      do 470 K = 1, KCHEM
         do 460 J = 1, KOUNT
            BUFF2(NVAR) = TOTKL(J,K)
            NVAR = NVAR+1
460      continue
470   continue
      do 500 J = 1, KOUNT
         do 490 K = 1, KCHEM
            do 480 I = 1, KCHEM
               BUFF2(NVAR) = YIELDL(I,K,J)
               NVAR = NVAR+1
480         continue
490      continue
500   continue
      if (NDAT.gt.1) go to 510
      NVAR = NVAR-1
      ITRAIL = mod(NVAR,VARDEC)
      NRECS = NVAR/VARDEC
      if (ITRAIL.ne.0) NRECS = NRECS+1
      IBUFF(3) = NRECS
      IBUFF(4) = ITRAIL
      if (ITRAIL.eq.0) IBUFF(4) = VARDEC
510   continue
      NRECS = IBUFF(3)
      ITRAIL = IBUFF(4)
      FIRREC = OFFSET+1
      LASTRC = FIRREC+NRECS-1
      NSTART = 1
      if (NRECS.eq.1) go to 530
      NEND = VARDEC
      do 520 K = FIRREC, LASTRC-1
         write (WRKLUN(MACHNO),rec=K) (BUFF2(I),I=NSTART,NEND)
         NSTART = NEND+1
         NEND = NEND+VARDEC
520   continue
530   continue
      NEND = (NRECS-1)*VARDEC+ITRAIL
      write (WRKLUN(MACHNO),rec=LASTRC) (BUFF2(I),I=NSTART,NEND)
      if (NDAT.eq.1) write (WRKLUN(MACHNO),rec=1) (IBUFF(I),I=1,4)
      return
      end
