  In this paper we generalize the classical Groebner basis technique to prove
the existence and present a method of computation of a dimension polynomial in
two variables associated with a finitely generated D-module, that is, a
finitely generated module over a Weyl algebra. We also present corresponding
algorithms and examples of computation of such polynomials and show that a
bivariate dimension polynomial can contain some invariants that are not carried
by the Bernstein dimension polynomial. The obtained results are applied to the
isomorphism problem for $D$-modules; they have also potential applications to
classification problems of differential algebraic groups.
