:
 
if(test -r LOCK) then
  cat LOCK
  echo "Remove LOCK file, in order to start CompHEP anyway"   
  exit
fi

echo "CompHEP is already started here, process number $$" > LOCK

trap "rm LOCK" 0 1 2 3

while :
do 
  $COMPHEP/s_comphep
  case $? in 
    13) ;;
    24)  $COMPHEP/s_comphep -blind "]}}]]]}9" 
         cd results 
         $COMPHEP/nCompil_c 1>/dev/null 2>/dev/null
         $COMPHEP/ld_c 
         cd ..
        break;;
    25)  $COMPHEP/s_comphep -blind "]}}]]]]}9" 
         cd results 
         $COMPHEP/nCompil_f 1>/dev/null 2/dev/null
         $COMPHEP/ld_f 
         cd ..
        break;;
    *)
      break 
  esac 
done 

echo 'End of CompHEP session.'
