      program readqnblendwind_smallend

c Fortran program to read binary QSCAT/NCEP blended wind data files.
c This routine can be adapted to read either the zonal and
c meridional wind data ("uv") or the windstress curl data ("curl").
c
c UV or Curl
c
c   Either read two arrays (u and v, in m/s), or one array (curl,
c   in N/m3).  Change record length for open statement, read
c   statements, and call to swap4 subroutine accordingly.
c
c Big-endian vs. little-endian
c
c   The data files were produced on a little-endian machine 
c   (a pentium PC).  Use "readqnblendwind_bigend.f" to read data
c   on big-endian machine.
c
c Geographic Grid
c
c   The data domain is a 0.5x0.5 degree grid, 720 x 353, starting at 
c   (0.5E, 88.0S) and ending at (360.0E, 88.0N).  There are data
c   values at all grid points, including land and ice points. 
c   Users who wish to examine ocean points only need to use 
c   appropriate land/ice masks.
c
c Time convention
c
c   Time is 6-hourly; the "day" variable is in days of year: 
c   e.g. January 1, 6hr = day 0.25. There is no February 29 in leap
c   years.  This data was produced for ocean models, that require
c   a constant number of days per year.  In all years days go from 
c   0.25 to 365.00.
c
c Data file types
c
c   bln : QSCAT scatterometer data blended with NCEP analyses.
c         The blended data has realistic highwavenumber variability
c         everywhere and preserves the satellite data where it occurs.
c         For each 6-hourly field, 12 hours of QSCAT satellite swaths
c         are overlayed on the global NCEP analysis map, centered on 
c         the analysis time.
c
c   low : NCEP analysis splined to the 0.5x0.5 degree grid.
c
c
c Version 3.0, May 1      , 2003: for blended winds version 3.0,
c                                 sample output is in separate file
c
c-----------------------------------------------------------------------

      parameter
     $( nlon = 720
     $, nlat = 353
     $)

      real
     $  day
     $, u(nlon,nlat)
     $, v(nlon,nlat)
     $, c(nlon,nlat)

      character dfname*80

      logical readuv     ! to read either uv or curl files
c
c pick datatype
c
      readuv = .true.
c
c open input
c
      if (readuv) then
         dfname =   'uv.200012.bln'
      else
         dfname = 'curl.200012.bln'
      endif

      write(6,1010) dfname
 1010 format("input= ",a80)
      open(11,file=dfname,form='unformatted')
c
c read data
c
      nread = 0

 11   read(11,end=99) day
      if (readuv) then
         read(11) u
         read(11) v
      else
         read(11) c
      endif

      nread = nread + 1

      if (readuv) then ! print some u and v data
         ip1 =  21
         ip2 =  25
         jp  =  20
         write(6,1020) day,ip1,ip2,jp,
     $                 (u(i,jp),i=ip1,ip2),(v(i,jp),i=ip1,ip2)
         jp = 330
         write(6,1020) day,ip1,ip2,jp,
     $                 (u(i,jp),i=ip1,ip2),(v(i,jp),i=ip1,ip2)
 1020    format(/,"day=",f19.4,
     $          " print data at i=",i4," to",i4,", j=",i4,
     $          /,"  u=",5e16.7,/,"  v=",5e16.7)
      endif

      if (.not.readuv) then ! print some curl data
         ip1 =  21
         ip2 =  25
         jp  =  20
         write(6,1030) day,ip1,ip2,jp,(c(i,jp),i=ip1,ip2)
         jp = 330
         write(6,1030) day,ip1,ip2,jp,(c(i,jp),i=ip1,ip2)
 1030    format(/,"day=",f9.4,
     $          " print data at i=",i4," to",i4,", j=",i4,
     $          /,"  c=",5e16.7)
      endif

      if (nread.gt.5) goto 99
      goto 11
c
c end of input file
c
 99   close(11)
      write(6,1040) nread
 1040 format(/,"Nread=",i4)

      stop
      end

