Jpp  15.0.3
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mkqueue.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 #
3 # \author mdejong
4 #
5 script=${0##*/}
6 
7 # ----------------------------------------------------------------------------------------
8 # Simple desktop batch queue processor.
9 #
10 # The batch queue is defined by a standard FIFO and
11 # the entries in the queue are processed line-by-line.
12 # Each entry is executed as a separate process in the background,
13 # commonly referred to as a job.
14 # The number of jobs that can simultaneously run is limited by the queue size.
15 # The batch queue can be terminated by submitting a job with contents "exit".
16 #
17 # The batch queue may also be an existing regular file.
18 # The entries in the queue are processed as normal but
19 # the batch queue will terminate when the end-of-file is reached.
20 #
21 # A job can be submitted using the puts_queue function (see qlib.sh or qlib.csh).
22 # A series of joint commands can be submitted using a sequence of
23 # calls to put_queue, terminated by a single puts_queue call.
24 # ----------------------------------------------------------------------------------------
25 
26 if [ -z $JPP_DIR ]; then
27  echo "Variable JPP_DIR undefined."
28  exit
29 fi
30 
31 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
32 source qlib.sh
33 
34 set_variable: DEBUG MKQUEUE_DEBUG 3
35 set_variable QUEUE_NAME ${TMPDIR:-/tmp}/queue # default name of queue
36 set_variable QUEUE_SIZE 1 # default size of queue
37 set_variable COMMAND mkqueue.sh
38 set_variable SLEEP_TIME 1s # sleep time
39 
40 if do_usage $*; then
41  print -u2 "$script [queue name [queue size]] <option>"
42  print -u2 "Possible options: start, stop, continue, restart."
43  exit
44 fi
45 
46 case $# in
47  3) set_variable QUEUE_SIZE $argv[2];&
48  2) set_variable QUEUE_NAME $argv[1];&
49  1) set_variable OPTION $argv[-1];;
50  *) fatal "Wrong number of options.";;
51 esac
52 
53 if ( is_CCLyon ); then
54  fatal "This batch queue processor is intended for use on a desktop."
55 fi
56 
57 if (( $QUEUE_SIZE < 1 )); then
58  fatal "Invalid queue size $QUEUE_SIZE."
59 fi
60 
61 if [[ $OPTION != "start" && $OPTION != "stop" && $OPTION != "continue" && $OPTION != "restart" ]]; then
62  fatal "Invalid option $OPTION."
63 fi
64 
65 if [[ $OPTION == "stop" || $OPTION == "restart" ]]; then
66 
67  PID=(`get_pid $COMMAND`)
68 
69  PID[$PID[(i)$$]]=
70 
71  if [[ -n $PID ]]; then
72  notice "Stop $COMMAND."
73  kill -9 $PID
74  fi
75 
76  rm -f $QUEUE_NAME # remove FIFO
77 
78  OPTION=${OPTION/restart/start}
79 
80 elif [[ $OPTION == "continue" ]]; then
81 
82  PID=(`get_pid $COMMAND`)
83 
84  PID[$PID[(i)$$]]=
85 
86  if [[ -n $PID ]]; then
87  notice "$script is running with PID(s) $PID"
88  else
89  OPTION=start
90  fi
91 
92 fi
93 
94 if [[ $OPTION = "start" ]]; then
95 
96  notice "Start batch queue ${QUEUE_NAME} >& ${QUEUE_NAME}_log"
97 
98  trap "" HUP # trap hangup
99 
100  queue $QUEUE_NAME $QUEUE_SIZE $SLEEP_TIME >& ${QUEUE_NAME}_log &
101 
102  while [[ ! -e $QUEUE_NAME ]]; do
103  sleep $SLEEP_TIME
104  done
105 
106 fi
then usage $script< detector file >< detectorfile > nIf the range of floors is the first detector file is aligned to the second before the comparison nIn only modules within the given range of floors are used fi case set_variable RANGE $argv[3]
then usage $script< detector >< run >< outputfile > fi case set_variable OPTION
Definition: JTuna.sh:26
then echo Submitting reweighting and histogram comparison jobs to nikhef stbc batch queue
then echo Enter input within $TIMEOUT_S seconds echo n User name
Definition: JCookie.sh:42
o $QUALITY_ROOT d $DEBUG!JPlot1D f
Definition: JDataQuality.sh:66
exit
Definition: JPizza.sh:36
then echo
const int n
Definition: JPolint.hh:660
then PID
Definition: mkqueue.sh:67
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null set_variable
Definition: JAcoustics.sh:20
set_variable NUMBER_OF_ITERATIONS set_variable EPSILON cat acoustics_fit_parameters txt<< EOF $CONFIGURATION[*]Nmin=3;sigma_s=100.0e-6;stdev=10.0;mestimator=0;fixStrings=0;EOF for STRING in $STRINGS[*];do#fit stretching and(z) position of given string set_variable DETECTOR_TMP ${TMPDIR:-/tmp}/detector_A.datx JEditDetector-a $DETECTOR-o $DETECTOR_TMP-r $STRING JEditDetector-a $DETECTOR-o $DETECTOR-k $STRING for MUL in 0.005 0.001;do DX_M=0.2 for((N=0;$N< $NUMBER_OF_ITERATIONS;++N));do CHI2[3]=$CHI2[1] fitPositionOfString $STRING Z $DX_M fitStretchingOfString $STRING $MUL if(($CHI2[3]-$CHI2[1]< $EPSILON));then break fi done if(($N >=$NUMBER_OF_ITERATIONS));then printf"warning: reached maximum number of iterations %d - converenge %7.3f\n"$N $(($CHI2[3]-$CHI2[1])) fi done JMergeDetector-a $DETECTOR-a $DETECTOR_TMP-o $DETECTOR rm-f $DETECTOR_TMP JConvertDetectorFormat-a $DETECTOR-o $DETECTOR-r-d 0 > &dev null done
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR if do_usage *then usage $script[(input file)+] fi set_variable DEBUG set_variable WORKDIR TMPDIR
print
Definition: JConvertDusj.sh:44
skip elif((BINFRAC< 1.0))
Q FIFO
Definition: JDataQuality.sh:55
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:42
script
Definition: JAcoustics.sh:2
*fatal Wrong option $OPTION
esac $JPP_BIN JLogger sh $LOGGER until pgrep JGetMessage</dev/null > dev null