      subroutine read4restart(fname,grid,nstart,tstop,icnt,
     & mmr,nnr,mr,nr,uar)
      include 'netcdf.inc'

      character*(*) fname,grid
c.....grid and array sizes
      integer mmr,nnr
      integer mr,nr
c.....restart number
      integer nstart
      integer*4 icnt
c.....snapshot time
      real*8 tstop
c.....data
      real*8 uar(mmr,nnr)
      real*8 uas(mr,nr)
c.....nc stuff
      integer iret, ncid
      integer id,nvar
      character*10 dumb
c.....index
      integer i,j

 701  format(' restart data file: ', a)

      iret = nf_open(fname,0,ncid)

      if (iret .ne. NF_NOERR) then
        nstart=0
        tstop=-1.
        icnt=0
        write(3,*) '.'
        write(3,701) fname(1:lnblnk(fname))
        write(3,*) 'file not found, no restart'
        write(3,*) '.'
      else
c..... read data
        call check_err(nf_inq_varid(ncid,'nstart',id))
        call check_err(nf_get_var_int(ncid, id, nstart))
        call check_err(nf_inq_varid(ncid,'icnt',id))
        call check_err(nf_get_var_int(ncid, id, icnt))
        call check_err(nf_inq_varid(ncid,'tstop',id))
        call check_err(nf_get_var_double(ncid, id, tstop))

        if (grid.eq.'ua') then
          write(3,*) '.'
          write(3,701) fname(1:lnblnk(fname))
          write(3,*) 'file found, running from restart'
          write(3,*) '.'
          call check_err(nf_inq_varid(ncid,'ua',id))
          call check_err(nf_get_var_double(ncid, id, uas))
        else if (grid.eq.'va') then
          call check_err(nf_inq_varid(ncid,'va',id))
          call check_err(nf_get_var_double(ncid, id, uas))
        else if (grid.eq.'qa') then
          call check_err(nf_inq_varid(ncid,'qa',id))
          call check_err(nf_get_var_double(ncid, id, uas))
        else if (grid.eq.'ub1') then
          call check_err(nf_inq_varid(ncid,'ub1',id))
          call check_err(nf_get_var_double(ncid, id, uas))
        else if (grid.eq.'vb1') then
          call check_err(nf_inq_varid(ncid,'vb1',id))
          call check_err(nf_get_var_double(ncid, id, uas))
        else if (grid.eq.'qb1') then
          call check_err(nf_inq_varid(ncid,'qb1',id))
          call check_err(nf_get_var_double(ncid, id, uas))
        else if (grid.eq.'uc1') then
          call check_err(nf_inq_varid(ncid,'uc1',id))
          call check_err(nf_get_var_double(ncid, id, uas))
        else if (grid.eq.'vc1') then
          call check_err(nf_inq_varid(ncid,'vc1',id))
          call check_err(nf_get_var_double(ncid, id, uas))
        else if (grid.eq.'qc1') then
          call check_err(nf_inq_varid(ncid,'qc1',id))
          call check_err(nf_get_var_double(ncid, id, uas))
        endif

        call check_err(nf_close(ncid))

c.....read array into full-sized array
        do i=1,mr
          do j=1,nr
            uar(i,j) = uas(i,j)
          end do
        end do

      endif

      return
      end
