Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.* 1 > Newsgroup comp.lang.idl-pvwave

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 07-13-2012, 12:03 AM
Stewart Allen
Guest
 
Posts: n/a
Default compilation strangeness

Hi,

I am experiencing a strange compilation bug that I can't explain.

I have a procedure 'timeseries' (inside timeseries.pro) that calls a function 'stats' (inside stats.pro). Both files are in my IDL path (although different directories). However, IDL doesn't automatically find and compile stats when I try to compile timeseries:

IDL> print,file_which('stats.pro')
% Compiled module: FILE_WHICH.
/home/scrallen/idl_scripts/sim_code/stats.pro
IDL> .compile timeseries

calcstats = stats(rim,sim,arrival=1,tol=(run_no ge 7?0.01:1))
^
% Syntax error.
At: /home/data/BH/timeseries.pro, Line 41
% 1 Compilation error(s) in module TS.
IDL> .compile stats
% Compiled module: STATS.
IDL> .compile timeseries
% Compiled module: TIMESERIES.

As you can see, I'm forced to explicitly compile stats, even though I'm fairly sure IDL ought to find it and automatically compile it with timeseries.

Can anyone explain what's going on? And what am I doing wrong?

Cheers,
Stewart
Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 07-13-2012, 12:21 AM
Paulo Penteado
Guest
 
Posts: n/a
Default Re: compilation strangeness

On Jul 12, 9:03*pm, Stewart Allen <scral...@gmail.com> wrote:
> * * calcstats = stats(rim,sim,arrival=1,tol=(run_no ge 7?0.01:1))
> * * * * * * * * * * * * * * * * * * * ^
> % Syntax error.
> * At: /home/data/BH/timeseries.pro, Line 41
> % 1 Compilation error(s) in module TS.
> IDL> .compile stats
> % Compiled module: STATS.
> IDL> .compile timeseries
> % Compiled module: TIMESERIES.
>
> As you can see, I'm forced to explicitly compile stats, even though I'm fairly sure IDL ought to find it and automatically compile it with timeseries.
>
> Can anyone explain what's going on? And what am I doing wrong?


When that call to stats is first encountered, if stats was not
previously compiled, IDL is assuming it is not a function, it is an
array indexed with parentheses. In array indices there cannot be an
equal sign, which is the syntax error. If you compile stats, then IDL
knows there is a function called stats, and interprets that line as a
funcion call.

If you only use square brackets for array indexing inside the code for
timeseries (as you should), you can solve that by adding

compile_opt strictarr

(or "compile_opt idl2", which also changes the default integer to 32
bit)

to the beginning of the timeseries procedure. This will make only
square brackets allowed for array indexing, so parentheses will always
mean function calls.

Reply With Quote
  #3 (permalink)  
Old 07-13-2012, 07:54 PM
Stewart Allen
Guest
 
Posts: n/a
Default Re: compilation strangeness

Ah, I've been using compile_opt IDL2 on all new code for a while now, but this code was written quick and on the fly and I omitted it... Adding it fixes the issue.

Lesson learned: compile_opt IDL2 is ALWAYS a good idea.

Thanks,
Stewart

On Thursday, 12 July 2012 17:03:06 UTC-7, Stewart Allen wrote:
> Hi,
>
> I am experiencing a strange compilation bug that I can't explain.
>
> I have a procedure 'timeseries' (inside timeseries.pro) that calls a function 'stats' (inside stats.pro). Both files are in my IDL path (although different directories). However, IDL doesn't automatically find and compile stats when I try to compile timeseries:
>
> IDL&gt; print,file_which('stats.pro')
> % Compiled module: FILE_WHICH.
> /home/scrallen/idl_scripts/sim_code/stats.pro
> IDL&gt; .compile timeseries
>
> calcstats = stats(rim,sim,arrival=1,tol=(run_no ge 7?0.01:1))
> ^
> % Syntax error.
> At: /home/data/BH/timeseries.pro, Line 41
> % 1 Compilation error(s) in module TS.
> IDL&gt; .compile stats
> % Compiled module: STATS.
> IDL&gt; .compile timeseries
> % Compiled module: TIMESERIES.
>
> As you can see, I'm forced to explicitly compile stats, even though I'm fairly sure IDL ought to find it and automatically compile it with timeseries.
>
> Can anyone explain what's going on? And what am I doing wrong?
>
> Cheers,
> Stewart


Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 01:05 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.