Subversion Repositories lagranto.um

Rev

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

Rev 3 Rev 5
Line 210... Line 210...
210
  set idir      = -1
210
  set idir      = -1
211
  @ timediff_hh = $idir * $timediff_hh
211
  @ timediff_hh = $idir * $timediff_hh
212
endif
212
endif
213
 
213
 
214
# Get also minutes for time difference, if <start_min> or <end_min> != 0
214
# Get also minutes for time difference, if <start_min> or <end_min> != 0
215
set timediff_mm=
215
set timediff_mm=00
216
 
216
 
217
if ( $startdate_min != 00 || $enddate_min != 00 ) then
217
if ( $startdate_min != 00 || $enddate_min != 00 ) then
218
  @ min = ( $enddate_min - $startdate_min )
218
  @ min = ( $enddate_min - $startdate_min )
219
  if ( $min == 0 ) then
219
  if ( $min == 0 ) then
220
    set timediff_mm=
220
    set timediff_mm=
Line 258... Line 258...
258
 
258
 
259
# Take the time increment from flag list ('nil', if not defined)
259
# Take the time increment from flag list ('nil', if not defined)
260
set timeinc = ${flag_i}
260
set timeinc = ${flag_i}
261
 
261
 
262
# Find a first data file (if possible corresponding to start/end date
262
# Find a first data file (if possible corresponding to start/end date
263
# If starttime is not a data time, take the first file in the direectory
263
# If starttime is not a data time, take the first file in the directory
264
if ( $direction == "f" ) then
264
if ( $direction == "f" ) then
265
  set file=${charp}${startdate_ymdh}
265
  set file=${charp}${startdate_ymdh}
266
else
266
else 
267
  set file=${charp}${enddate_ymdh}
267
  set file=${charp}${enddate_ymdh}
268
endif
268
endif
Line 271... Line 271...
271
endif
271
endif
272
 
272
 
273
# Determine timeinc (the time difference in hours between two data file)
273
# Determine timeinc (the time difference in hours between two data file)
274
# if not already defined with option -i
274
# if not already defined with option -i
275
if ( ${timeinc} == "nil" ) then
275
if ( ${timeinc} == "nil" ) then
276
  set date1=`echo $file | cut -c 2-12`
276
  set date1=`echo $file | cut -c 2-`
277
  set n=`ls ${charp}[0-9_]*[0-9] | grep -n $date1 | awk -F: '{print $1}'`
277
  set n=`\ls ${charp}[0-9_]*[0-9] | grep -n $date1 | awk -F: '{print $1}'`
278
  @ n ++
278
  @ n ++
279
  set date2=`ls ${charp}[0-9_]*[0-9] | head -$n | tail -1 | cut -c 2-12`
279
  set date2=`\ls ${charp}[0-9_]*[0-9] | head -$n | tail -1 | cut -c 2-`
280
  set timeinc=`${LAGRANTO}/goodies/gettidiff $date2 $date1`
280
  set timeinc=`${LAGRANTO}/goodies/gettidiff $date2 $date1`
281
endif
281
endif
282
if ( $timeinc == 0 ) then
282
if ( $timeinc == 0 ) then
283
    echo " ERROR: cannot set the time increment between input files ***"
283
    echo " ERROR: cannot set the time increment between input files ***"
284
    exit 1
284
    exit 1
285
endif
285
endif
286
 
286
 
-
 
287
# Decide whether the time increment is smaller than 1 h; if so set the hires
-
 
288
# flag and convert the timeincement into fractional hour
287
# Search the first file to use
289
set flag = `echo ${timeinc} | grep -n '\.'`
-
 
290
set hires = 0
-
 
291
 
-
 
292
if ( "${flag}" != "" ) then
-
 
293
  echo "Input files availability < 1 hour ($timeinc): switch to hires"
-
 
294
  echo "mode. All input files must be of form: P{yyyymmdd_hhmm}"
-
 
295
  set hires = 1
-
 
296
  set timeinc_min = `echo "(${timeinc} * 100 + 0.5)/1" | bc`
-
 
297
  set timeinc     = `echo "scale=2; ${timeinc} * 100 / 60" | bc`
-
 
298
  goto hires
-
 
299
endif
-
 
300
 
-
 
301
# Search the first file to use: We step through all P files and see whether they are
-
 
302
# good P files. Let's first do the test for the first data file found. If it's ok, we 
-
 
303
# take it; if not, we step through all P files and find the good one
288
set flag=0
304
set flag=0
289
set td=
305
set td=
-
 
306
 
-
 
307
set date = `echo ${file} | cut -c 2-12`
-
 
308
set td1  = `${LAGRANTO}/goodies/gettidiff ${startdate_ymdh} ${date}`
-
 
309
set td2  = `${LAGRANTO}/goodies/gettidiff ${enddate_ymdh}   ${date}`
-
 
310
 
-
 
311
if (( $td1 < $timeinc || $td2 < $timeinc ) && ( $td1 >= 0 || $td2 >= 0 )) then
-
 
312
   set datfiles=$date
-
 
313
   if ( $td1 < $timeinc    ) set td=$td1
-
 
314
   if ( $td2 < $timeinc    ) set td=$td2
-
 
315
   if ( ( $startdate_min > 0 ) || ( $enddate_min > 0 ) ) @ td ++
-
 
316
   goto label2      
-
 
317
endif
-
 
318
 
290
foreach i ( ${charp}????????_?? )
319
foreach i ( ${charp}????????_?? )
291
 
320
 
292
  set date = `echo $i | cut -c 2-12`
321
  set date = `echo $i | cut -c 2-12`
293
  set td1  = `${LAGRANTO}/goodies/gettidiff ${startdate_ymdh} ${date}`
322
  set td1  = `${LAGRANTO}/goodies/gettidiff ${startdate_ymdh} ${date}`
294
  set td2  = `${LAGRANTO}/goodies/gettidiff ${enddate_ymdh}   ${date}`
323
  set td2  = `${LAGRANTO}/goodies/gettidiff ${enddate_ymdh}   ${date}`
Line 300... Line 329...
300
      goto label2
329
      goto label2
301
  endif
330
  endif
302
 
331
 
303
end
332
end
304
 
333
 
305
# if no P/T-files are available for the specified time period, then $td is
-
 
306
# still undefined
-
 
307
if ( $td == "" ) then
334
if ( $td == "" ) then
-
 
335
  echo
308
  echo " ERROR: no data files available for the specified time period"
336
  echo " ERROR: no data files available for the specified time period"
309
  exit 1
337
  exit 1
310
endif
338
endif
311
 
339
 
-
 
340
# If the input files come with time increment < 1 hour, handle it in this
-
 
341
# special section. The aim is not to 'interfere' with the well established
-
 
342
# code handling the standard case with time increment >= 1 hour. In this mode
-
 
343
# we require that the start and end date are available as P files: no start is
-
 
344
# allowed between the model output files
-
 
345
hires:
-
 
346
 
-
 
347
set flag=0
-
 
348
set td=0
-
 
349
 
-
 
350
if ( $direction == "f" ) then
-
 
351
  set file=${charp}${startdate}
-
 
352
else 
-
 
353
  set file=${charp}${enddate}
-
 
354
endif
-
 
355
 
-
 
356
if ( -f $file ) then
-
 
357
  set date     = `echo ${file} | cut -c 2-14`
-
 
358
  set datfiles = $date
-
 
359
  set td       = 0
-
 
360
  goto label2
-
 
361
else
-
 
362
  echo
-
 
363
  echo " ERROR: no data files available for the specified time period"
-
 
364
  exit 1
-
 
365
endif
-
 
366
 
312
# Everything is fine so far: proceed
367
# Everything is fine so far (first data file found): proceed
313
label2:
368
label2:
314
 
369
 
315
# Calculate the number of further files
370
# Calculate the number of further files; handle hires (timeinc<1 h) and
-
 
371
# standard mode (timeinc >= 1 h) separately
-
 
372
if ( ${hires} == 0 ) then
316
@ num = ( $timediff_hh + $td ) / $timeinc + 1
373
 @ num = ( $timediff_hh + $td ) / $timeinc + 1
317
@ dum1 = ( $num - 1 ) * $timeinc
374
 @ dum1 = ( $num - 1 ) * $timeinc
318
@ dum2 = $timediff_hh + $td
375
 @ dum2 = $timediff_hh + $td
319
if ( $dum1 != $dum2 ) @ num ++
376
 if ( $dum1 != $dum2 ) @ num ++
-
 
377
else
-
 
378
 set num = `echo "( ${timediff_hh}*60 + ${timediff_mm} ) / ( ${timeinc_min} ) + 1" | bc`
-
 
379
endif 
320
 
380
 
321
# Get a list of all needed files
381
# Get a list of all needed files
322
set numfiles=$num
382
set numfiles=$num
323
set sfiles=1
383
set sfiles=1
-
 
384
echo $datfiles
324
while ( $num > 1 )
385
while ( $num > 1 )
-
 
386
  if ( $hires == 0 ) then
325
  set date=`${LAGRANTO}goodies/newtime $date $timeinc`
387
     set date=`${LAGRANTO}/goodies/newtime $date $timeinc`
-
 
388
  else
-
 
389
     set date=`${LAGRANTO}/goodies/newtime $date $timeinc_min`
-
 
390
  endif
326
 
391
  
327
  echo $date
392
  echo ${date}
328
 
393
  
329
  if ( ! -f ${charp}${date} ) then
394
  if ( ! -f ${charp}${date} ) then
330
    echo " ERROR: file with primary data is missing for $date"
395
    echo " ERROR: file with primary data is missing for $date"
331
    exit 1
396
    exit 1
332
  else if ( ! -f ${chars}${date} ) then
397
  else if ( ! -f ${chars}${date} ) then
Line 339... Line 404...
339
end
404
end
340
 
405
 
341
# Write some status information
406
# Write some status information
342
echo "Primary file prefix            : ${charp}"
407
echo "Primary file prefix            : ${charp}"
343
echo "Secondary file prefix          : ${chars}"
408
echo "Secondary file prefix          : ${chars}"
-
 
409
if ( ${hires} == 0 ) then
344
echo "Time increment for input files : ${timeinc}"
410
  echo "Time increment for input files : ${timeinc} h"
-
 
411
else
-
 
412
  echo "Time increment for input files : ${timeinc_min} min (0$timeinc h) "
-
 
413
endif
345
echo "# input files                  : ${numfiles}"
414
echo "# input files                  : ${numfiles}"
346
echo "${charp} files availability           : 1"  
415
echo "${charp} files availability           : 1"  
347
echo "${chars} files availability           : ${sfiles}"     
416
echo "${chars} files availability           : ${sfiles}"     
348
echo "First input file               : $datfiles[1] " 
417
echo "First input file               : $datfiles[1] " 
349
echo "Last input file                : $datfiles[$numfiles] " 
418
echo "Last input file                : $datfiles[$numfiles] " 
350
 
419
 
-
 
420
echo
-
 
421
echo $datfiles
-
 
422
 
351
# ---------------------------------------------------------------------
423
# ---------------------------------------------------------------------
352
# Handle vertical wind - scaling factor
424
# Handle vertical wind - scaling factor
353
# ---------------------------------------------------------------------
425
# ---------------------------------------------------------------------
354
 
426
 
355
echo
427
echo
Line 392... Line 464...
392
# Take the time step and output step from flag list ('nil', if not defined)
464
# Take the time step and output step from flag list ('nil', if not defined)
393
set timestep = ${flag_t}
465
set timestep = ${flag_t}
394
set deltout  = ${flag_o}
466
set deltout  = ${flag_o}
395
 
467
 
396
# Calculate the time step
468
# Calculate the time step
-
 
469
if ( $hires == 0 ) then
397
if ( $timestep == "nil" ) @ timestep = ( 60 * $timeinc ) / 12
470
  if ( $timestep == "nil" ) @ timestep = ( 60 * $timeinc ) / 12
-
 
471
else
-
 
472
  if ( $timestep == "nil" ) set timestep =  `echo "scale=2; $timeinc_min / 12" | bc`
-
 
473
endif
398
 
474
 
399
# Take the output interval from time increment
475
# Take the output interval from time increment
-
 
476
if ( $hires == 0 ) then
400
if ( $deltout == "nil" ) @ deltout = 60 * ${timeinc}
477
  if ( $deltout == "nil" ) @ deltout = 60 * ${timeinc}
-
 
478
else
-
 
479
  if ( $deltout == "nil" ) set deltout = ${timeinc_min}
-
 
480
endif
401
 
481
 
402
# Check whether the timestep is an integer ratio of deltout
482
# Check whether the timestep is an integer ratio of deltout
403
@ flag = $deltout / $timestep
483
#@ flag = $deltout / $timestep
404
@ flag = $deltout - ( $flag * $timestep )
484
#@ flag = $deltout - ( $flag * $timestep )
-
 
485
set flag = `echo "scale=2; $deltout / $timestep" | bc`
-
 
486
set flag = `echo "scale=2; $deltout - ( $flag * $timestep )" | bc`   
405
if ( $flag != 0 ) then
487
if ( $flag != 0 ) then
406
  echo " ERROR: output time interval should be multiple of timestep"
488
  echo " ERROR: output time interval should be multiple of timestep"
407
  echo 
489
  echo 
408
  echo "           $deltout min  : output time interval"
490
  echo "           $deltout min  : output time interval"
409
  echo "           $timestep min  : time step"
491
  echo "           $timestep min  : time step"