Subversion Repositories lagranto.wrf

Rev

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