While running the main script main.py with the TrunkV4 configuration (using the varlist.json file from DEF_TrunkV4), an error occurs in the Tools/ml.py module, at line 354 in the evaluate function:
UnboundLocalError: local variable 'index' referenced before assignment
Bug cause hypothesis : The variable index is not defined for some variable names because the conditional logic in the evaluate() function only assigns a value to index for specific cases (e.g., when varname starts with "biomass", "carbon", "litter", etc.). However, for newer or differently named variables like "soil_carbon" or "cc_biomass_c"—which are introduced in the TrunkV4 version—the function does not include any matching condition, so index remains undefined, resulting in the UnboundLocalError.
The idea here is to handle well the new variables :
- soil_carbon(time, l_e, z_d, y, x)
- litter_c(time, m_a, l_e, z_d, y, x)
- cc_biomass_c(time, a_c, a_b, a_a, y, x)
While running the main script main.py with the TrunkV4 configuration (using the varlist.json file from DEF_TrunkV4), an error occurs in the Tools/ml.py module, at line 354 in the evaluate function:
UnboundLocalError: local variable 'index' referenced before assignmentBug cause hypothesis : The variable index is not defined for some variable names because the conditional logic in the evaluate() function only assigns a value to index for specific cases (e.g., when varname starts with "biomass", "carbon", "litter", etc.). However, for newer or differently named variables like "soil_carbon" or "cc_biomass_c"—which are introduced in the TrunkV4 version—the function does not include any matching condition, so index remains undefined, resulting in the UnboundLocalError.
The idea here is to handle well the new variables :