Subversion Repositories lagranto.wrf

Rev

Rev 8 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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