Subversion Repositories lagranto.wrf

Rev

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

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