Subversion Repositories lagranto.um

Rev

Rev 3 | Rev 7 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 michaesp 1
#!/bin/csh
2
 
3
# ---------------------------------------------------------------------
4
# Usage, parameter settings
5
# ---------------------------------------------------------------------
6
 
7
# Write usage information
8
if ( (${#argv} == 0) | (${#argv} < 4) ) then
9
  echo 
10
  echo "--------------------------------------------------------------"
11
  echo "Usage: caltra startdate enddate startf outfile [flags]        "
12
  echo 
13
  echo "        startdate : Start date in format yyyymmdd_hh(mm)      "
14
  echo "        endate    : End date in format yyyymmdd_hh(mm)        "
15
  echo "        startf    : Starting coordinates                      "
16
  echo "        outfile   : Output file                               "
17
  echo "        [ flags ] : Optional list of flags                    "
18
  echo
19
  echo " Optional flags                                               "
20
  echo "        -j          : Jumping flag for crossing lower boundary "
21
  echo "        -i hours    : Time increment for input files in hours  "
22
  echo "        -t min      : Time steps for calculation               "
23
  echo "        -o min      : Output interval in minutes               "
24
  echo "        -p          : Periodicity flag                         "
25
  echo "        -changet    : flag whether to change times on P,S files before calculation" 
26
  echo "        -noclean    : flag whether to remove temporary files"
27
  echo "--------------------------------------------------------------"
28
  exit 0
29
endif
30
 
31
# Write title
32
echo 
33
echo '========================================================='
34
echo '       *** START OF PREPROCESSOR CALTRA ***              '
35
echo
36
 
37
# Get the arguments
38
set startdate = $1
39
set enddate   = $2
40
set startf    = $3
41
set outfile   = $4
42
if ( ${#argv} > 4 ) then
43
   set flags = $5
44
else
45
   set flags=
46
endif 
47
 
48
# Set base directories (run+prog)
49
set cdfdir=${PWD}
50
set tradir=${PWD}
51
 
52
# Set program paths and filenames 
53
set parfile = ${tradir}/caltra.param 
54
 
55
# Set the prefix of the primary and secondary data files
56
set charp = 'P'
57
set chars = 'S'
58
 
59
echo '---- DIRECTORIES AND PROGRAMS ---------------------------'
60
echo    
61
echo "CDF directory         : ${cdfdir}"
62
echo "TRA directory         : ${tradir}"
63
echo "PROGRAM CALTRA        : ${LAGRANTO}/caltra/caltra"
64
echo "PARAMETER file        : ${parfile}"
65
echo
66
 
67
# ---------------------------------------------------------------------
68
# Set optional flags
69
# ---------------------------------------------------------------------
70
 
71
echo '---- OPTIONAL FLAGS -------------------------------------'
72
echo
73
 
74
# Set some default values ("nil" must be set according to input files)
75
set flag_j     = "nil"
76
set flag_i     = "nil"
77
set flag_t     = "nil"
78
set flag_o     = "nil"
79
set flag_p     = "nil"
80
set changet    = 'false'
81
set noclean    = 'false'
82
set timecheck  = 'yes' 
83
 
84
 
85
while ( $#argv > 0 )
86
 
87
  switch ( $argv[1] )
88
 
89
   case -j
90
     set flag_j=1
91
     echo "Flag '-j'     -> ${flag_j} (user defined)"
92
   breaksw
93
 
94
   case -i
95
     set flag_i=$argv[2]
96
     echo "Flag '-i'     -> ${flag_i} (user defined)"
97
     shift;
98
   breaksw
99
 
100
   case -t
101
     set flag_t=$argv[2]
102
     echo "Flag '-t'     -> ${flag_t} (user defined)"
103
     shift;
104
   breaksw
105
 
106
   case -o
107
     set flag_o=$argv[2]
108
     echo "Flag '-o'     -> ${flag_o} (user defined)"
109
     shift;
110
   breaksw
111
 
112
   case -p
113
     set flag_p=1
114
     echo "Flag '-p'     -> ${flag_p} (user defined)"
115
   breaksw
116
 
117
   case -changet
118
     set changet = 'true'
119
     echo "changet       -> true (user defined)"
120
   breaksw
121
 
122
   case -noclean
123
     set noclean = 'true'
124
     echo "noclean       -> true (user defined)"
125
   breaksw
126
 
127
   case -notimecheck
128
     set timecheck = 'no'
129
     echo "timecheck               -> no (user defined)"
130
   breaksw
131
 
132
 
133
  endsw
134
 
135
  shift;
136
 
137
end
138
 
139
# No change of times necessary if no check requested
140
if ( "${timecheck}" == "no" ) then
141
   set  changet = 'false'
142
endif
143
 
144
# Set some defaults
145
if ( "${flag_j}"     == "nil" ) then
146
    set flag_j     = 0
147
    echo "Flag '-j'     -> 0 (default)"
148
endif
149
if ( "${flag_p}"     == "nil" ) then
150
    set flag_p     = 0
151
    echo "Flag '-p'     -> 0 (default)"
152
endif
153
 
154
# ---------------------------------------------------------------------
155
# Handle the time specifier - startdate, enddate
156
# ---------------------------------------------------------------------
157
 
158
echo
159
echo '---- TIME RANGE -----------------------------------------'
160
echo
161
 
162
# Check format of start and end date - must be the same
163
set ns=`echo $startdate | sed -e 's/_[0-9]*//' | wc -c`
164
set ne=`echo $enddate   | sed -e 's/_[0-9]*//' | wc -c`
165
if ( $ns != $ne ) then
166
  echo " ERROR: start and end date must be in the same format ***"
167
  exit 1
168
endif
169
if ( $ns != 9 ) then
170
  echo " ERROR: Date format must be yyyymmdd ***"
171
  exit 1
172
endif
173
set ns=`echo $startdate | sed -e 's/[0-9]*_//' | wc -c`
174
set ne=`echo $enddate   | sed -e 's/[0-9]*_//' | wc -c`
175
if ( $ns != $ne ) then
176
  echo " ERROR: start and end date must be in the same format ***"
177
  exit 1
178
endif
179
if ( ( $ns != 5 ) & ( $ns != 3 ) ) then
180
  echo " ERROR: Time format must be hh(mm) ***"
181
  exit 1
182
endif
183
 
184
# Split the start and end date into <yymmdd_hh and mm>
185
set startdate_ymdh = `echo $startdate | cut -c 1-11`
186
set startdate_min  = `echo $startdate | cut -c 12-13`
187
if ( $startdate_min == "" ) set startdate_min = 00
188
 
189
set enddate_ymdh = `echo $enddate | cut -c 1-11`
190
set enddate_min  = `echo $enddate | cut -c 12-13`
191
if ( $enddate_min == "" ) set enddate_min = 00
192
 
193
# Get the time difference between <start_ymdh> and <end_ymdh> date
194
# Decide whether trajectoriesare forward or backward
195
set timediff_hh = `${LAGRANTO}/goodies/gettidiff ${enddate_ymdh} ${startdate_ymdh}`
196
 
197
if ( $timediff_hh == 0 ) then
198
  if ( $enddate_min > $startdate_min ) then
199
    set direction = f
200
    set idir      = 1
201
  else
202
    set direction = b
203
    set idir      = -1
204
  endif
205
else if ( $timediff_hh > 0 ) then
206
  set direction = f
207
  set idir      = 1
208
else
209
  set direction = b
210
  set idir      = -1
211
  @ timediff_hh = $idir * $timediff_hh
212
endif
213
 
214
# Get also minutes for time difference, if <start_min> or <end_min> != 0
5 michaesp 215
set timediff_mm=00
3 michaesp 216
 
217
if ( $startdate_min != 00 || $enddate_min != 00 ) then
218
  @ min = ( $enddate_min - $startdate_min )
219
  if ( $min == 0 ) then
220
    set timediff_mm=
221
  else if ( $min > 0 ) then
222
    if ( $idir == 1 ) then
223
      set timediff_mm=$min
224
    else
225
      @ timediff_hh --
226
      @ timediff_mm = 60 - $min
227
    endif
228
  else
229
    if ( $idir == 1 ) then
230
      @ timediff_hh --
231
      @ timediff_mm = 60 + $min
232
    else
233
      @ timediff_mm = 0 - $min
234
    endif
235
  endif
236
endif
237
 
238
# Set the reference date equal to the satrtdate
239
set refdate=${startdate}
240
 
241
# Write status information
242
echo "Time range      : ${startdate} -> ${enddate}"
243
if ( ${timediff_mm} !=  "" ) then
244
   echo "Time difference : ${timediff_hh} h ${timediff_mm} min"
245
else
246
   echo "Time difference : ${timediff_hh} h"
247
endif
248
echo "Direction       : ${direction} (${idir})"
249
echo "Reference date  : ${refdate}"
250
 
251
# ---------------------------------------------------------------------
252
# Check availability of input data 
253
# ---------------------------------------------------------------------
254
 
255
echo
256
echo '---- INPUT FILES ----------------------------------------'
257
echo
258
 
259
# Take the time increment from flag list ('nil', if not defined)
260
set timeinc = ${flag_i}
261
 
262
# Find a first data file (if possible corresponding to start/end date
5 michaesp 263
# If starttime is not a data time, take the first file in the directory
3 michaesp 264
if ( $direction == "f" ) then
265
  set file=${charp}${startdate_ymdh}
5 michaesp 266
else 
3 michaesp 267
  set file=${charp}${enddate_ymdh}
268
endif
269
if ( ! -f $file ) then
270
  set file=`ls ${charp}[0-9_]*[0-9] | head -1 | sed -e 's/@//'`
271
endif
272
 
273
# Determine timeinc (the time difference in hours between two data file)
274
# if not already defined with option -i
275
if ( ${timeinc} == "nil" ) then
5 michaesp 276
  set date1=`echo $file | cut -c 2-`
277
  set n=`\ls ${charp}[0-9_]*[0-9] | grep -n $date1 | awk -F: '{print $1}'`
3 michaesp 278
  @ n ++
5 michaesp 279
  set date2=`\ls ${charp}[0-9_]*[0-9] | head -$n | tail -1 | cut -c 2-`
3 michaesp 280
  set timeinc=`${LAGRANTO}/goodies/gettidiff $date2 $date1`
281
endif
282
if ( $timeinc == 0 ) then
283
    echo " ERROR: cannot set the time increment between input files ***"
284
    exit 1
285
endif
286
 
5 michaesp 287
# Decide whether the time increment is smaller than 1 h; if so set the hires
288
# flag and convert the timeincement into fractional hour
289
set flag = `echo ${timeinc} | grep -n '\.'`
290
set hires = 0
291
 
292
if ( "${flag}" != "" ) then
293
  echo "Input files availability < 1 hour ($timeinc): switch to hires"
294
  echo "mode. All input files must be of form: P{yyyymmdd_hhmm}"
295
  set hires = 1
296
  set timeinc_min = `echo "(${timeinc} * 100 + 0.5)/1" | bc`
297
  set timeinc     = `echo "scale=2; ${timeinc} * 100 / 60" | bc`
298
  goto hires
299
endif
300
 
301
# Search the first file to use: We step through all P files and see whether they are
302
# good P files. Let's first do the test for the first data file found. If it's ok, we 
303
# take it; if not, we step through all P files and find the good one
3 michaesp 304
set flag=0
305
set td=
5 michaesp 306
 
307
set date = `echo ${file} | cut -c 2-12`
308
set td1  = `${LAGRANTO}/goodies/gettidiff ${startdate_ymdh} ${date}`
309
set td2  = `${LAGRANTO}/goodies/gettidiff ${enddate_ymdh}   ${date}`
310
 
311
if (( $td1 < $timeinc || $td2 < $timeinc ) && ( $td1 >= 0 || $td2 >= 0 )) then
312
   set datfiles=$date
313
   if ( $td1 < $timeinc    ) set td=$td1
314
   if ( $td2 < $timeinc    ) set td=$td2
315
   if ( ( $startdate_min > 0 ) || ( $enddate_min > 0 ) ) @ td ++
316
   goto label2      
317
endif
318
 
3 michaesp 319
foreach i ( ${charp}????????_?? )
320
 
321
  set date = `echo $i | cut -c 2-12`
322
  set td1  = `${LAGRANTO}/goodies/gettidiff ${startdate_ymdh} ${date}`
323
  set td2  = `${LAGRANTO}/goodies/gettidiff ${enddate_ymdh}   ${date}`
324
  if (( $td1 < $timeinc || $td2 < $timeinc ) && ( $td1 >= 0 || $td2 >= 0 )) then
325
      set datfiles=$date
326
      if ( $td1 < $timeinc    ) set td=$td1
327
      if ( $td2 < $timeinc    ) set td=$td2
328
      if ( ( $startdate_min > 0 ) || ( $enddate_min > 0 ) ) @ td ++
329
      goto label2
330
  endif
331
 
332
end
333
 
334
if ( $td == "" ) then
5 michaesp 335
  echo
3 michaesp 336
  echo " ERROR: no data files available for the specified time period"
337
  exit 1
338
endif
339
 
5 michaesp 340
# If the input files come with time increment < 1 hour, handle it in this
341
# special section. The aim is not to 'interfere' with the well established
342
# code handling the standard case with time increment >= 1 hour. In this mode
343
# we require that the start and end date are available as P files: no start is
344
# allowed between the model output files
345
hires:
346
 
347
set flag=0
348
set td=0
349
 
350
if ( $direction == "f" ) then
351
  set file=${charp}${startdate}
352
else 
353
  set file=${charp}${enddate}
354
endif
355
 
356
if ( -f $file ) then
357
  set date     = `echo ${file} | cut -c 2-14`
358
  set datfiles = $date
359
  set td       = 0
360
  goto label2
361
else
362
  echo
363
  echo " ERROR: no data files available for the specified time period"
364
  exit 1
365
endif
366
 
367
# Everything is fine so far (first data file found): proceed
3 michaesp 368
label2:
369
 
5 michaesp 370
# Calculate the number of further files; handle hires (timeinc<1 h) and
371
# standard mode (timeinc >= 1 h) separately
372
if ( ${hires} == 0 ) then
373
 @ num = ( $timediff_hh + $td ) / $timeinc + 1
374
 @ dum1 = ( $num - 1 ) * $timeinc
375
 @ dum2 = $timediff_hh + $td
376
 if ( $dum1 != $dum2 ) @ num ++
377
else
378
 set num = `echo "( ${timediff_hh}*60 + ${timediff_mm} ) / ( ${timeinc_min} ) + 1" | bc`
379
endif 
380
 
3 michaesp 381
# Get a list of all needed files
382
set numfiles=$num
383
set sfiles=1
5 michaesp 384
echo $datfiles
3 michaesp 385
while ( $num > 1 )
5 michaesp 386
  if ( $hires == 0 ) then
387
     set date=`${LAGRANTO}/goodies/newtime $date $timeinc`
388
  else
389
     set date=`${LAGRANTO}/goodies/newtime $date $timeinc_min`
390
  endif
391
 
392
  echo ${date}
393
 
3 michaesp 394
  if ( ! -f ${charp}${date} ) then
395
    echo " ERROR: file with primary data is missing for $date"
396
    exit 1
397
  else if ( ! -f ${chars}${date} ) then
398
    set sfiles=0
399
    set datfiles=`echo $datfiles $date`
400
  else
401
    set datfiles=`echo $datfiles $date`
402
  endif
403
  @ num --
404
end
405
 
406
# Write some status information
407
echo "Primary file prefix            : ${charp}"
408
echo "Secondary file prefix          : ${chars}"
5 michaesp 409
if ( ${hires} == 0 ) then
410
  echo "Time increment for input files : ${timeinc} h"
411
else
412
  echo "Time increment for input files : ${timeinc_min} min (0$timeinc h) "
413
endif
3 michaesp 414
echo "# input files                  : ${numfiles}"
415
echo "${charp} files availability           : 1"  
416
echo "${chars} files availability           : ${sfiles}"     
417
echo "First input file               : $datfiles[1] " 
418
echo "Last input file                : $datfiles[$numfiles] " 
419
 
5 michaesp 420
echo
421
echo $datfiles
422
 
3 michaesp 423
# ---------------------------------------------------------------------
424
# Handle vertical wind - scaling factor
425
# ---------------------------------------------------------------------
426
 
427
echo
428
echo '---- VERTICAL WIND SCALING ------------------------------'
429
echo
430
 
431
# Check whether OMEGA is avialbale on first file
432
set first=$datfiles[1]
433
set file="${charp}${first}"
434
set omflag=`${LAGRANTO}/goodies/getvars $file | grep " OMEGA " | wc -l`
435
if ( $omflag != 1 ) then
436
   echo " ERROR: variable OMEGA is not on file $file"
437
   exit 1
438
endif
439
 
440
# Get the maximum and minimum wind on 850 hPa and decide the <wfactor>
441
set wmin  = `${LAGRANTO}/goodies/getmima $file OMEGA P850 | awk '{print $1}'`
442
set wmax  = `${LAGRANTO}/goodies/getmima $file OMEGA P850 | awk '{print $2}'`
443
set wmin  = `echo $wmin | sed -e 's/\.//'`
444
set wmax  = `echo $wmax | sed -e 's/\.//'`
445
set wdiff = `echo $wmax - $wmin | bc`
446
 
447
if ( $wdiff > 400 ) then
448
    set wfactor=1.
449
else
450
    set wfactor=100.
451
endif
452
 
453
# Write status information
454
echo "Vertical scaling factor (wfactor)  : ${wfactor}"
455
 
456
# ---------------------------------------------------------------------
457
# Time step and output interval
458
# ---------------------------------------------------------------------
459
 
460
echo
461
echo '---- TIME STEPS -----------------------------------------'
462
echo
463
 
464
# Take the time step and output step from flag list ('nil', if not defined)
465
set timestep = ${flag_t}
466
set deltout  = ${flag_o}
467
 
468
# Calculate the time step
5 michaesp 469
if ( $hires == 0 ) then
470
  if ( $timestep == "nil" ) @ timestep = ( 60 * $timeinc ) / 12
471
else
472
  if ( $timestep == "nil" ) set timestep =  `echo "scale=2; $timeinc_min / 12" | bc`
473
endif
3 michaesp 474
 
475
# Take the output interval from time increment
5 michaesp 476
if ( $hires == 0 ) then
477
  if ( $deltout == "nil" ) @ deltout = 60 * ${timeinc}
478
else
479
  if ( $deltout == "nil" ) set deltout = ${timeinc_min}
480
endif
3 michaesp 481
 
482
# Check whether the timestep is an integer ratio of deltout
5 michaesp 483
#@ flag = $deltout / $timestep
484
#@ flag = $deltout - ( $flag * $timestep )
485
set flag = `echo "scale=2; $deltout / $timestep" | bc`
486
set flag = `echo "scale=2; $deltout - ( $flag * $timestep )" | bc`   
3 michaesp 487
if ( $flag != 0 ) then
488
  echo " ERROR: output time interval should be multiple of timestep"
489
  echo 
490
  echo "           $deltout min  : output time interval"
491
  echo "           $timestep min  : time step"
492
  exit 1
493
endif
494
 
495
# Calculate the start and the end time relative to the first datfile
496
if ( $direction == f ) then
497
  set tstart = `${LAGRANTO}/goodies/gettidiff $startdate $datfiles[1]`
498
  set tend   = `${LAGRANTO}/goodies/gettidiff $datfiles[$numfiles] $enddate`
499
else
500
  set tstart = `${LAGRANTO}/goodies/gettidiff $datfiles[$numfiles] $startdate`
501
  set tend   = `${LAGRANTO}/goodies/gettidiff $enddate $datfiles[1]`
502
endif
503
 
504
# Check whether tstart and tend are a multiple of the output time interval
505
if ( $tstart != 0 ) then
506
  if ( `echo $tstart | grep "\."` != "" ) then
507
    set dum=`echo $tstart | sed -e 's/[-0-9]*\.//'`
508
    @ flag = $dum / $deltout
509
    @ flag = $dum - ( $flag * $deltout )
510
    if ( $flag != 0 ) then
511
      echo " ERROR : the start time should be shifted relative to the first"
512
      echo "         datafile by a multiple of the output time interval"
513
      echo "         hint:  set the latter with the option -o"
514
      exit 1
515
    endif
516
  endif
517
endif
518
if ( `echo $tend | grep "\."` != "" ) then
519
  set dum=`echo $tend | sed -e 's/[-0-9]*\.//'`
520
  @ flag = $dum / $deltout
521
  @ flag = $dum - ( $flag * $deltout )
522
  if ( $flag != 0 ) then
523
    echo " ERROR : the end time should be shifted relative to the first"
524
    echo "         datafile by a multiple of the output time interval"
525
    echo "         hint:  set the latter with the option -o"
526
    exit 1
527
  endif
528
endif
529
 
530
# Write status information
531
echo "Trajectory calculation time step [min] : ${timestep}"
532
echo "Output time step [min]                 : ${deltout}"
533
if ( $direction == f ) then
534
  echo "Start time relative to first file      : $datfiles[1] + ${tstart} "
535
  echo "End time relative to first file        : $datfiles[$numfiles] - ${tend} "  
536
else
537
  echo "Start time relative to first file      : $datfiles[$numfiles] - ${tstart} "
538
  echo "End time relative to last file         : $datfiles[1] + ${tend} "
539
endif
540
 
541
# ---------------------------------------------------------------------
542
# Start file
543
# ---------------------------------------------------------------------
544
 
545
echo
546
echo '---- START FILE -----------------------------------------'
547
echo
548
 
549
# Check if start file is available
550
if ( ! -f ${startf} ) then
551
   echo " ERROR : start file ${startf} is missing"
552
   exit 1
553
endif
554
 
555
# Decide whether startfile has an explicit format specifier
556
set format = "0"
557
foreach app ( 1 2 3 4 5 6 7 8 9 )
558
  set flag = `echo ${startf} | grep ".${app}"`
559
  if ( "${flag}" != "" ) set format = "${app}"
560
end
561
 
562
# If format is 0, it might nevertheless be a hidden format 1
563
if ( "${format}" == "0" ) then
564
    set ncol = `awk "{print NF}" ${startf} | tail -1` 
565
    if ( "${ncol}" != "3" ) then
566
        set format = "1"
567
        echo " WARNING: ${startf} is a hidden trajectory file of format 1"
568
        echo "          it will be renamed: ${startf} -> ${startf}.1"
569
        echo
570
        ln -sf ${startf} ${startf}.1
571
        set startf = "${startf}.1"
572
    endif
573
endif
574
 
575
# Get the number of trajectories
576
if ( "${format}" == "0" ) then
577
   set ntra = `wc -l ${startf} | awk '{print $1}' `
578
   set ncol = 3
579
else
580
   set ntra = `${LAGRANTO}/goodies/trainfo.sh ${startf} ntra`
581
   set ncol = `${LAGRANTO}/goodies/trainfo.sh ${startf} ncol`
582
   set ntim = `${LAGRANTO}/goodies/trainfo.sh ${startf} ntim`
583
 
584
   if ( "${ntim}" != "1" ) then
585
      echo " ERROR: starting trajectory file must only have one time... Stop"
586
      exit 1
587
   endif
588
 
589
endif
590
 
591
# Write status information
592
echo "Start file                  : ${startf} "
593
if ( "${format}" == "0" ) then 
594
   echo "Format                      : (lon,lat,p) list"
595
else
596
   echo "Format                      : trajectory file (${format})"
597
endif
598
echo "# coordinates (lon,lat,lev) : ${ntra} "  
599
echo "# columns                   : ${ncol} "  
600
 
601
# ---------------------------------------------------------------------
602
# Prepare input file for caltra and run it
603
# ---------------------------------------------------------------------
604
 
605
# Set times relative to the reference date
606
if ( "${changet}" == "true" ) then
607
 echo
608
 echo '---- CHANGE TIMES ON DATA FILES  ------------------------'
609
 echo   
610
 foreach i ( $datfiles )
611
   ${LAGRANTO}/goodies/changet.sh ${refdate} ${charp}${i}
612
 end
613
 if ( ${sfiles} == 1 ) then
614
   foreach i ( $datfiles )
615
     ${LAGRANTO}/goodies/changet.sh ${refdate} ${chars}${i}
616
   end
617
 endif
618
endif
619
 
620
# Split the reference date
621
set yyyy=`echo ${refdate}   | cut -c 1-4` 
622
set   mm=`echo ${refdate}   | cut -c 5-6` 
623
set   dd=`echo ${refdate}   | cut -c 7-8` 
624
set   hh=`echo ${refdate}   | cut -c 10-11` 
625
set  min=`echo ${refdate}00 | cut -c 12-13` 
626
 
627
# Get the total tiem range
628
if ( ${timediff_mm} != '' ) then
629
   @ timerange = 60 * ${timediff_hh} + ${timediff_mm}
630
else
631
   @ timerange = 60 * ${timediff_hh}
632
endif
633
 
634
# Write parameter file
635
\rm -f ${parfile}
636
touch ${parfile}
637
 
638
\echo $idir                   >> $parfile
639
echo $numfiles                >> $parfile
640
foreach i ( $datfiles )
641
  echo $i                     >> $parfile
642
end
643
echo $timeinc                 >> $parfile
644
echo $flag_p                  >> $parfile
645
echo \"${startf}\"            >> $parfile
646
echo ${ntra}                  >> $parfile
647
echo ${ncol}                  >> $parfile
648
echo \"${outfile}\"           >> $parfile
649
echo $timestep                >> $parfile
650
echo $tstart                  >> $parfile
651
echo $tend                    >> $parfile
652
echo $deltout                 >> $parfile
653
echo $flag_j                  >> $parfile
654
echo $wfactor                 >> $parfile
655
echo $yyyy                    >> $parfile
656
echo $mm                      >> $parfile
657
echo $dd                      >> $parfile
658
echo $hh                      >> $parfile
659
echo $min                     >> $parfile
660
echo $timerange               >> $parfile
661
echo \"${timecheck}\"         >> $parfile
662
 
663
# Finish the preprocessor
664
echo 
665
echo '       *** END OF PREPROCESSOR CALTRA ***              '
666
echo '========================================================='
667
echo
668
 
669
# Run caltra
670
${LAGRANTO}/caltra/caltra
671
 
672
if ( "${status}" != "0" ) then
673
  echo "ERROR:  Program <caltra> failed"
674
  exit 1
675
endif
676
 
677
# ----------------------------------------------------------
678
# Final tasks (make clean)
679
# ----------------------------------------------------------
680
 
681
finish:
682
 
683
if ( "${noclean}" == "false" ) then
684
  \rm -f ${parfile}
685
 endif
686
 
687
exit 0 
688