c    @(#)advectml.f	1.2
c
c
c
c
c
      subroutine advectml(f,fadd,fnew)
c
c
c leonard walstad 5/84
c
c
c this routine will advect level k of field f using u,v,wz
c as defined the the corresponding arrays.  the result is stored 
c in af in units of f/s.
c
c----------------------------------------------------------------------
c
c
      include'mladv.inc'
c
c
c
      dimension f(mnmax), fadd(mnmax), fnew(mnmax)
c
c
c  qg model quantities needed  ( the arrays in common /scrat/ are
c  used as scratch arrays.)
c
      common /scrat/ r(mn0), r1(mn0), r2(mn0), r3(mn0)
c
c
      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
      common/cnn/n,nm1,nm2,np1      
c
      common /extpar/rlat0,rlng0,t0,v0,dhor,ht,time0,r0,f0star
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
c
c --- now advect
c
c
      do 85 ip=1,msq

        if (ifperh .eq. 0) then

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

           fnew(ip) = fadd(ip) - mlstep * (r1(ip) + wtot)

          else

           fnew(ip)=fadd(ip)-mlstep*r1(ip)

         endif

   85 continue
c
c
c
      return
      end
