! Compute the divergence of a horizontal vector field vx(x,y),vy(x,y)
! represented by its discrete approximation using Daubechies' wavelets.
! Using the errors on the velocity field we also evaluate the errors on
! the divergence field
!
! M. Rieutord, 27/6/2000
!
! Add the curl, correct delta_div and rename the module, 8/3/01


	module m_div_curl

contains
	subroutine divergence(ux,uy,du,div,delta_div)

	use deriw2d

	implicit none

	real(kind(0d0)), pointer, dimension(:,:) :: ux,uy,du,div,delta_div
	integer n1,n2
	
	n1=size(ux,1); n2=size(uy,2)
	allocate(div(n1,n2),delta_div(n1,n2))

	div=dx(ux,1)+dx(uy,2)
	delta_div=abs(dx(du,1))+abs(dx(du,2))

	end subroutine

        subroutine rot(ux,uy,du,curl,delta_curl)

        use deriw2d

        implicit none

        real(kind(0d0)), pointer, dimension(:,:) :: ux,uy,du,curl,delta_curl
        integer n1,n2

        n1=size(ux,1); n2=size(uy,2)
        allocate(curl(n1,n2),delta_curl(n1,n2))

        curl=dx(uy,1)-dx(ux,2)
        delta_curl=abs(dx(du,1))+abs(dx(du,2))

        end subroutine

	end module
