source: SH_SHM/trunk/source/seed_io/seed_copy.csh @ 16

Revision 16, 5.6 KB checked in by marcus, 15 years ago (diff)

r1 | svn | 2007-12-13 11:10:29 +0100 (Do, 13 Dez 2007) | 2 lines

Initial import

  • Property svn:executable set to *
Line 
1#! /bin/csh
2#
3# file seed_copy.csh
4#      =============
5#
6# version 8, 9-May-2007
7#
8# copies Mini-SEED files to output directory
9# K. Stammler, 5-Jul-95
10
11if  ("$1" == "help" || "$1" == "-help")  then
12        echo "Usage: $0 <sfdfile> <streamlist> <from> <to> <workdir> <outfile> [<exact>]"
13        exit
14endif
15
16#setenv QUIET_STARTUP
17#source /usr/local/common_startup
18#unsetenv QUIET_STARTUP
19
20#set echo
21
22# set constants
23set scrdir=tmp_dir_$$
24set seedspec="/programs/sol2/seed/own/src"
25setenv HEADER_INPUT $seedspec/inputs
26set jkpath="JK:"
27
28# get parameters from command line
29set sfdfile="$1"
30set streamwild="$2"
31set fromtime="$3"
32set totime="$4"
33set outdir="$5"
34set outfile="$6"
35set exact="$7"
36
37# store original directory
38set startdir=$PWD
39
40# inquire empty parameters
41while  ("$sfdfile" == "")
42        echo -n "sfd-file directory [/cdrom]: "
43        set sfdfile="$<"
44        if  ("$sfdfile" == "")  set sfdfile="/cdrom"
45        set sfdfile="`eval echo $sfdfile`"/sfdfile.sfd
46        #if  ("$sfdfile" == '$ARCH')  set sfdfile="$ARCH/sfdfile.sfd"
47        if  (! -e $sfdfile && "$sfdfile" != "$jkpath" && "$sfdfile" != "DB:")  then
48                if  (-e $sfdfile/sfdfile.sfd)  then
49                        set sfdfile="$sfdfile/sfdfile.sfd"
50                else
51                        echo "file $sfdfile does not exist"
52                        set sfdfile=""
53                endif
54        endif
55end
56if  ("$streamwild" == "")  then
57        echo -n "streamlist [grf]: "
58        set streamwild="$<"
59        if  ("$streamwild" == "")  set streamwild="grf"
60endif
61while  ("$fromtime" == "")
62        echo -n "from time [23-jul-95_8:23 or 23,7,95,8,23]: "
63        set fromtime="$<"
64end
65while  ("$totime" == "")
66        echo -n "to time   [23-jul-95_8:23 or 23,7,95,8,23]: "
67        set totime="$<"
68end
69while  ("$outdir" == "")
70        echo -n "working directory: "
71        set outdir="$<"
72        if  (! -d $outdir)  then
73                echo "$outdir is an illegal directory"
74                set outdir=""
75                continue
76        endif
77        if  (! -w $outdir)  then
78                echo "cannot write to $outdir"
79                set outdir=""
80        endif
81end
82if  ("$outfile" == "")  then
83        echo -n "output file [seedout.sed]: "
84        set outfile="$<"
85        if  ("$outfile" == "")  set outfile="seedout.sed"
86endif
87
88## get list of streams
89#if  ("$streamwild" == "grf")  set streamwild='gr[a-c]?-bh-?'
90#if  ("$streamwild" == "grf-bh-?")  set streamwild='gr[a-c]?-bh-?'
91#if  ("$streamwild" == "grf-bh-z")  set streamwild='gr[a-c]?-bh-z'
92#if  ("$streamwild" == "grsn")  set streamwild='[a-f,h-z]*-bh-? grfo-bh-? gsh-bh-?'
93#if  ("$streamwild" == "grsn-hh-?")  set streamwild='[a-f,h-z]*-hh-? gsh-hh-?'
94#if  ("$streamwild" == "grsn-hh-z")  set streamwild='[a-f,h-z]*-hh-z gsh-hh-z'
95#if  ("$streamwild" == "grsn-bh-?")  set streamwild='[a-f,h-z]*-bh-? grfo-bh-? gsh-bh-?'
96#if  ("$streamwild" == "grsn-bh-z")  set streamwild='[a-f,h-z]*-bh-z grfo-bh-z gsh-bh-z'
97#if  ("$streamwild" == "grsn-lh-?")  set streamwild='[a-f,h-z]*-lh-? grfo-lh-? gsh-lh-?'
98#if  ("$streamwild" == "grsn-lh-z")  set streamwild='[a-f,h-z]*-lh-z grfo-lh-z gsh-lh-z'
99#
100#set streamlist=`(chdir $SEED_PROG/streams; ls $streamwild)`
101
102set streamlist=""
103if  ("$streamwild" == "grf")        set streamlist=`$DPROG/list_streams.csh grf-bh`
104if  ("$streamwild" == "grf-bh-?")   set streamlist=`$DPROG/list_streams.csh grf-bh`
105if  ("$streamwild" == "grf-bh-z")   set streamlist=`$DPROG/list_streams.csh grf-bh | grep z$`
106if  ("$streamwild" == "grsn")       set streamlist=`$DPROG/list_streams.csh grsn-bh-all`
107if  ("$streamwild" == "grsn-hh-?")  set streamlist=`$DPROG/list_streams.csh grsn-hh-all`
108if  ("$streamwild" == "grsn-hh-z")  set streamlist=`$DPROG/list_streams.csh grsn-hh-all | grep z$`
109if  ("$streamwild" == "grsn-bh-?")  set streamlist=`$DPROG/list_streams.csh grsn-bh-all`
110if  ("$streamwild" == "grsn-bh-z")  set streamlist=`$DPROG/list_streams.csh grsn-bh-all | grep z$`
111if  ("$streamwild" == "grsn-lh-?")  set streamlist=`$DPROG/list_streams.csh grsn-lh-all`
112if  ("$streamwild" == "grsn-lh-z")  set streamlist=`$DPROG/list_streams.csh grsn-lh-all | grep z$`
113if  ("$streamwild" == "sxnet")      set streamlist=`$DPROG/list_streams.csh sxnet-bh-all`
114if  ("$streamwild" == "sxnet-bh-?") set streamlist=`$DPROG/list_streams.csh sxnet-bh-all`
115if  ("$streamwild" == "sxnet-bh-z") set streamlist=`$DPROG/list_streams.csh sxnet-bh-all | grep z$`
116
117if  ("$streamlist" == "")  then
118        set streamlist=`(chdir $SEED_PROG/streams; ls $streamwild)`
119endif
120
121# copy data to temporary directory
122chdir $outdir
123mkdir $scrdir
124chdir $scrdir
125if  ("$sfdfile" == "$jkpath")  then
126        set loc_sfdfile="$sfdfile"
127        set pathcache=""
128        set f_pathcache=""
129else if  ("$sfdfile" == "DB:")  then
130        set loc_sfdfile=/tmp/seed_copy_$$.sfd
131        if  (-e $loc_sfdfile)  \rm $loc_sfdfile
132        if  ("`uname`" == "Linux")  then
133                echo "station chan    comp    pathid  relpath sdate   stime   edate   etime   recnum hswap    recsize offset  dataflags       priority        dataformat" >$loc_sfdfile
134                $SH_UTIL/sfdb/sfd_from_sfdb.py $fromtime $totime >>$loc_sfdfile
135                set pathcache=""
136                set f_pathcache=""
137        else
138                $SEED_PROG/sfd_from_sfdb.csh $fromtime $totime >$loc_sfdfile
139                set f_pathcache=/tmp/seed_pathcache_$$.000
140                if  (-e $f_pathcache)  \rm $f_pathcache
141                $SH_UTIL/sol_sql_call.csh szpc35 "select * from pathtab order by id" >$f_pathcache
142                set pathcache="-pathcache=$f_pathcache"
143        endif
144else
145        set pathcache=""
146        set f_pathcache=""
147        set loc_sfdfile=$startdir/$sfdfile
148        if  (! -e $loc_sfdfile)  set loc_sfdfile=$sfdfile
149endif
150if  ("$exact" == "exact")  then
151        set exact="-exact"
152else
153        set exact=""
154endif
155foreach stream ($streamlist)
156        echo "copying stream $stream"
157        $SEED_PROG/copy_recs $pathcache -defaultnet=GR $exact $loc_sfdfile $stream \
158                $fromtime $totime standard
159end
160
161if  ("$sfdfile" == "DB:")  \rm $loc_sfdfile
162if  ("$f_pathcache" != "")  \rm $f_pathcache
163
164if  ("$outfile" == "mini-seed")  then
165        mv * ..
166        chdir ..
167        rmdir $scrdir
168        exit
169endif
170
171# create seed-volume
172$seedspec/seed_volume.csh '*' $outfile
173
174# remove scratch dir
175if  (-f ./$outfile)  mv $outfile ..
176chdir ..
177\rm -rf $scrdir
Note: See TracBrowser for help on using the repository browser.