Subversion Repositories lagranto.ocean

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 michaesp 1
#!/bin/csh
2
 
3
# Write usage information
4
if ( ${#argv} == 0) then
5
  echo 
6
  ${LAGRANTO}/bin/lagrantohelp datelist short
7
  echo  
8
  exit 0
9
endif
10
 
11
# Handle fixed arguments
12
set filename = $1
13
set mode     = $2
14
 
15
# Redirect output to screen if requested
16
if ( "${filename}" == "stdout" ) set filename="/dev/stdout"
17
if ( "${filename}" == "screen" ) set filename="/dev/stdout"
18
 
19
# Handle optional arguments
20
set interval = "6"
21
 
22
while ( $#argv > 0 )
23
 
24
  switch ( $argv[1] )
25
 
26
   case -create
27
     set startdate = $argv[2] 
28
     set finaldate = $argv[3] 
29
     shift;
30
     shift;
31
   breaksw
32
 
33
   case -indir
34
     set dirname = $argv[2] 
35
     shift;
36
   breaksw
37
 
38
   case -next
39
     set date = $argv[2] 
40
     shift;
41
   breaksw
42
 
43
   case -prev
44
     set date = $argv[2] 
45
     shift;
46
   breaksw
47
 
48
   case -isin
49
     set date = $argv[2] 
50
     shift;
51
   breaksw
52
 
53
   case -interval
54
     set interval = $argv[2] 
55
     shift;
56
   breaksw
57
 
58
   case -overlap
59
     set file1 = $argv[2] 
60
     set file2 = $argv[3] 
61
     shift;
62
     shift;
63
   breaksw
64
 
65
   case -onlyin1
66
     set file1 = $argv[2] 
67
     set file2 = $argv[3] 
68
     shift;
69
     shift;
70
   breaksw
71
 
72
   case -onlyin2
73
     set file1 = $argv[2] 
74
     set file2 = $argv[3] 
75
     shift;
76
     shift;
77
   breaksw
78
 
79
   case -totime
80
     set refdate = $argv[2] 
81
     shift;
82
   breaksw
83
 
84
   case -todate
85
     set refdate = $argv[2] 
86
     shift;
87
   breaksw
88
 
89
  endsw
90
 
91
  shift;
92
 
93
end
94
 
95
# Mode: -create startdate finaldate
96
if ( "${mode}" == "-create" ) then
97
 
98
   \rm -f datelist.param
99
   echo \"${filename}\"    >  datelist.param
100
   echo \"${mode}\"        >> datelist.param
101
   echo \"${startdate}00\" >> datelist.param
102
   echo \"${finaldate}00\" >> datelist.param
103
   echo ${interval}        >> datelist.param
104
 
105
   ${LAGRANTO}/goodies/datelist
106
 
107
endif
108
 
109
# Mode: -first 
110
if ( "${mode}" == "-first" ) then
111
 
112
   head -1 ${filename} 
113
 
114
endif
115
 
116
# Mode: -last 
117
if ( "${mode}" == "-last" ) then
118
 
119
   tail -1 ${filename} 
120
 
121
endif
122
 
123
# Mode: -ndates 
124
if ( "${mode}" == "-ndates" ) then
125
 
126
   wc -l ${filename} | awk '{ print $1}'
127
 
128
endif
129
 
130
# Mode: -timerange 
131
if ( "${mode}" == "-timerange" ) then
132
 
133
   set firstdate = `head -1 ${filename}`
134
   set finaldate = `tail -1 ${filename}`  
135
 
136
   ${LAGRANTO}/goodies/gettidiff ${finaldate} ${firstdate}
137
 
138
endif
139
 
140
# Mode: -indir {directory name}
141
if ( "${mode}" == "-indir" ) then
142
 
143
    ls -1 ${dirname} | perl -ne 'print  if s/.*([0-9]{8}_[0-9]{2}).*/\1/' | sort | uniq >! ${filename}
144
 
145
endif
146
 
147
# Mode: -next
148
if ( "${mode}" == "-next" ) then
149
 
150
  set last = `tail -1 ${filename}` 
151
  if ( "${date}" != "${last}" ) then
152
     set next = `sed -n "/${date}/{n;p;}" ${filename}`
153
     echo ${next}
154
  else
155
     echo "nil"
156
  endif
157
 
158
endif
159
 
160
# Mode: -prev
161
if ( "${mode}" == "-prev" ) then
162
 
163
  set first = `head -1 ${filename}` 
164
  if ( "${date}" != "${first}" ) then
165
     set prev = `sed -n "/${date}/{g;p;};h" ${filename}`
166
     echo ${prev}
167
  else
168
     echo "nil"
169
  endif
170
 
171
endif 
172
 
173
# Mode: -isin
174
if ( "${mode}" == "-isin" ) then
175
 
176
  set flag = `sed -n "/${date}/p" ${filename}`
177
 
178
  if ( "${flag}" != "" ) then
179
    echo "1"
180
  else
181
    echo "0"
182
  endif
183
 
184
endif 
185
 
186
# Mode: -overlap
187
if ( "${mode}" == "-overlap" ) then
188
    if ( "${filename}" != "/dev/stdout" ) then 
189
       set outfile = ${filename}.$$
190
       \rm -f ${outfile}
191
       grep -f ${file1} ${file2} > ${outfile}
192
       \mv ${outfile} ${filename}
193
    else
194
       grep -f ${file1} ${file2}
195
    endif
196
endif
197
 
198
# Mode: -onlyin1
199
if ( "${mode}" == "-onlyin1" ) then
200
 
201
   \rm -f datelist.param
202
   echo \"${filename}\"    >  datelist.param
203
   echo \"${mode}\"        >> datelist.param
204
   echo \"${file1}\"       >> datelist.param
205
   echo \"${file2}\"       >> datelist.param
206
 
207
   ${LAGRANTO}/goodies/datelist
208
 
209
endif
210
 
211
# Mode: -onlyin2
212
if ( "${mode}" == "-onlyin2" ) then
213
    set outfile1 = "tmp1.$$"
214
    set outfile2 = "tmp2.$$"
215
    \rm -f ${outfile1}
216
    \rm -f ${outfile2}
217
    grep -f  ${file2}    ${file1} >! ${outfile1}
218
    grep -vf ${outfile1} ${file2} >! ${outfile2}
219
    if ( "${filename}" != "/dev/stdout" ) then
220
      \mv ${outfile2} ${filename}
221
    else
222
      cat  ${outfile2}
223
    endif
224
    \rm -f ${outfile1}
225
    \rm -f ${outfile2}
226
endif
227
 
228
# Mode: -totime 
229
if ( "${mode}" == "-totime" ) then
230
 
231
   \rm -f datelist.param
232
   echo \"${filename}\"    >  datelist.param
233
   echo \"${mode}\"        >> datelist.param
234
   echo \"${refdate}00\"   >> datelist.param
235
 
236
   ${LAGRANTO}/goodies/datelist
237
 
238
endif
239
 
240
# Mode: -todate
241
if ( "${mode}" == "-todate" ) then
242
 
243
   \rm -f datelist.param
244
   echo \"${filename}\"    >  datelist.param
245
   echo \"${mode}\"        >> datelist.param
246
   echo \"${refdate}00\"   >> datelist.param
247
 
248
   ${LAGRANTO}/goodies/datelist
249
 
250
endif
251
 
252
# Mode: -randsample
253
if ( "${mode}" == "-randsample" ) then
254
 
255
   \rm -f datelist.param
256
   echo \"${filename}\"    >  datelist.param
257
   echo \"${mode}\"        >> datelist.param
258
   echo ${randsample}      >> datelist.param
259
 
260
   ${LAGRANTO}/goodies/datelist
261
 
262
endif
263
 
264
exit 0
265