  Let S be a flat surface of genus g with cone type singularities. Given a
bipartite graph G isoradially embedded in S, we define discrete analogs of the
2^{2g} Dirac operators on S. These discrete objects are then shown to converge
to the continuous ones, in some appropriate sense. Finally, we obtain necessary
and sufficient conditions on the pair (S,G) for these discrete Dirac operators
to be Kasteleyn matrices of the graph G. As a consequence, if these conditions
are met, the partition function of the dimer model on G can be explicitly
written as an alternating sum of the determinants of these 2^{2g} discrete
Dirac operators.
