  We generalize the Gr\"obner basis method for free D-modules to the case of
several term orderings induced by a partition of the set of basic variables.
Using this generalized Gr\"obner basis technique we prove the existence and
give a method of computation of a dimension polynomial in several variables
associated with a finitely generated D-module. We show that this dimension
polynomial carries more invariants of a D-module than the classical
(univariate) Bernstein polynomial. We also show that the introduced
multivariate dimension polynomial can be used for characterization of holonomic
D-modules.
