2 #------------------------------------------------------------------
4 # Purpose: A general purpose larsoft batch worker script.
6 # Adapted from condor_lBdetMC.sh by E. Church.
10 # condor_lar.sh [options]
14 # -c, --config <arg> - Configuration (fcl) file (required).
15 # -s, --source <arg> - Input file (full path).
16 # -S, --source-list <arg> - Input file list (full path, one per line).
17 # -o, --output <arg> - Output file name.
18 # -T, --TFileName <arg> - TFile output file name
19 # -n, --nevts <arg> - Number of events to process.
20 # --nskip <arg> - Number of events to skip.
21 # --nfile <arg> - Number of files to process per worker.
22 # --nfile_skip <arg> - Number of files to skip (use with option -S).
23 # --inputmode <arg> - Input mode ('textfile' or '', default '')
24 # --args <args...> - Arguments for lar command line (place at end).
26 # Sam and parallel project options.
28 # --sam_user <arg> - Specify sam user (default $GRID_USER).
29 # --sam_group <arg> - Specify sam group (default --group option).
30 # --sam_station <arg> - Specify sam station (default --group option).
31 # --sam_defname <arg> - Sam dataset definition name.
32 # --sam_project <arg> - Sam project name.
33 # --sam_start - Specify that this worker should be responsible for
34 # starting and stopping the sam project.
35 # --recur - Recursive input dataset (force snapshot).
36 # --sam_schema <arg> - Use this option with argument "root" to stream files using
37 # xrootd. Leave this option out for standard file copy.
38 # --njobs <arg> - Parallel project with specified number of jobs (default one).
39 # --single - Specify that the output and log directories will be emptied
40 # by the batch worker, and therefore the output and log
41 # directories will only ever contain output from a single
44 # Mix input options (second input stream).
46 # --mix_defname <arg> - Specify mix input sam dataset definition.
47 # --mix_project <arg> - Specify mix input sam project.
51 # --ups <arg> - Comma-separated list of top level run-time ups products.
52 # -r, --release <arg> - Release tag.
53 # -q, -b, --build <arg> - Release build qualifier (default "debug", or "prof").
54 # --localdir <arg> - Larsoft local test release directory (default none).
55 # --localtar <arg> - Tarball of local test release.
56 # --mrb - Ignored (for compatibility).
57 # --srt - Exit with error status (SRT run time no longer supported).
61 # -h, --help - Print help.
62 # -i, --interactive - For interactive use.
63 # -g, --grid - Be grid-friendly.
64 # --group <arg> - Group or experiment (required).
65 # --workdir <arg> - Work directory (required).
66 # --outdir <arg> - Output directory (required).
67 # --logdir <arg> - Log directory (required).
68 # --scratch <arg> - Scratch directory (only for interactive).
69 # --cluster <arg> - Job cluster (override $CLUSTER)
70 # --process <arg> - Process within cluster (override $PROCESS).
71 # --procmap <arg> - Name of process map file (override $PROCESS).
72 # --init-script <arg> - User initialization script execute.
73 # --init-source <arg> - User initialization script to source (bash).
74 # --end-script <arg> - User end-of-job script to execute.
75 # --exe <arg> - Specify art-like executable (default "lar").
76 # --init <path> - Absolute path of environment initialization script.
80 # Run time environment setup.
82 # MRB run-time environmental setup is controlled by four options:
83 # --release (-r), --build (-b, -q), --localdir, and --localtar.
85 # a) Use option --release or -r to specify version of top-level product(s).
86 # b) Use option --build or -b to specify build full qualifiers (e.g.
87 # "debug:e5" or "e5:prof").
88 # c) Options --localdir or --localtar are used to specify your local
89 # test release. Use one or the other (not both).
91 # Use --localdir to specify the location of your local install
92 # directory ($MRB_INSTALL).
94 # Use --localtar to specify thye location of a tarball of your
95 # install directory (made relative to $MRB_INSTALL).
97 # Note that --localdir is not grid-friendly.
101 # 1. Each batch worker is uniquely identified by two numbers stored
102 # in environment variables $CLUSTER and $PROCESS (the latter is
103 # a small integer that starts from zero and varies for different
104 # jobs in a parallel job group). These environment variables are
105 # normally set by the batch system, but can be overridden by options
106 # --cluster, --process, and --procmap (e.g. to rerun failed jobs).
108 # 2. The work directory must be set to an existing directory owned
109 # by the submitter and readable by the batch worker. Files from the
110 # work directory are copied to the batch worker scratch directory at
111 # the start of the job.
113 # 3. The job configuration file (-c option), initialization and end-of-job
114 # scripts (optins --init-script, --init-source, --end-script) may
115 # be stored in the work directory specified by option --workdir, or they
116 # may be specified as absolute paths visible on the worker node.
118 # 4. A local test release may be specified as an absolute path using
119 # --localdir, or a tarball using --localtar. The location of the tarball
120 # may be specified as an absolute path visible on the worker, or a
121 # relative path relative to the work directory.
123 # 5. The output directory must exist and be writable by the batch
124 # worker (i.e. be group-writable for grid jobs). The worker
125 # makes a new subdirectory called ${CLUSTER}_${PROCESS} in the output
126 # directory and copies all files in the batch scratch directory there
127 # at the end of the job. If the output directory is not specified, the
128 # default is /grid/data/<group>/outstage/<user> (user is defined as
129 # owner of work directory).
131 # 6. Parallel projects are specified whenever --njobs is specified to
132 # be greater than one. Parallel projects are supported for single file,
133 # file list, and sam project input.
135 # In all cases, each worker processes some number of complete files.
136 # If the number of jobs is greater than the number of input files, some
137 # workers will not have any input files to process.
139 # In any case, options --nfile and --nevts can be used to limit the
140 # number of files or events that are processed by a single worker,
141 # regardless of the way files are divided among the workers.
143 # Option --njobs is incompatible with options --nskip, and --nfile_skip.
145 # a) Non-sam (single file or file list) input.
147 # In this case, input files are preassigned to workers such that all input
148 # files are approximately evenly divided among the workers. All files
149 # preassigned to this worker are copied to the scratch directory at the
152 # b) Sam project input.
154 # In this case, files are assigned to workers in a non-deterministic
155 # manner by the sam system. The sam system fetches input files to the
156 # scratch directory and deletes processed input files during job execution.
159 # 7. Using option -n or --nevts to limit number of events processed:
161 # a) If no input files are specified (e.g. mc generation), --nevts
162 # specifies total number of events among all workers.
164 # b) If input files are specified, --nevts specifies total number of
165 # events processed by each worker or from each input file, whichever
168 # 8. The interactive option (-i or --interactive) allows this script
169 # to be run interactively by overriding some settings that are normally
170 # obtained from the batch system, including $CLUSTER, $PROCESS, and
171 # the scratch directory. Interactive jobs always set PROCESS=0 (unless
172 # overridden by --process).
174 # 9. The grid option (-g or --grid) instructs this script to use grid-
175 # friendly tools. This means that there must be no direct access to
176 # bluearc disks. File transfers are done using gridftp or other
177 # grid-friendly protocol. Local test releases are not allowed to
178 # be specified as directories (--localdir), but may be specified as
179 # tarballs (--localtar).
181 # 10. Mix options (--mix_defname, --mix_project) are only partially handled
182 # in this script. These options are parsed and their values are stored
183 # in shell variables. It is assumed that the sam project specified
184 # by --mix_project has been started externally, unless --sam_start is
185 # also specified, in which case this script will start the project.
186 # This script does not include any provision for joining the project.
187 # Further processing of these options (joining sam project, generating
188 # command line options or fcl wrappers) should be handled by user
189 # provided initialization scripts (--init-script, --init-source).
191 # 11. Option --init <path> is optional. If specified, it should point to
192 # the absolute path of the experiment environment initialization script,
193 # which path must be visible from the batch worker (e.g. /cvmfs/...).
194 # If this option is not specified, this script will look for and source
195 # a script with hardwired name "setup_experiment.sh" in directory
196 # ${CONDIR_DIR_INPUT}.
199 # Created: H. Greenlee, 29-Aug-2012
201 #------------------------------------------------------------------
258 while [ $# -gt 0 ];
do
263 awk
'/^# Usage:/,/^# End options/{print $0}' $0 | cut -c3- | head -
n -2
269 if [ $# -gt 1 ]; then
277 if [ $# -gt 1 ]; then
285 if [ $# -gt 1 ]; then
293 if [ $# -gt 1 ]; then
301 if [ $# -gt 1 ]; then
309 if [ $# -gt 1 ]; then
317 if [ $# -gt 1 ]; then
323 # Number of events to skip.
325 if [ $# -gt 1 ]; then
331 # Number of files to process.
333 if [ $# -gt 1 ]; then
339 # Number of files to skip.
341 if [ $# -gt 1 ]; then
347 # Number of parallel jobs.
349 if [ $# -gt 1 ]; then
355 # Single worker mode.
362 if [ $# -gt 1 ]; then
370 if [ $# -gt 1 ]; then
378 if [ $# -gt 1 ]; then
384 # Sam dataset definition name.
386 if [ $# -gt 1 ]; then
395 if [ $# -gt 1 ]; then
402 # Sam start/stop project flag.
414 if [ $# -gt 1 ]; then
420 # General arguments for lar command line.
422 if [ $# -gt 1 ]; then
429 # Top level ups products (comma-separated list).
431 if [ $# -gt 1 ]; then
439 if [ $# -gt 1 ]; then
445 # Release build qualifier.
447 if [ $# -gt 1 ]; then
453 # Local test release directory.
455 if [ $# -gt 1 ]; then
461 # Local test release tarball.
463 if [ $# -gt 1 ]; then
475 echo
"SRT run time environment is no longer supported."
491 if [ $# -gt 1 ]; then
499 if [ $# -gt 1 ]; then
507 if [ $# -gt 1 ]; then
515 if [ $# -gt 1 ]; then
523 if [ $# -gt 1 ]; then
531 if [ $# -gt 1 ]; then
537 # Process within cluster.
539 if [ $# -gt 1 ]; then
547 if [ $# -gt 1 ]; then
553 # User initialization script.
555 if [ $# -gt 1 ]; then
561 # User source initialization script.
563 if [ $# -gt 1 ]; then
569 # User end-of-job script.
571 if [ $# -gt 1 ]; then
577 # Declare good output root files to SAM.
582 # Run validation steps in project.py on root outputs directly in the job.
587 # Copy Output to FTS.
592 # Mix input sam dataset.
594 if [ $# -gt 1 ]; then
601 # Mix input sam project.
603 if [ $# -gt 1 ]; then
610 # Alter the output file's parentage such that it's parent(s) are from the input list OR sam process
611 --maintain_parentage )
615 # Specify alternate art-like executable.
617 if [ $# -gt 1 ]; then
623 # Specify environment initialization script path.
625 if [ $# -gt 1 ]; then
633 echo
"Unknown option $1"
640 #echo
"INFILE=$INFILE"
641 #echo
"INLIST=$INLIST"
642 #echo
"OUTFILE=$OUTFILE"
647 #echo
"NFILE_SKIP=$NFILE_SKIP"
652 #echo
"LOCALDIR=$LOCALDIR"
653 #echo
"LOCALTAR=$LOCALTAR"
654 #echo
"INTERACTIVE=$INTERACTIVE"
656 #echo
"WORKDIR=$WORKDIR"
657 #echo
"OUTDIR=$OUTDIR"
658 #echo
"LOGDIR=$LOGDIR"
659 #echo
"SCRATCH=$SCRATCH"
662 #echo
"INITSCRIPT=$INITSCRIPT"
663 #echo
"INITSOURCE=$INITSOURCE"
664 #echo
"ENDSCRIPT=$ENDSCRIPT"
665 #echo
"VALIDATE_IN_JOB=$VALIDATE_IN_JOB"
667 # Done with arguments.
669 echo
"Nodename: `hostname -f`"
676 if [
x$QUAL =
x ]; then
680 if [
x$SAM_GROUP =
x ]; then
684 if [
x$SAM_STATION =
x ]; then
688 # Standardize sam_schema (xrootd ->
root).
690 if [
x$SAM_SCHEMA = xxrootd ]; then
694 # Fix for sites with newer linux kernels:
700 echo "uname -
r: `uname -
r`"
703 # Make sure work directory is defined and exists.
705 if [
x$WORKDIR =
x ]; then
706 echo
"Work directory not specified."
709 if [ $GRID -eq 0 -
a ! -d $WORKDIR ]; then
710 echo
"Work directory $WORKDIR does not exist."
713 echo
"Work directory: $WORKDIR"
717 echo
"Condor dir input: $CONDOR_DIR_INPUT"
719 # Initialize experiment ups products and mrb.
721 echo
"Initializing ups and mrb."
723 if [
x$INIT !=
x ]; then
724 if [ ! -f $INIT ]; then
725 echo
"Environment initialization script $INIT not found."
728 echo
"Sourcing $INIT"
731 echo
"Sourcing setup_experiment.sh"
732 source ${CONDOR_DIR_INPUT}/setup_experiment.sh
735 echo PRODUCTS=$PRODUCTS
737 # Ifdh may already be setup by jobsub wrapper.
738 # If not, set it up here.
740 echo
"IFDHC_DIR=$IFDHC_DIR"
741 if [
x$IFDHC_DIR =
x ]; then
742 echo
"Setting up ifdhc, because jobsub did not set it up."
745 echo
"IFDHC_DIR=$IFDHC_DIR"
747 # Set GROUP environment variable.
750 if [
x$GRP !=
x ]; then
753 echo
"GROUP not specified."
759 # Set options for ifdh.
761 if [ $GRID -ne 0 ]; then
763 # Figure out if this is a production job.
764 # This option is only used when copying back output.
765 # It affects the ownership of copied back files.
767 echo
"X509_USER_PROXY = $X509_USER_PROXY"
768 #if ! echo $X509_USER_PROXY | grep -q Production; then
770 # IFDH_OPT="--force=$FORCE"
773 # IFDH_OPT="--force=$FORCE"
776 echo
"IFDH_OPT=$IFDH_OPT"
778 # Make sure fcl file argument was specified.
780 if [
x$FCL =
x ]; then
781 echo
"No configuration option (-c|--config) was specified."
785 # Make sure output directory exists and is writable.
787 if [
x$OUTDIR =
x ]; then
788 echo
"Output directory not specified."
791 if [ $GRID -eq 0 -
a \( ! -d $OUTDIR -o ! -
w $OUTDIR \) ]; then
792 echo
"Output directory $OUTDIR does not exist or is not writable."
795 echo
"Output directory: $OUTDIR"
797 # Make sure log directory exists and is writable.
799 if [
x$LOGDIR =
x ]; then
800 echo
"Log directory not specified."
803 if [ $GRID -eq 0 -
a \( ! -d $LOGDIR -o ! -
w $LOGDIR \) ]; then
804 echo
"Log directory $LOGDIR does not exist or is not writable."
807 echo
"Log directory: $LOGDIR"
809 # See if we need to set umask for group write.
811 if [ $GRID -eq 0 ]; then
812 OUTUSER=`
stat -c %U $OUTDIR`
813 LOGUSER=`
stat -c %U $LOGDIR`
815 if [ $OUTUSER != $CURUSER -o $LOGUSER != $CURUSER ]; then
816 echo
"Setting umask for group write."
821 # Make sure scratch directory is defined.
822 # For batch, the scratch directory is always $_CONDOR_SCRATCH_DIR
823 # For interactive, the scratch directory is specified by option
824 # --scratch or --outdir.
826 if [ $INTERACTIVE -eq 0 ]; then
829 if [
x$SCRATCH =
x ]; then
833 if [
x$SCRATCH =
x -o ! -d
"$SCRATCH" -o ! -
w "$SCRATCH" ]; then
834 echo
"Local scratch directory not defined or not writable."
838 # Create the scratch directory in the condor scratch diretory.
839 # Copied from condor_lBdetMC.sh.
840 # Scratch directory path is stored in $TMP.
841 # Scratch directory is automatically deleted when shell exits.
843 # Do not change this section.
844 # It creates a temporary working directory that automatically cleans up all
845 # leftover files at the end.
846 TMP=`mktemp -d ${SCRATCH}/working_dir.XXXXXXXXXX`
847 TMP=${TMP:-${SCRATCH}/working_dir.$$}
849 { [[ -
n "$TMP" ]] &&
mkdir -
p "$TMP"; } || \
850 { echo
"ERROR: unable to create temporary directory!" 1>&2;
exit 1; }
851 trap
"[[ -n \"$TMP\" ]] && { rm -rf \"$TMP\"; }" 0
854 # End of the section you should not change.
856 echo
"Scratch directory: $TMP"
858 # Copy files from work directory to scratch directory.
860 echo
"No longer fetching files from work directory."
861 echo
"that's now done with using jobsub -f commands"
863 cp ${CONDOR_DIR_INPUT}
then source grid fermiapp products dune setup_dune_fermiapp sh exit else echo No setup file found exit fi setup
see a below echo S(symbol in a section other than those above)
process_name opflash particleana ie x
maintain_parentage MAINTAIN_PARENTAGE
BEGIN_PROLOG dataFFTHistosEW root
constexpr BitMask< Storage > Set(Flag_t< Storage > flag)
Returns a bit mask which sets the specified flag.
auto end(FixedBins< T, C > const &) noexcept
then echo Setting up ifdhc
if &&[-z"$BASH_VERSION"] then echo Attempting to switch to bash bash shellSwitch exit fi &&["$1"= 'shellSwitch'] shift declare a IncludeDirectives for Dir in
then echo File list $list not found else cat $list while read file do echo $file sed s
BEGIN_PROLOG sequence::SlidingWindowTriggerPatternsOppositeWindows END_PROLOG simSlidingORM6O6 effSlidingORW output
i interactive INTERACTIVE