c
c @(#)cross.f	1.4
c
      subroutine cross

      include'mladv.inc'

      common /scrat/ r(mn0), r1(mn0), r2(mn0), r3(mn0)
 
      common/cnn/n,nm1,nm2,np1
 
      common /extpar/rlat0,rlng0,t0,v0,dhor,ht,time0,r0,f0star

      common/parm/kz,m,mm1,mm2,mp1,msq,tim,tmax,tstart,hy,rea,dt,
     +   xbasin,yy(mx0),icalc,kzp1,kzm1,iftop,ifbot,iftvv,ifrel,theta,
     +   ifsbl,ifeva
c
c
c----------------------------------------------------------------------
c
c
c   horizontal advection by the quasigeostrophic fields
c
c
      fact=v0/(dxyml*hy)
c
      call darajac(r,hdpth(1,mlcur),r1,m,n,fact)
c
c
c --- now advect
c
c
      do 85 ip=1,msq


        wtot = wsurf(ip) - hdpth(ip,mlcur) * wzvel(ip)

        hnew = hdpth(ip,mladd)-mlstep*(r1(ip) + wtot)

        call findkml(hdpth(ip,mladd),zml,l,k1)
        call findkml(hnew,zml,l,k2)

        if (abs(k1-k2) .gt. 1) then
           write(*,*)'CFL VIOLATION**********'
           write(*,*)ip,k1,k2,mltime,hnew,hdpth(ip,mladd)
c          stop
          endif

        if (k2.lt.k1) then
           zcross(ip,1) = 1.0
           zcross(ip,2) = k1
         else if (k2.gt.k1) then
           zcross(ip,1) = -1.0
           zcross(ip,2) = k1
         else
           zcross(ip,1) = 0.0
        endif

   85 continue
c
c
c
      return
      end
