Subversion Repositories lagranto.wrf

Rev

Rev 21 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 21 Rev 23
Line 199... Line 199...
199
  set idir      = -1
199
  set idir      = -1
200
  @ timediff_hh = $idir * $timediff_hh
200
  @ timediff_hh = $idir * $timediff_hh
201
endif
201
endif
202
 
202
 
203
# Get also minutes for time difference, if <start_min> or <end_min> != 0
203
# Get also minutes for time difference, if <start_min> or <end_min> != 0
204
set timediff_mm=
204
set timediff_mm=00
205
 
205
 
206
if ( $startdate_min != 00 || $enddate_min != 00 ) then
206
if ( $startdate_min != 00 || $enddate_min != 00 ) then
207
  @ min = ( $enddate_min - $startdate_min )
207
  @ min = ( $enddate_min - $startdate_min )
208
  if ( $min == 0 ) then
208
  if ( $min == 0 ) then
209
    set timediff_mm=
209
    set timediff_mm=
Line 254... Line 254...
254
  set file=${charp}${startdate_ymdh}
254
  set file=${charp}${startdate_ymdh}
255
else
255
else
256
  set file=${charp}${enddate_ymdh}
256
  set file=${charp}${enddate_ymdh}
257
endif
257
endif
258
if ( ! -f $file ) then
258
if ( ! -f $file ) then
259
  set file=`ls ${charp}[0-9_]*[0-9] | head -1 | sed -e 's/@//'`
259
  set file=`\ls ${charp}[0-9_]*[0-9] | head -1 | sed -e 's/@//'`
260
endif
260
endif
261
 
261
 
262
# Determine timeinc (the time difference in hours between two data file)
262
# Determine timeinc (the time difference in hours between two data file)
263
# if not already defined with option -i
263
# if not already defined with option -i
264
if ( ${timeinc} == "nil" ) then
264
if ( ${timeinc} == "nil" ) then
265
  set date1=`echo $file | cut -c 2-12`
265
  set date1=`echo $file | cut -c 2-`
266
  set n=`ls ${charp}[0-9_]*[0-9] | grep -n $date1 | awk -F: '{print $1}'`
266
  set n=`\ls ${charp}[0-9_]*[0-9] | grep -n $date1 | awk -F: '{print $1}'`
267
  @ n ++
267
  @ n ++
268
  set date2=`ls ${charp}[0-9_]*[0-9] | head -$n | tail -1 | cut -c 2-12`
268
  set date2=`\ls ${charp}[0-9_]*[0-9] | head -$n | tail -1 | cut -c 2-`
269
  set timeinc=`${LAGRANTO}/goodies/gettidiff $date2 $date1`
269
  set timeinc=`${LAGRANTO}/goodies/gettidiff $date2 $date1`
270
endif
270
endif
271
if ( $timeinc == 0 ) then
271
if ( $timeinc == 0 ) then
272
    echo " ERROR: cannot set the time increment between input files ***"
272
    echo " ERROR: cannot set the time increment between input files ***"
273
    exit 1
273
    exit 1
274
endif
274
endif
275
 
275
 
-
 
276
# Decide whether the time increment is smaller than 1 h; if so set the hires
-
 
277
# flag and convert the timeincement into fractional hour
-
 
278
set flag = `echo ${timeinc} | grep -n '\.'`
-
 
279
set hires = 0
-
 
280
if ( "${flag}" != "" ) then
-
 
281
  echo
-
 
282
  echo "Input files availability < 1 hour ($timeinc): switch to hires"
-
 
283
  echo "mode. All input files must be of form: P{yyyymmdd_hhmm}"
-
 
284
  set hires = 1
-
 
285
  set timeinc_min = `echo "(${timeinc} * 100 + 0.5)/1" | bc`
-
 
286
  set timeinc     = `echo "scale=2; ${timeinc} * 100 / 60" | bc`
-
 
287
  goto hires
-
 
288
endif
-
 
289
 
276
# Search the first file to use: We step through all P files and see whether they are
290
# Search the first file to use: We step through all P files and see whether they are
277
# good P files. Let's first do the test for the first data file found. If it's ok, we 
291
# good P files. Let's first do the test for the first data file found. If it's ok, we 
278
# take it; if not, we step through all P files and find the good one  
292
# take it; if not, we step through all P files and find the good one  
279
set flag=0
293
set flag=0
280
set td=
294
set td=
Line 312... Line 326...
312
if ( $td == "" ) then
326
if ( $td == "" ) then
313
  echo " ERROR: no data files available for the specified time period"
327
  echo " ERROR: no data files available for the specified time period"
314
  exit 1
328
  exit 1
315
endif
329
endif
316
 
330
 
-
 
331
# If the input files come with time increment < 1 hour, handle it in this
-
 
332
# special section. The aim is not to 'interfere' with the well established
-
 
333
# code handling the standard case with time increment >= 1 hour. In this mode
-
 
334
# we require that the start and end date are available as P files: no start is
-
 
335
# allowed between the model output files
-
 
336
hires:
-
 
337
 
-
 
338
set flag=0
-
 
339
set td=0
-
 
340
 
-
 
341
if ( $direction == "f" ) then
-
 
342
  set file=${charp}${startdate}
-
 
343
else 
-
 
344
  set file=${charp}${enddate}
-
 
345
endif
-
 
346
 
-
 
347
if ( -f $file ) then
-
 
348
  set date     = `echo ${file} | cut -c 2-14`
-
 
349
  set datfiles = $date
-
 
350
  set td       = 0
-
 
351
  goto label2
-
 
352
else
-
 
353
  echo
-
 
354
  echo " ERROR: no data files available for the specified time period"
-
 
355
  exit 1
-
 
356
endif
-
 
357
 
317
# Everything is fine so far: proceed
358
# Everything is fine so far: proceed
318
label2:
359
label2:
319
 
360
 
320
# Check whether first date is ok - before or at needed dates
361
# Check whether first date is ok - before or at needed dates
321
if ( $direction == "f" ) then
362
if ( $direction == "f" ) then
Line 326... Line 367...
326
  if ( $tdiff0 < 0 ) then
367
  if ( $tdiff0 < 0 ) then
327
  echo " ERROR: data files missing for the specified time period"
368
  echo " ERROR: data files missing for the specified time period"
328
  exit 1
369
  exit 1
329
endif
370
endif
330
 
371
 
331
# Calculate the number of further files
372
# Calculate the number of further files; handle hires (timeinc<1 h) and
-
 
373
# standard mode (timeinc >= 1 h) separately
-
 
374
if ( ${hires} == 0 ) then
332
@ num = ( $timediff_hh + $td ) / $timeinc + 1
375
   @ num = ( $timediff_hh + $td ) / $timeinc + 1
333
@ dum1 = ( $num - 1 ) * $timeinc
376
   @ dum1 = ( $num - 1 ) * $timeinc
334
@ dum2 = $timediff_hh + $td
377
   @ dum2 = $timediff_hh + $td
335
if ( $dum1 != $dum2 ) @ num ++
378
   if ( $dum1 != $dum2 ) @ num ++
-
 
379
else
-
 
380
    set num = `echo "( ${timediff_hh}*60 + ${timediff_mm} ) / ( ${timeinc_min} ) + 1" | bc`
-
 
381
endif 
336
 
382
 
337
# Get a list of all needed files
383
# Get a list of all needed files
338
set numfiles=$num
384
set numfiles=$num
339
set sfiles=1
385
set sfiles=1
340
echo $datfiles
386
echo $datfiles 
341
while ( $num > 1 )
387
while ( $num > 1 )
-
 
388
  if ( $hires == 0 ) then
342
  set date=`${LAGRANTO}/goodies/newtime $date $timeinc`
389
     set date=`${LAGRANTO}/goodies/newtime $date $timeinc`
-
 
390
  else
-
 
391
     echo ${date} ${timeinc_min}
-
 
392
     set date=`${LAGRANTO}/goodies/newtime $date $timeinc_min`
-
 
393
  endif
343
 
394
  
344
  echo $date
395
  echo ${date}
345
 
396
  
346
  if ( ! -f ${charp}${date} ) then
397
  if ( ! -f ${charp}${date} ) then
347
    echo " ERROR: file with primary data is missing for $date"
398
    echo " ERROR: file with primary data is missing for $date"
348
    exit 1
399
    exit 1
349
  else if ( ! -f ${chars}${date} ) then
400
  else if ( ! -f ${chars}${date} ) then
Line 356... Line 407...
356
end
407
end
357
 
408
 
358
# Write some status information
409
# Write some status information
359
echo "Primary file prefix            : ${charp}"
410
echo "Primary file prefix            : ${charp}"
360
echo "Secondary file prefix          : ${chars}"
411
echo "Secondary file prefix          : ${chars}"
-
 
412
if ( ${hires} == 0 ) then
361
echo "Time increment for input files : ${timeinc}"
413
  echo "Time increment for input files : ${timeinc} h"
-
 
414
else
-
 
415
  echo "Time increment for input files : ${timeinc_min} min (0$timeinc h) "
-
 
416
endif
362
echo "# input files                  : ${numfiles}"
417
echo "# input files                  : ${numfiles}"
363
echo "${charp} files availability           : 1"  
418
echo "${charp} files availability           : 1"  
364
echo "${chars} files availability           : ${sfiles}"     
419
echo "${chars} files availability           : ${sfiles}"     
365
echo "First input file               : $datfiles[1] " 
420
echo "First input file               : $datfiles[1] " 
366
echo "Last input file                : $datfiles[$numfiles] " 
421
echo "Last input file                : $datfiles[$numfiles] " 
Line 382... Line 437...
382
# Take the time step and output step from flag list ('nil', if not defined)
437
# Take the time step and output step from flag list ('nil', if not defined)
383
set timestep = ${flag_t}
438
set timestep = ${flag_t}
384
set deltout  = ${flag_o}
439
set deltout  = ${flag_o}
385
 
440
 
386
# Calculate the time step
441
# Calculate the time step
-
 
442
if ( $hires == 0 ) then
387
if ( $timestep == "nil" ) @ timestep = ( 60 * $timeinc ) / 12
443
  if ( $timestep == "nil" ) @ timestep = ( 60 * $timeinc ) / 12
-
 
444
else
-
 
445
  if ( $timestep == "nil" ) set timestep =  `echo "scale=2; $timeinc_min / 12" | bc`
-
 
446
endif
388
 
447
 
389
# Take the output interval from time increment
448
# Take the output interval from time increment
-
 
449
if ( $hires == 0 ) then
390
if ( $deltout == "nil" ) @ deltout = 60 * ${timeinc}
450
  if ( $deltout == "nil" ) @ deltout = 60 * ${timeinc}
-
 
451
else
-
 
452
  if ( $deltout == "nil" ) set deltout = ${timeinc_min}
-
 
453
endif
391
 
454
 
392
# Check whether the timestep is an integer ratio of deltout
455
# Check whether the timestep is an integer ratio of deltout
393
@ flag = $deltout / $timestep
456
#@ flag = $deltout / $timestep
394
@ flag = $deltout - ( $flag * $timestep )
457
#@ flag = $deltout - ( $flag * $timestep )
-
 
458
set flag = `echo "scale=2; $deltout / $timestep" | bc`
-
 
459
set flag = `echo "scale=2; $deltout - ( $flag * $timestep )" | bc`   
395
if ( $flag != 0 ) then
460
if ( $flag != 0 ) then
396
  echo " ERROR: output time interval should be multiple of timestep"
461
  echo " ERROR: output time interval should be multiple of timestep"
397
  echo 
462
  echo 
398
  echo "           $deltout min  : output time interval"
463
  echo "           $deltout min  : output time interval"
399
  echo "           $timestep min  : time step"
464
  echo "           $timestep min  : time step"