Subversion Repositories lagranto.wrf

Rev

Rev 11 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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