timjmiller / wham

State-space, age-structured fish stock assessment model
https://timjmiller.github.io/wham
Other
32 stars 16 forks source link

Bug when running retros #72

Closed GiancarloMCorrea closed 1 year ago

GiancarloMCorrea commented 1 year ago

Testing the new growth branch, I found a bug that made my model crash (R session aborted) and produce NaNs when running retros. The same issue happened (but the model did not crash, I don't know why yet) when using the devel branch.

The problem is here. avg_years_ind and XSPR_R_avg_yrs are not changed before running retros, so the indices are out of range and produced NaN or Inf when running _get_static_SPRres function.

This can be easily solved by adding here:

temp$data$avg_years_ind = temp$data$avg_years_ind - peel temp$data$XSPR_R_avg_yrs = temp$data$XSPR_R_avg_yrs[1:n_years]

Hope this helps.

timjmiller commented 1 year ago

Thanks @GiancarloMCorrea. Now fixed on devel branch.