      parameter (ijgrid=26*22)
 
      CHARACTER*32 LABEL

      DIMENSION IDATE(4)
      DIMENSION TSEA  ( ijgrid ), SMC   ( ijgrid , 2 ),
     &          SHELEG( ijgrid ), STC   ( ijgrid , 2 ),
     &          TG3   ( ijgrid ),
     &          ZORL  ( ijgrid ), SLMSK ( ijgrid ),
     &          PLANTR( ijgrid ), F10M  ( ijgrid ), ALBED ( ijgrid ),
     &          CV    ( ijgrid ), CVB   ( ijgrid ), HPRIME( ijgrid ),
     &          CVT   ( ijgrid ), CANOPY( ijgrid )
      DIMENSION WORK( ijgrid )


 
      nread=21
      open(nread,form='formatted',status='old',readonly)
 
      nwrite=22
      open(nwrite,form='unformatted',status='unknown')


      LOLA = ijgrid
      iverbose =  2


      READ(NREAD,'(a32)') LABEL
      WRITE(NWRITE) LABEL

      print*, 'ZZZZZ ',LABEL,' ZZZZZZ'

      READ(NREAD,'(e12.6,4i5)') GHOUR, IDATE
      WRITE(NWRITE) GHOUR, IDATE


99    FORMAT(1H ,'GHOUR, IDATE=',F10.2,2X,4(1X,I4))
      PRINT *,'FIX FIELD READ IN FROM UNIT=',NREAD
      PRINT 99,GHOUR, IDATE
      PRINT *,GHOUR, IDATE

      READ(NREAD,'(6e12.6)') TSEA
      WRITE(NWRITE) TSEA

         if ( iverbose .gt. 1 ) 
     *   call stats(tsea,ijgrid,1,'TSEA')


      READ(NREAD,'(6e12.6)') SMC
      WRITE(NWRITE) SMC
         if ( iverbose .gt. 1 ) 
     *   call stats(smc(1,1),ijgrid,1,'SMC1')
         if ( iverbose .gt. 1 ) 
     *   call stats(smc(1,2),ijgrid,1,'SMC2')


      READ(NREAD,'(6e12.6)') SHELEG
      WRITE(NWRITE) SHELEG
         if ( iverbose .gt. 1 ) 
     *   call stats(sheleg,ijgrid,1,'SHLG')


      READ(NREAD,'(6e12.6)') STC
      WRITE(NWRITE) STC
         if ( iverbose .gt. 1 ) 
     *   call stats(stc(1,1),ijgrid,1,'STC1')
         if ( iverbose .gt. 1 ) 
     *   call stats(stc(1,2),ijgrid,1,'STC2')

      READ(NREAD,'(6e12.6)') TG3
      WRITE(NWRITE) TG3
         if ( iverbose .gt. 1 ) 
     *   call stats(tg3,ijgrid,1,'TG3 ')


      READ(NREAD,'(6e12.6)') ZORL
      WRITE(NWRITE) ZORL
         if ( iverbose .gt. 1 ) 
     *   call stats(zorl,ijgrid,1,'ZORL')


      READ(NREAD,'(6e12.6)') CV
      WRITE(NWRITE) CV
         if ( iverbose .gt. 1 ) 
     *   call stats(cv,ijgrid,1,'CV  ')


      READ(NREAD,'(6e12.6)') CVB
      WRITE(NWRITE) CVB
         if ( iverbose .gt. 1 ) 
     *   call stats(cvb,ijgrid,1,'CVB ')



      READ(NREAD,'(6e12.6)') CVT
      WRITE(NWRITE) CVT
         if ( iverbose .gt. 1 ) 
     *   call stats(cvt,ijgrid,1,'CVT ')


      READ(NREAD,'(6e12.6)') ALBED
      WRITE(NWRITE) ALBED
         if ( iverbose .gt. 1 ) 
     *   call stats(albed,ijgrid,1,'ALBD')


      READ(NREAD,'(6e12.6)') SLMSK
      WRITE(NWRITE) SLMSK
         if ( iverbose .gt. 1 ) 
     *   call stats(slmsk,ijgrid,1,'MASK')


      READ(NREAD,'(6e12.6)') PLANTR
      WRITE(NWRITE) PLANTR
         if ( iverbose .gt. 1 ) 
     *   call stats(plantr,ijgrid,1,'PLTR')


      READ(NREAD,'(6e12.6)') HPRIME
c      WRITE(NWRITE) HPRIME
c         if ( iverbose .gt. 1 ) 
c     *   call stats(hprime,ijgrid,1,'HPRM')


      READ(NREAD,'(6e12.6)') CANOPY
      WRITE(NWRITE) CANOPY
         if ( iverbose .gt. 1 ) 
     *   call stats(canopy,ijgrid,1,'CNPY')


      READ(NREAD,'(6e12.6)') F10M
      WRITE(NWRITE) F10M
         if ( iverbose .gt. 1 ) 
     *   call stats(f10m,ijgrid,1,'F10M')



      PRINT 101,GHOUR,IDATE,LOLA
101   FORMAT(1H ,'IN FIXIO FHOUR IDATE LOLA=',F9.2,2X,4(1X,I4),2X,I5)

C
      goto 5001
5000  PRINT *,' ERROR IN INPUT IN RFIXIO '
5001  continue
      END


      subroutine stats(grd,nx,ny,clab)

      character*4 clab
      integer     nx,ny
      real*8      rmax,rmin,rbar,rdev
      dimension   grd(nx,ny)

      rmax=maxval(grd)
      rmin=minval(grd)
      rbar=sum(grd)/size(grd)

      if (rbar .eq. 0.0 ) then
        print*,clab//" WARNING STATS: RBAR RMIN RMAX",rbar,rmin,rmax
        return
      endif

      rdev=sqrt(sum( (grd - rbar)**2)/(size(grd)-1))

      write(*,'(a22,4(1x,f16.7))')
     * clab//" MAX MIN AVG VRC ",rmax,rmin,rbar,rdev

      return
      end

