      subroutine PAKENV(RECNUM)
      include 'SIZE.INC'
      include 'GLOBAL.INC'
      include 'LOCAL.INC'
      include 'UNITS.INC'
      real BUFFER(VARREC)
      integer IBUFF(VARIEC), RRECS, IRECS, CRECS, TRECS
     &,NREALS, NINTS, NCHARS
      integer RECNUM, OFFSET, NUSED
      integer RECDAT(FILDAT),HRECS,M,I,L,ISET,J,K
      character*1 CBUFF(VARCEC)
      include 'ENVSIZ.INC'
      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
      NREALS = RECDAT(25)
      NINTS = RECDAT(26)
      NCHARS = RECDAT(51)
      RRECS = RECDAT(21)
      IRECS = RECDAT(22)
      CRECS = RECDAT(55)
      TRECS = RRECS+IRECS+CRECS
      ISET = RECDAT(11)-1
      do 130 I = 1, VARCEC
         CBUFF(I) = ' '
130   continue
      do 140 I = 1, VARIEC
         IBUFF(I) = 0
140   continue
      do 150 I = 1, VARREC
         BUFFER(I) = 0.0
150   continue
      IO(1) = LATG
      IO(2) = LONGG
      IO(3) = ELEVG
      NUSED = 3
      do 160 I = 1, NPX
         IO(NUSED+1) = VOLG(I)
         IO(NUSED+2) = AREAG(I)
         IO(NUSED+3) = DEPTHG(I)
         IO(NUSED+4) = XSAG(I)
         IO(NUSED+5) = LENGG(I)
         IO(NUSED+6) = WIDTHG(I)
         NUSED = NUSED+6
160   continue
      do 180 I = 1, NCON
         IO(NUSED+1) = XSTURG(I)
         IO(NUSED+2) = CHARLG(I)
         IO(NUSED+3) = ADVPRG(I)
         NUSED = NUSED+3
         do 170 J = 1, MAXDAT
            IO(NUSED+J) = DSPG(I,J)
170      continue
         NUSED = NUSED+MAXDAT
180   continue
      do 190 I = 1, MAXDAT
         IO(NUSED+1) = OXRADG(I)
         IO(NUSED+2) = CLOUDG(I)
         IO(NUSED+3) = RAING(I)
         IO(NUSED+4) = OZONEG(I)
         IO(NUSED+5) = RHUMG(I)
         IO(NUSED+6) = ATURBG(I)
         NUSED = NUSED+6
190   continue
      do 210 I = 1, MAXDAT
         do 200 J = 1, NPX
            IO(NUSED+1) = FROCG(J,I)
            IO(NUSED+2) = CECG(J,I)
            IO(NUSED+3) = AECG(J,I)
            IO(NUSED+4) = PCTWAG(J,I)
            IO(NUSED+5) = TCELG(J,I)
            IO(NUSED+6) = PHG(J,I)
            IO(NUSED+7) = POHG(J,I)
            IO(NUSED+8) = REDAGG(J,I)
            IO(NUSED+9) = BACPLG(J,I)
            IO(NUSED+10) = BNBACG(J,I)
            IO(NUSED+11) = PLMASG(J,I)
            IO(NUSED+12) = BNMASG(J,I)
            IO(NUSED+13) = KO2G(J,I)
            IO(NUSED+14) = STFLOG(J,I)
            IO(NUSED+15) = STSEDG(J,I)
            IO(NUSED+16) = NPSFLG(J,I)
            IO(NUSED+17) = NPSEDG(J,I)
            IO(NUSED+18) = SEEPSG(J,I)
            IO(NUSED+19) = DOCG(J,I)
            IO(NUSED+20) = CHLG(J,I)
            IO(NUSED+21) = DFACG(J,I)
            IO(NUSED+22) = DISO2G(J,I)
            IO(NUSED+23) = EVAPG(J,I)
            IO(NUSED+24) = WINDG(J,I)
            IO(NUSED+25) = BULKDG(J,I)
            IO(NUSED+26) = SUSEDG(J,I)
            NUSED = NUSED+26
200      continue
210   continue
      IOI(1) = KOUNT
      NUSED = 1
      do 220 I = 1, NCON
         IOI(NUSED+1) = JFRADG(I)
         IOI(NUSED+2) = ITOADG(I)
         IOI(NUSED+3) = JTURBG(I)
         IOI(NUSED+4) = ITURBG(I)
         NUSED = NUSED+4
220   continue
      do 230 I = 1, 50
         IOC(I) = ECONAM(I)
230   continue
      NUSED = 50
      do 240 I = 1, 6
         IOC(NUSED+1) = RPASS(2)(I:I)
         IOC(NUSED+2) = WPASS(2)(I:I)
         NUSED = NUSED+2
240   continue
      do 250 I = 1, NPX
         IOC(NUSED+I) = TYPEG(I)
250   continue
      NUSED = NUSED+NPX
      do 260 I = 1, MAXDAT
         IOC(NUSED+I) = AIRTYG(I)
260   continue
      NUSED = NUSED+MAXDAT
      OFFSET = (RECNUM-1)*TRECS+ISET
      do 290 I = 1, RRECS
         J = (I-1)*VARREC
         K = J+VARREC
         J = J+1
         M = 0
         do 270 L = J, K
            M = M+1
            if (L.gt.NREALS) go to 280
            BUFFER(M) = IO(L)
270      continue
280      continue
         J = OFFSET+I
         write (RANUNT(MACHNO),rec=J) BUFFER
290   continue
      OFFSET = OFFSET+RRECS
      do 320 I = 1, IRECS
         J = (I-1)*VARIEC
         K = J+VARIEC
         J = J+1
         M = 0
         do 300 L = J, K
            M = M+1
            if (L.gt.NINTS) go to 310
            IBUFF(M) = IOI(L)
300      continue
310      continue
         J = OFFSET+I
         write (RANUNT(MACHNO),rec=J) IBUFF
320   continue
      OFFSET = OFFSET+IRECS
      do 350 I = 1, CRECS
         J = (I-1)*VARCEC
         K = J+VARCEC
         J = J+1
         M = 0
         do 330 L = J, K
            M = M+1
            if (L.gt.NCHARS) go to 340
            CBUFF(M) = IOC(L)
330      continue
340      continue
         J = OFFSET+I
         write (RANUNT(MACHNO),rec=J) CBUFF
350   continue
      return
      end
