Role of carbon dioxide in the dynamics of magma ascent in explosive eruptions