Pool dynamics of time-dependent compartmental systems with application to the terrestrial carbon cycle