1 | #! /bin/csh |
---|
2 | # |
---|
3 | # file shm_exec_hypocenter |
---|
4 | # =================== |
---|
5 | # |
---|
6 | # version 3, 15-Nov-2004 |
---|
7 | # |
---|
8 | # Execute hypocenter program on picked phases |
---|
9 | # K. Stammler, 11-Mar-2003 |
---|
10 | |
---|
11 | if ("$1" == "") then |
---|
12 | echo "Usage: $0 <evtfile>" |
---|
13 | exit |
---|
14 | endif |
---|
15 | |
---|
16 | # get parameters |
---|
17 | set evtfile=$1 |
---|
18 | |
---|
19 | # set constants |
---|
20 | set hypexec=/programs/linux/bin/hyp |
---|
21 | #set hypiasp=/programs/sol2/hypocenter/DAT |
---|
22 | set hypoin=hypocenter-in.dat |
---|
23 | set hyphead=STATION0.HYP |
---|
24 | set hyplog=hyp.log |
---|
25 | |
---|
26 | if (! -e $evtfile) then |
---|
27 | echo "$0 : Input file $evtfile not found. Abort." |
---|
28 | exit |
---|
29 | endif |
---|
30 | |
---|
31 | cd $SH_SCRATCH |
---|
32 | |
---|
33 | # check depth type |
---|
34 | set depqual="" |
---|
35 | set res=`grep 'Depth type' $evtfile` |
---|
36 | if ($#res == 5) then |
---|
37 | if ($res[5] == "preset") then |
---|
38 | set res=`grep 'Depth (km)' $evtfile` |
---|
39 | if ($#res == 4) then |
---|
40 | set depqual="-d=$res[4]" |
---|
41 | endif |
---|
42 | endif |
---|
43 | endif |
---|
44 | |
---|
45 | if (-e $hypoin) \rm $hypoin |
---|
46 | $SH_UTIL/ev2hypocenter $depqual -a $evtfile $hypoin |
---|
47 | |
---|
48 | # check for velocity model |
---|
49 | set modelname="" |
---|
50 | if (-e table_prefix.txt) set modelname=`cat table_prefix.txt` |
---|
51 | if (-e $SH_INPUTS/hypocenter_velmod_$modelname.dat) then |
---|
52 | set velmod=$SH_INPUTS/hypocenter_velmod_$modelname.dat |
---|
53 | else |
---|
54 | set velmod=$SH_INPUTS/hypocenter_velmod.dat |
---|
55 | endif |
---|
56 | echo "Hypocenter: using velocity model $velmod" |
---|
57 | |
---|
58 | # create file STATION0.HYP |
---|
59 | if (-e $hyphead) \rm $hyphead |
---|
60 | touch $hyphead |
---|
61 | echo "RESET TEST(13)=2.0" >>$hyphead |
---|
62 | echo "" >>$hyphead |
---|
63 | set slist=`grep 'Station code' $evtfile | awk '{print $4}' | sort -u` |
---|
64 | foreach s ($slist) |
---|
65 | $SH_UTIL/statinf -hypocenter $s >>$hyphead |
---|
66 | end |
---|
67 | echo "" >>$hyphead |
---|
68 | cat $velmod >>$hyphead |
---|
69 | echo "" >>$hyphead |
---|
70 | echo " 5.0 1100.2200. 1.74" >>$hyphead |
---|
71 | |
---|
72 | # check for IASP91 model |
---|
73 | if (! -e IASP91.HED) ln -s $SH_INPUTS/IASP91.HED IASP91.HED |
---|
74 | if (! -e IASP91.TBL) ln -s $SH_INPUTS/IASP91.TBL IASP91.TBL |
---|
75 | |
---|
76 | # call hypocenter |
---|
77 | if (-e $hyplog) \rm $hyplog |
---|
78 | $hypexec <<END >& $hyplog |
---|
79 | $hypoin |
---|
80 | n |
---|
81 | END |
---|
82 | |
---|
83 | if (-e hypout.evt) \rm hypout.evt |
---|
84 | $SH_UTIL/ev4hypocenter print.out hypsum.out hypout.evt hypview.txt |
---|
85 | |
---|
86 | # if something went wrong, get at least back the input data |
---|
87 | if (! -e hypout.evt) then |
---|
88 | cp $evtfile hypout.evt |
---|
89 | else if (-z hypout.evt) then |
---|
90 | cp $evtfile hypout.evt |
---|
91 | else |
---|
92 | set num=`grep -c 'Station code' hypout.evt` |
---|
93 | if ($num < 2) cp $evtfile hypout.evt |
---|
94 | endif |
---|
95 | |
---|
96 | $SH_TEXTEDIT hypview.txt & |
---|