3 |
michaesp |
1 |
#!/bin/csh
|
|
|
2 |
|
|
|
3 |
# ---------------------------------------------------------------------
|
|
|
4 |
# Usage, parameter settings
|
|
|
5 |
# ---------------------------------------------------------------------
|
|
|
6 |
|
|
|
7 |
# Write usage information
|
|
|
8 |
if ( (${#argv} == 0) | (${#argv} < 2) ) then
|
|
|
9 |
echo
|
|
|
10 |
/home/binderh/prog/programs/lagranto.mf/bin/lagrantohelp lidar short
|
|
|
11 |
echo
|
|
|
12 |
exit 0
|
|
|
13 |
endif
|
|
|
14 |
|
|
|
15 |
# Write title
|
|
|
16 |
echo
|
|
|
17 |
echo '========================================================='
|
|
|
18 |
echo ' *** START OF PREPROCESSOR LIDAR *** '
|
|
|
19 |
echo
|
|
|
20 |
|
|
|
21 |
# Get the arguments
|
|
|
22 |
set inpfile = $1
|
|
|
23 |
set outfile = $2
|
|
|
24 |
|
|
|
25 |
# Set base directories (run+prog)
|
|
|
26 |
set cdfdir=${PWD}
|
|
|
27 |
set tradir=${PWD}
|
|
|
28 |
|
|
|
29 |
# Set program paths and filenames
|
|
|
30 |
set parfile = ${tradir}/trace.param
|
|
|
31 |
set prog = /home/binderh/prog/programs/lagranto.mf/lidar/lidar
|
|
|
32 |
|
|
|
33 |
# Set the prefix of the primary and secondary data files
|
|
|
34 |
set charp = 'P'
|
|
|
35 |
set chars = 'S'
|
|
|
36 |
|
|
|
37 |
echo '---- DIRECTORIES AND PROGRAMS ---------------------------'
|
|
|
38 |
echo
|
|
|
39 |
echo "CDF directory : ${cdfdir}"
|
|
|
40 |
echo "TRA directory : ${tradir}"
|
|
|
41 |
echo "PROGRAM LIDAR : ${prog}"
|
|
|
42 |
echo "PARAMETER file : ${parfile}"
|
|
|
43 |
echo
|
|
|
44 |
|
|
|
45 |
# ---------------------------------------------------------------------
|
|
|
46 |
# Set optional flags
|
|
|
47 |
# ---------------------------------------------------------------------
|
|
|
48 |
|
|
|
49 |
echo '---- OPTIONAL FLAGS -------------------------------------'
|
|
|
50 |
echo
|
|
|
51 |
|
|
|
52 |
# Set some default values ("nil" must be set according to input files)
|
|
|
53 |
set flag_i = "nil"
|
|
|
54 |
set flag_v = "tracevars"
|
|
|
55 |
set flag_f = "nil"
|
|
|
56 |
set tvfile = 'tracevars'
|
|
|
57 |
set changet = 'false'
|
|
|
58 |
set noclean = 'false'
|
|
|
59 |
set timecheck = 'no'
|
|
|
60 |
set intmode = 'normal'
|
|
|
61 |
set pmin = 'nil'
|
|
|
62 |
set pmax = 'nil'
|
|
|
63 |
set npre = 100
|
|
|
64 |
set centering = 'no'
|
|
|
65 |
set orientation = 'vertical'
|
|
|
66 |
set outmode = 'sum'
|
|
|
67 |
set dumpcoord = 'no'
|
|
|
68 |
|
|
|
69 |
# Set flag for consistency
|
|
|
70 |
set isok = 1
|
|
|
71 |
set explicit_limits = false
|
|
|
72 |
|
|
|
73 |
while ( $#argv > 0 )
|
|
|
74 |
|
|
|
75 |
switch ( $argv[1] )
|
|
|
76 |
|
|
|
77 |
case -i
|
|
|
78 |
set flag_i=$argv[2]
|
|
|
79 |
echo "Flag '-i' -> ${flag_i} (user defined)"
|
|
|
80 |
shift;
|
|
|
81 |
breaksw
|
|
|
82 |
|
|
|
83 |
case -pmin
|
|
|
84 |
set explicit_limits = true
|
|
|
85 |
set pmin=$argv[2]
|
|
|
86 |
echo "Flag '-pmin' -> pmin (user defined): ${pmin}"
|
|
|
87 |
shift;
|
|
|
88 |
breaksw
|
|
|
89 |
|
|
|
90 |
case -pmax
|
|
|
91 |
set explicit_limits = true
|
|
|
92 |
set pmax=$argv[2]
|
|
|
93 |
echo "Flag '-pmax' -> pmax (user defined): ${pmax}"
|
|
|
94 |
shift;
|
|
|
95 |
breaksw
|
|
|
96 |
|
|
|
97 |
case -npre
|
|
|
98 |
set npre=$argv[2]
|
|
|
99 |
echo "Flag '-npre' -> npre (user defined): ${npre}"
|
|
|
100 |
shift;
|
|
|
101 |
breaksw
|
|
|
102 |
|
|
|
103 |
case -centering
|
|
|
104 |
set centering = 'yes'
|
|
|
105 |
echo "Flag '-centering' -> centering (user defined): ${centering}"
|
|
|
106 |
breaksw
|
|
|
107 |
|
|
|
108 |
case -dumpcoord
|
|
|
109 |
set dumpcoord = 'yes'
|
|
|
110 |
echo "Flag '-dumpcoord' -> dumpcoord (user defined): ${dumpcoord}"
|
|
|
111 |
breaksw
|
|
|
112 |
|
|
|
113 |
case -orientation
|
|
|
114 |
set orientation=$argv[2]
|
|
|
115 |
echo "Flag '-orientation'-> orientation (user defined): ${orientation}"
|
|
|
116 |
shift;
|
|
|
117 |
breaksw
|
|
|
118 |
|
|
|
119 |
case -v
|
|
|
120 |
set flag_v="-v"
|
|
|
121 |
set tvfile=$argv[2]
|
|
|
122 |
echo "Flag '-v' -> ${tvfile} (user defined)"
|
|
|
123 |
shift;
|
|
|
124 |
if ( $isok == 2 ) set isok = 0
|
|
|
125 |
if ( $isok == 1 ) set isok = 2
|
|
|
126 |
breaksw
|
|
|
127 |
|
|
|
128 |
case -f
|
|
|
129 |
set flag_f="-f"
|
|
|
130 |
set tvfile="tracevars.tmp"
|
|
|
131 |
shift;
|
|
|
132 |
set tvar="$argv[1]"
|
|
|
133 |
shift;
|
|
|
134 |
set tscale="$argv[1]"
|
|
|
135 |
echo "Flag '-f' -> ${tvar} ${tscale} (user defined)"
|
|
|
136 |
if ( $isok == 2 ) set isok = 0
|
|
|
137 |
if ( $isok == 1 ) set isok = 2
|
|
|
138 |
breaksw
|
|
|
139 |
|
|
|
140 |
case -changet
|
|
|
141 |
set changet = 'true'
|
|
|
142 |
echo "changet -> true (user defined)"
|
|
|
143 |
breaksw
|
|
|
144 |
|
|
|
145 |
case -noclean
|
|
|
146 |
set noclean = 'true'
|
|
|
147 |
echo "noclean -> true (user defined)"
|
|
|
148 |
breaksw
|
|
|
149 |
|
|
|
150 |
case -mean
|
|
|
151 |
set outmode = 'mean'
|
|
|
152 |
echo "outmode -> mean (user defined)"
|
|
|
153 |
breaksw
|
|
|
154 |
|
|
|
155 |
case -timecheck
|
|
|
156 |
set timecheck = 'yes'
|
|
|
157 |
echo "timecheck -> yes (user defined)"
|
|
|
158 |
breaksw
|
|
|
159 |
|
|
|
160 |
case -nearest
|
|
|
161 |
set intmode = 'nearest'
|
|
|
162 |
echo "intmode -> nearest (user defined)"
|
|
|
163 |
breaksw
|
|
|
164 |
|
|
|
165 |
endsw
|
|
|
166 |
|
|
|
167 |
shift;
|
|
|
168 |
|
|
|
169 |
end
|
|
|
170 |
|
|
|
171 |
# For orientation=normal: only centering is reasonable
|
|
|
172 |
if ( "${orientation}" == "normal" && "${centering}" == "no" ) then
|
|
|
173 |
echo "For horizontal(normal) Lidar, only centering is reasonable - > mode changed"
|
|
|
174 |
set centering = 'yes'
|
|
|
175 |
endif
|
|
|
176 |
|
|
|
177 |
# No change of times necessary if no check requested
|
|
|
178 |
if ( "${timecheck}" == "no" ) then
|
|
|
179 |
set changet = 'false'
|
|
|
180 |
endif
|
|
|
181 |
|
|
|
182 |
# Check consitency of arguments
|
|
|
183 |
if ( $isok == 0 ) then
|
|
|
184 |
echo
|
|
|
185 |
echo " ERROR: Use either option '-v' or '-f', but not both..."
|
|
|
186 |
exit 1
|
|
|
187 |
endif
|
|
|
188 |
|
|
|
189 |
# Set position boundaries - pmin,pmax (pressure, lat,lon, deg rotated)
|
|
|
190 |
if ( ( "${pmin}" == "nil" ) && ( "${orientation}" == "vertical" ) ) then
|
|
|
191 |
set pmin = 100
|
|
|
192 |
set pmax = 1000
|
|
|
193 |
else if ( ( "${pmin}" == "nil" ) && ( "${orientation}" == "lat" ) ) then
|
|
|
194 |
set pmin = -90
|
|
|
195 |
set pmax = 90
|
|
|
196 |
else if ( ( "${pmin}" == "nil" ) && ( "${orientation}" == "lon" ) ) then
|
|
|
197 |
set pmin = -180
|
|
|
198 |
set pmax = 180
|
|
|
199 |
else if ( ( "${pmin}" == "nil" ) && ( "${orientation}" == "normal" ) ) then
|
|
|
200 |
set pmin = -90
|
|
|
201 |
set pmax = 90
|
|
|
202 |
endif
|
|
|
203 |
|
|
|
204 |
# If centering is chosen, set reasonable upper and lower limits
|
|
|
205 |
if ( ( "$centering" == "yes" ) && ( "${explicit_limits}" == "false" ) ) then
|
|
|
206 |
if ( "${orientation}" == "vertical" ) then
|
|
|
207 |
set pmin = -500
|
|
|
208 |
set pmax = 500
|
|
|
209 |
else if ( "${orientation}" == "lat" ) then
|
|
|
210 |
set pmin = -10
|
|
|
211 |
set pmax = 10
|
|
|
212 |
else if ( "${orientation}" == "lon" ) then
|
|
|
213 |
set pmin = -10
|
|
|
214 |
set pmax = 10
|
|
|
215 |
else if ( "${orientation}" == "normal" ) then
|
|
|
216 |
set pmin = -10
|
|
|
217 |
set pmax = 10
|
|
|
218 |
endif
|
|
|
219 |
endif
|
|
|
220 |
|
|
|
221 |
# ---------------------------------------------------------------------
|
|
|
222 |
# Handle the input trajectory file
|
|
|
223 |
# ---------------------------------------------------------------------
|
|
|
224 |
|
|
|
225 |
echo
|
|
|
226 |
echo '---- TIME RANGE -----------------------------------------'
|
|
|
227 |
echo
|
|
|
228 |
|
|
|
229 |
# Check whether the input file can be found
|
|
|
230 |
if ( ! -f ${inpfile} ) then
|
|
|
231 |
echo " ERROR : Input file ${inpfile} is missing"
|
|
|
232 |
exit 1
|
|
|
233 |
endif
|
|
|
234 |
|
|
|
235 |
# Get the start, end and reference date for the tracing
|
|
|
236 |
set startdate = `/home/binderh/prog/programs/lagranto.mf/goodies/trainfo.sh ${inpfile} startdate`
|
|
|
237 |
set enddate = `/home/binderh/prog/programs/lagranto.mf/goodies/trainfo.sh ${inpfile} enddate`
|
|
|
238 |
set refdate = `/home/binderh/prog/programs/lagranto.mf/goodies/trainfo.sh ${inpfile} refdate`
|
|
|
239 |
set ntra = `/home/binderh/prog/programs/lagranto.mf/goodies/trainfo.sh ${inpfile} ntra`
|
|
|
240 |
set ntim = `/home/binderh/prog/programs/lagranto.mf/goodies/trainfo.sh ${inpfile} ntim`
|
|
|
241 |
set ncol = `/home/binderh/prog/programs/lagranto.mf/goodies/trainfo.sh ${inpfile} ncol`
|
|
|
242 |
|
|
|
243 |
# Check format of start and end date - must be the same
|
|
|
244 |
set ns=`echo $startdate | sed -e 's/_[0-9]*//' | wc -c`
|
|
|
245 |
set ne=`echo $enddate | sed -e 's/_[0-9]*//' | wc -c`
|
|
|
246 |
if ( $ns != $ne ) then
|
|
|
247 |
echo " ERROR: start and end date must be in the same format ***"
|
|
|
248 |
exit 1
|
|
|
249 |
endif
|
|
|
250 |
if ( $ns != 9 ) then
|
|
|
251 |
echo " ERROR: Date format must be yyyymmdd ***"
|
|
|
252 |
exit 1
|
|
|
253 |
endif
|
|
|
254 |
set ns=`echo $startdate | sed -e 's/[0-9]*_//' | wc -c`
|
|
|
255 |
set ne=`echo $enddate | sed -e 's/[0-9]*_//' | wc -c`
|
|
|
256 |
if ( $ns != $ne ) then
|
|
|
257 |
echo " ERROR: start and end date must be in the same format ***"
|
|
|
258 |
exit 1
|
|
|
259 |
endif
|
|
|
260 |
if ( ( $ns != 5 ) & ( $ns != 3 ) ) then
|
|
|
261 |
echo " ERROR: Time format must be hh(mm) ***"
|
|
|
262 |
exit 1
|
|
|
263 |
endif
|
|
|
264 |
|
|
|
265 |
# Split the start and end date into <yymmdd_hh and mm>
|
|
|
266 |
set startdate_ymdh = `echo $startdate | cut -c 1-11`
|
|
|
267 |
set startdate_min = `echo $startdate | cut -c 12-13`
|
|
|
268 |
if ( $startdate_min == "" ) set startdate_min = 00
|
|
|
269 |
|
|
|
270 |
set enddate_ymdh = `echo $enddate | cut -c 1-11`
|
|
|
271 |
set enddate_min = `echo $enddate | cut -c 12-13`
|
|
|
272 |
if ( $enddate_min == "" ) set enddate_min = 00
|
|
|
273 |
|
|
|
274 |
# Get the time difference between <start_ymdh> and <end_ymdh> date
|
|
|
275 |
# Decide whether trajectoriesare forward or backward
|
|
|
276 |
set timediff_hh = `/home/binderh/prog/programs/lagranto.mf/goodies/gettidiff ${enddate_ymdh} ${startdate_ymdh}`
|
|
|
277 |
|
|
|
278 |
if ( $timediff_hh == 0 ) then
|
|
|
279 |
if ( $enddate_min > $startdate_min ) then
|
|
|
280 |
set direction = f
|
|
|
281 |
set idir = 1
|
|
|
282 |
else
|
|
|
283 |
set direction = b
|
|
|
284 |
set idir = -1
|
|
|
285 |
endif
|
|
|
286 |
else if ( $timediff_hh > 0 ) then
|
|
|
287 |
set direction = f
|
|
|
288 |
set idir = 1
|
|
|
289 |
else
|
|
|
290 |
set direction = b
|
|
|
291 |
set idir = -1
|
|
|
292 |
@ timediff_hh = $idir * $timediff_hh
|
|
|
293 |
endif
|
|
|
294 |
|
|
|
295 |
# Get also minutes for time difference, if <start_min> or <end_min> != 0
|
|
|
296 |
set timediff_mm=
|
|
|
297 |
|
|
|
298 |
if ( $startdate_min != 00 || $enddate_min != 00 ) then
|
|
|
299 |
@ min = ( $enddate_min - $startdate_min )
|
|
|
300 |
if ( $min == 0 ) then
|
|
|
301 |
set timediff_mm=
|
|
|
302 |
else if ( $min > 0 ) then
|
|
|
303 |
if ( $idir == 1 ) then
|
|
|
304 |
set timediff_mm=$min
|
|
|
305 |
else
|
|
|
306 |
@ timediff_hh --
|
|
|
307 |
@ timediff_mm = 60 - $min
|
|
|
308 |
endif
|
|
|
309 |
else
|
|
|
310 |
if ( $idir == 1 ) then
|
|
|
311 |
@ timediff_hh --
|
|
|
312 |
@ timediff_mm = 60 + $min
|
|
|
313 |
else
|
|
|
314 |
@ timediff_mm = 0 - $min
|
|
|
315 |
endif
|
|
|
316 |
endif
|
|
|
317 |
endif
|
|
|
318 |
|
|
|
319 |
# Write status information
|
|
|
320 |
echo "Time range : ${startdate} -> ${enddate}"
|
|
|
321 |
if ( ${timediff_mm} != "" ) then
|
|
|
322 |
echo "Time difference : ${timediff_hh} h ${timediff_mm} min"
|
|
|
323 |
else
|
|
|
324 |
echo "Time difference : ${timediff_hh} h"
|
|
|
325 |
endif
|
|
|
326 |
echo "Direction : ${direction} (${idir})"
|
|
|
327 |
|
|
|
328 |
# ---------------------------------------------------------------------
|
|
|
329 |
# Check availability of input data
|
|
|
330 |
# ---------------------------------------------------------------------
|
|
|
331 |
|
|
|
332 |
echo
|
|
|
333 |
echo '---- INPUT FILES ----------------------------------------'
|
|
|
334 |
echo
|
|
|
335 |
|
|
|
336 |
# Take the time increment from flag list ('nil', if not defined)
|
|
|
337 |
set timeinc = ${flag_i}
|
|
|
338 |
|
|
|
339 |
# Find a first data file (if possible corresponding to start/end date
|
|
|
340 |
# If starttime is not a data time, take the first file in the direectory
|
|
|
341 |
if ( $direction == "f" ) then
|
|
|
342 |
set file=${charp}${startdate_ymdh}
|
|
|
343 |
else
|
|
|
344 |
set file=${charp}${enddate_ymdh}
|
|
|
345 |
endif
|
|
|
346 |
if ( ! -f $file ) then
|
|
|
347 |
set file=`ls ${charp}[0-9_]*[0-9] | head -1 | sed -e 's/@//'`
|
|
|
348 |
endif
|
|
|
349 |
|
|
|
350 |
# Determine timeinc (the time difference in hours between two data file)
|
|
|
351 |
# if not already defined with option -i
|
|
|
352 |
if ( ${timeinc} == "nil" ) then
|
|
|
353 |
set date1=`echo $file | cut -c 2-12`
|
|
|
354 |
set n=`ls ${charp}[0-9_]*[0-9] | grep -n $date1 | awk -F: '{print $1}'`
|
|
|
355 |
@ n ++
|
|
|
356 |
set date2=`ls ${charp}[0-9_]*[0-9] | head -$n | tail -1 | cut -c 2-12`
|
|
|
357 |
set timeinc=`/home/binderh/prog/programs/lagranto.mf/goodies/gettidiff $date2 $date1`
|
|
|
358 |
endif
|
|
|
359 |
if ( $timeinc == 0 ) then
|
|
|
360 |
echo " ERROR: cannot set the time increment between input files ***"
|
|
|
361 |
exit 1
|
|
|
362 |
endif
|
|
|
363 |
|
|
|
364 |
# Search the first file to use
|
|
|
365 |
set flag=0
|
|
|
366 |
set td=
|
|
|
367 |
foreach i ( ${charp}????????_?? )
|
|
|
368 |
|
|
|
369 |
set date = `echo $i | cut -c 2-12`
|
|
|
370 |
set td1 = `/home/binderh/prog/programs/lagranto.mf/goodies/gettidiff ${startdate_ymdh} ${date}`
|
|
|
371 |
set td2 = `/home/binderh/prog/programs/lagranto.mf/goodies/gettidiff ${enddate_ymdh} ${date}`
|
|
|
372 |
|
|
|
373 |
if (( $td1 < $timeinc || $td2 < $timeinc ) && ( $td1 >= 0 || $td2 >= 0 )) then
|
|
|
374 |
set datfiles=$date
|
|
|
375 |
if ( $td1 < $timeinc ) set td=$td1
|
|
|
376 |
if ( $td2 < $timeinc ) set td=$td2
|
|
|
377 |
if ( ( $startdate_min > 0 ) || ( $enddate_min > 0 ) ) @ td ++
|
|
|
378 |
goto label2
|
|
|
379 |
endif
|
|
|
380 |
|
|
|
381 |
end
|
|
|
382 |
|
|
|
383 |
# if no P/T-files are available for the specified time period, then $td is
|
|
|
384 |
# still undefined
|
|
|
385 |
if ( $td == "" ) then
|
|
|
386 |
echo " ERROR: no data files available for the specified time period"
|
|
|
387 |
exit 1
|
|
|
388 |
endif
|
|
|
389 |
|
|
|
390 |
# Everything is fine so far: proceed
|
|
|
391 |
label2:
|
|
|
392 |
|
|
|
393 |
# Check whether first date is ok - before or at needed dates
|
|
|
394 |
if ( $direction == "f" ) then
|
|
|
395 |
set tdiff0 = `/home/binderh/prog/programs/lagranto.mf/goodies/gettidiff ${startdate_ymdh} ${date}`
|
|
|
396 |
else
|
|
|
397 |
set tdiff0 = `/home/binderh/prog/programs/lagranto.mf/goodies/gettidiff ${enddate_ymdh} ${date}`
|
|
|
398 |
endif
|
|
|
399 |
if ( $tdiff0 < 0 ) then
|
|
|
400 |
echo " ERROR: data files missing for the specified time period"
|
|
|
401 |
exit 1
|
|
|
402 |
endif
|
|
|
403 |
|
|
|
404 |
# Calculate the number of further files
|
|
|
405 |
@ num = ( $timediff_hh + $td ) / $timeinc + 1
|
|
|
406 |
@ dum1 = ( $num - 1 ) * $timeinc
|
|
|
407 |
@ dum2 = $timediff_hh + $td
|
|
|
408 |
if ( $dum1 != $dum2 ) @ num ++
|
|
|
409 |
|
|
|
410 |
# Get a list of all needed files
|
|
|
411 |
set numfiles=$num
|
|
|
412 |
set sfiles=1
|
|
|
413 |
while ( $num > 1 )
|
|
|
414 |
|
|
|
415 |
set date=`/home/binderh/prog/programs/lagranto.mf/goodies/newtime $date $timeinc`
|
|
|
416 |
if ( ! -f ${charp}${date} ) then
|
|
|
417 |
echo " ERROR: file with primary data is missing for $date"
|
|
|
418 |
exit 1
|
|
|
419 |
else if ( ! -f ${chars}${date} ) then
|
|
|
420 |
set sfiles=0
|
|
|
421 |
set datfiles=`echo $datfiles $date`
|
|
|
422 |
else
|
|
|
423 |
set datfiles=`echo $datfiles $date`
|
|
|
424 |
endif
|
|
|
425 |
@ num --
|
|
|
426 |
end
|
|
|
427 |
|
|
|
428 |
# Calculate the start and the end time relative to the first datfile
|
|
|
429 |
if ( $direction == f ) then
|
|
|
430 |
set tstart = `/home/binderh/prog/programs/lagranto.mf/goodies/gettidiff $startdate $datfiles[1]`
|
|
|
431 |
set tend = `/home/binderh/prog/programs/lagranto.mf/goodies/gettidiff $datfiles[$numfiles] $enddate`
|
|
|
432 |
else
|
|
|
433 |
set tstart = `/home/binderh/prog/programs/lagranto.mf/goodies/gettidiff $datfiles[$numfiles] $startdate`
|
|
|
434 |
set tend = `/home/binderh/prog/programs/lagranto.mf/goodies/gettidiff $enddate $datfiles[1]`
|
|
|
435 |
endif
|
|
|
436 |
|
|
|
437 |
|
|
|
438 |
# Write some status information
|
|
|
439 |
echo "Primary file prefix : ${charp}"
|
|
|
440 |
echo "Secondary file prefix : ${chars}"
|
|
|
441 |
echo "Time increment for input files : ${timeinc}"
|
|
|
442 |
echo "# input files : ${numfiles}"
|
|
|
443 |
echo "First input file : $datfiles[1] "
|
|
|
444 |
echo "Last input file : $datfiles[$numfiles] "
|
|
|
445 |
echo "${charp} files availability : 1"
|
|
|
446 |
echo "${chars} files availability : ${sfiles}"
|
|
|
447 |
if ( $direction == f ) then
|
|
|
448 |
echo "Start time relative to first file : $datfiles[1] + ${tstart} "
|
|
|
449 |
echo "End time relative to last file : $datfiles[$numfiles] - ${tend} "
|
|
|
450 |
else
|
|
|
451 |
echo "Start time relative to last file : $datfiles[$numfiles] - ${tstart} "
|
|
|
452 |
echo "End time relative to first file : $datfiles[1] + ${tend} "
|
|
|
453 |
endif
|
|
|
454 |
|
|
|
455 |
# ---------------------------------------------------------------------
|
|
|
456 |
# Check availability of input data
|
|
|
457 |
# ---------------------------------------------------------------------
|
|
|
458 |
|
|
|
459 |
echo
|
|
|
460 |
echo '---- TRACEVAR FILE --------------------------------------'
|
|
|
461 |
echo
|
|
|
462 |
|
|
|
463 |
# If "-f" option is used, create a temporary tracevar file
|
|
|
464 |
if ( "${flag_f}" == "-f" ) then
|
|
|
465 |
|
|
|
466 |
# Preset values for <compfl> and <tprefix>
|
|
|
467 |
set tcompfl=1
|
|
|
468 |
set tprefix='P'
|
|
|
469 |
|
|
|
470 |
# Check availability on P file
|
|
|
471 |
foreach var ( `/home/binderh/prog/programs/lagranto.mf/goodies/getvars ${charp}$datfiles[1]` )
|
|
|
472 |
if ( "${var}" == "${tvar}" ) then
|
|
|
473 |
set tcompfl=0
|
|
|
474 |
set tprefix="P"
|
|
|
475 |
endif
|
|
|
476 |
end
|
|
|
477 |
|
|
|
478 |
# Check availability on S file
|
|
|
479 |
if ( ${sfiles} == 1 ) then
|
|
|
480 |
foreach var ( `/home/binderh/prog/programs/lagranto.mf/goodies/getvars ${chars}$datfiles[1]` )
|
|
|
481 |
if ( "${var}" == "${tvar}" ) then
|
|
|
482 |
set tcompfl=0
|
|
|
483 |
set tprefix="S"
|
|
|
484 |
endif
|
|
|
485 |
end
|
|
|
486 |
endif
|
|
|
487 |
|
|
|
488 |
# Write the temporary <tracevars> file
|
|
|
489 |
echo "${tvar} ${tscale} ${tcompfl} ${tprefix}" >! ${tvfile}
|
|
|
490 |
echo "Temporary tracervar file <${tvfile}> created"
|
|
|
491 |
echo
|
|
|
492 |
|
|
|
493 |
endif
|
|
|
494 |
|
|
|
495 |
|
|
|
496 |
# Check if tracevars-file exists
|
|
|
497 |
if ( ! -f $tvfile ) then
|
|
|
498 |
echo " ERROR: file $tvfile was not found ***"
|
|
|
499 |
exit 1
|
|
|
500 |
endif
|
|
|
501 |
|
|
|
502 |
# check if the variables contained in the tracevars-file are available in the
|
|
|
503 |
# data file and check also if there are no empty lines in the tracevars-file
|
|
|
504 |
|
|
|
505 |
set nlines = `cat $tvfile | wc -l`
|
|
|
506 |
set vars = `cat $tvfile | awk '{print $1}'`
|
|
|
507 |
set nvars = `echo $vars | wc -w`
|
|
|
508 |
if ( $nlines != $nvars ) then
|
|
|
509 |
echo " ERROR: tracevars-files must not contain empty lines ***"
|
|
|
510 |
exit 1
|
|
|
511 |
endif
|
|
|
512 |
set calf=`cat $tvfile | awk '{print $3}'`
|
|
|
513 |
set tfil=`cat $tvfile | awk '{print $4}'`
|
|
|
514 |
foreach v ( $vars )
|
|
|
515 |
if ( $calf[1] == 0 ) then
|
|
|
516 |
set v0 = `echo $v | awk 'BEGIN {FS = ":"}; {print $1}'`
|
|
|
517 |
set flag=`/home/binderh/prog/programs/lagranto.mf/goodies/getvars $tfil[1]$datfiles[1] | grep " $v0 " | wc -l`
|
|
|
518 |
set iscomment=`echo $v0 | cut -c 1`
|
|
|
519 |
if ( "${iscomment}" != "#" ) then
|
|
|
520 |
if ( $flag == 0 ) then
|
|
|
521 |
echo " ERROR: variable $v listed in $tvfile is not on the $tfil[1]-files ***"
|
|
|
522 |
exit 1
|
|
|
523 |
endif
|
|
|
524 |
endif
|
|
|
525 |
endif
|
|
|
526 |
shift calf
|
|
|
527 |
shift tfil
|
|
|
528 |
end
|
|
|
529 |
set ntrace=${nlines}
|
|
|
530 |
|
|
|
531 |
# Write some status information
|
|
|
532 |
cat ${tvfile}
|
|
|
533 |
echo
|
|
|
534 |
echo "# Number of tracing variables : ${ntrace}"
|
|
|
535 |
|
|
|
536 |
# ---------------------------------------------------------------------
|
|
|
537 |
# Prepare input file for trace and run it
|
|
|
538 |
# ---------------------------------------------------------------------
|
|
|
539 |
|
|
|
540 |
# Set times relative to the reference date
|
|
|
541 |
if ( "${changet}" == "true" ) then
|
|
|
542 |
echo
|
|
|
543 |
echo '---- CHANGE TIMES ON DATA FILES ------------------------'
|
|
|
544 |
echo
|
|
|
545 |
foreach i ( $datfiles )
|
|
|
546 |
/home/binderh/prog/programs/lagranto.mf/goodies/changet.sh ${refdate} ${charp}${i}
|
|
|
547 |
end
|
|
|
548 |
if ( ${sfiles} == 1 ) then
|
|
|
549 |
foreach i ( $datfiles )
|
|
|
550 |
/home/binderh/prog/programs/lagranto.mf/goodies/changet.sh ${refdate} ${chars}${i}
|
|
|
551 |
end
|
|
|
552 |
endif
|
|
|
553 |
endif
|
|
|
554 |
|
|
|
555 |
# ---------------------------------------------------------------------
|
|
|
556 |
# Prepare input file for lidar and run it
|
|
|
557 |
# ---------------------------------------------------------------------
|
|
|
558 |
|
|
|
559 |
# Write parameter file
|
|
|
560 |
\rm -f ${parfile}
|
|
|
561 |
touch ${parfile}
|
|
|
562 |
|
|
|
563 |
echo $inpfile >> $parfile
|
|
|
564 |
echo $outfile >> $parfile
|
|
|
565 |
echo $outmode >> $parfile
|
|
|
566 |
echo $startdate >> $parfile
|
|
|
567 |
echo $enddate >> $parfile
|
|
|
568 |
echo $idir >> $parfile
|
|
|
569 |
echo $numfiles >> $parfile
|
|
|
570 |
foreach i ( $datfiles )
|
|
|
571 |
echo $i >> $parfile
|
|
|
572 |
end
|
|
|
573 |
echo $timeinc >> $parfile
|
|
|
574 |
echo $tstart >> $parfile
|
|
|
575 |
echo $tend >> $parfile
|
|
|
576 |
echo $ntra >> $parfile
|
|
|
577 |
echo $ntim >> $parfile
|
|
|
578 |
echo $ncol >> $parfile
|
|
|
579 |
echo $ntrace >> $parfile
|
|
|
580 |
cat ${tvfile} >> $parfile
|
|
|
581 |
/home/binderh/prog/programs/lagranto.mf/goodies/getvars ${charp}$datfiles[1] | wc -l >> $parfile
|
|
|
582 |
/home/binderh/prog/programs/lagranto.mf/goodies/getvars ${charp}$datfiles[1] >> $parfile
|
|
|
583 |
if ( $sfiles == 1 ) then
|
|
|
584 |
/home/binderh/prog/programs/lagranto.mf/goodies/getvars ${chars}$datfiles[1] | wc -l >> $parfile
|
|
|
585 |
/home/binderh/prog/programs/lagranto.mf/goodies/getvars ${chars}$datfiles[1] >> $parfile
|
|
|
586 |
else
|
|
|
587 |
echo 0 >> $parfile
|
|
|
588 |
endif
|
|
|
589 |
echo \"${timecheck}\" >> $parfile
|
|
|
590 |
echo \"${intmode}\" >> $parfile
|
|
|
591 |
echo ${pmin},${pmax},${npre} >> $parfile
|
|
|
592 |
echo \"${centering}\" >> $parfile
|
|
|
593 |
echo \"${orientation}\" >> $parfile
|
|
|
594 |
echo \"${dumpcoord}\" >> $parfile
|
|
|
595 |
|
|
|
596 |
# Finish the preprocessor
|
|
|
597 |
echo
|
|
|
598 |
echo ' *** END OF PREPROCESSOR LIDAR *** '
|
|
|
599 |
echo '========================================================='
|
|
|
600 |
echo
|
|
|
601 |
|
|
|
602 |
# Run lidar
|
|
|
603 |
${prog}
|
|
|
604 |
|
|
|
605 |
if ( "${status}" != "0" ) then
|
|
|
606 |
echo "ERROR: Program <lidar> failed"
|
|
|
607 |
exit 1
|
|
|
608 |
endif
|
|
|
609 |
|
|
|
610 |
# ---------------------------------------------------------------------
|
|
|
611 |
# Final tasks (make clean)
|
|
|
612 |
# ---------------------------------------------------------------------
|
|
|
613 |
|
|
|
614 |
finish:
|
|
|
615 |
|
|
|
616 |
if ( "${noclean}" == "false" ) then
|
|
|
617 |
\rm -f ${parfile}
|
|
|
618 |
endif
|
|
|
619 |
|
|
|
620 |
exit 0
|
|
|
621 |
|