R/zchunk_batch_no_climate_model_xml.R

Defines functions module_batch_no_climate_model_xml

Documented in module_batch_no_climate_model_xml

#' module_batch_no_climate_model_xml
#'
#' Construct XML data structure for \code{no_climate_model.xml}.
#'
#' @param command API command to execute
#' @param ... other optional parameters, depending on command
#' @return Depends on \code{command}: either a vector of required inputs,
#' a vector of output names, or (if \code{command} is "MAKE") all
#' the generated outputs: \code{no_climate_model.xml}, \code{disable_climate_model.xml}.
module_batch_no_climate_model_xml <- function(command, ...) {
  if(command == driver.DECLARE_INPUTS) {
    return(c())
  } else if(command == driver.DECLARE_OUTPUTS) {
    return(c(XML = "no_climate_model.xml",
             XML = "disable_climate_model.xml"))
  } else if(command == driver.MAKE) {

    # ===================================================

    no_climate_data <- tibble(carbon.model.start.year = modeltime.MAGICC_C_START_YEAR)
    delete_climate <- tibble(delete = 1)

    # Produce outputs
    create_xml("no_climate_model.xml") %>%
      add_xml_data(no_climate_data, "NoClimateModel") ->
      no_climate_model.xml

    create_xml("disable_climate_model.xml") %>%
      add_xml_data(delete_climate, "DeleteMAGICC") %>%
      add_xml_data(delete_climate, "DeleteHector") %>%
      add_xml_data(no_climate_data, "NoClimateModel") ->
      disable_climate_model.xml

    return_data(no_climate_model.xml, disable_climate_model.xml)
  } else {
    stop("Unknown command")
  }
}
rohmin9122/gcam-korea-release documentation built on Nov. 26, 2020, 8:11 a.m.