Subversion Repositories lagranto.wrf

Rev

Rev 11 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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