wiki!
"Until the advent of nuclear marine propulsion, most 20th century submarines used batteries for running underwater and gasoline (petrol) or diesel engines on the surface and to recharge the batteries. Early submarines used gasoline, but this quickly gave way to paraffin, then diesel, because of reduced flammability. Diesel-electric became the standard means of propulsion. The diesel or gasoline engine and the electric motor, separated by clutches, were initially on the same shaft and drove the propeller. This allowed the engine to drive the electric motor as a generator to recharge the batteries and also propel the submarine if required. The clutch between the motor and the engine would be disengaged when the submarine dove so that the motor could be used to turn the propeller. The motor could have more than one armature on the shaft, and these could be electrically coupled in series for slow speed and in parallel for high speed. (These alternative connections were known as "group down" and "group up", respectively.)"