Skip to content
kdorheim edited this page Mar 19, 2018 · 9 revisions

The driver runs the GCAM data system.

Located in R/driver.R, it:

  • Scans the package to find all available Chunks.
  • Queries the chunks for their inputs requirements and outputs.
  • Runs the chunks one by one, feeding data from one to another.
  • Does extensive error checking.
  • Writes the xml files

Normally, you should never have to deal with the driver, except by invoking it:

# run the driver, building all inputs
driver()

# run it quietly, saving the input for a chunk you're working on
x <- driver(quiet = TRUE, stop_before = "my_chunk_name")

# Full example for an existing chunk
driver(stop_before = "module_aglu_LA100.FAO_downscale_ctry") -> x
debug(gcamdata:::module_aglu_LA100.FAO_downscale_ctry)
gcamdata:::module_aglu_LA100.FAO_downscale_ctry("MAKE", x)

# Examine a chunk's outputs
driver(stop_after = "module_aglu_LA100.FAO_downscale_ctry") -> x
print(x)

# Return a specific piece of data
driver(return_data = "L210.TechCoef") -> x

There are a number of other options: see ?driver.

The driver can also be used to generate the xml files.

# gcamdata must be able to use Java to create the xml files and the driver must 
# be set up so that it saves the xml files. 
options(gcamdata.use_java = TRUE);
driver(write_outputs = TRUE)