Thermodynamics and energetics of the atmosphere and oceans