c--------------------------------------------------------------------
c  This read software is courtesy of Brian Soden, GFDL/NOAA.

        program rd_smmr
        parameter(nlon=360,nlat=180)
        character*1 lrec(12,nlon), dummy, cfile*80
        integer*2 ibuf(12)
        real*4 wind(nlon,nlat), vapor(nlon,nlat), cloud(nlon,nlat)

        data n1/256/


        if (iargc().ne.2) then
         print*, 'Usage: <infile> <outfile>'
         stop
        endif
        call getarg(1,cfile)
        open(8,file=cfile,access='direct',recl=4321)
        call getarg(2,cfile)
        open(9,file=cfile,access='direct',recl=nlon*nlat*4)

        do lat=1,nlat
         xlat=lat-90.5
         read(8) lrec, dummy
         do lon=1,nlon
          xlon=lon-0.5
          do i=1,12
           ibuf(i)=ichar(lrec(i,lon))
          enddo
          nwin=n1*ibuf( 1)+ibuf( 2)
          nvap=n1*ibuf( 3)+ibuf( 4)
          ncld=n1*ibuf( 5)+ibuf( 6)
          iwin=n1*ibuf( 7)+ibuf( 8)
          ivap=n1*ibuf( 9)+ibuf(10)
          icld=n1*ibuf(11)+ibuf(12)

          if(nwin.ge.10000) then
           iceflg=1
           nwin=nwin-10000
          else
           iceflg=0
          endif

          wind(lon,lat)=0.01*iwin
          vapor(lon,lat)=0.01*ivap
          xcloud=0.01*icld
          if(xcld.ge.0.0) then
           cloud(lon,lat)=0.7*(xcloud+0.0028*xcloud*xcloud)
          else
           cloud(lon,lat)=0.7*xcloud
          endif
        
         enddo
        enddo

        write(9,rec=1) vapor

        stop
        end

c--------------------------------------------------------------------

_________________________________________________

Brian Soden             bjs@gfdl.gov     
GFDL/NOAA               http://www.gfdl.gov/~bjs/
Princeton University    609-452-6575
Post Office  Box 308    609-987-5063  [FAX]
Princeton, NJ  08542
_________________________________________________
