2 |
michaesp |
1 |
#!/bin/csh
|
|
|
2 |
|
|
|
3 |
# -----------------------------------------------------------------------------
|
|
|
4 |
# Handle parameters
|
|
|
5 |
# -----------------------------------------------------------------------------
|
|
|
6 |
|
11 |
michaesp |
7 |
# Set Lagranto
|
|
|
8 |
set LAGRANTO = ${LAGRANTOBASE}.${MODEL}/
|
|
|
9 |
|
8 |
michaesp |
10 |
# Write usage information
|
|
|
11 |
if ( ${#argv} == 0) then
|
|
|
12 |
echo
|
|
|
13 |
${LAGRANTO}/bin/lagrantohelp wrfmap short
|
|
|
14 |
echo
|
|
|
15 |
exit 0
|
|
|
16 |
endif
|
|
|
17 |
|
2 |
michaesp |
18 |
# Name of the input file
|
|
|
19 |
set mode = $1
|
|
|
20 |
|
|
|
21 |
if ( "${mode}" == "-create" ) then
|
|
|
22 |
set inpfile = $2
|
|
|
23 |
if ( $#argv == 3 ) then
|
|
|
24 |
set anglemode = $3
|
|
|
25 |
else
|
|
|
26 |
set anglemode = 'dateline'
|
|
|
27 |
endif
|
|
|
28 |
endif
|
|
|
29 |
|
|
|
30 |
if ( "${mode}" == "-ll2xy" ) then
|
|
|
31 |
set flag = `${LAGRANTO}/bin/isnumber $2`
|
|
|
32 |
if ( "${flag}" == "1" ) then
|
|
|
33 |
set mode = "-ll2xy.single"
|
|
|
34 |
set lonpos = $2
|
|
|
35 |
set latpos = $3
|
|
|
36 |
else
|
|
|
37 |
set inpfile = $2
|
|
|
38 |
set outfile = $3
|
|
|
39 |
endif
|
|
|
40 |
endif
|
|
|
41 |
|
|
|
42 |
if ( "${mode}" == "-xy2ll" ) then
|
|
|
43 |
set flag = `${LAGRANTO}/bin/isnumber $2`
|
|
|
44 |
if ( "${flag}" == "1" ) then
|
|
|
45 |
set mode = "-xy2ll.single"
|
|
|
46 |
set xpos = $2
|
|
|
47 |
set ypos = $3
|
|
|
48 |
else
|
|
|
49 |
set inpfile = $2
|
|
|
50 |
set outfile = $3
|
|
|
51 |
endif
|
|
|
52 |
endif
|
|
|
53 |
|
21 |
michaesp |
54 |
if ( "${mode}" == "-vec2ll" ) then
|
|
|
55 |
set inpfile = $2
|
|
|
56 |
set outfile = $3
|
|
|
57 |
set vectorx = $4
|
|
|
58 |
set vectory = $5
|
|
|
59 |
endif
|
|
|
60 |
|
|
|
61 |
if ( "${mode}" == "-vec2xy" ) then
|
|
|
62 |
set inpfile = $2
|
|
|
63 |
set outfile = $3
|
|
|
64 |
set vectorx = $4
|
|
|
65 |
set vectory = $5
|
|
|
66 |
endif
|
|
|
67 |
|
2 |
michaesp |
68 |
if ( "${mode}" == "-p2z" ) then
|
|
|
69 |
set flag = `${LAGRANTO}/bin/isnumber $2`
|
|
|
70 |
if ( "${flag}" == "1" ) then
|
|
|
71 |
set mode = "-p2z.single"
|
|
|
72 |
set xpos = $2
|
|
|
73 |
set ypos = $3
|
|
|
74 |
set ppos = $4
|
|
|
75 |
else
|
|
|
76 |
set inpfile = $2
|
|
|
77 |
set outfile = $3
|
|
|
78 |
endif
|
|
|
79 |
endif
|
|
|
80 |
|
|
|
81 |
if ( "${mode}" == "-z2p" ) then
|
|
|
82 |
set flag = `${LAGRANTO}/bin/isnumber $2`
|
|
|
83 |
if ( "${flag}" == "1" ) then
|
|
|
84 |
set mode = "-z2p.single"
|
|
|
85 |
set xpos = $2
|
|
|
86 |
set ypos = $3
|
|
|
87 |
set zpos = $4
|
|
|
88 |
else
|
|
|
89 |
set inpfile = $2
|
|
|
90 |
set outfile = $3
|
|
|
91 |
endif
|
|
|
92 |
endif
|
|
|
93 |
|
11 |
michaesp |
94 |
if ( "${mode}" == "-mapscale" ) then
|
|
|
95 |
if ( $#argv == 2 ) then
|
|
|
96 |
set nfilter = $2
|
|
|
97 |
else
|
|
|
98 |
set nfilter = 0
|
|
|
99 |
endif
|
|
|
100 |
endif
|
|
|
101 |
|
2 |
michaesp |
102 |
# -----------------------------------------------------------------------------
|
|
|
103 |
# Create mapping file
|
|
|
104 |
# -----------------------------------------------------------------------------
|
|
|
105 |
|
|
|
106 |
if ( "${mode}" == "-create" ) then
|
|
|
107 |
|
|
|
108 |
# Test whether input file is present
|
|
|
109 |
if ( ! -f ${inpfile} ) then
|
|
|
110 |
echo " ERROR: input file ${inpfile} is missing... Stop"
|
|
|
111 |
exit 1
|
|
|
112 |
endif
|
|
|
113 |
|
|
|
114 |
# Check whether grid description is available
|
|
|
115 |
set ok = `${LAGRANTO}/bin/getvars ${inpfile} | grep XLAT`
|
|
|
116 |
if ( "{ok}" == "" ) then
|
|
|
117 |
echo "Mapping XLAT is missing on ${inpfile}... Stop"
|
|
|
118 |
exit 1
|
|
|
119 |
endif
|
|
|
120 |
set ok = `${LAGRANTO}/bin/getvars ${inpfile} | grep XLONG`
|
|
|
121 |
if ( "{ok}" == "" ) then
|
|
|
122 |
echo "Mapping XLONG is missing on ${inpfile}... Stop"
|
|
|
123 |
exit 1
|
|
|
124 |
endif
|
|
|
125 |
|
|
|
126 |
# Calculate the forward transformation
|
|
|
127 |
\rm -f wrfmap.param
|
|
|
128 |
echo \"${mode}\" >! wrfmap.param
|
|
|
129 |
echo \"${inpfile}\" >> wrfmap.param
|
|
|
130 |
echo \"${anglemode}\" >> wrfmap.param
|
|
|
131 |
|
|
|
132 |
${LAGRANTO}/goodies/wrfmap
|
|
|
133 |
|
|
|
134 |
# Make clean
|
|
|
135 |
\rm -f wrfmap.param
|
|
|
136 |
|
|
|
137 |
endif
|
|
|
138 |
|
|
|
139 |
# -----------------------------------------------------------------------------
|
|
|
140 |
# Transform lon/lat -> x/y
|
|
|
141 |
# -----------------------------------------------------------------------------
|
|
|
142 |
|
|
|
143 |
if ( "${mode}" == "-ll2xy" ) then
|
|
|
144 |
|
|
|
145 |
# Test whether input file is present
|
|
|
146 |
if ( ! -f ${inpfile} ) then
|
|
|
147 |
echo " ERROR: input file ${inpfile} is missing... Stop"
|
|
|
148 |
exit 1
|
|
|
149 |
endif
|
|
|
150 |
|
|
|
151 |
# Decide whether startfile has an explicit format specifier
|
|
|
152 |
set format = "0"
|
|
|
153 |
foreach app ( 1 2 3 4 5 6 7 8 9 )
|
|
|
154 |
set flag = `echo ${inpfile} | grep ".${app}"`
|
|
|
155 |
if ( "${flag}" != "" ) set format = "${app}"
|
|
|
156 |
end
|
|
|
157 |
|
|
|
158 |
# If format is 0, it might nevertheless be a hidden format 1
|
|
|
159 |
if ( "${format}" == "0" ) then
|
|
|
160 |
set ncol = `awk "{print NF}" ${inpfile} | tail -1`
|
|
|
161 |
if ( "${ncol}" != "3" ) then
|
|
|
162 |
set format = "1"
|
|
|
163 |
echo " WARNING: ${inpfile} is a hidden trajectory file of format 1"
|
|
|
164 |
echo " it will be renamed: ${inpfile} -> ${inpfile}.1"
|
|
|
165 |
echo
|
|
|
166 |
ln -sf ${inpfile} ${inpfile}.1
|
|
|
167 |
set inpfile = "${inpfile}.1"
|
|
|
168 |
endif
|
|
|
169 |
endif
|
|
|
170 |
|
|
|
171 |
# Get the number of trajectories
|
|
|
172 |
if ( "${format}" == "0" ) then
|
|
|
173 |
set ntra = `wc -l ${inpfile} | awk '{print $1}' `
|
|
|
174 |
set ncol = 3
|
|
|
175 |
set ntim = 1
|
|
|
176 |
else
|
|
|
177 |
set ntra = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ntra`
|
|
|
178 |
set ncol = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ncol`
|
|
|
179 |
set ntim = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ntim`
|
|
|
180 |
endif
|
|
|
181 |
|
|
|
182 |
# Prepare parameter file and run Fortran code
|
|
|
183 |
\rm -f wrfmap.param
|
|
|
184 |
echo \"${mode}\" >! wrfmap.param
|
|
|
185 |
echo \"${inpfile}\" >> wrfmap.param
|
|
|
186 |
echo \"${outfile}\" >> wrfmap.param
|
|
|
187 |
echo ${ntra} ${ntim} ${ncol} >> wrfmap.param
|
|
|
188 |
|
|
|
189 |
cat wrfmap.param
|
|
|
190 |
${LAGRANTO}/goodies/wrfmap
|
|
|
191 |
|
|
|
192 |
# Make clean
|
|
|
193 |
\rm -f wrfmap.param
|
|
|
194 |
|
|
|
195 |
endif
|
|
|
196 |
|
|
|
197 |
# -----------------------------------------------------------------------------
|
|
|
198 |
# Transform x/y -> lon/lat
|
|
|
199 |
# -----------------------------------------------------------------------------
|
|
|
200 |
|
|
|
201 |
if ( "${mode}" == "-xy2ll" ) then
|
|
|
202 |
|
|
|
203 |
# Test whether input file is present
|
|
|
204 |
if ( ! -f ${inpfile} ) then
|
|
|
205 |
echo " ERROR: input file ${inpfile} is missing... Stop"
|
|
|
206 |
exit 1
|
|
|
207 |
endif
|
|
|
208 |
|
|
|
209 |
# Decide whether startfile has an explicit format specifier
|
|
|
210 |
set format = "0"
|
|
|
211 |
foreach app ( 1 2 3 4 5 6 7 8 9 )
|
|
|
212 |
set flag = `echo ${inpfile} | grep ".${app}"`
|
|
|
213 |
if ( "${flag}" != "" ) set format = "${app}"
|
|
|
214 |
end
|
|
|
215 |
|
|
|
216 |
# If format is 0, it might nevertheless be a hidden format 1
|
|
|
217 |
if ( "${format}" == "0" ) then
|
|
|
218 |
set ncol = `awk "{print NF}" ${inpfile} | tail -1`
|
|
|
219 |
if ( "${ncol}" != "3" ) then
|
|
|
220 |
set format = "1"
|
|
|
221 |
echo " WARNING: ${inpfile} is a hidden trajectory file of format 1"
|
|
|
222 |
echo " it will be renamed: ${inpfile} -> ${inpfile}.1"
|
|
|
223 |
echo
|
|
|
224 |
ln -sf ${inpfile} ${inpfile}.1
|
|
|
225 |
set inpfile = "${inpfile}.1"
|
|
|
226 |
endif
|
|
|
227 |
endif
|
|
|
228 |
|
|
|
229 |
# Get the number of trajectories
|
|
|
230 |
if ( "${format}" == "0" ) then
|
|
|
231 |
set ntra = `wc -l ${inpfile} | awk '{print $1}' `
|
|
|
232 |
set ncol = 3
|
|
|
233 |
set ntim = 1
|
|
|
234 |
else
|
|
|
235 |
set ntra = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ntra`
|
|
|
236 |
set ncol = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ncol`
|
|
|
237 |
set ntim = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ntim`
|
|
|
238 |
endif
|
|
|
239 |
|
|
|
240 |
# Prepare parameter file and run Fortran code
|
|
|
241 |
\rm -f wrfmap.param
|
|
|
242 |
echo \"${mode}\" >! wrfmap.param
|
|
|
243 |
echo \"${inpfile}\" >> wrfmap.param
|
|
|
244 |
echo \"${outfile}\" >> wrfmap.param
|
|
|
245 |
echo ${ntra} ${ntim} ${ncol} >> wrfmap.param
|
|
|
246 |
|
|
|
247 |
${LAGRANTO}/goodies/wrfmap
|
|
|
248 |
|
|
|
249 |
# Make clean
|
|
|
250 |
\rm -f wrfmap.param
|
|
|
251 |
|
|
|
252 |
endif
|
|
|
253 |
|
|
|
254 |
# -----------------------------------------------------------------------------
|
|
|
255 |
# Transform single lon/lat -> x/y
|
|
|
256 |
# -----------------------------------------------------------------------------
|
|
|
257 |
|
|
|
258 |
if ( "${mode}" == "-ll2xy.single" ) then
|
|
|
259 |
|
|
|
260 |
# Prepare parameter file and run Fortran code
|
|
|
261 |
\rm -f wrfmap.param
|
|
|
262 |
echo \"${mode}\" >! wrfmap.param
|
|
|
263 |
echo ${lonpos}, ${latpos} >> wrfmap.param
|
|
|
264 |
|
|
|
265 |
${LAGRANTO}/goodies/wrfmap
|
|
|
266 |
|
|
|
267 |
# Make clean
|
|
|
268 |
\rm -f wrfmap.param
|
|
|
269 |
|
|
|
270 |
endif
|
|
|
271 |
|
|
|
272 |
# -----------------------------------------------------------------------------
|
|
|
273 |
# Transform single x/y -> lon/lat
|
|
|
274 |
# -----------------------------------------------------------------------------
|
|
|
275 |
|
|
|
276 |
if ( "${mode}" == "-xy2ll.single" ) then
|
|
|
277 |
|
|
|
278 |
# Prepare parameter file and run Fortran code
|
|
|
279 |
\rm -f wrfmap.param
|
|
|
280 |
echo \"${mode}\" >! wrfmap.param
|
|
|
281 |
echo ${xpos}, ${ypos} >> wrfmap.param
|
|
|
282 |
|
|
|
283 |
${LAGRANTO}/goodies/wrfmap
|
|
|
284 |
|
|
|
285 |
# Make clean
|
|
|
286 |
\rm -f wrfmap.param
|
|
|
287 |
|
|
|
288 |
endif
|
|
|
289 |
|
|
|
290 |
# -----------------------------------------------------------------------------
|
|
|
291 |
# Calculate map scale factors
|
|
|
292 |
# -----------------------------------------------------------------------------
|
|
|
293 |
|
|
|
294 |
if ( "${mode}" == "-mapscale" ) then
|
|
|
295 |
|
|
|
296 |
# Prepare parameter file and run Fortran code
|
|
|
297 |
\rm -f wrfmap.param
|
|
|
298 |
echo \"${mode}\" >! wrfmap.param
|
11 |
michaesp |
299 |
echo ${nfilter} >> wrfmap.param
|
2 |
michaesp |
300 |
|
|
|
301 |
${LAGRANTO}/goodies/wrfmap
|
|
|
302 |
|
|
|
303 |
# Make clean
|
|
|
304 |
\rm -f wrfmap.param
|
|
|
305 |
|
|
|
306 |
endif
|
|
|
307 |
|
|
|
308 |
# -----------------------------------------------------------------------------
|
|
|
309 |
# Transform pressure to height : x,y,p -> x,y,z
|
|
|
310 |
# -----------------------------------------------------------------------------
|
|
|
311 |
|
|
|
312 |
if ( "${mode}" == "-p2z" ) then
|
|
|
313 |
|
|
|
314 |
# Test whether input file is present
|
|
|
315 |
if ( ! -f ${inpfile} ) then
|
|
|
316 |
echo " ERROR: input file ${inpfile} is missing... Stop"
|
|
|
317 |
exit 1
|
|
|
318 |
endif
|
|
|
319 |
|
|
|
320 |
# Decide whether startfile has an explicit format specifier
|
|
|
321 |
set format = "0"
|
|
|
322 |
foreach app ( 1 2 3 4 5 6 7 8 9 )
|
|
|
323 |
set flag = `echo ${inpfile} | grep ".${app}"`
|
|
|
324 |
if ( "${flag}" != "" ) set format = "${app}"
|
|
|
325 |
end
|
|
|
326 |
|
|
|
327 |
# If format is 0, it might nevertheless be a hidden format 1
|
|
|
328 |
if ( "${format}" == "0" ) then
|
|
|
329 |
set ncol = `awk "{print NF}" ${inpfile} | tail -1`
|
|
|
330 |
if ( "${ncol}" != "3" ) then
|
|
|
331 |
set format = "1"
|
|
|
332 |
echo " WARNING: ${inpfile} is a hidden trajectory file of format 1"
|
|
|
333 |
echo " it will be renamed: ${inpfile} -> ${inpfile}.1"
|
|
|
334 |
echo
|
|
|
335 |
ln -sf ${inpfile} ${inpfile}.1
|
|
|
336 |
set inpfile = "${inpfile}.1"
|
|
|
337 |
endif
|
|
|
338 |
endif
|
|
|
339 |
|
|
|
340 |
# Get the number of trajectories
|
|
|
341 |
if ( "${format}" == "0" ) then
|
|
|
342 |
set ntra = `wc -l ${inpfile} | awk '{print $1}' `
|
|
|
343 |
set ncol = 3
|
|
|
344 |
set ntim = 1
|
|
|
345 |
else
|
|
|
346 |
set ntra = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ntra`
|
|
|
347 |
set ncol = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ncol`
|
|
|
348 |
set ntim = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ntim`
|
|
|
349 |
endif
|
|
|
350 |
|
|
|
351 |
# Prepare parameter file and run Fortran code
|
|
|
352 |
\rm -f wrfmap.param
|
|
|
353 |
echo \"${mode}\" >! wrfmap.param
|
|
|
354 |
echo \"${inpfile}\" >> wrfmap.param
|
|
|
355 |
echo \"${outfile}\" >> wrfmap.param
|
|
|
356 |
echo ${ntra} ${ntim} ${ncol} >> wrfmap.param
|
|
|
357 |
|
|
|
358 |
cat wrfmap.param
|
|
|
359 |
${LAGRANTO}/goodies/wrfmap
|
|
|
360 |
|
|
|
361 |
# Make clean
|
|
|
362 |
\rm -f wrfmap.param
|
|
|
363 |
|
|
|
364 |
endif
|
|
|
365 |
|
|
|
366 |
# -----------------------------------------------------------------------------
|
|
|
367 |
# Transform single pressure to height : x,y,p -> x,y,z
|
|
|
368 |
# -----------------------------------------------------------------------------
|
|
|
369 |
|
|
|
370 |
if ( "${mode}" == "-p2z.single" ) then
|
|
|
371 |
|
|
|
372 |
# Prepare parameter file and run Fortran code
|
|
|
373 |
\rm -f wrfmap.param
|
|
|
374 |
echo \"${mode}\" >! wrfmap.param
|
|
|
375 |
echo ${xpos}, ${ypos},${ppos} >> wrfmap.param
|
|
|
376 |
|
|
|
377 |
${LAGRANTO}/goodies/wrfmap
|
|
|
378 |
|
|
|
379 |
# Make clean
|
|
|
380 |
\rm -f wrfmap.param
|
|
|
381 |
|
|
|
382 |
endif
|
|
|
383 |
|
|
|
384 |
# -----------------------------------------------------------------------------
|
|
|
385 |
# Transform height to pressure : x,y,z -> x,y,p
|
|
|
386 |
# -----------------------------------------------------------------------------
|
|
|
387 |
|
|
|
388 |
if ( "${mode}" == "-z2p" ) then
|
|
|
389 |
|
|
|
390 |
# Test whether input file is present
|
|
|
391 |
if ( ! -f ${inpfile} ) then
|
|
|
392 |
echo " ERROR: input file ${inpfile} is missing... Stop"
|
|
|
393 |
exit 1
|
|
|
394 |
endif
|
|
|
395 |
|
|
|
396 |
# Decide whether startfile has an explicit format specifier
|
|
|
397 |
set format = "0"
|
|
|
398 |
foreach app ( 1 2 3 4 5 6 7 8 9 )
|
|
|
399 |
set flag = `echo ${inpfile} | grep ".${app}"`
|
|
|
400 |
if ( "${flag}" != "" ) set format = "${app}"
|
|
|
401 |
end
|
|
|
402 |
|
|
|
403 |
# If format is 0, it might nevertheless be a hidden format 1
|
|
|
404 |
if ( "${format}" == "0" ) then
|
|
|
405 |
set ncol = `awk "{print NF}" ${inpfile} | tail -1`
|
|
|
406 |
if ( "${ncol}" != "3" ) then
|
|
|
407 |
set format = "1"
|
|
|
408 |
echo " WARNING: ${inpfile} is a hidden trajectory file of format 1"
|
|
|
409 |
echo " it will be renamed: ${inpfile} -> ${inpfile}.1"
|
|
|
410 |
echo
|
|
|
411 |
ln -sf ${inpfile} ${inpfile}.1
|
|
|
412 |
set inpfile = "${inpfile}.1"
|
|
|
413 |
endif
|
|
|
414 |
endif
|
|
|
415 |
|
|
|
416 |
# Get the number of trajectories
|
|
|
417 |
if ( "${format}" == "0" ) then
|
|
|
418 |
set ntra = `wc -l ${inpfile} | awk '{print $1}' `
|
|
|
419 |
set ncol = 3
|
|
|
420 |
set ntim = 1
|
|
|
421 |
else
|
|
|
422 |
set ntra = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ntra`
|
|
|
423 |
set ncol = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ncol`
|
|
|
424 |
set ntim = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ntim`
|
|
|
425 |
endif
|
|
|
426 |
|
|
|
427 |
# Prepare parameter file and run Fortran code
|
|
|
428 |
\rm -f wrfmap.param
|
|
|
429 |
echo \"${mode}\" >! wrfmap.param
|
|
|
430 |
echo \"${inpfile}\" >> wrfmap.param
|
|
|
431 |
echo \"${outfile}\" >> wrfmap.param
|
|
|
432 |
echo ${ntra} ${ntim} ${ncol} >> wrfmap.param
|
|
|
433 |
|
|
|
434 |
cat wrfmap.param
|
|
|
435 |
${LAGRANTO}/goodies/wrfmap
|
|
|
436 |
|
|
|
437 |
# Make clean
|
|
|
438 |
\rm -f wrfmap.param
|
|
|
439 |
|
|
|
440 |
endif
|
|
|
441 |
|
|
|
442 |
# -----------------------------------------------------------------------------
|
|
|
443 |
# Transform single height to pressure : x,y,z -> x,y,p
|
|
|
444 |
# -----------------------------------------------------------------------------
|
|
|
445 |
|
|
|
446 |
if ( "${mode}" == "-z2p.single" ) then
|
|
|
447 |
|
|
|
448 |
# Prepare parameter file and run Fortran code
|
|
|
449 |
\rm -f wrfmap.param
|
|
|
450 |
echo \"${mode}\" >! wrfmap.param
|
|
|
451 |
echo ${xpos}, ${ypos},${zpos} >> wrfmap.param
|
|
|
452 |
|
|
|
453 |
${LAGRANTO}/goodies/wrfmap
|
|
|
454 |
|
|
|
455 |
# Make clean
|
|
|
456 |
\rm -f wrfmap.param
|
|
|
457 |
|
|
|
458 |
endif
|
21 |
michaesp |
459 |
|
|
|
460 |
# -----------------------------------------------------------------------------
|
|
|
461 |
# Transform vector x/y-relative -> lon/lat-relative
|
|
|
462 |
# -----------------------------------------------------------------------------
|
|
|
463 |
|
|
|
464 |
if ( "${mode}" == "-vec2ll" ) then
|
|
|
465 |
|
|
|
466 |
# Test whether input file is present
|
|
|
467 |
if ( ! -f ${inpfile} ) then
|
|
|
468 |
echo " ERROR: input file ${inpfile} is missing... Stop"
|
|
|
469 |
exit 1
|
|
|
470 |
endif
|
|
|
471 |
|
|
|
472 |
# Decide whether startfile has an explicit format specifier
|
|
|
473 |
set format = "0"
|
|
|
474 |
foreach app ( 1 2 3 4 5 6 7 8 9 )
|
|
|
475 |
set flag = `echo ${inpfile} | grep ".${app}"`
|
|
|
476 |
if ( "${flag}" != "" ) set format = "${app}"
|
|
|
477 |
end
|
|
|
478 |
|
|
|
479 |
# If format is 0, it might nevertheless be a hidden format 1
|
|
|
480 |
if ( "${format}" == "0" ) then
|
|
|
481 |
set ncol = `awk "{print NF}" ${inpfile} | tail -1`
|
|
|
482 |
if ( "${ncol}" != "3" ) then
|
|
|
483 |
set format = "1"
|
|
|
484 |
echo " WARNING: ${inpfile} is a hidden trajectory file of format 1"
|
|
|
485 |
echo " it will be renamed: ${inpfile} -> ${inpfile}.1"
|
|
|
486 |
echo
|
|
|
487 |
ln -sf ${inpfile} ${inpfile}.1
|
|
|
488 |
set inpfile = "${inpfile}.1"
|
|
|
489 |
endif
|
|
|
490 |
endif
|
|
|
491 |
|
|
|
492 |
# Get the number of trajectories
|
|
|
493 |
if ( "${format}" == "0" ) then
|
|
|
494 |
set ntra = `wc -l ${inpfile} | awk '{print $1}' `
|
|
|
495 |
set ncol = 3
|
|
|
496 |
set ntim = 1
|
|
|
497 |
else
|
|
|
498 |
set ntra = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ntra`
|
|
|
499 |
set ncol = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ncol`
|
|
|
500 |
set ntim = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ntim`
|
|
|
501 |
endif
|
|
|
502 |
|
|
|
503 |
# Prepare parameter file and run Fortran code
|
|
|
504 |
\rm -f wrfmap.param
|
|
|
505 |
echo \"${mode}\" >! wrfmap.param
|
|
|
506 |
echo \"${inpfile}\" >> wrfmap.param
|
|
|
507 |
echo \"${outfile}\" >> wrfmap.param
|
|
|
508 |
echo ${ntra} ${ntim} ${ncol} >> wrfmap.param
|
|
|
509 |
echo \"${vectorx}\" >> wrfmap.param
|
|
|
510 |
echo \"${vectory}\" >> wrfmap.param
|
|
|
511 |
|
|
|
512 |
${LAGRANTO}/goodies/wrfmap
|
|
|
513 |
|
|
|
514 |
# Make clean
|
|
|
515 |
\rm -f wrfmap.param
|
|
|
516 |
|
|
|
517 |
endif
|
|
|
518 |
|
|
|
519 |
# -----------------------------------------------------------------------------
|
|
|
520 |
# Transform vector lon/lat-relative -> x/y-relative
|
|
|
521 |
# -----------------------------------------------------------------------------
|
|
|
522 |
|
|
|
523 |
if ( "${mode}" == "-vec2xy" ) then
|
|
|
524 |
|
|
|
525 |
# Test whether input file is present
|
|
|
526 |
if ( ! -f ${inpfile} ) then
|
|
|
527 |
echo " ERROR: input file ${inpfile} is missing... Stop"
|
|
|
528 |
exit 1
|
|
|
529 |
endif
|
|
|
530 |
|
|
|
531 |
# Decide whether startfile has an explicit format specifier
|
|
|
532 |
set format = "0"
|
|
|
533 |
foreach app ( 1 2 3 4 5 6 7 8 9 )
|
|
|
534 |
set flag = `echo ${inpfile} | grep ".${app}"`
|
|
|
535 |
if ( "${flag}" != "" ) set format = "${app}"
|
|
|
536 |
end
|
|
|
537 |
|
|
|
538 |
# If format is 0, it might nevertheless be a hidden format 1
|
|
|
539 |
if ( "${format}" == "0" ) then
|
|
|
540 |
set ncol = `awk "{print NF}" ${inpfile} | tail -1`
|
|
|
541 |
if ( "${ncol}" != "3" ) then
|
|
|
542 |
set format = "1"
|
|
|
543 |
echo " WARNING: ${inpfile} is a hidden trajectory file of format 1"
|
|
|
544 |
echo " it will be renamed: ${inpfile} -> ${inpfile}.1"
|
|
|
545 |
echo
|
|
|
546 |
ln -sf ${inpfile} ${inpfile}.1
|
|
|
547 |
set inpfile = "${inpfile}.1"
|
|
|
548 |
endif
|
|
|
549 |
endif
|
|
|
550 |
|
|
|
551 |
# Get the number of trajectories
|
|
|
552 |
if ( "${format}" == "0" ) then
|
|
|
553 |
set ntra = `wc -l ${inpfile} | awk '{print $1}' `
|
|
|
554 |
set ncol = 3
|
|
|
555 |
set ntim = 1
|
|
|
556 |
else
|
|
|
557 |
set ntra = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ntra`
|
|
|
558 |
set ncol = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ncol`
|
|
|
559 |
set ntim = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ntim`
|
|
|
560 |
endif
|
|
|
561 |
|
|
|
562 |
# Prepare parameter file and run Fortran code
|
|
|
563 |
\rm -f wrfmap.param
|
|
|
564 |
echo \"${mode}\" >! wrfmap.param
|
|
|
565 |
echo \"${inpfile}\" >> wrfmap.param
|
|
|
566 |
echo \"${outfile}\" >> wrfmap.param
|
|
|
567 |
echo ${ntra} ${ntim} ${ncol} >> wrfmap.param
|
|
|
568 |
echo \"${vectorx}\" >> wrfmap.param
|
|
|
569 |
echo \"${vectory}\" >> wrfmap.param
|
|
|
570 |
|
|
|
571 |
${LAGRANTO}/goodies/wrfmap
|
|
|
572 |
|
|
|
573 |
# Make clean
|
|
|
574 |
\rm -f wrfmap.param
|
|
|
575 |
|
|
|
576 |
endif
|
|
|
577 |
|