3 |
michaesp |
1 |
#!/bin/csh
|
|
|
2 |
|
|
|
3 |
# Set some parameters
|
|
|
4 |
set crifile=${PWD}/select.parsed
|
|
|
5 |
|
|
|
6 |
# Set base directories (run+prog)
|
|
|
7 |
set cdfdir=${PWD}
|
|
|
8 |
set tradir=${PWD}
|
|
|
9 |
|
|
|
10 |
# Write usage information
|
|
|
11 |
if ( ${#argv} == 0 ) then
|
|
|
12 |
echo
|
|
|
13 |
/home/binderh/prog/programs/lagranto.mf/bin/lagrantohelp select short
|
|
|
14 |
echo
|
|
|
15 |
exit 0
|
|
|
16 |
endif
|
|
|
17 |
|
|
|
18 |
# Write list of special selection criteria
|
|
|
19 |
if ( "$1" == "-special" ) then
|
|
|
20 |
grep '%)' /home/binderh/prog/programs/lagranto.mf/select/special.f
|
|
|
21 |
exit 0
|
|
|
22 |
endif
|
|
|
23 |
|
|
|
24 |
# Write title
|
|
|
25 |
echo
|
|
|
26 |
echo '========================================================='
|
|
|
27 |
echo ' *** START OF PREPROCESSOR SELECT *** '
|
|
|
28 |
echo
|
|
|
29 |
|
|
|
30 |
# Save input arguments
|
|
|
31 |
set inpfile=$1
|
|
|
32 |
set outfile=$2
|
|
|
33 |
set crit="$3"
|
|
|
34 |
shift
|
|
|
35 |
shift
|
|
|
36 |
shift
|
|
|
37 |
|
|
|
38 |
# Handle optional arguments
|
|
|
39 |
echo
|
|
|
40 |
echo '---- OPTIONAL FLAGS -------------------------------------'
|
|
|
41 |
echo
|
|
|
42 |
|
|
|
43 |
set noclean = 'false'
|
|
|
44 |
set format = 'trajectory'
|
|
|
45 |
set regionf = 'regionf'
|
|
|
46 |
set trigger = 'nil'
|
|
|
47 |
|
|
|
48 |
while ( $#argv > 0 )
|
|
|
49 |
|
|
|
50 |
switch ( $argv[1] )
|
|
|
51 |
|
|
|
52 |
case -noclean
|
|
|
53 |
set noclean = 'true'
|
|
|
54 |
echo "noclean -> true (user defined)"
|
|
|
55 |
breaksw
|
|
|
56 |
|
|
|
57 |
case -trigger
|
|
|
58 |
set trigger = '-trigger'
|
|
|
59 |
echo "trigger -> true (user defined)"
|
|
|
60 |
breaksw
|
|
|
61 |
|
|
|
62 |
case -boolean
|
|
|
63 |
set format = 'boolean'
|
|
|
64 |
echo "format -> boolean (user defined)"
|
|
|
65 |
breaksw
|
|
|
66 |
|
|
|
67 |
case -index
|
|
|
68 |
set format = 'index'
|
|
|
69 |
echo "format -> index (user defined)"
|
|
|
70 |
breaksw
|
|
|
71 |
|
|
|
72 |
case -count
|
|
|
73 |
set format = 'count'
|
|
|
74 |
echo "format -> count (user defined)"
|
|
|
75 |
breaksw
|
|
|
76 |
|
|
|
77 |
case -startf
|
|
|
78 |
set format = 'startf'
|
|
|
79 |
echo "format -> startf (user defined)"
|
|
|
80 |
breaksw
|
|
|
81 |
|
|
|
82 |
case -regionf
|
|
|
83 |
set regionf = $argv[2]
|
|
|
84 |
echo "regionf -> ${regionf} (user defined)"
|
|
|
85 |
shift;
|
|
|
86 |
breaksw
|
|
|
87 |
|
|
|
88 |
endsw
|
|
|
89 |
|
|
|
90 |
shift;
|
|
|
91 |
|
|
|
92 |
end
|
|
|
93 |
|
|
|
94 |
# Decide whether <select> is a file or an explicit criterion
|
|
|
95 |
set flag_select = 'criterion'
|
|
|
96 |
set test = `echo ${crit} | grep ':' | wc -c`
|
|
|
97 |
if ( "${test}" == "0" ) then
|
|
|
98 |
set flag_select = 'file'
|
|
|
99 |
set flag_selectfile = $crit
|
|
|
100 |
if ( -f ${flag_selectfile} ) then
|
|
|
101 |
set crit = `cat ${flag_selectfile}`
|
|
|
102 |
else
|
|
|
103 |
echo " ERROR: criterion file ${flag_selectfile} is missing... Stop"
|
|
|
104 |
exit 1
|
|
|
105 |
endif
|
|
|
106 |
endif
|
|
|
107 |
|
|
|
108 |
# Get the start, end and reference date for the tracing
|
|
|
109 |
set ntra = `/home/binderh/prog/programs/lagranto.mf/goodies/trainfo.sh ${inpfile} ntra`
|
|
|
110 |
set ntim = `/home/binderh/prog/programs/lagranto.mf/goodies/trainfo.sh ${inpfile} ntim`
|
|
|
111 |
set ncol = `/home/binderh/prog/programs/lagranto.mf/goodies/trainfo.sh ${inpfile} ncol`
|
|
|
112 |
set times = `/home/binderh/prog/programs/lagranto.mf/goodies/trainfo.sh ${inpfile} times`
|
|
|
113 |
set vars = `/home/binderh/prog/programs/lagranto.mf/goodies/trainfo.sh ${inpfile} vars`
|
|
|
114 |
|
|
|
115 |
# Split the criterion into subunits (with Perl)
|
|
|
116 |
/home/binderh/prog/programs/lagranto.mf/select/select.perl "${crit}" >! ${crifile}
|
|
|
117 |
if ( "${status}" != "0" ) then
|
|
|
118 |
echo "ERROR: Parser <select> failed"
|
|
|
119 |
exit 1
|
|
|
120 |
endif
|
|
|
121 |
|
|
|
122 |
# Write some status information
|
|
|
123 |
echo
|
|
|
124 |
echo '---- DIRECTORIES AND PROGRAMS ---------------------------'
|
|
|
125 |
echo
|
|
|
126 |
echo "CDF directory : ${cdfdir}"
|
|
|
127 |
echo "TRA directory : ${tradir}"
|
|
|
128 |
echo "PROGRAM SELECT : /home/binderh/prog/programs/lagranto.mf/select/select"
|
|
|
129 |
echo "PARSER : /home/binderh/prog/programs/lagranto.mf/select/select.perl"
|
|
|
130 |
echo "CRITERION FILE : ${crifile}"
|
|
|
131 |
echo
|
|
|
132 |
echo '---- INPUT PARAMETERS -----------------------------------'
|
|
|
133 |
echo
|
|
|
134 |
echo "Input file : ${inpfile}"
|
|
|
135 |
echo "Output file : ${outfile}"
|
|
|
136 |
echo "Output format : ${format}"
|
|
|
137 |
if ( "${flag_select}" == "criterion" ) then
|
|
|
138 |
echo "Criterion : ${crit}"
|
|
|
139 |
else
|
|
|
140 |
echo "Criterion : ${crit} (from file ${flag_selectfile})"
|
|
|
141 |
endif
|
|
|
142 |
echo
|
|
|
143 |
echo '---- INPUT FILE -----------------------------------------'
|
|
|
144 |
echo
|
|
|
145 |
echo "# TRA : ${ntra}"
|
|
|
146 |
echo "# TIMES : ${ntim}"
|
|
|
147 |
echo "# COLUMNS : ${ncol}"
|
|
|
148 |
echo "Times : ${times}"
|
|
|
149 |
echo "Variables : ${vars}"
|
|
|
150 |
echo
|
|
|
151 |
echo '---- PARSED CRITERION ------------------------------------'
|
|
|
152 |
echo
|
|
|
153 |
cat ${crifile}
|
|
|
154 |
|
|
|
155 |
# Finish the preprocessor
|
|
|
156 |
echo
|
|
|
157 |
echo ' *** END OF PREPROCESSOR SELECT *** '
|
|
|
158 |
echo '========================================================='
|
|
|
159 |
echo
|
|
|
160 |
|
|
|
161 |
# Run the selection programme
|
|
|
162 |
echo \"${inpfile}\" >! select.param
|
|
|
163 |
echo \"${outfile}\" >> select.param
|
|
|
164 |
echo \"${format}\" >> select.param
|
|
|
165 |
echo \"${crifile}\" >> select.param
|
|
|
166 |
echo ${ntra} >> select.param
|
|
|
167 |
echo ${ntim} >> select.param
|
|
|
168 |
echo ${ncol} >> select.param
|
|
|
169 |
echo \"${regionf}\" >> select.param
|
|
|
170 |
echo \"${trigger}\" >> select.param
|
|
|
171 |
|
|
|
172 |
/home/binderh/prog/programs/lagranto.mf/select/select
|
|
|
173 |
|
|
|
174 |
if ( "${status}" != "0" ) then
|
|
|
175 |
echo "ERROR: Program <select> failed"
|
|
|
176 |
exit 1
|
|
|
177 |
endif
|
|
|
178 |
|
|
|
179 |
# Make clean
|
|
|
180 |
if ( "${noclean}" == "false" ) then
|
|
|
181 |
\rm -f select.param
|
|
|
182 |
\rm -f ${crifile}
|
|
|
183 |
endif
|
|
|
184 |
|
|
|
185 |
exit 0
|