Every time a spell is cast, a casting check (1d20+caster level+revelant ability score modifier) check must be made, DC=10+2xspell level. A success indicates the spell succeeds, a failure indicates it failure, but the spell is not lost. For every 5 points the spell succeeds by, it’s effective level increases by one, allowing the caster to raise the DC by +1 or to apply metamagic feats to the spell. Unknown metamagic feats cost 1 extra level. A natural 20 is a critical success. The caster should roll the check again, and if the second check succeeds, the spell remains in the caster’s memory, as if it had not been cast. A natural 1 on the roll is a critical failure. The spell fails, is lost from the caster’s memory, and the caster should roll the check again. If the second roll fails, a summon monster spell of the same level as the spell cast will take effect, the summoned creature will be under the effect of a confusion spell, attacking the caster if it has it’s choice. If a second 1 is rolled to confirm the critical failure, an arcane catastrophe takes place.
Spells can be cast in rituals, allowing the caster to take 10 or 20 on the check. Taking 20 does not allow the spell to remain in the caster’s memory, but otherwise it works. Spells with casting times of less than a full round will take 5 rounds taking 10, or 10 taking 20. Full round spells will take 10 and 20 rounds respectively. Longer casting times will be multiplied by 10 or 20.
It is possible for non-casters to cast spells ritually, provided they have instruction, in the form of a spellbook or a scroll. While they use the longer casting time (equivalent to taking 10) they still roll normally. Their caster level is 0, so the check is simply 1d20+ the relevant ability score modifier (usually intelligence, since sorcerers are less likely to scribe scrolls).