Subversion Repositories lagranto.wrf

Rev

Rev 2 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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