[SAC-HELP] Do Loop Bug

George Helffrich george at gly.bris.ac.uk
Thu Oct 9 06:55:13 PDT 2008


Dear All -

	It is a feature-cum-bug in SAC's implementation of DO that all the 
numeric values are generated as a single string upon entry to the loop. 
  If there are many values (80 in your case) that's a long string and it 
can get truncated or overflow.  Here's a workaround that uses 
SYSTEMCOMMAND to build a file of macro invocations for each time 
window.  Beware of all the "@"-escapes:

funcgen seismogram; w /tmp/hold0; w /tmp/hold1; r /tmp/hold0 /tmp/hold1
sc echo xlim @$1 @$2                               > /tmp/macro
sc echo title 'Particle Motion from @$1 to @$2@$' >> /tmp/macro
sc echo plotpm                                    >> /tmp/macro
sc echo 2400 2800 5 | awk '{for@(t=@$1;t<=@$2;t+=@$3@) printf "m 
/tmp/macro @%f @%f\n",t,t+100}' > /tmp/sac.in
sc rm -f /tmp/macro /tmp/sac.in

On 9 Oct 2008, at 06:51, Bob Hancock wrote:

> I copied the Do Loop macro for particle motion plots from the Do Loop 
> Examples contained in the MACRO Section of the SAC Manual, and have 
> found a problem – See Macro followed by explanation below:
>
> READ ABC
>  SETBB TIME1 0
>  DO TIME2 FROM 2 TO 10 BY 2
>  XLIM %TIME1 $TIME2
>  TITLE 'Particle Motion from %TIME1 to $TIME2$'
>  PLOTPM
>  SETBB TIME1 $TIME2
>  ENDDO
>
> There are four variables in the macro
>
>  Time1 – The starting value for XLIM
>  Time2 – The ending value for XLIM
>  Upper limit of macro processing
>  Incremental value to increase or decrease the values of both Time1 
> and Time2 for the next increment.
>
>  As long as the incremental value is equal to or greater than the time 
> difference between Time1 and Time2, the macro works as advertised. 
>  NOTE – This is how the Macro above is setup.
>
>  However, when the incremental time is decreased to less than the 
> value between Time1 and Time2, the time difference between Time1 and 
> Time two is AUTOMATICALLY decreased to equal the incremental value. 
>  See values in Macro below:
>
> READ ABC
>  SETBB TIME1 2300
>  DO TIME2 FROM 2400 TO 2800 BY 5
>  XLIM %TIME1 $TIME2
>  TITLE 'Particle Motion from %TIME1 to $TIME2$'
>  PLOTPM
>  SETBB TIME1 $TIME2
>  ENDDO
>
>  I have not found a solution to this problem.
>
>  If anyone has encountered this problem, or has a suggestion on how to 
> alleviate the problem, I would appreciate hearing from them.
>
>  Thank You
>
>  Bob Hancock  _______________________________________________
> sac-help mailing list
> sac-help at iris.washington.edu
> http://www.iris.washington.edu/mailman/listinfo/sac-help
>
                                     George Helffrich
                                     george at geology.bristol.ac.uk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 5117 bytes
Desc: not available
URL: <http://www.iris.washington.edu/pipermail/sac-help/attachments/20081009/7a74aa49/attachment.bin>


More information about the sac-help mailing list