Users will often want to make changes to gcamdata code or add new “chunks”. Below we offer some advice and tips about how to achieve this.

What is a Chunk?

A chunk is just our term for a unit of code corresponding to a single R file in gcamdata. A chunk will normally comprise a single function, chunks are separated into files according to what module they belong to: aglu, emissions, energy, gcam-usa, modeltime, and socioeconomics.

Chunks know how to respond to three messages sent by the driver: * driver.DECLARE_INPUTS: The chunk returns the names of its required inputs.. * driver.DECLARE_OUTPUTS: The chunk returns the names of the outputs it will produce. * driver.MAKE: The chunk builds its data outputs and returns them.

Code Style

Basic Chunk Debugging

  • To walk through a chunk, we recommend following these steps

Input Data

  • All input data needs to be documented
  • Constant values should be set in the constants file, not within individual chunks. Make sure to check if the constant already exists and defined new constants in ALL CAPS with, optionally, an initial lowercase qualifier. See the many examples in the file.
  • Some proprietary and prebuilt data is used in gcamdata.

Writing Chunks