JGCRI / hector

The Hector Simple Climate Model
http://jgcri.github.io/hector/
GNU General Public License v3.0
107 stars 45 forks source link

Address CO2 RF bug that throws an error with constraints #660

Closed kdorheim closed 1 year ago

kdorheim commented 1 year ago

When running Hector with an idealized CO2 constraint (preindustrial co2 as we do in the abrupt step and 1% increase runs) we run into the following error.

# Set up a Hector core
ini_file <- here::here("inst", "input", "hector_ssp245.ini")
hc <- newcore(ini_file)

# Fetch the pre-industrial value
prei_co2 <- fetchvars(hc, dates = NA, vars = PREINDUSTRIAL_CO2())

# Read in constant [CO2]
df <- data.frame(year = 1745:2100, 
                 value = prei_co2$value)
setvar(hc, dates = df$year, values = df$value, var = CO2_CONSTRAIN(), unit = getunits(CO2_CONSTRAIN()))
reset(hc)
run(hc)

Throws the following error

> run(hc)
Error in run(hc) : 
  Error while running hector:  msg:     Caller is requesting unknown condition for CO2 SARF 
func:   run
file:   forcing_component.cpp
ffile:  forcing_component.cpp

line:   340
Called from: run(hc)