Subversion Repositories lagranto.icon

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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