Modular curves over finite fields I'm looking for a detailed reference for modular curves over finite fields, such as $X(N)$, $X_1(N)$, and $X_0(N)$. There seems to be a lot of literature dealing with them over $\mathbb{C}$, but I'm specifically interested in them from the perspective of algebraic geometry. Also, do there exist tables of their point counts over $\mathbb{F}_q$ for some small (but hopefully at least up to $N=15$ or so) values of $N$, or algorithms (e.g. in Sage) for calculating such information? For genus 0 the Riemann hypothesis for curves over finite fields gives an exact formula, of course.
 A: In the classical theory, you see that the set-theoretic points of the complex manifolds $Y(N)$, $Y_1(N)$, etc., are in bijection with certain complex tori plus some additional data (level structure) (up to isomorphism). But they are in fact moduli spaces in the more precise sense (involving Yoneda's lemma) for complex analytic elliptic curves over more general complex analytic spaces (think of them as families of complex analytic elliptic curves, or just complex tori). This involves their functors of points, as opposed to just their set-theoretic ones, and is a hint of the existence of more general moduli spaces $Y(N)$, etc., which live over (localizations of) the ring of integers and, upon base changing to $\mathbf{C}$ and taking $\mathbf{C}$-rational points (the $\mathbf{C}$-analytification), yield the familiar complex manifolds.
Exceedingly thorough treatments of these integral models of modular curves (which can be reduced modulo various primes $p$ to get modular curves over finite fields, which are not always nonsingular) can be found in Deligne-Rapoport (giant paper) or Katz-Mazur (giant book). Both also consider the "compactifications" $X(N)$, $X_1(N)$, etc., but their points of view are somewhat different. Also, while I have not thoroughly read either (more of KM), they are both challenging, requiring a fairly good knowledge of algebraic geometry from the modern point of view (although KM essentially avoids the explicit use of algebraic stacks, using lots of descent theory, they don't get the moduli interpretation of the set of cusps in terms of "generalized elliptic curves" that DR do). I would say KM is somewhat easier (relatively speaking), and, if you're a native English-speaker, it has the minor advantage of being in English. 
Basically, there exist integral versions of (compactified) modular curves (under assumptions on $N$, depending on the moduli problem under consideration) whose functor of points are related to (generalized) elliptic curves over very general bases (one inverts the level to get regular schemes when the moduli problems are representable, but their bad reduction, i.e. primes dividing the level, is of great interest as well, and well studied). These objects can be reduced modulo various primes, and the algebro-geometric nature of the resulting curves depends on whether or not $p$ divides the level. I guess this material is considered "classical" at this point. The compatibility with the analytic theory is not entirely trivial, as again, one has to formulate the correct moduli problem for elliptic curves over complex analytic spaces properly (at which point the compatibility is a consequence of functoriality of analytification and Yoneda's lemma). 
I'm not sure about point counts in finite fields. Certainly there are descriptions of the curves over finite fields one gets by reducing modulo "bad primes" in DR and KM (involving "supersingular points"). I'm not sure how much more detailed I can\should be. There are definitely people active on this site (or if not here, then on MO) who are absolute experts on this subject, and could likely give much more enlightening information. 
EDIT: I should note that there are probably less technically demanding approaches to reduction of modular curves, at least in special cases, but I haven't learned them. At least the two references I cite are (among) the definitive sources for the thoroughly "modern" algebra-geometric approach. 
A: The short answer is given by the Grothendieck-Lefschetz trace formula
$$ \#X(\mathbf F_p) = \sum (-1)^i \mathrm{Tr}(\mathrm{Frob}_p \mid H^i_c(X;\mathbf Q_\ell)).$$
For $X$ a compact modular curve associated with a congruence subgroup $\Gamma$, this means that you need to understand the Galois representation $H^1(X,\mathbf Q_\ell)$, as the trace on $H^0$ and $H^2$ just gives you $p+1$. For $p$ not dividing the level, the trace on $H^1$ is given by the Eichler-Shimura theorem. Specifically, $H^1(X)$ is (possibly after extending scalars) the direct sum of the $2$-dimensional Galois representations attached to Hecke eigenforms of weight 2 and level $\Gamma$, and the trace of $\mathrm{Frob}_p$ on $H^1(X)$ is the same as the trace of the Hecke operator $T_p$ acting on this space of cusp forms. This is the same as the sum of the $p$th Fourier coefficient of all normalized Hecke eigenforms. So you can indeed compute the number of $\mathbf F_p$-points in SAGE: this is equivalent to finding a list of all Hecke eigenforms of weight 2 for this level, and telling SAGE to spit out their Fourier coefficients.
