Global resonances in the evolution of solar magnetic fields