APSIM模型运行错误: 'output'变量未定义
The error 'object 'output' not found' indicates that the variable 'output' is not defined in the code. This usually occurs because the line of code that runs the APSIM model and generates the output is commented out. To resolve this issue, uncomment the line of code that runs the APSIM model and define the 'output' variable. The corrected code should look like this:
for (depth in c(5, 15, 30, 60, 100, 200)) {
# 设置土壤参数
soil_parameters <- list(
Site = site,
Latitude = lat,
Longitude = lon,
Depth = depth,
LL15 = soil_df$LL15[i],
DUL = soil_df$DUL[i],
SAT = soil_df$SAT[i],
BD = soil_df$BD[i]
)
# 运行APSIM模型
output <- run_APSIM(sim_parameters, soil_parameters) # Uncomment this line
system(paste(apsim_exe, file_apsim),wait = TRUE,ignore.stdout=TRUE,show.output.on.console=FALSE)
# 将结果保存为CSV文件
#需要定义一个新的apsim文件!
file_apsim <- paste0('E:/weidan/region1wheat/SHIYONG.apsim')
writeLines(apsim, file_apsim)
system(paste(apsim_exe, file_apsim),wait = TRUE,ignore.stdout=TRUE,show.output.on.console=FALSE)
file.copy('E:/weidan/region1wheat/SHIYONG.out',paste0('E:/weidan/region1wheat/SHIYONG/',df$name[i],'.out'))
write.csv(output, output_file)
}
After uncommenting the line and defining 'output', the code should run without errors. If the problem persists, check the 'run_APSIM' function and ensure it is correctly defined and returns the desired output.
原文地址: https://www.cveoy.top/t/topic/nCc6 著作权归作者所有。请勿转载和采集!