comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: 'loop limit expression too large for loop variable type' error
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: 'loop limit expression too large for loop variable type' error [message #72316] Mon, 30 August 2010 09:56 Go to next message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Aug 30, 11:58 am, Chris Torrence <gorth...@gmail.com> wrote:
> On Aug 30, 9:47 am, Paulo Penteado <pp.pente...@gmail.com> wrote:
>
>
>
>
>
>> On Aug 30, 12:36 pm, Snow53 <jennifer_wa...@hotmail.com> wrote:
>
>>> My code runs great on small data sets, but I'm trying to use it for
>>> larger sets and I've started getting an
>>> ''loop limit expression too large for loop variable type' error when I
>>> reach the "for j=0, num_ids-1 do begin".  Why is this happening and
>>> how can I fix it?
>
>> It appears that num_ids is 2^16 or larger, which would overflow the
>> loop variable initialized with the type int. Use instead
>
>> for j=0L, num_ids-1
>
>> Or add at the beginning
>
>> compile_opt idl2
>
>> or compile_opt defint32
>
>> Assuming it would fit into a long (2^32).
>
> Or you could upgrade to IDL 8.0, which automatically promotes the loop
> variable to a long or long64 if the loop limit is greater than the
> maximum value for the loop variable. If it isn't greater than the
> maximum, then it leaves it alone.
>
> Cheers,
>
> Chris
> ITTVIS

Damn, that's going to seriously erode my perceived guru status, since
easily half the questions I get boil down to this issue! ;-)

-Jeremy.
Re: 'loop limit expression too large for loop variable type' error [message #72319 is a reply to message #72316] Mon, 30 August 2010 08:57 Go to previous messageGo to next message
Snow53 is currently offline  Snow53
Messages: 32
Registered: July 2010
Member
On Aug 30, 9:47 am, Paulo Penteado <pp.pente...@gmail.com> wrote:
> On Aug 30, 12:36 pm, Snow53 <jennifer_wa...@hotmail.com> wrote:
>
>> My code runs great on small data sets, but I'm trying to use it for
>> larger sets and I've started getting an
>> ''loop limit expression too large for loop variable type' error when I
>> reach the "for j=0, num_ids-1 do begin".  Why is this happening and
>> how can I fix it?
>
> It appears that num_ids is 2^16 or larger, which would overflow the
> loop variable initialized with the type int. Use instead
>
> for j=0L, num_ids-1
>
> Or add at the beginning
>
> compile_opt idl2
>
> or compile_opt defint32
>
> Assuming it would fit into a long (2^32).

Thanks for the compile_opt tips!
Re: 'loop limit expression too large for loop variable type' error [message #72320 is a reply to message #72319] Mon, 30 August 2010 08:58 Go to previous messageGo to next message
chris_torrence@NOSPAM is currently offline  chris_torrence@NOSPAM
Messages: 528
Registered: March 2007
Senior Member
On Aug 30, 9:47 am, Paulo Penteado <pp.pente...@gmail.com> wrote:
> On Aug 30, 12:36 pm, Snow53 <jennifer_wa...@hotmail.com> wrote:
>
>> My code runs great on small data sets, but I'm trying to use it for
>> larger sets and I've started getting an
>> ''loop limit expression too large for loop variable type' error when I
>> reach the "for j=0, num_ids-1 do begin".  Why is this happening and
>> how can I fix it?
>
> It appears that num_ids is 2^16 or larger, which would overflow the
> loop variable initialized with the type int. Use instead
>
> for j=0L, num_ids-1
>
> Or add at the beginning
>
> compile_opt idl2
>
> or compile_opt defint32
>
> Assuming it would fit into a long (2^32).

Or you could upgrade to IDL 8.0, which automatically promotes the loop
variable to a long or long64 if the loop limit is greater than the
maximum value for the loop variable. If it isn't greater than the
maximum, then it leaves it alone.

Cheers,

Chris
ITTVIS
Re: 'loop limit expression too large for loop variable type' error [message #72322 is a reply to message #72319] Mon, 30 August 2010 08:47 Go to previous messageGo to next message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Aug 30, 12:36 pm, Snow53 <jennifer_wa...@hotmail.com> wrote:
> My code runs great on small data sets, but I'm trying to use it for
> larger sets and I've started getting an
> ''loop limit expression too large for loop variable type' error when I
> reach the "for j=0, num_ids-1 do begin".  Why is this happening and
> how can I fix it?

It appears that num_ids is 2^16 or larger, which would overflow the
loop variable initialized with the type int. Use instead

for j=0L, num_ids-1

Or add at the beginning

compile_opt idl2

or compile_opt defint32

Assuming it would fit into a long (2^32).
Re: 'loop limit expression too large for loop variable type' error [message #72324 is a reply to message #72322] Mon, 30 August 2010 08:43 Go to previous messageGo to next message
Snow53 is currently offline  Snow53
Messages: 32
Registered: July 2010
Member
An update:

I'm now trying with,

for j=0L, num_ids-1 do begin

instead of just,

for j=0, num_ids-1 do begin.

It seems to be working..... :)
Re: 'loop limit expression too large for loop variable type' error [message #72401 is a reply to message #72316] Tue, 31 August 2010 14:27 Go to previous message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
On Aug 30, 12:56 pm, Jeremy Bailin <astroco...@gmail.com> wrote:
> On Aug 30, 11:58 am, Chris Torrence <gorth...@gmail.com> wrote:
>
>
>
>> On Aug 30, 9:47 am, Paulo Penteado <pp.pente...@gmail.com> wrote:
>
>>> On Aug 30, 12:36 pm, Snow53 <jennifer_wa...@hotmail.com> wrote:
>
>>>> My code runs great on small data sets, but I'm trying to use it for
>>>> larger sets and I've started getting an
>>>> ''loop limit expression too large for loop variable type' error when I
>>>> reach the "for j=0, num_ids-1 do begin".  Why is this happening and
>>>> how can I fix it?
>
>>> It appears that num_ids is 2^16 or larger, which would overflow the
>>> loop variable initialized with the type int. Use instead
>
>>> for j=0L, num_ids-1
>
>>> Or add at the beginning
>
>>> compile_opt idl2
>
>>> or compile_opt defint32
>
>>> Assuming it would fit into a long (2^32).
>
>> Or you could upgrade to IDL 8.0, which automatically promotes the loop
>> variable to a long or long64 if the loop limit is greater than the
>> maximum value for the loop variable. If it isn't greater than the
>> maximum, then it leaves it alone.
>
>> Cheers,
>
>> Chris
>> ITTVIS
>
> Damn, that's going to seriously erode my perceived guru status, since
> easily half the questions I get boil down to this issue! ;-)
>
> -Jeremy.

Wow - it really starts to look like now *everybody* will be able to
use IDL right off the bat... unless we work hard to press ITT into
introducing a few new additional obscure features designed to baffle
the IDL noobs!

In the meantime I suggest we start feeding IDL noobs programs
like the following in order to save the last scraps of our
claims to elitism...

execute='(i=execute("'&execute=execute(execute+'"'+$
'))--')&i$1i='print'&i1$i='scope_varname'&i2$i=' s'+$
'trtrim'&i$i='i'&i$i=i$i+'$i=('+i2$i+'('+i1$i+'(' +$
i$i+')'+','+i$i+'+++1))[0]'&execute=execute(i$i)&i=$
' for '+i$i+' = '&execute=execute('i2$i='+i2$i+'('+$
call_function(i2$i,execute) +',2)')&execute=i+i2$i+$
','+i2$i+i2$i+' do '+i$1i+','+i$i
execute=execute(execute)





Ciao,
Paolo
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDLDE 8.0 Command Line Errors
Next Topic: multi plot with superposed axis

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:10:31 PDT 2025

Total time taken to generate the page: 0.00681 seconds