#!/bin/sh
#

source `dirname $0`/../Sourcefile.sh
printprocesslog "INFO starting $0"
program=CheckRawFilesAvail
step=RawFileAvailISDC

set -C

# check if script is already running
lockfile=$lockpath/lock-$program.txt
checklock 

# get todo list
gettodo 


for (( s=0 ; s < $num ; s++ ))
do
   night=${primaries[$s+$s]}
   runid=${primaries[$s+$s+1]}
   
   setstatus "start" 

   rawfile=$rawdata/`echo $night | cut -c 1-4`/`echo $night | cut -c 5-6`/`echo $night | cut -c 7-8`/$night"_"`printf %03d $runid`".fits.gz"
   test -e $rawfile 
   check1=$?

   case $check1 in
      1)   printprocesslog "WARN "$rawfile" missing."
           check=$check1
           ;;
      0)   printprocesslog "INFO found rawfile "$rawfile
           ;;
   esac

   setstatus "stop" 
done

finish 

