Modular invariance and discrete torsion on orbifolds