Subversion Repositories lagranto.wrf

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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