Skip to content

Commit

Permalink
ALL output slots now display correct simulation year
Browse files Browse the repository at this point in the history
Previously, when future scenarios were run, the original years would be used as output. For instance, a scenario in 2020-2050 would have outputs from 1980-2010. I've utilized the delta year that I pass in for carbon effects and added it to the model year ONLY IN THE OUTPUT FUNCTIONALITY. The rest of the model still needs the 'incorrect' years.
  • Loading branch information
Zachary-Kramer committed May 4, 2017
1 parent b9e2f19 commit 050dfbb
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions SW_Output.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ void SW_OUT_construct(void)
{
/* =================================================== */
OutKey k;

/* note that an initializer that is called during
* execution (better called clean() or something)
* will need to free all allocated memory first
Expand Down Expand Up @@ -458,7 +458,7 @@ void SW_OUT_construct(void)

}
}

bFlush = FALSE;
tOffset = 1;

Expand Down Expand Up @@ -1207,7 +1207,10 @@ void SW_OUT_write_today(void)
OutKey k;
Bool writeit;
int i;


// Adjust the model year to match simulation years for the output
SW_Model.year += SW_Carbon.addtl_yr;

ForEachOutKey(k)
{
for (i = 0; i < numPeriods; i++)
Expand Down Expand Up @@ -1282,6 +1285,10 @@ void SW_OUT_write_today(void)
}
}
}

// Revert changes to model year, as rest of the model does not use simulation years
SW_Model.year -= SW_Carbon.addtl_yr;

}

static void get_none(void)
Expand Down Expand Up @@ -1353,7 +1360,7 @@ void get_co2effects(void) {
total = grass + shrub + tree + forb;

#ifdef RSOILWAT
p_Rco2effects_mo[SW_Output[eSW_CO2Effects].mo_row + mo_nrow * 0] = SW_Model.year + c->addtl_yr;
p_Rco2effects_mo[SW_Output[eSW_CO2Effects].mo_row + mo_nrow * 0] = SW_Model.year;
p_Rco2effects_mo[SW_Output[eSW_CO2Effects].mo_row + mo_nrow * 1] = month + 1;
p_Rco2effects_mo[SW_Output[eSW_CO2Effects].mo_row + mo_nrow * 2] = grass;
p_Rco2effects_mo[SW_Output[eSW_CO2Effects].mo_row + mo_nrow * 3] = shrub;
Expand Down Expand Up @@ -1387,7 +1394,7 @@ void get_co2effects(void) {
WUE_mult = c->co2_wue_mult;

#ifdef RSOILWAT
p_Rco2effects_yr[SW_Output[eSW_CO2Effects].yr_row + yr_nrow * 0] = SW_Model.year + c->addtl_yr;
p_Rco2effects_yr[SW_Output[eSW_CO2Effects].yr_row + yr_nrow * 0] = SW_Model.year;
p_Rco2effects_yr[SW_Output[eSW_CO2Effects].yr_row + yr_nrow * 1] = grass;
p_Rco2effects_yr[SW_Output[eSW_CO2Effects].yr_row + yr_nrow * 2] = shrub;
p_Rco2effects_yr[SW_Output[eSW_CO2Effects].yr_row + yr_nrow * 3] = tree;
Expand Down

0 comments on commit 050dfbb

Please sign in to comment.