Forums

Back

Invalid Index error

Laura Lee, modified 5 Years ago.

Invalid Index error

Youngling Posts: 95 Join Date: 3/31/16 Recent Posts

Hello all-

I'm running a model with three fleets and four surveys for the 1982 to 2017 time period. While the model is running, the likelihood is reported as "nan" and when finished, I receive the following error: "Error: Invalid index 2018 used for array range [1, 0] in "dmatrix& d3_array::operator() (int i, int j, int k)". array bound exceeded - - slice index too high"

I've attached my files and would appreciate any advice.

Thanks in advance for your time.

Cheers,

Laura

 

PS I'm using version 3.30.14.01 safe

IT
Ian Taylor, modified 6 Years ago.

RE: Invalid Index error

Youngling Posts: 117 Join Date: 12/8/14 Recent Posts
Hi Laura,
This was a case of two independent errors making it harder to diagnose either one. Here's what I figured out:

I made the "Error: Invalid index 2018 used for array range..." go away by changing
0 # Forecast: 0=none; 1=F(SPR); 2=F(MSY) 3=F(Btgt) or F0.1; 4=Ave F (uses first-last relF yrs); 5=input annual F scalar
0 # N forecast years 
to
1 # Forecast: 0=none; 1=F(SPR); 2=F(MSY) 3=F(Btgt) or F0.1; 4=Ave F (uses first-last relF yrs); 5=input annual F scalar
10 # N forecast years 
I though to do this because the last message in the console before the error was "finished benchmark for reporting" which is normally followed by "finished forecast for reporting". I'm not sure what the problem was with no forecast, but didn't dig deeper because the error was gone and the "nan" values associated with length comp likelihoods for fleets 1 to 3 still remained. However, with the forecast no longer producing that error, the model output files were now being written.

Running the r4ss commands
model <- SS_output(...)
SS_plots(model, plot = 1:12)
where the plot groups are subset after having the function crash on plot group 13 which is the length comp data plots.
Looking through the plots helped me see in the selectivity pots that fleets 2 and 3 have 0 retained fish but the length comps are associated with Partition = 2 = retained. Changing the Partition values for the length comps associated with fleets 1 to 3 to 0=combined made the nan values go away. I'm not sure why there were nan values for fleet 1 given that it did have retained fish, but changing to Partition = 0 fixed it.

That partition error should be an easy one to add an informative warning about so I'll work with Rick to have that added in the future. He may also have insight into the source of the forecast error.
-Ian


On Mon, Jul 29, 2019 at 7:45 AM Laura Lee <VLab.Notifications@noaa.gov> wrote:

Hello all-

I'm running a model with three fleets and four surveys for the 1982 to 2017 time period. While the model is running, the likelihood is reported as "nan" and when finished, I receive the following error: "Error: Invalid index 2018 used for array range [1, 0] in "dmatrix& d3_array::operator() (int i, int j, int k)". array bound exceeded - - slice index too high"

I've attached my files and would appreciate any advice.

Thanks in advance for your time.

Cheers,

Laura

 

PS I'm using version 3.30.14.01 safe


--
Laura Lee Stock Synthesis Virtual Lab Forum https://vlab.noaa.gov/group/stock-synthesis/discussions-forums-/-/message_boards/view_message/7227387 VLab.Notifications@noaa.gov
KD
Kathryn Doering, modified 6 Years ago.

RE: Invalid Index error

Youngling Posts: 57 Join Date: 2/19/19 Recent Posts

Hi Laura, 

Which exe are you using? Still 3.30.14.01 safe?

Thanks,
Kathryn

KD
Kathryn Doering, modified 6 Years ago.

RE: Invalid Index error

Youngling Posts: 57 Join Date: 2/19/19 Recent Posts

Hi Laura,

 

I modified your original model files with the changes  Ian described and the 3.30.14.01 exe and it ran for me without the indexing error (I used option -nohess). I've attached the model files I used (note the only differences are 2 lines in the forecasting file and the lengthcomps partitioning codes in the data file, which I ran through r4ss functions SS_readdataand SS_writedat to replace the partition codes for length comps, so the formatting will look different.) Do these work for you, or do you still get the same error?

 

Thank you,

Kathryn