Ion Acceleration in the Magnetosphere and Ionosphere