  We study the reduction of certain integral models of Shimura varieties of PEL
type with Iwahori level structure. On these spaces we have the
Kottwitz-Rapoport and the $p$-rank stratification. We show that the $p$-rank is
constant on a KR stratum, generalizing a result of Ng\^o and Genestier. We
prove an abstract, uniform formula for the $p$-rank on a KR stratum. In the
symplectic and in the unitary case we derive explicit formulas for its value.
We apply these formulas to the question of the density of the ordinary locus
and to the question of the dimension of the $p$-rank 0 locus.
