Simulating the carbon flux between the terrestrial environment and the atmosphere