Skip to content

Strange behavior of 2-d array within function

3 messages · Gabriel Toro, Bert Gunter, PIKAL Petr

#
Hi,

I have a function, which defines an array of dimensions 5000 by 60, calculates the values within that array and then returns the array on exit.

I get an error: Error in my_simulated[ir, 1:it] : incorrect number of dimensions

For some strange reason, the array is somehow being changed from
       mode "numeric" and attributes $dim=6000 by 50
       to
       mode "list" and attributes NULL

This change occurs at more or less random iterations within a loop (all within the same function call). I am not explicitly manipulating the mode or attributes of the array after it is created.

I would appreciate any suggestions on what may be causing this problem. I have stared at the code for a long time, run the debugger, etc.

Thanks,

Gabriel
#
Likely impossible to answer without seeing your  code.

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Wed, Oct 6, 2021 at 11:33 AM Gabriel Toro <toro at lettisci.com> wrote:

            

  
  
#
Hi

I would print/save iteration number to see at what time this occured and
probably traceback() could give you some hint.
Alternatively you could make a function from your code see ?function and use
debug to trace the error.

Without some working example it is impossible to see where is the problem.

Cheers
Petr
calculates
dimensions
within