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