9if [ -z $JPP_DIR ]; then
 
   10    echo "Variable JPP_DIR undefined."
 
   14source $JPP_DIR/setenv.sh $JPP_DIR
 
   16set_variable:  DEBUG    COMPASS_DEBUG    2
 
   17set_variable:  WORKDIR  COMPASS_WORKDIR  ./
 
   20    usage "$script <detector identifier> (run[-run])+"\
 
   21          "\nAuxiliary script to download AHRS data from database."
 
   25    set_variable  DETECTOR_ID     $argv[1]
 
   26    set_array     RUNS            $argv[2,-1]
 
   28    fatal "Wrong number of arguments."
 
   33let "NUMBER_OF_ERRORS = 0"
 
   37BUFFER=(`JRuns -D $DETECTOR_ID -F RUN`)
 
   39for RUN in ${RUNS:*BUFFER}; do
 
   41    set_variable  AHRS_FILE  $WORKDIR/KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_ahrs.root
 
   43    if [[ ! -f $AHRS_FILE ]]; then
 
   45        echo -n "Writing $AHRS_FILE... "
 
   49            -@ "detid  = $DETECTOR_ID"     \
 
   55        if (( $? == 0 )); then
 
   59            let "NUMBER_OF_ERRORS = $NUMBER_OF_ERRORS + 1"
 
   64if (( $NUMBER_OF_ERRORS != 0 )); then
 
   65    error "Number of errors $NUMBER_OF_ERRORS"