      subroutine TimeStep_nr(q,u,v,d,qw,uw,vw,dw,q1,u1,v1,d1,h,ndum
     &           ,x1,x2,y1,y2,h1,h2,n1,n2,mm,nn,dt)
c..... Computes one time step for specified arrays                           
c..... nested grids 
CC    no narr or nests                                           
cA    this version uses cylindrical coordinates with runup (arun 2/6/2006)

      real*8 d(mm,nn),q(mm,nn),u(mm,nn),v(mm,nn)
      real*8 PI,RE,GA,dt,time,grnd,dry,fi,fr
      real*8 uw(ndum),vw(ndum),qw(ndum),dw(ndum),h1(n1),h2(n2)
     &     ,u1(ndum),q1(ndum),v1(ndum),h(ndum)
     &     ,x1(nn,3),x2(nn,3),y1(mm,3),y2(mm,3)
      common /run/time,nstep,npics,grnd,dry,fi,fr
      common /const/ PI,RE,GA
c     ** Sweep along X (longitude) **                                                    
C      write(*,*)'Timestep_n n1 = ',n1,' n2 = ',n2                                       
         do 50 j=2,n2-1
            fi=PI/180.*h2(j)
            do i=1,n1
               dw(i)=d(i,j)
               qw(i)=q(i,j)
               uw(i)=u(i,j)
               vw(i)=v(i,j)
               if(i.LT.n1)
     &           h(i)=(h1(i+1)-h1(i))*111320.*COS(fi)
            end do
c            write(*,*)'Entering lon calculation j=',j
            call swrun_lon(uw,qw,vw,dw,u1,q1,v1,n1,h
     &          ,x1(j,1),x1(j,2),x1(j,3)
     &          ,x2(j,1),x2(j,2),x2(j,3),dt)
c            write(*,*)'qw77=',qw(77),'dw77=',dw(77)
            do 52 i=1,n1
c               if (dw(i).LE.grnd.AND.dw(i).GT.-8500.)then
c                  qw(i)=qw(i)-dw(i)+d(i,j)
c               endif
               q(i,j)=qw(i)
               u(i,j)=uw(i)
               v(i,j)=vw(i)

 52                     continue
 50                           continue
c     ** Sweep along Y **                                                                
         fi=PI/180.*h2(1)
         do 60 j=2,n1-1
            do i=1,n2
               dw(i)=d(j,i)
               qw(i)=q(j,i)
               uw(i)=v(j,i)
               vw(i)=u(j,i)
               if(i.LT.n2)
     &           h(i)=(h2(i+1)-h2(i))*111320.
            end do
            call swrun_lat(uw,qw,vw,dw,u1,q1,v1,n2,h
     &          ,y1(j,2),y1(j,1),y1(j,3)
     &          ,y2(j,2),y2(j,1),y2(j,3),dt)
            do 62 i=1,n2
c               if (dw(i) .LE. grnd.AND.dw(i).GT.-8500.) then
c                  qw(i)=qw(i)-dw(i)+d(j,i)
c               end if
               q(j,i)=qw(i)
               u(j,i)=vw(i)
               v(j,i)=uw(i)
 62          continue
 60        continue
      return
      end

