Index: trunk/MagicSoft/Mars/datacenter/scripts/runcallisto
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/runcallisto	(revision 8454)
+++ trunk/MagicSoft/Mars/datacenter/scripts/runcallisto	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -51,5 +51,5 @@
 sequence=$process
 
-# lock sequ
+# lock sequ for cal
 lockfile=$lockpath/lock-$table-$column-$sequence.txt
 checklock >> $scriptlog 2>&1
@@ -62,6 +62,4 @@
 no=`printf %08d $sequence | cut -c 0-4`
 no2=`printf %08d $sequence`
-var1=$no
-var2=$no2
 outpath="$datapath/$program/$no/$no2"
 makedir $outpath >> $scriptlog 2>&1
@@ -80,11 +78,22 @@
    if [ $sequence -gt 200000 ]
    then
-   	ln -vs $callistorcmux $outpath/callisto.rc >> $scriptlog 2>&1
+      ln -vs $callistorcmux $outpath/callisto.rc >> $scriptlog 2>&1
    else
-   	ln -vs $callistorcnew $outpath/callisto.rc >> $scriptlog 2>&1
+      ln -vs $callistorcnew $outpath/callisto.rc >> $scriptlog 2>&1
    fi
    callistorcseq=$outpath/callisto.rc
 fi
 
+# lock sequ for zipping
+lockfile=$lockpath/calzip$sequence.txt
+# if lockfile is already existing, 1 is returned
+if ! checklock return 1 >> $scriptlog 2>&1
+then
+   # reset lockfile name
+   lockfile=$lockpath/lock-$table-$column-$sequence.txt
+   finish >> $scriptlog 2>&1
+fi
+
+primvar=$no2
 setstatus "start" >> $scriptlog 2>&1
 
@@ -92,4 +101,8 @@
 ./callisto -b -q -v4 -f --log=$outpath/$program$no2.log --html=$outpath/$program$no2.html --out=$outpath --config=$callistorcseq $sequfile  2>> $scriptlog > /dev/null
 check1=$?
+
+# remove lockfile for zip and reset lockfile name
+rm -v $lockfile >> $scriptlog 2>&1
+lockfile=$lockpath/lock-$table-$column-$sequence.txt
 
 case $check1 in
@@ -117,9 +130,11 @@
            # find cc and caco file
            # if file is missing continue with next sequence
+           date=`date --date \`basename $calfile | cut -d_ -f1 +%Y/%m/%d\``
+           ccpath=$subsystempath/cc/$date
+           cacopath=$subsystempath/caco/$date
            runno=`echo $calfile | cut -d_ -f2 | sed -e 's/^0//' | sed -e 's/^0//' | sed -e 's/^0//' `
-           ccfile=`find /magic/subsystemdata/cc/ -name [2][0][0-2][0-9][0,1][0-9][0-3][0-9]_*${runno}_[P,D,C,S]_*_S.rep -and ! -name [2][0][0-2][0-9][0,1][0-9][0-3][0-9]_*[1-9]${runno}_[P,D,C,S]_*_S.rep`
+           ccfile=`find $ccpath -name 20[0-2][0-9][01][0-9][0-3][0-9]_*${runno}_[PDCS]_*_S.rep`
            source=`echo $ccfile | cut -d_ -f4`
-           cacofile=`find /magic/subsystemdata/caco/ -name dc_[2][0][0-2][0-9]_[0,1][0-9]_[0-3][0-9]_*${runno}_${source}.txt -and ! -name dc_[2][0][0-2][0-9]_[0,1][0-9]_[0-3][0-9]_*[1-9]${runno}_${source}.txt`
-#            cacofile=`find /magic/subsystemdata/caco/ -name dc_[2][0][0-2][0-9]_[0,1][0-9]_[0-3][0-9]_*${runno}_*.txt`
+           cacofile=`find /magic/subsystemdata/caco/$date -name dc_20[0-2][0-9]_[01][0-9]_[0-3][0-9]_*${runno}_${source}.txt`
            if [ "$ccfile" = "" ]
            then
@@ -138,13 +153,10 @@
               do 
                  newrun=`echo $runno - $i | bc`
-                 path=`dirname $ccfile`
-                 path=`echo $path | sed -e 's/cc/caco/'`
-                 echo "path: "$path >> $scriptlog 2>&1
-                 cacofile=`find $path -name *$newrun*`
+                 cacofile=`find $cacopath -name *$newrun*`
                  if [ "$cacofile" = "" ]
                  then
                     if [ $i -eq 9 ]
                     then
-                       echo "no cacofile found" >> $scriptlog 2>&1
+                       echo "no cacofile found for runno $newrun in $cacopath" >> $scriptlog 2>&1
                        printprocesslog "ERROR cacofile $cacofile not found for $calfile"
                        com=$Fnocacofile
@@ -164,13 +176,13 @@
            check2=$?
            case $check2 in
-                   0)   echo " check2=$check2 -> everything ok, merppccupdate worked -> continue" >> $scriptlog 2>&1
-                        printprocesslog "INFO merppupdated $calfile sucessfully with $ccfile"
-                        ;;
-        	   *)   echo " check2=$check2 -> ERROR -> merppccupdate failed" >> $scriptlog 2>&1
-                        printprocesslog "ERROR merppccupdate with file $ccfile failed for $calfile"
-                        com=$Fmerppcc
-                        comadd=$runno
-                        check=$check2
-                        break ;;
+              0)   echo " check2=$check2 -> everything ok, merppccupdate worked -> continue" >> $scriptlog 2>&1
+                   printprocesslog "INFO merppupdated $calfile sucessfully with $ccfile"
+                   ;;
+              *)   echo " check2=$check2 -> ERROR -> merppccupdate failed" >> $scriptlog 2>&1
+                   printprocesslog "ERROR merppccupdate with file $ccfile failed for $calfile"
+                   com=$Fmerppcc
+                   comadd=$runno
+                   check=$check2
+                   break ;;
            esac
            echo "./merpp -u --log=$merpplogpath/merppcacoupdate$runno.log --html=$merpplogpath/merppcacoupdate$runno.html --auto-time $cacofile $calfile 2>> $scriptlog> /dev/null" >> $scriptlog 2>&1
@@ -178,13 +190,13 @@
            check3=$?
            case $check3 in
-                   0)   echo " check3=$check3 -> everything ok, merppcacoupdate worked -> continue" >> $scriptlog 2>&1
-                        printprocesslog "INFO merppupdated $calfile sucessfully with $cacofile"
-                        ;;
-        	   *)   echo " check3=$check3 -> ERROR -> merppcacoupdate failed" >> $scriptlog 2>&1
-                        printprocesslog "ERROR merppcacoupdate with file $cacofile failed for $calfile"
-                        com=$Fmerppcaco
-                        comadd=$runno
-                        check=$check3
-                        break ;;
+              0)   echo " check3=$check3 -> everything ok, merppcacoupdate worked -> continue" >> $scriptlog 2>&1
+                   printprocesslog "INFO merppupdated $calfile sucessfully with $cacofile"
+                   ;;
+              *)   echo " check3=$check3 -> ERROR -> merppcacoupdate failed" >> $scriptlog 2>&1
+                   printprocesslog "ERROR merppcacoupdate with file $cacofile failed for $calfile"
+                   com=$Fmerppcaco
+                   comadd=$runno
+                   check=$check3
+                   break ;;
            esac
         done
