Index: trunk/MagicSoft/Mars/datacenter/scripts/buildsequenceentries
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/buildsequenceentries	(revision 7265)
+++ trunk/MagicSoft/Mars/datacenter/scripts/buildsequenceentries	(revision 7460)
@@ -20,9 +20,18 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2004
+#   Copyright: MAGIC Software Development, 2000-2006
 #
 #
 # ========================================================================
 #
+# This script launches the building of sequences for all days for which 
+# this step is needed. 
+#
+# After checking, if the script is already running, the todolist is 
+# written by using the macro getdolist.C
+# Then the sequences are built for each date in the todolist using the 
+# macro buildsequenceentries.C
+# If this was successful, the status is inserted into the database using 
+# the macro setstatus.C
 #
 
@@ -52,4 +61,5 @@
 makedir $getstatuslogpath >> $scriptlog 2>&1
 
+# check if script is already running
 date > $lockpath/lock-buildsequenceentries.txt >> $scriptlog 2>&1 
 checklock0=$?
@@ -57,5 +67,5 @@
     0)   echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
     1)   echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
-         echo "-> getting list for buildsequenceentries is running -> exit" >> $scriptlog 2>&1
+         echo "-> buildsequenceentries is running -> exit" >> $scriptlog 2>&1
          date  >> $scriptlog 2>&1
          exit;;
@@ -63,15 +73,19 @@
 esac
 
-
-echo "getting list..." >> $scriptlog 2>&1
+# get todo list
+echo "getting todo list..." >> $scriptlog 2>&1
 check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatus.log | grep int | sed -e 's/(int)//'`
 
 case $check0 in 
-   1)   echo "check0=$check0 -> everything ok -> do step" >> $scriptlog 2>&1;;
-   *)   echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
+   1)   echo "check0=$check0 -> everything ok, got todo list -> build sequence entries" >> $scriptlog 2>&1;;
+   *)   echo "check0=$check0 -> ERROR -> could not get todo list -> exit" >> $scriptlog 2>&1
+	rm -v $todofile >> $scriptlog 2>&1
+	rm -v $lockpath/lock-buildsequenceentries.txt >> $scriptlog 2>&1
+   	date  >> $scriptlog 2>&1
+	exit;;
 esac
 
+# retrieve dates from todofile
 dates=(`cat $todofile`)
-
 if [ "$dates" = "" ]
 then 
@@ -84,5 +98,4 @@
 
 echo "dates: "${dates[@]} >> $scriptlog 2>&1
-
 for date in ${dates[@]}
 do 
@@ -95,5 +108,5 @@
 
    case $check1 in
-      1)   echo "check1=$check1 -> everything ok -> setting status..." >> $scriptlog 2>&1
+      1)   echo "check1=$check1 -> everything ok -> setting status for $date..." >> $scriptlog 2>&1
            setstatuslogpath=$logpath/setstatus/buildsequenceentries/$year2
            makedir $setstatuslogpath >> $scriptlog 2>&1
@@ -102,8 +115,8 @@
            case $check2 in
    	      1)   echo "check2=$check2 -> everything ok, status has been set" >> $scriptlog 2>&1;;
-   	      *)   echo "check2=$check2 -> ERROR -> step could not be set" >> $scriptlog 2>&1;;
+   	      *)   echo "check2=$check2 -> ERROR -> step could not be set for $date" >> $scriptlog 2>&1;;
            esac
    	   ;;
-      *)   echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
+      *)   echo "check1=$check1 -> ERROR - buildsequenceentries.C failed for $date -> step has to be repeated" >> $scriptlog 2>&1;;
    esac
 done
