htcondor_exec.sh
Go to the documentation of this file.
1 #
2 # Simple shell script used as 'Executable' with HTCondor batch submission scripts.
3 # Configures GENIE, cd's to the job directory and executes the input GENIE commands.
4 #
5 # Syntax:
6 # ./htcondor_exec.sh [/path/genie_setup_script] [/job/dir] [executable --argument1 --argument2 ...] [another_executable --argument1 --argument2 ...] ...
7 #
8 # C.Andreopoulos <constantinos.andreopoulos \at cern.ch>
9 #
10 
11 #!/bin/bash
12 
13 #echo "Number of arguments: ${#@}"
14 
15 #
16 # first two arguments are the setup script and the job directory
17 #
18 
19 genie_setup=$1
20 jobs_dir=$2
21 
22 echo "htcondor_exec.sh / GENIE setup script: $genie_setup"
23 echo "htcondor_exec.sh / Job directory: $jobs_dir"
24 
25 source $genie_setup
26 cd $jobs_dir
27 
28 shift
29 shift
30 
31 #
32 # remaining arguments are genie executables and their arguments
33 #
34 
35 # Known commands to look
36 known_exec=(
37  'gevcomp'
38  'gevdump'
39  'gevgen'
40  'gevgen_atmo'
41  'gevgen_hadron'
42  'gevgen_ndcy'
43  'gevgen_t2k'
44  'gevpick'
45  'gevscan'
46  'gmkspl'
47  'gmxpl'
48  'gntpc'
49  'gspl2root'
50  'gspladd'
51  'gxscomp'
52  )
53 
54 #echo "Number of known commands: ${#known_exec[@]}"
55 
56 genie_command=""
57 genie_args=""
58 
59 do_run=0
60 
61 # loop over arguments
62 for x in $@
63 do
64  new_command=0
65 
66  # loop over known GENIE commands
67  for y in ${known_exec[@]}
68  do
69  # current argument is a known GENIE command
70  if [ "$x" == "$y" ]
71  then
72  #
73  if [ "$do_run" -eq 1 ]
74  then
75  echo "htcondor_exec.sh / Executing: ${genie_command} ${genie_args}"
76  ${genie_command} ${genie_args}
77 
78  fi
79  new_command=1
80  do_run=1
81  genie_command="$x"
82  genie_args=""
83  break
84  fi
85  done
86 
87  if [ "$new_command" -eq 1 ]
88  then
89  continue
90  fi
91 
92  genie_args="${genie_args} $x";
93 done
94 
95 echo "htcondor_exec.sh / Executing: ${genie_command} ${genie_args}"
96 ${genie_command} ${genie_args}
97