!
!  vertex_avg.f90
!
      subroutine vertex_avg(v,vavg,ni,nj,nk)
      implicit none 
      integer :: ni,nj,nk
      real :: v(ni+1,nj+1,nk+1),vavg(ni,nj,nk)
      integer :: i,j,k
!      
      do i=1,ni
        do j=1,nj
          do k=1,nk
            vavg(i,j,k) = ( v(i,j,k)+v(i+1,j,k)+v(i,j+1,k)+v(i+1,j+1,k)+ &
                          v(i,j,k+1)+v(i+1,j,k+1)+v(i,j+1,k+1)+v(i+1,j+1,k+1) )/8.0
          enddo
        enddo  
      enddo
!
      end subroutine vertex_avg 