        subroutine ENVOUT
      include 'SIZE.INC'
      include 'GLOBAL.INC'
      include 'LOCAL.INC'
      include 'UNITS.INC'
        real OUT1(NCON), OUT2(NCON), OUT3(NCON,MAXDAT)
        integer LOC1(NCON), LOC2(NCON), KNT
        integer J, NSPEC1, NSPEC2, N, NFIRST, NLAST
5000  format (1PG10.4,7G10.4)
5010  format (16I5)
5020  format (80A1)
      if (MODEG.eq.3.or.PRSWG.eq.0) then
         NFIRST = 1
         NLAST = 12
      else
         NFIRST = MONTHG
         NLAST = MONTHG
      endif
      write (RWLUN(MACHNO),5020) ECONAM
      write (RWLUN(MACHNO),5010) KOUNT
      write (RWLUN(MACHNO),5020) (TYPEG(J),J=1,KOUNT)
      write (RWLUN(MACHNO),5000) LATG,LONGG,ELEVG
      write (RWLUN(MACHNO),5000) (VOLG(J),J=1,KOUNT)
      write (RWLUN(MACHNO),5000) (AREAG(J),J=1,KOUNT)
      write (RWLUN(MACHNO),5000) (DEPTHG(J),J=1,KOUNT)
      write (RWLUN(MACHNO),5000) (XSAG(J),J=1,KOUNT)
      write (RWLUN(MACHNO),5000) (LENGG(J),J=1,KOUNT)
      write (RWLUN(MACHNO),5000) (WIDTHG(J),J=1,KOUNT)
      do 100 J = 1, NCON
         LOC1(J) = 0
         LOC2(J) = 0
         OUT1(J) = 0.0
100   continue
      KNT = 0
      do 110 J = 1, NCON
         if (JFRADG(J).eq.0.and.ITOADG(J).eq.0) go to 110
         KNT = KNT+1
         LOC1(KNT) = JFRADG(J)
         LOC2(KNT) = ITOADG(J)
         OUT1(KNT) = ADVPRG(J)
110   continue
      do 120 J = 1, NCON
         JFRADG(J) = LOC1(J)
         ITOADG(J) = LOC2(J)
         ADVPRG(J) = OUT1(J)
120   continue
      NSPEC1 = KNT
      write (RWLUN(MACHNO),5010) NSPEC1
      write (RWLUN(MACHNO),5010) (JFRADG(J),J=1,NSPEC1)
      write (RWLUN(MACHNO),5010) (ITOADG(J),J=1,NSPEC1)
      write (RWLUN(MACHNO),5000) (ADVPRG(J),J=1,NSPEC1)
      do 140 J = 1, NCON
         LOC1(J) = 0
         LOC2(J) = 0
         OUT1(J) = 0.0
         OUT2(J) = 0.0
         do 130 N = 1, MAXDAT
            OUT3(J,N) = 0.0
130      continue
140   continue
      KNT = 0
      do 160 J = 1, NCON
         if (JTURBG(J).eq.0.and.ITURBG(J).eq.0) go to 160
         KNT = KNT+1
         LOC1(KNT) = JTURBG(J)
         LOC2(KNT) = ITURBG(J)
         OUT1(KNT) = XSTURG(J)
         OUT2(KNT) = CHARLG(J)
         do 150 N = NFIRST, NLAST
            OUT3(KNT,N) = DSPG(J,N)
150      continue
160   continue
      do 180 J = 1, NCON
         JTURBG(J) = LOC1(J)
         ITURBG(J) = LOC2(J)
         XSTURG(J) = OUT1(J)
         CHARLG(J) = OUT2(J)
         do 170 N = NFIRST, NLAST
            DSPG(J,N) = OUT3(J,N)
170      continue
180   continue
      NSPEC2 = KNT
      write (RWLUN(MACHNO),5010) NSPEC2
      write (RWLUN(MACHNO),5010) (JTURBG(J),J=1,NSPEC2)
      write (RWLUN(MACHNO),5010) (ITURBG(J),J=1,NSPEC2)
      write (RWLUN(MACHNO),5000) (XSTURG(J),J=1,NSPEC2)
      write (RWLUN(MACHNO),5000) (CHARLG(J),J=1,NSPEC2)
      do 190 N = NFIRST, NLAST
         write (RWLUN(MACHNO),5000) (DSPG(J,N),J=1,NSPEC2)
         write (RWLUN(MACHNO),5000) (WINDG(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) (STFLOG(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) (STSEDG(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) (NPSFLG(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) (NPSEDG(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) (SEEPSG(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) RAING(N)
         write (RWLUN(MACHNO),5000) CLOUDG(N)
         write (RWLUN(MACHNO),5000) OZONEG(N)
         write (RWLUN(MACHNO),5000) RHUMG(N)
         write (RWLUN(MACHNO),5000) ATURBG(N)
         write (RWLUN(MACHNO),5020) AIRTYG(N)
         write (RWLUN(MACHNO),5000) (DFACG(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) (EVAPG(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) (SUSEDG(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) (BULKDG(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) (PCTWAG(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) (FROCG(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) (CECG(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) (AECG(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) (TCELG(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) (PHG(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) (POHG(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) OXRADG(N)
         write (RWLUN(MACHNO),5000) (BACPLG(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) (BNBACG(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) (PLMASG(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) (BNMASG(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) (KO2G(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) (DOCG(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) (CHLG(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) (DISO2G(J,N),J=1,KOUNT)
         write (RWLUN(MACHNO),5000) (REDAGG(J,N),J=1,KOUNT)
190   continue
      return
      end
