c    @(#)cfvn.f	1.1
      subroutine cfvn
      parameter(nobnd=0)
c
c
c
      include'mladv.inc'
c
c
c-------------------------------------------------------------------
c
      common /scrat/r(mn0),r1(mn0),r2(mn0),r3(mn0)
      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

      common /cnn/n,nm1,nm2,np1
c
      external btrace
c
c
      if (nobnd .eq. 1) return

      libnd=mbnd
      do 10 ibnd=1,mbnd
        nibnd=ibnd+1
        if(nibnd.gt.mbnd)nibnd=1
        lip=ipofb(libnd)
        nip=ipofb(nibnd)
        if(strm0(nip)-strm0(lip) .gt. 0.0 ) then
          ifin(ibnd)=1
        else
          ifin(ibnd)=0
        endif
        libnd=ibnd
   10 continue
c
c --- corners
c
      if(strm0(2)-strm0(1) .gt. 0.0)ifin(1)=ifin(1)+1
      if(strm0(m+1)-strm0(1) .gt. 0.0)ifin(1)=ifin(1)+1
c
      if(strm0(m+m)-strm0(m) .gt.0.0)ifin(m)=ifin(m)+1
      if(strm0(m)-strm0(m-1) .gt.0.0)ifin(m)=ifin(m)+1
c
      if(strm0(msq-1)-strm0(msq) .gt.0.0)ifin(m+n-1)=
     .                                     ifin(m+n-1)+1
      if(strm0(msq)-strm0(msq-m) .gt.0.0)ifin(m+n-1)=
     .                                     ifin(m+n-1)+1
c
      if(strm0(msq-m-m+1)-strm0(msq-m+1) .gt.0.0)ifin(m+n+m-2)=
     .                                             ifin(m+n+m-2)+1
      if(strm0(msq-m+1)-strm0(msq-m+2) .gt.0.0)ifin(m+n+m-2)=
     .                                           ifin(m+n+m-2)+1
c
c
c
c
c
c
      do 70 k=1,l
        do 60 ibnd=1,mbnd
          if(ifin(ibnd).eq.0)go to 60
          ip=ipofb(ibnd)
          buoy(ip,k,mlcur)=bndbuoy(ibnd,k)
          temp(ip,k,mlcur)=bndtemp(ibnd,k)
   60   continue
   70 continue
c
c
c
      do 73 itrace=1,ntrace
        icurtrace=itrace
        do 72 k=1,l
          do 71 ibnd=1,mbnd
            if(ifin(ibnd).eq.0)go to 71
            ip=ipofb(ibnd)
            trace(ip,k,mlcur,itrace)=bndtrace(ibnd,k,itrace)
   71     continue
   72   continue
   73 continue
c
c
      do 80 ibnd=1,mbnd
        if(ifin(ibnd).eq.0)go to 80
        ip=ipofb(ibnd)
        hdpth(ip,mlcur)=bnddpth(ibnd)
c       out(ip)=bndmld(ibnd)
c
   80 continue
c
c
c
      curz=zml(l)
      do 90 ip=1,msq
        if(wsurf(ip)+curz*wzvel(ip) .gt. 0.0 ) then
          buoy(ip,l,mlcur)=0.0
          temp(ip,l,mlcur)=0.0
          do 89 itrace=1,ntrace
             icurtrace=itrace
             trace(ip,l,mlcur,itrace)=btrace(ip)
   89     continue
        endif
   90 continue
c
c
c
      return
      end
