Thread: Fwd: Do loop problem - SAC macro

Started: 2012-06-27 04:26:51
Last activity: 2012-06-27 04:26:51
Topics: SAC Help
George Helffrich
2012-06-27 04:26:51
Dear LE -

Segmentation faults should never happen in a program, let alone SAC. But perfection is for the gods, not programmers, so a workaround is needed. A workaround that avoids use of the suspect DO loop implementation is to define a macro that processes one file and to then call it for each file. For example:

# Define macro
cat << EOF > /tmp/onefile
read $1$.SAC
ch stla 32.8118 stlo -118.8036
w $1$.hac
EOF

# Find files and make list of SAC commands to run macro on each one
ls *.SAC | sed -e 's/.SAC//' | awk '{print "m /tmp/onefile",$1}' > /tmp/sac.in

# Run SAC and process list of files
sac
m /tmp/sac.in
quit

On 26 Jun 2012, at 18:19, lennin escobar wrote:

I am running a SAC macro to add the lat and long to a total of 32 events. It turns out that the macro only counts 26 events and leaves the rest of the events untouched.

I ran the macro for several folders (I have to do it for many folders with 32 events each) and I found out that 26 is the max iterations that the DO loop can do under SAC. Also, I found out that when number of events is greater that 32 the macro does not even run and the following message just comes out:
"Segmentation fault".

here is the macro :


echo on

**cc OBS02
**cc LAT = 32.8118
**cc LON =-118.8036

cd /home/lennin/lennin1/test3_99/added_events/all_OBS/OBS02

do STAT wild xx*.SAC
r $STAT

ch stla 32.8118
ch stlo -118.8036

write change SAC hac
enddo

echo off


any input?

Thanks
_______________________________________________
sac-help mailing list
sac-help<at>iris.washington.edu
http://www.iris.washington.edu/mailman/listinfo/sac-help

George Helffrich
george.helffrich<at>bris.ac.uk



09:45:12 v.ad6b513c