Subversion Repositories lagranto.wrf

Rev

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

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