Subversion Repositories lagranto.wrf

Rev

Rev 8 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
 
54
if ( "${mode}" == "-p2z" ) then
55
   set flag = `${LAGRANTO}/bin/isnumber $2`
56
   if ( "${flag}" == "1" ) then
57
   	 set mode   = "-p2z.single"
58
   	 set xpos   = $2
59
   	 set ypos   = $3
60
   	 set ppos   = $4
61
   else
62
     set inpfile   = $2
63
     set outfile   = $3
64
   endif
65
endif
66
 
67
if ( "${mode}" == "-z2p" ) then
68
   set flag = `${LAGRANTO}/bin/isnumber $2`
69
   if ( "${flag}" == "1" ) then
70
   	 set mode   = "-z2p.single"
71
   	 set xpos   = $2
72
   	 set ypos   = $3
73
   	 set zpos   = $4
74
   else
75
     set inpfile   = $2
76
     set outfile   = $3
77
   endif
78
endif
79
 
11 michaesp 80
if ( "${mode}" == "-mapscale" ) then
81
   if ( $#argv == 2 ) then
82
      set nfilter = $2
83
   else
84
      set nfilter = 0
85
   endif  
86
endif
87
 
2 michaesp 88
# -----------------------------------------------------------------------------
89
# Create mapping file
90
# -----------------------------------------------------------------------------
91
 
92
if ( "${mode}" == "-create" ) then
93
 
94
# Test whether input file is present
95
if ( ! -f ${inpfile} ) then
96
   echo " ERROR: input file ${inpfile} is missing... Stop"
97
   exit 1
98
endif
99
 
100
# Check whether grid description is available
101
set ok = `${LAGRANTO}/bin/getvars ${inpfile} | grep XLAT`
102
if ( "{ok}" == "" ) then
103
   echo "Mapping XLAT is missing on ${inpfile}... Stop"
104
   exit 1
105
endif
106
set ok = `${LAGRANTO}/bin/getvars ${inpfile} | grep XLONG`
107
if ( "{ok}" == "" ) then
108
   echo "Mapping XLONG is missing on ${inpfile}... Stop"
109
   exit 1
110
endif
111
 
112
# Calculate the forward transformation
113
\rm -f wrfmap.param
114
echo \"${mode}\"      >! wrfmap.param
115
echo \"${inpfile}\"   >> wrfmap.param
116
echo \"${anglemode}\" >> wrfmap.param
117
 
118
${LAGRANTO}/goodies/wrfmap
119
 
120
# Make clean
121
\rm -f wrfmap.param
122
 
123
endif
124
 
125
# -----------------------------------------------------------------------------
126
# Transform lon/lat -> x/y
127
# -----------------------------------------------------------------------------
128
 
129
if ( "${mode}" == "-ll2xy" ) then
130
 
131
# Test whether input file is present
132
if ( ! -f ${inpfile} ) then
133
   echo " ERROR: input file ${inpfile} is missing... Stop"
134
   exit 1
135
endif
136
 
137
# Decide whether startfile has an explicit format specifier
138
set format = "0"
139
foreach app ( 1 2 3 4 5 6 7 8 9 )
140
  set flag = `echo ${inpfile} | grep ".${app}"`
141
  if ( "${flag}" != "" ) set format = "${app}"
142
end
143
 
144
# If format is 0, it might nevertheless be a hidden format 1
145
if ( "${format}" == "0" ) then
146
    set ncol = `awk "{print NF}" ${inpfile} | tail -1` 
147
    if ( "${ncol}" != "3" ) then
148
        set format = "1"
149
        echo " WARNING: ${inpfile} is a hidden trajectory file of format 1"
150
        echo "          it will be renamed: ${inpfile} -> ${inpfile}.1"
151
        echo
152
        ln -sf ${inpfile} ${inpfile}.1
153
        set inpfile = "${inpfile}.1"
154
    endif
155
endif
156
 
157
# Get the number of trajectories
158
if ( "${format}" == "0" ) then
159
   set ntra = `wc -l ${inpfile} | awk '{print $1}' `
160
   set ncol = 3
161
   set ntim = 1
162
else
163
   set ntra = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ntra`
164
   set ncol = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ncol`
165
   set ntim = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ntim`
166
endif
167
 
168
# Prepare parameter file and run Fortran code
169
\rm -f wrfmap.param 
170
echo \"${mode}\"             >! wrfmap.param
171
echo \"${inpfile}\"          >> wrfmap.param
172
echo \"${outfile}\"          >> wrfmap.param
173
echo ${ntra} ${ntim} ${ncol} >> wrfmap.param
174
 
175
cat wrfmap.param
176
${LAGRANTO}/goodies/wrfmap
177
 
178
# Make clean
179
\rm -f wrfmap.param
180
 
181
endif 
182
 
183
# -----------------------------------------------------------------------------
184
# Transform x/y -> lon/lat
185
# -----------------------------------------------------------------------------
186
 
187
if ( "${mode}" == "-xy2ll" ) then
188
 
189
# Test whether input file is present
190
if ( ! -f ${inpfile} ) then
191
   echo " ERROR: input file ${inpfile} is missing... Stop"
192
   exit 1
193
endif
194
 
195
# Decide whether startfile has an explicit format specifier
196
set format = "0"
197
foreach app ( 1 2 3 4 5 6 7 8 9 )
198
  set flag = `echo ${inpfile} | grep ".${app}"`
199
  if ( "${flag}" != "" ) set format = "${app}"
200
end
201
 
202
# If format is 0, it might nevertheless be a hidden format 1
203
if ( "${format}" == "0" ) then
204
    set ncol = `awk "{print NF}" ${inpfile} | tail -1` 
205
    if ( "${ncol}" != "3" ) then
206
        set format = "1"
207
        echo " WARNING: ${inpfile} is a hidden trajectory file of format 1"
208
        echo "          it will be renamed: ${inpfile} -> ${inpfile}.1"
209
        echo
210
        ln -sf ${inpfile} ${inpfile}.1
211
        set inpfile = "${inpfile}.1"
212
    endif
213
endif
214
 
215
# Get the number of trajectories
216
if ( "${format}" == "0" ) then
217
   set ntra = `wc -l ${inpfile} | awk '{print $1}' `
218
   set ncol = 3
219
   set ntim = 1
220
else
221
   set ntra = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ntra`
222
   set ncol = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ncol`
223
   set ntim = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ntim`
224
endif
225
 
226
# Prepare parameter file and run Fortran code
227
\rm -f wrfmap.param 
228
echo \"${mode}\"             >! wrfmap.param
229
echo \"${inpfile}\"          >> wrfmap.param
230
echo \"${outfile}\"          >> wrfmap.param
231
echo ${ntra} ${ntim} ${ncol} >> wrfmap.param
232
 
233
${LAGRANTO}/goodies/wrfmap
234
 
235
# Make clean
236
\rm -f wrfmap.param
237
 
238
endif
239
 
240
# -----------------------------------------------------------------------------
241
# Transform single lon/lat -> x/y
242
# -----------------------------------------------------------------------------
243
 
244
if ( "${mode}" == "-ll2xy.single" ) then
245
 
246
# Prepare parameter file and run Fortran code
247
\rm -f wrfmap.param 
248
echo \"${mode}\"             >! wrfmap.param
249
echo ${lonpos}, ${latpos}    >> wrfmap.param
250
 
251
${LAGRANTO}/goodies/wrfmap
252
 
253
# Make clean
254
\rm -f wrfmap.param
255
 
256
endif
257
 
258
# -----------------------------------------------------------------------------
259
# Transform single x/y -> lon/lat
260
# -----------------------------------------------------------------------------
261
 
262
if ( "${mode}" == "-xy2ll.single" ) then
263
 
264
# Prepare parameter file and run Fortran code
265
\rm -f wrfmap.param 
266
echo \"${mode}\"             >! wrfmap.param
267
echo ${xpos}, ${ypos}    >> wrfmap.param
268
 
269
${LAGRANTO}/goodies/wrfmap
270
 
271
# Make clean
272
\rm -f wrfmap.param
273
 
274
endif
275
 
276
# -----------------------------------------------------------------------------
277
# Calculate map scale factors
278
# -----------------------------------------------------------------------------
279
 
280
if ( "${mode}" == "-mapscale" ) then
281
 
282
# Prepare parameter file and run Fortran code
283
\rm -f wrfmap.param 
284
echo \"${mode}\"      >! wrfmap.param
11 michaesp 285
echo ${nfilter}       >> wrfmap.param
2 michaesp 286
 
287
${LAGRANTO}/goodies/wrfmap
288
 
289
# Make clean
290
\rm -f wrfmap.param
291
 
292
endif
293
 
294
# -----------------------------------------------------------------------------
295
# Transform pressure to height : x,y,p -> x,y,z
296
# -----------------------------------------------------------------------------
297
 
298
if ( "${mode}" == "-p2z" ) then
299
 
300
# Test whether input file is present
301
if ( ! -f ${inpfile} ) then
302
   echo " ERROR: input file ${inpfile} is missing... Stop"
303
   exit 1
304
endif
305
 
306
# Decide whether startfile has an explicit format specifier
307
set format = "0"
308
foreach app ( 1 2 3 4 5 6 7 8 9 )
309
  set flag = `echo ${inpfile} | grep ".${app}"`
310
  if ( "${flag}" != "" ) set format = "${app}"
311
end
312
 
313
# If format is 0, it might nevertheless be a hidden format 1
314
if ( "${format}" == "0" ) then
315
    set ncol = `awk "{print NF}" ${inpfile} | tail -1` 
316
    if ( "${ncol}" != "3" ) then
317
        set format = "1"
318
        echo " WARNING: ${inpfile} is a hidden trajectory file of format 1"
319
        echo "          it will be renamed: ${inpfile} -> ${inpfile}.1"
320
        echo
321
        ln -sf ${inpfile} ${inpfile}.1
322
        set inpfile = "${inpfile}.1"
323
    endif
324
endif
325
 
326
# Get the number of trajectories
327
if ( "${format}" == "0" ) then
328
   set ntra = `wc -l ${inpfile} | awk '{print $1}' `
329
   set ncol = 3
330
   set ntim = 1
331
else
332
   set ntra = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ntra`
333
   set ncol = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ncol`
334
   set ntim = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ntim`
335
endif
336
 
337
# Prepare parameter file and run Fortran code
338
\rm -f wrfmap.param 
339
echo \"${mode}\"             >! wrfmap.param
340
echo \"${inpfile}\"          >> wrfmap.param
341
echo \"${outfile}\"          >> wrfmap.param
342
echo ${ntra} ${ntim} ${ncol} >> wrfmap.param
343
 
344
cat wrfmap.param
345
${LAGRANTO}/goodies/wrfmap
346
 
347
# Make clean
348
\rm -f wrfmap.param
349
 
350
endif 
351
 
352
# -----------------------------------------------------------------------------
353
# Transform single pressure to height : x,y,p -> x,y,z
354
# -----------------------------------------------------------------------------
355
 
356
if ( "${mode}" == "-p2z.single" ) then
357
 
358
# Prepare parameter file and run Fortran code
359
\rm -f wrfmap.param 
360
echo \"${mode}\"                 >! wrfmap.param
361
echo ${xpos}, ${ypos},${ppos}    >> wrfmap.param
362
 
363
${LAGRANTO}/goodies/wrfmap
364
 
365
# Make clean
366
\rm -f wrfmap.param
367
 
368
endif
369
 
370
# -----------------------------------------------------------------------------
371
# Transform height to pressure : x,y,z -> x,y,p
372
# -----------------------------------------------------------------------------
373
 
374
if ( "${mode}" == "-z2p" ) then
375
 
376
# Test whether input file is present
377
if ( ! -f ${inpfile} ) then
378
   echo " ERROR: input file ${inpfile} is missing... Stop"
379
   exit 1
380
endif
381
 
382
# Decide whether startfile has an explicit format specifier
383
set format = "0"
384
foreach app ( 1 2 3 4 5 6 7 8 9 )
385
  set flag = `echo ${inpfile} | grep ".${app}"`
386
  if ( "${flag}" != "" ) set format = "${app}"
387
end
388
 
389
# If format is 0, it might nevertheless be a hidden format 1
390
if ( "${format}" == "0" ) then
391
    set ncol = `awk "{print NF}" ${inpfile} | tail -1` 
392
    if ( "${ncol}" != "3" ) then
393
        set format = "1"
394
        echo " WARNING: ${inpfile} is a hidden trajectory file of format 1"
395
        echo "          it will be renamed: ${inpfile} -> ${inpfile}.1"
396
        echo
397
        ln -sf ${inpfile} ${inpfile}.1
398
        set inpfile = "${inpfile}.1"
399
    endif
400
endif
401
 
402
# Get the number of trajectories
403
if ( "${format}" == "0" ) then
404
   set ntra = `wc -l ${inpfile} | awk '{print $1}' `
405
   set ncol = 3
406
   set ntim = 1
407
else
408
   set ntra = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ntra`
409
   set ncol = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ncol`
410
   set ntim = `${LAGRANTO}/goodies/trainfo.sh ${inpfile} ntim`
411
endif
412
 
413
# Prepare parameter file and run Fortran code
414
\rm -f wrfmap.param 
415
echo \"${mode}\"             >! wrfmap.param
416
echo \"${inpfile}\"          >> wrfmap.param
417
echo \"${outfile}\"          >> wrfmap.param
418
echo ${ntra} ${ntim} ${ncol} >> wrfmap.param
419
 
420
cat wrfmap.param
421
${LAGRANTO}/goodies/wrfmap
422
 
423
# Make clean
424
\rm -f wrfmap.param
425
 
426
endif 
427
 
428
# -----------------------------------------------------------------------------
429
# Transform single height to pressure : x,y,z -> x,y,p
430
# -----------------------------------------------------------------------------
431
 
432
if ( "${mode}" == "-z2p.single" ) then
433
 
434
# Prepare parameter file and run Fortran code
435
\rm -f wrfmap.param 
436
echo \"${mode}\"                 >! wrfmap.param
437
echo ${xpos}, ${ypos},${zpos}    >> wrfmap.param
438
 
439
${LAGRANTO}/goodies/wrfmap
440
 
441
# Make clean
442
\rm -f wrfmap.param
443
 
444
endif